CLI Reference¶
The pyoas command is the entry point for all code generation tasks.
Global options¶
All commands accept:
| Option | Default | Description |
|---|---|---|
--config PATH |
pyoas.yaml |
Path to the config file |
--help |
— | Show help and exit |
pyoas init¶
Generate a starter pyoas.yaml config.
| Argument / Option | Default | Description |
|---|---|---|
SPEC |
(required) | Path to the OpenAPI spec file |
--output PATH |
pyoas.yaml |
Where to write the config |
--force |
— | Overwrite an existing config |
Example:
pyoas validate¶
Validate the OpenAPI spec.
Exits 0 if the spec is valid, non-zero otherwise. Prints validation errors to stderr.
pyoas models¶
Generate Pydantic v2 model files only.
| Option | Description |
|---|---|
--tags TAG1,TAG2 |
Comma-separated list of tags to generate; default: all |
--clean |
Purge the models output directory before generating |
Example:
pyoas fastapi¶
Generate FastAPI router files only.
Same options as pyoas models.
pyoas generate¶
Generate models + routers, and optionally run scaffolding if configured.
This is the primary command for day-to-day use. It generates:
- Pydantic v2 models (
pyoas) - FastAPI routers (
pyoas[fastapi]) - Service stubs — if
services.generate: true - Test stubs — if
tests.generate: true - Dependency stubs — if
dependencies.generate: true - Claude Code skills — if
skills.generate: true
pyoas diff¶
Dry-run: compute what would be generated and diff against current files.
- Exits 0 if no files would change
- Exits 1 if any file would be added or modified
- Prints a unified diff to stdout
Use in CI to enforce that generated files are up to date:
pyoas watch¶
Watch the spec file and re-run pyoas generate on every change.
Useful during development. Press Ctrl+C to stop.
pyoas scaffold¶
Standalone scaffolding commands. These are normally invoked automatically by pyoas generate when the corresponding generate: true flag is set. Use these to run scaffolding independently.
pyoas scaffold services¶
Scaffold service stub files. Skips existing files unless services.overwrite: true.
pyoas scaffold tests¶
Scaffold pytest test stub files. Appends new test classes to existing files.
pyoas scaffold dependencies¶
Scaffold dependency injection stubs (src/dependencies/auth.py). Skips if exists.
pyoas scaffold skills¶
Scaffold Claude Code skill files. Requires pyoas[claude]. Skips existing files unless skills.overwrite: true.
Exit codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Generation error, validation failure, or diff detected changes |
2 |
Bad arguments / config parse error |