CLI reference
CLI commands, generated files, overwrite behavior, and non-interactive use.
@genko-me/cli installs SDK packages, syncs types, and provides setup instructions for AI tools. This page corresponds to the 0.2.7 implementation. On Node.js 20.12 or later, run from the directory where the app's package.json is located.
Choose a command
| Command | Usage |
|---|---|
init | Initial dependency addition, connection settings, and type generation |
pull | Regenerate types from the latest schema in the dashboard |
mcp | Show how to register the OAuth MCP server with an AI client |
skill | Show how to add genko.me instructions to a project |
init: initial setup
npx @genko-me/cli initEnter your workspace ID (the slug in /w/{slug} on the dashboard) and API key, then select the APIs to sync. The CLI fetches the API definitions and adds or updates @genko-me/sdk@^0.6.0 and the development dependency @genko-me/cli@^0.2.6. If the project's package.json includes Next.js, it also adds or updates @genko-me/react@^0.5.0 and includes import "server-only" in client.ts. The package manager determines this from the package.json specification and lock file.
| File | Contents | Edit manually? |
|---|---|---|
lib/schema.ts | Types and definitions for each API | Do not change as they will be regenerated |
lib/client.ts | createGenko connection settings | Plugins etc. can be added |
genko.config.json | Workspace, base URL, generation destination | Adjust if necessary |
.env.example | Guide to environment variables | Adjust to project operation |
.env.local | Storage location if the key is not set elsewhere | Treated as secret information |
If the key can be obtained from an environment variable or an existing environment file, do not store it in .env.local. The keys are not displayed on the screen.
init stops if generated files or configuration already exist. --force allows overwriting; use pull for routine type updates instead.
CLI generates connection settings and schema. Files for list/details pages are not generated. Please place the example page of Quick Start.
The interactive prompt masks the key and shows connection progress, generated file paths, and next steps. A generated file will not be created if you cancel during input. In an environment without a terminal such as CI, use --yes and --apis and environment variables.
pull: update types
npx @genko-me/cli pullReads the schema from the connection destination of genko.config.json and regenerates the configured schema file. lib/client.ts will not be overwritten. If there are no changes to the schema, the file will not be rewritten and no update message will be displayed.
Since the API list is also synchronized, there is no need to edit the generated client. Since it only retrieves the schema, it does not upload entries or migrate data.
Configuration file
{ "version": 1, "workspace": "your-workspace", "baseUrl": "https://api.genko.me", "schemaOutput": "lib/schema.ts", "clientOutput": "lib/client.ts"}The destination is the path from the project root. For example, if you want to move to src/lib, also match the configuration path. API keys are not written in this file.
Projects using src/lib
init checks the routing directory and chooses the destination.
| Configuration | Generate destination |
|---|---|
src/app or src/pages | src/lib/schema.ts/src/lib/client.ts |
Root app or pages | lib/schema.ts/lib/client.ts |
| None of the above | lib/schema.ts/lib/client.ts |
If you have both, give priority to the root side, similar to Next.js. pull does not re-detect and uses the generation destination saved in genko.config.json. If you want to move the generation destination of an existing project, move the two files and change schemaOutput and clientOutput as well. Custom import aliases will not change automatically.
Select APIs to sync
Running init interactively shows API names and endpoints. Move with the arrow keys, check with Space, and confirm with Enter. You can interrupt it with Ctrl+C. Your selections are saved to endpoints in the configuration file.
# Select APIs on first setupnpx @genko-me/cli init --workspace your-workspace --apis blog,works# Change the selection in an initialized projectnpx @genko-me/cli pull --select-apis# Change and save the selection without promptsnpx @genko-me/cli pull --apis blog,works# Sync all APIs, including future additionsnpx @genko-me/cli pull --all-apisThe API schema referenced from the selected API is automatically included because the display component handles the reference destination. This also applies to the destination where the reference was followed. It does not generate extraneous APIs. If the selected API or reference destination has been deleted or the definition cannot be obtained because it is not covered by the API key, the existing file will not be changed and an error will occur.
To get the list for selection, read the definition of the API allowed by that key from the delivery API's _schema. After that, narrow down the APIs to be generated and synchronized. Entry data is not fetched. API selection is not a setting that limits access rights.
Existing configuration without endpoints and init --yes without targeting will synchronize all APIs as before. If you want to fix the target, please specify --apis. If you use --watch, first save your selection with pull --select-apis.
Non-interactive execution
In CI etc., set GENKO_API_KEY in the secret information store and then execute.
npx @genko-me/cli init --workspace your-workspace --yes --skip-install| Option | Purpose |
|---|---|
--workspace | Workspace ID (slug). GENKO_WORKSPACE can also be specified in init |
--yes | Skip interactive input |
--base-url | Connect to another delivery API. In init, you can also specify GENKO_API_BASE_URL |
--skip-install | Skip installation of dependent packages |
--apis | Specify endpoints to synchronize separated by commas and save |
--all-apis | Synchronize all APIs including future additions |
--select-apis | Re-select synchronization target interactively |
--force | Allow overwriting of existing files during initial configuration |
pull does not refer to GENKO_WORKSPACE or GENKO_API_BASE_URL, but uses configuration file or command options. If you pass only --workspace and --base-url, they apply only to the current fetch, and if you also specify API selection changes, they will be saved in the configuration file. The connection destination of client.ts is not automatically rewritten, so if you change the connection destination, please update it at the same time.
In an environment where --skip-install is specified, please prepare dependencies such as SDK separately. For CIs that have already been initialized, pull is usually used.
Settings for AI tools
npx @genko-me/cli mcp --manualnpx @genko-me/cli skill --printThese only display the settings. Please refer to MCP Server and Skill for the storage location and overwriting policy when actually registering and deploying.
Troubleshooting
| Situation | Action |
|---|---|
| Already initialized | Use pull and check that you are in the right project |
| Authentication error | Check key issuer and workspace |
| Unable to call new API | Synchronize API list and field definition with pull |
| Type changes disappear | Change the schema in the dashboard, not the generated file |
| Key missing in production | Set the environment variable in production and redeploy |
For a walkthrough of your first CLI setup, return to Quick Start.
Automatic synchronization during development
Run pull --watch in another terminal. Checks every 10 seconds and updates schema.ts only when changes occur. The API list is also synchronized, so there is no need to manually update the selected API to client.ts. If you want to use a new API, add it to the selection with pull --select-apis. Stop with Ctrl+C.
Last updated: October 16, 2026