init
Initialize chowbea-axios in your project with full setup.
init is the one-time (or "we're starting over") command. Interactive by default, scriptable when stdin isn't a TTY. It creates config, installs axios, scaffolds the editable client files, and optionally fetches your first spec.
What it does not do: fill _generated/ with contracts and operations. That's fetch's job unless your endpoint isn't localhost and init can reach it on first run.
Usage
chowbea-axios init [flags]What it does
- Creates
api.config.tomlwith your settings - Installs axios as a project dependency
- Adds npm scripts (
api:fetch,api:watch, etc.) - Generates client files (
api.client.ts,api.instance.ts,api.error.ts,api.helpers.ts) - Optionally sets up concurrent dev script (api:watch + your dev server)
- Optionally scaffolds a hardened CI workflow at
.github/workflows/chowbea-axios-ci.yml - Optionally scaffolds the Vite codegen plugins (
--with-vite-plugins) for Surfaces and Side Panels - Runs initial fetch (if endpoint is not localhost)
The generated entrypoint is api.client.ts. Rename or re-export if your conventions demand it — just stay consistent.
Interactive prompts
- OpenAPI spec endpoint URL — default
http://localhost:3000/docs/swagger/json - Output folder location — default
app/services/api - Package manager — auto-detected from lockfile, or choose manually
- Concurrent dev script (optional) —
api:watchalongside your dev server
Flags
| Flag | Description | Default |
|---|---|---|
--force, -f | Skip all confirmations and overwrite everything | false |
--non-interactive | Skip every prompt — requires --endpoint or --spec-file. Also auto-enabled when stdin isn't a TTY. | false |
--endpoint <url> | Spec source. Required (with --non-interactive) if --spec-file isn't set. | - |
--spec-file <path> | Local spec source. Alternative to --endpoint. | - |
--output-folder <path> | Override the output folder prompt | src/api |
--package-manager <pm> | Force a specific package manager (npm, pnpm, yarn, bun). Auto-detected from lockfile by default. | auto |
--skip-scripts | Skip adding npm scripts to package.json | false |
--skip-client | Skip generating client files | false |
--skip-concurrent | Skip setting up concurrent dev script | false |
--skip-workflow | Skip scaffolding the GitHub Actions workflow | false |
--with-vite-plugins | Scaffold the Vite codegen plugins (Surfaces & Side Panels) | false |
--base-url-env <var> | Environment variable name for base URL | API_BASE_URL |
--env-accessor <str> | How to access env vars in the generated client (process.env or import.meta.env) | process.env |
--auth-mode <mode> | Auth interceptor mode: bearer-localstorage, custom, or none | custom |
--token-key <key> | localStorage key for auth token (only used with bearer-localstorage) | auth-token |
--with-credentials | Include credentials (cookies) in requests | true |
--timeout <ms> | Request timeout in milliseconds | 30000 |
-q, --quiet | Suppress non-error output | false |
-v, --verbose | Show detailed output | false |
Examples
Basic setup
chowbea-axios initNon-interactive setup (CI / project starters)
--non-interactive skips every prompt. Supply a spec source via --endpoint or --spec-file:
chowbea-axios init --non-interactive \
--endpoint https://staging.example.com/openapi.json \
--output-folder src/api \
--package-manager npmForce overwrite
chowbea-axios init --forceCustom instance configuration
chowbea-axios init \
--base-url-env "NEXT_PUBLIC_API_URL" \
--env-accessor "process.env" \
--auth-mode "bearer-localstorage" \
--token-key "session-token" \
--timeout 60000Skip client generation
chowbea-axios init --skip-clientWith Vite plugins
chowbea-axios plugins --setup
# or during init:
chowbea-axios init --with-vite-pluginsGenerated files
Output folder is configurable — src/api is the default. api.contracts.ts, api.types.ts, and api.operations.ts land in _generated/ on first fetch, not during init.
After fetch, wire The Query Layer: contracts for types, api.op for calls.
CI workflow template
By default, init scaffolds .github/workflows/chowbea-axios-ci.yml — re-fetches on every PR and fails when generated output is stale.
permissions: contents: readconcurrencycancel-in-progress- Node 22 + npm cache (commented variants for bun/pnpm/yarn)
- Pinned action SHAs
varsorsecretsfallback forSTAGING_API_ENDPOINT
Pass --skip-workflow to opt out.
Existing setup detection
Already initialized? Init asks before clobbering:
Existing setup detected:
- api.config.toml
- api.instance.ts
- api.client.ts
Continue with setup? (existing files may be modified) (Y/n)Use --force to skip the guilt trip.
Concurrent dev script
Optional script running api:watch with your dev server via concurrently:
{
"scripts": {
"dev:all": "concurrently --names 'api,dev' \"npm run api:watch\" \"npm run dev\""
}
}Init installs concurrently as a dev dependency if you opt in. Your future self will forget to run api:watch otherwise.
Next steps
After init:
- Start your API server (localhost endpoints)
- Run
chowbea-axios fetchto populate_generated/ - Import
apifromapi.client.tsand build the query layer