specbook init [--agents | --no-agents] |
Scaffolds the config, the #api/* import and an environments folder, adds @faker-js/faker and typescript to devDependencies (each only if missing), writes a tsconfig.json that covers requests, flows and the config unless the project has one (it never edits one that exists), and writes .specbook/agent-guide.md for AI coding agents. It creates an AGENTS.md that points to the guide when the project has no AGENTS.md or CLAUDE.md, and never edits one that exists. --agents adds a marked Specbook section to an existing file, and a later run refreshes only that section. --no-agents skips the guide and AGENTS.md. |
specbook add <service> --spec <path or url> [--base-url url] |
Registers a spec and generates its code. An address is downloaded to openapi/ and recorded in openapi/sources.json. --base-url sets the API address instead of the spec’s first server. It also writes the credentials the spec’s security schemes ask for: a secret named for the service for each scheme, and an auth profile for every way the spec accepts, the cheapest to fill first, listed on the service with the first as the default. An OAuth scheme gets a sign-in when the spec has a flow a person can use, and a profile that fetches a token with a client id and secret when it offers client credentials. See Authorization. |
specbook add --refresh [service...] |
Downloads the recorded addresses again, reports what changed and regenerates. It leaves the config, and its credentials, as they are. |
specbook generate [service...] |
Generates types, operations, examples and metadata from the specs. dev, build and test do it when needed. |
specbook dev [--port n] |
Opens the docs, a play panel and a credential proxy, so you can run requests as you write them. |
specbook build [--out dir] [--minimal] [--viewer] |
Builds a static docs site and specbook.js (to dist-docs unless --out says otherwise). --minimal publishes only what your requests and flows use, and --viewer copies the spec viewer to <out>/viewer/. |
specbook test [glob...] |
Runs requests and flows against an environment. |
specbook bundle [--out file] [--tag t] [--external pkg] |
Compiles the tests into one .mjs that runs with just node. --tag limits it to requests and flows with that tag (repeat it for several), and --external leaves a package as an import, to be installed where the file runs (a browser cannot load it). The file takes the specbook test flags below. |
specbook check |
Validates specs, generated code drift, imported operations, placeholders, environment files and auth profiles. |
specbook secrets [--env name] [--secrets-file path] |
Shows where each secret resolves from, never the values. --secrets-file includes a dotenv file, as test would. |
specbook preview <url or file> [--port n] [--no-open] |
Opens any OpenAPI document in the UI, with no project. --port chooses the port, and --no-open does not launch the browser. |