CLI utilities for csrd service generation and feature augmentation
Project description
csrd-utils
CLI and runtime helpers for generating csrd services and augmenting existing services with optional features.
Install
pip install "csrd-utils @ git+https://github.com/csrd-api/fastapi-common.git#subdirectory=packages/utils"
CLI
csrd --help
csrd --version
csrd new workspace # create workspace, then choose none/service/cluster
csrd new service # requires workspace; prompts to create one if missing
csrd new service --interactive --name items # pre-fills name prompt with 'items'
csrd new service --name inventory --no-interactive --output ./my-workspace
csrd new service --name pricing --output ./my-workspace --no-interactive
csrd new cluster --spec ./cluster.yaml --output ./my-workspace
csrd new cluster # requires workspace; interactive mode can offer to create one
csrd feature list
csrd feature plan workers --service .
csrd feature plan workers --service . --json
csrd feature add workers --service .
csrd doctor --service .
csrd audit # if cwd is workspace, audits all services
csrd audit --service . # explicitly audit one service path
csrd completion bash # print bash completion script
feature plan --json is useful for CI or tooling wrappers.
Bash tab completion
Enable command/subcommand completion in bash:
source <(csrd completion bash)
Then examples like csrd ne<TAB> and csrd new wor<TAB> complete to new and workspace.
Workspace extraction command
Service extraction into a sibling workspace is supported:
csrd workspace extract-service --service ./source-ws/src/pricing --target-workspace ../pricing-ws --mode copy
csrd workspace extract-service --service ./source-ws/src/pricing --target-workspace ../pricing-ws --mode move
csrd workspace extract-service --service ./source-ws/src/pricing --target-workspace ../pricing-ws --dry-run --json
Use extraction when service ownership diverges, release cadence becomes independent, or workspace orchestration starts coupling unrelated deployments.
Manual fallback remains available if needed:
csrd new workspace --name pricing-ws --output .. --generate none
cp -a ./source-ws/src/pricing ../pricing-ws/src/pricing
cd ../pricing-ws
csrd new cluster --spec ./.csrd/cluster.yaml --output . --force
Interactive generation behavior
csrd new serviceandcsrd new clusterare workspace-first commands.- If a workspace marker is missing in the selected output path, interactive flows ask to create one and continue.
- Non-interactive generation errors when no workspace marker is present.
- Workspace cluster source of truth is persisted at
.csrd/cluster.yaml. - If
.csrd/cluster.yamlalready exists,csrd new serviceappends the generated service and refreshes scaffold files (docker-compose.yml,.env.example,README.md,smoke.sh). Service source directories and running containers are never touched. - If
.csrd/cluster.yamlis missing,csrd new servicebootstraps.csrd/cluster.yamland writes initial cluster scaffold files. csrd new serviceruns a compact interactive flow by default (core prompts 1-6), then asks whether to show advanced options.csrd new workspacecreates a workspace directory and prompts whether to generatenone,service, orclusterimmediately.- In compact mode, advanced options are hidden by default.
csrd new service --interactiveruns the full verbose interactive flow.- Passing
--name <value>in interactive mode uses that value as the name prompt default. - You can still overwrite the default by entering a different value at the prompt.
- Use
--no-interactivefor fully flag-driven generation. - Database default is
none. - All yes/no prompts default to
No(y/N).
Typical workflow
# 0) Create a workspace and generate a service inside it
csrd new workspace --name local-dev --output . --generate none
csrd new service --name inventory --output ./local-dev --database postgres --workers
# 1) Verify service compatibility
csrd doctor --service ./local-dev/src/inventory
# 1b) Audit for weak/insecure defaults
csrd audit --service ./local-dev/src/inventory
# 2) Inspect available bundled features
csrd feature list
# 3) Dry-run a feature
csrd feature plan workers --service ./local-dev/src/inventory
# 4) Apply feature files/merges
csrd feature add workers --service ./local-dev/src/inventory
# 5) Add a second service — workspace auto-upgrades to cluster
csrd new service --name pricing --output ./local-dev --database postgres
Bundled assets
features/workers/feature manifests and fragmentstemplates/cookiecutter-service/template starter
Python API
from pathlib import Path
from csrd_utils import ServiceAugmentor
from csrd_utils.resources import features_path
with features_path() as feature_lib:
augmentor = ServiceAugmentor(Path("."), feature_lib)
ok, changes = augmentor.add_feature("workers", plan=True)
Documentation
docs/CLI_REFERENCE.md- full command/flag referencedocs/FEATURES.md- bundled feature catalog and behaviordocs/FUTURE_WORK.md- remaining provider-specific CI wiring work (Phase 5B)docs/AGENT_SMOKE_TESTS.md- copy/paste validation flow for clean workspacesdocs/COMMAND_MATRIX.yaml- machine-readable command matrix for automationAGENTS.md- package-local rules for autonomous agents
CLI-only agent mode
If an agent can only see the installed CLI (not source files), use this exploration sequence:
csrd --help
csrd new --help
csrd new workspace --help
csrd new service --help
csrd new cluster --help
csrd feature --help
csrd doctor --help
csrd audit --help
csrd feature list
Then run a clean smoke flow:
mkdir -p /tmp/csrd-smoke
csrd new workspace --name ws --output /tmp/csrd-smoke --generate none
csrd new service --name demo-svc --output /tmp/csrd-smoke/ws --no-interactive
csrd doctor --service /tmp/csrd-smoke/ws/src/demo-svc
csrd audit --service /tmp/csrd-smoke/ws/src/demo-svc
csrd feature plan workers --service /tmp/csrd-smoke/ws/src/demo-svc
csrd feature add workers --service /tmp/csrd-smoke/ws/src/demo-svc
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file csrd_utils-0.3.80.tar.gz.
File metadata
- Download URL: csrd_utils-0.3.80.tar.gz
- Upload date:
- Size: 63.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77998f61c546fc51b9b41a38886266171e1a3bfa826101c062b3be5f6fa000c7
|
|
| MD5 |
ed3b4ccc7c6957c51bed7ddc50f0982c
|
|
| BLAKE2b-256 |
d904a826eea928e8685276b060b19ebb4e282b30d0fc1fbe7d23b0bdd8148a9e
|
Provenance
The following attestation bundles were made for csrd_utils-0.3.80.tar.gz:
Publisher:
release.yml on csrd-api/fastapi-common
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
csrd_utils-0.3.80.tar.gz -
Subject digest:
77998f61c546fc51b9b41a38886266171e1a3bfa826101c062b3be5f6fa000c7 - Sigstore transparency entry: 1436016119
- Sigstore integration time:
-
Permalink:
csrd-api/fastapi-common@a51aea3af303e4504c28e3ba9536417cf9c5ef11 -
Branch / Tag:
refs/tags/v0.3.80 - Owner: https://github.com/csrd-api
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a51aea3af303e4504c28e3ba9536417cf9c5ef11 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file csrd_utils-0.3.80-py3-none-any.whl.
File metadata
- Download URL: csrd_utils-0.3.80-py3-none-any.whl
- Upload date:
- Size: 112.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20885459300b946ec39d04c83f733e4652353f65bc0824027c579d167720e674
|
|
| MD5 |
20b9a4142678197d35de320a8e6bef32
|
|
| BLAKE2b-256 |
4cb990ab84c8727a5e403ae9e90786498ca214acfb7ec9eea438be46be4213a4
|
Provenance
The following attestation bundles were made for csrd_utils-0.3.80-py3-none-any.whl:
Publisher:
release.yml on csrd-api/fastapi-common
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
csrd_utils-0.3.80-py3-none-any.whl -
Subject digest:
20885459300b946ec39d04c83f733e4652353f65bc0824027c579d167720e674 - Sigstore transparency entry: 1436016359
- Sigstore integration time:
-
Permalink:
csrd-api/fastapi-common@a51aea3af303e4504c28e3ba9536417cf9c5ef11 -
Branch / Tag:
refs/tags/v0.3.80 - Owner: https://github.com/csrd-api
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a51aea3af303e4504c28e3ba9536417cf9c5ef11 -
Trigger Event:
workflow_dispatch
-
Statement type: