ddd CLI is the fastest way to start a ddd_cqrs_es application and keep generated projects consistent as they grow.
It is published by the ddd-cqrs-es-cli crate, installs a binary named ddd, and is released with the same version as ddd_cqrs_es.
Use it for:
- new app scaffolding with opinionated presets
- fine-grained additions like events, commands, routes, projections, and tests
- capability wiring for Redis, gRPC, tracing, snapshots, and idempotency
- Spin runtime command resolution
- agent/MCP workflows that need deterministic dry-run JSON before writing files
Install
Install the published CLI:Quick Start
Create a small domain-only project:Command Model
Every command supports the same global controls:| Option | Purpose |
|---|---|
--cwd <path> | Run against a generated project without changing the shell directory. |
--dry-run | Preview file operations or runtime command resolution without writing or executing. |
--format text|json | Choose human text or machine-readable JSON output. |
--force | Allow overwriting files that would otherwise be protected. Inspect collisions first. |
--yes | Reserved for non-interactive confirmations as workflows grow. |
| Command | Use |
|---|---|
ddd init <path> | Create a generated project and ddd.toml manifest. |
ddd add ... | Add aggregates, events, commands, routes, tests, projections, and related stubs. |
ddd enable ... | Wire capabilities into an existing generated project. |
ddd serve | Resolve and run the app through the selected Spin runtime command. |
ddd watch | Resolve a rebuild/restart loop for the selected runtime command. |
ddd fresh | Reset schema/data only. This does not start the server. |
ddd doctor | Inspect required local tools. |
ddd check | Validate the generated project manifest and required files. |
ddd matrix | Print supported backend/realtime/transport combinations. |
ddd capabilities --json | Expose the machine-readable CLI contract for agents and MCP tools. |
Presets
Choose a preset withddd init --preset <preset>.
| Preset | Best For | Default Shape |
|---|---|---|
basic | Learning the framework or building a pure domain crate. | Aggregate, command, event, fixture test, and in-memory example. |
leptos-wasi | Full-stack app scaffolding for Leptos WASI on Spin. | Domain/application/store/server boundaries with REST/SSE and optional gRPC. |
native-api | Native Rust API service shape. | Axum-style API scaffold with native SQL adapter features. |
worker | Projection or process-manager workers. | Worker entrypoint plus projection/process-manager-oriented stubs. |
custom | A minimal base for explicit, agent-chosen capabilities. | Starts from the basic shape and lets you add capabilities intentionally. |
spin.
Generated Manifest
Every generated project includesddd.toml. The CLI uses this file to know what it can safely patch later.
Example shape:
ddd.toml, treat it as outside the supported generated-project patching path unless you intentionally adopt it.
Add Domain Code
Runddd add ... from the generated project root, or pass --cwd <project>.
Add a second aggregate:
name:RustType. The CLI inserts generated variants into marker regions in the generated domain module and updates ddd.toml.
Available add targets:
Enable Capabilities
Useddd enable ... when the project exists and you want to wire a capability into ddd.toml and, where applicable, Cargo.toml feature flags.
Runtime Matrix
The CLI currently scaffolds Spin-focused apps. Supported values:| Axis | Values |
|---|---|
| Runtime | spin |
| DB | sqlite, postgres, neon, supabase, turso, mysql, redis |
| Realtime | off, polling, redis |
| Transport | http, grpc, both |
| UI | none, leptos |
db=redismeans Redis is the durable event/checkpoint/read-model store.realtime=redismeans Redis is only the wake/notification transport unlessdb=redisis also selected.
transport=http, transport=grpc, and transport=both.
Serve, Watch, and Fresh
The runtime commands read fromddd.toml and can be overridden with flags.
Preview the command:
fresh is reset-only. It should not start the server.
Agent and MCP Workflow
Agents should use JSON dry-runs before changing files:- Run
ddd capabilities --json. - Run
ddd matrixif runtime/backend choices matter. - Run the mutating command with
--dry-run --format json. - Inspect
operations. - Apply the same command without
--dry-run. - Run
ddd check. - Run project tests.
File and Symbol Targeting
The current CLI targets generated projects throughddd.toml, aggregate names, and marker regions.
This syntax is not currently implemented:
ddd.
Release Pairing
The library and CLI are versioned together. For maintainers:cargo login first, or provide CARGO_REGISTRY_TOKEN in the environment.
The release script validates that ddd_cqrs_es and ddd-cqrs-es-cli have matching versions, then publishes ddd_cqrs_es before ddd-cqrs-es-cli.
Troubleshooting
ddd check fails with missing generated files:
- Run it from the generated project root or pass
--cwd <project>. - Confirm
ddd.toml,Cargo.toml, andsrc/domain/mod.rsexist.
ddd add event cannot find an aggregate:
- Use the aggregate name from
ddd.toml. - Run
ddd add aggregate <Name>first if the aggregate does not exist.
--runtime wasmtime is rejected:
- The CLI-generated runtime is currently Spin-only.
- Use
spin, or checkddd capabilities --jsonafter upgrading the CLI.
- Inspect the file before using
--force. - Prefer dry-run JSON to see exactly which path is colliding.