Contract Management
Manage contracts in your project using the contract subcommands.
contract add
Section titled “contract add”Add a new contract to the project.
contractual contract add [options]| Option | Alias | Required | Description |
|---|---|---|---|
--name | -n | Interactive: no | Contract name (unique identifier) |
--type | -t | Interactive: no | Contract type: openapi or json-schema |
--path | -p | Interactive: no | Path to spec file |
--version | -V | No | Initial version (default: 0.0.0) |
--skip-validation | No | Skip spec file validation |
Interactive mode
Section titled “Interactive mode”$ contractual contract add ? Contract name: user-api ? Contract type: openapi ? Path to spec file: ./specs/user.openapi.yaml Validating... ✓ Valid OpenAPI 3.0.3 ? Initial version: (0.0.0) Added user-api (openapi) at v0.0.0 Updated: contractual.yaml Created: .contractual/snapshots/user-api.yaml
Non-interactive mode
Section titled “Non-interactive mode”contractual contract add \ --name user-api \ --type openapi \ --path ./specs/user.openapi.yaml \ --version 1.0.0 \ --yesValidation
Section titled “Validation”The command validates:
- File exists
- File is valid spec of declared type (unless
--skip-validation) - Name is unique
$ contractual contract add --name orders-api --type openapi --path ./missing.yaml Error: Spec file not found: ./missing.yaml
$ contractual contract add --name orders-api --type json-schema --path ./specs/orders.openapi.yaml Warning: File appears to be OpenAPI, not JSON Schema. Continue? (y/N)
contract list
Section titled “contract list”List all contracts in the project.
contractual contract list [options]| Option | Description |
|---|---|
--json | Output as JSON |
Text output
Section titled “Text output”$ contractual contract list
Contracts (3):
Name Type Version Path
─────────────────────────────────────────────────────────
orders-api openapi 1.2.0 ./specs/orders.openapi.yaml
order-schema json-schema 1.0.0 ./schemas/order.schema.json JSON output
Section titled “JSON output”$ contractual contract list --json
{
"contracts": [
{
"name": "orders-api",
"type": "openapi",
"version": "1.2.0",
"path": "./specs/orders.openapi.yaml"
}
]
} contract remove
Section titled “contract remove”Remove a contract from the project.
contractual contract remove <name> [options]| Option | Description |
|---|---|
--keep-history | Keep version history and snapshots |
Interactive mode
Section titled “Interactive mode”$ contractual contract remove user-api ? Remove contract "user-api"? This will delete: - Entry in contractual.yaml - Version history (.contractual/snapshots/user-api.yaml) - Pending changesets mentioning user-api Continue? (y/N)
Non-interactive mode
Section titled “Non-interactive mode”Requires --yes flag:
contractual contract remove user-api --yesKeep history
Section titled “Keep history”To remove from config but preserve snapshots:
contractual contract remove user-api --keep-history --yesSee also
Section titled “See also”- Configuration - Contract configuration options
- CLI Commands - All CLI commands