CLI Spec v1
1. Commands
Global information flags:
--help,-h--version,-V
1.0 init
Initialize a Boundra workspace without overwriting application files.
Generated targets:
boundra.config.json- configured
apps/anddomains/directories
Options:
--root <path>(default:.)--name <kebab-case>(default: root directory name)
Behavior:
- an existing
boundra.config.jsonfails withPROJECT-003 - existing directories are preserved
- generated config is immediately accepted by
check-boundaries
1.1 create-domain <name>
Create a domain scaffold.
Input rules:
<name>must bekebab-case.
Generated targets:
<paths.domains>/[<parent-path>/]<name>/client/<paths.domains>/[<parent-path>/]<name>/server/<paths.domains>/[<parent-path>/]<name>/shared/<paths.domains>/[<parent-path>/]<name>/mcp/<paths.domains>/[<parent-path>/]<name>/tests/<paths.domains>/[<parent-path>/]<name>/<domain.manifestFile>
Options:
--root <path>(default:.)--path <parent-path>(default: empty; relative topaths.domains)
--path accepts one or more kebab-case directory segments, for example
create-domain order --path commerce/core. It rejects absolute paths, . and
.. segments, and a domain name that already exists at another root.
1.2 check-boundaries
Analyze imports and detect boundary rule violations.
Resolution inputs:
- relative and workspace-relative imports
- root/relative-extends
tsconfig.jsoncompilerOptions.paths - root
package.json#importslocal string mappings, including one*pattern
Resolving a package import alias makes existing boundary rules visible through that alias. It does not guarantee that a deployment platform includes the target source file in its server artifact.
Options:
--root <path>(default:.)--format text|json(default:text)--min-domains <positive integer>(optional; also accepts--min-domains=<n>)
Coverage reporting:
paths.domainsis analyzed independently frompaths.apps.- Domains are discovered recursively by the configured manifest filename.
- JSON metadata includes
scanned_file_countandanalyzed_domain_count.analyzed_domain_countcounts unique domains that contain at least one source file included by the configured scan, not merely loaded manifests. - Text output warns when no source files or no domains were analyzed.
- If
--min-domainsis set and the scan has no violations but covers fewer than the requested number of domains, the command returnsCOVERAGE-001and exit code 2. JSON uses the existing structured error shape with actual and expected coverage counts in context. If violations exist, they retain priority and exit code 1. Without the option, existing behavior and output remain unchanged.
1.3 graph-domains
Generate a domain dependency graph from domain manifests.
Options:
--root <path>(default:.)--format mermaid|json|dot(default:mermaid)--output <path>
1.4 generate route <domain>/<name>
1.5 generate query <domain>/<name>
1.6 generate mutation <domain>/<name>
Generate contract-centered template files.
Input rules:
<domain>and<name>must bekebab-case.<domain>must already exist.
Options:
--root <path>(default:.)
Side effects:
- Generated shared contract files are appended to the discovered domain
manifest under
publicApi.shared. - Generated shared contracts are exported from the discovered domain root's
shared/public.ts. - Generated query and mutation adapters are exported idempotently from the
discovered domain root's
client/public.ts. - Generation restores generated files, the manifest, and public barrels when a public API update fails, so retrying does not encounter partial output.
- Existing
publicApi.sharedentries are preserved and duplicate entries are not added. - Generated contracts contain input/result schemas and inferred types.
- Generated route files bind a validated server implementation.
- Generated query/mutation files expose framework-neutral async client functions.
1.7 add-dependency <domain>/<dependency>
Declare that one domain depends on another domain.
Input rules:
- both names must be
kebab-case - both domains must already exist
- a domain cannot depend on itself
Options:
--root <path>(default:.)
Side effects:
- append
<dependency>to the discovered<domain>manifestdependsOn - preserve existing dependencies
- do not add duplicates
1.8 generate resource <domain>/<name>
Generate a contract-only CRUD resource scaffold.
Generated targets:
domains/<domain>/shared/contracts/<name>.tsdomains/<domain>/client/resources/<name>.ts
The shared file owns list/create/update/delete schemas and contracts. The
client file exposes typed functions and is exported idempotently from
client/public.ts. Boundra does not generate persistence, HTTP routes, UI, or
ORM code.
2. CLI UX Principles
- Boundary diagnostics include rule code, file, line, import, message, and suggestion.
- Successful scaffolding output includes one summary line plus created paths.
- JSON output keeps a stable schema for CI and AI parsing.
- CLI failures include a stable code, context, and actionable suggestion.
- When JSON is requested, project/config failures are emitted as JSON.
3. Machine-Readable Output (JSON)
{
"status": "failed",
"violations": [
{
"rule": "BR-001",
"file": "domains/order/client/use-order.ts",
"line": 12,
"import": "domains/order/server/order-service",
"message": "client layer cannot import server layer",
"suggestion": "move shared contract to shared layer or call through an API boundary"
}
],
"meta": {
"command": "check-boundaries",
"violation_count": 1,
"scanned_file_count": 24,
"analyzed_domain_count": 2
}
}