cli-forge Extend
Use this stage when a generated Rust CLI Skill project, or a takeover-adopted
project that already matches the scaffold-compatible file layout, requires
optional capabilities like JSON streaming (stream), interactive terminal
sessions (repl), or background app-server daemon execution (daemon).
Purpose
Add optional feature modules to an existing project.
This stage expands feature-specific templates, injects the necessary hooks into
the main program flow, updates tests, and synchronizes the capability state
back to the cli-plan.yml contract.
Canonical References
Entry Gate
| # |
Check |
Source |
| 1 |
Target project directory exists |
Filesystem |
| 2 |
Scaffold baseline exists, or takeover baseline is scaffold-compatible |
Filesystem |
| 3 |
Requested feature is stream, repl, or daemon |
User/Router |
| 4 |
Feature is explicitly marked in_scope in cli-plan.yml |
Plan |
| 5 |
Feature is not already added (idempotency check) |
Filesystem |
Required Inputs
project_path
feature (stream, repl, or daemon)
- Details for updating the
cli-plan.yml
Workflow
- If the project lacks both
scaffold-receipt.yml and
takeover-receipt.yml, stop and route back to Takeover for baseline
establishment or refresh. Treat that path as the supported way to create a
takeover baseline for an existing project whose contracts may already
exist, not as a first-time-only adoption path.
- If the project only has
takeover-receipt.yml, continue only when the
adopted repository already contains the scaffold-compatible files this stage
patches directly and the overlay-required API/dependency surface:
Cargo.toml, SKILL.md, src/main.rs, src/lib.rs, src/help.rs, and
src/context.rs; tests/cli_test.rs should also be present when the
generated feature workflow is expected to patch the integration tests
directly. src/context.rs must expose the scaffold-style context/runtime
helpers the overlays call, including resolve_runtime_locations. For REPL
compatibility, the adopted dependency surface must also already include
rustyline plus the context API consumed by repl.rs.tpl. If those files
or required surfaces are missing, stop and tell the user normalization or
manual implementation is required; do not route back to Takeover.
- If the feature is missing or listed as
out_of_scope in cli-plan.yml,
route back to the Plan stage to update the CLI contract first. Do not add
code before the plan allows it.
- Follow
./instructions/add-feature.md.
- Expand exactly the requested templates from
./templates/
(e.g., stream.rs.tpl, repl.rs.tpl, or daemon.rs.tpl).
- Run integration updates safely:
- add the relevant flags to the args struct
- wire the subsystem branch into the
match loop
- add matching struct format assertions in tests
- update standard
SKILL.md boundaries, help text, and README wording
- Require explicit compiler safety at every step using
cargo clippy.
- Run the required verification boundaries from the generated project root:
cargo build
cargo test
cargo clippy -- -D warnings
cargo fmt --check
- Ensure
cli-plan.yml correctly reflects the added capability as in_scope.
- Generate
.cli-forge/extend-receipt.yml using the template at
./contracts/extend-receipt.yml.tpl.
Outputs
- Extended source code and documentation
- Updated
.cli-forge/cli-plan.yml
.cli-forge/extend-receipt.yml
Exit Gate
| # |
Check |
| 1 |
Feature files generated from template |
| 2 |
Source, README, help, and tests correctly wired |
| 3 |
cli-plan.yml updated and synced |
| 4 |
cargo build passes |
| 5 |
cargo clippy -- -D warnings passes |
| 6 |
cargo fmt --check passes |
| 7 |
cargo test passes |
| 8 |
extend-receipt.yml generated |
Guardrails
- Use templates EXCLUSIVELY from the bundled
./templates/ directory for this
stage. Do not reach outside this skill package for extension templates.
- If the feature being added contradicts the
cli-plan.yml, update the plan
first. Scaffolded code and the CLI plan must remain perfectly aligned.
- A takeover-adopted project remains takeover-adopted even after extension.
Keep
takeover-receipt.yml as the baseline marker and add
extend-receipt.yml as the feature-change record, but only after confirming
the repository already matches the scaffold-compatible file layout and
overlay-required API/dependency surface that this stage patches directly.
- If a takeover-adopted project does not have the scaffold-compatible files or
overlay-required API/dependency surface this stage expects, stop and tell the
user normalization or manual feature implementation is required. Do not route
that case back through Takeover.
- If a project already has
design-contract.yml and cli-plan.yml but lacks
both baseline receipts, route to Takeover specifically for baseline
establishment or contract refresh so the missing adopted baseline can be
recorded without pretending the project was scaffolded.
- If the target project already declares daemon behavior in
cli-plan.yml,
preserve that documented daemon surface. stream and repl overlays must
not silently rewrite daemon commands, routing flags, transport choices, or
recovery semantics.
- Refuse to add unsupported features through this stage. This stage only
handles
stream, repl, and daemon.
Next Step
Continue with ../cli-forge-validate/SKILL.md
to run the full compliance rule set.
1---2name: cli-forge-extend3description: Extend stage for the cli-forge skill family: add stream or repl features to an existing scaffolded skill project or to a takeover-adopted project that already matches the scaffold-compatible layout.4---56# cli-forge Extend78Use this stage when a generated Rust CLI Skill project, or a takeover-adopted9project that already matches the scaffold-compatible file layout, requires10optional capabilities like JSON streaming (`stream`), interactive terminal11sessions (`repl`), or background app-server daemon execution (`daemon`).1213## Purpose1415Add optional feature modules to an existing project.1617This stage expands feature-specific templates, injects the necessary hooks into18the main program flow, updates tests, and synchronizes the capability state19back to the `cli-plan.yml` contract.2021## Canonical References2223- [`./instructions/add-feature.md`](./instructions/add-feature.md)24- [`./planning-brief.md`](./planning-brief.md)25- [`./contracts/extend-receipt.yml.tpl`](./contracts/extend-receipt.yml.tpl)26- [`./templates/`](./templates/)27- [`../cli-forge-plan/instructions/daemon-app-server.md`](../cli-forge-plan/instructions/daemon-app-server.md)2829## Entry Gate3031| # | Check | Source |32| --- | --------------------------------------------------------- | ----------- |33| 1 | Target project directory exists | Filesystem |34| 2 | Scaffold baseline exists, or takeover baseline is scaffold-compatible | Filesystem |35| 3 | Requested feature is `stream`, `repl`, or `daemon` | User/Router |36| 4 | Feature is explicitly marked `in_scope` in `cli-plan.yml` | Plan |37| 5 | Feature is not already added (idempotency check) | Filesystem |3839## Required Inputs4041- `project_path`42- `feature` (`stream`, `repl`, or `daemon`)43- Details for updating the `cli-plan.yml`4445## Workflow46471. If the project lacks both `scaffold-receipt.yml` and48 `takeover-receipt.yml`, stop and route back to Takeover for baseline49 establishment or refresh. Treat that path as the supported way to create a50 takeover baseline for an existing project whose contracts may already51 exist, not as a first-time-only adoption path.522. If the project only has `takeover-receipt.yml`, continue only when the53 adopted repository already contains the scaffold-compatible files this stage54 patches directly and the overlay-required API/dependency surface:55 `Cargo.toml`, `SKILL.md`, `src/main.rs`, `src/lib.rs`, `src/help.rs`, and56 `src/context.rs`; `tests/cli_test.rs` should also be present when the57 generated feature workflow is expected to patch the integration tests58 directly. `src/context.rs` must expose the scaffold-style context/runtime59 helpers the overlays call, including `resolve_runtime_locations`. For REPL60 compatibility, the adopted dependency surface must also already include61 `rustyline` plus the context API consumed by `repl.rs.tpl`. If those files62 or required surfaces are missing, stop and tell the user normalization or63 manual implementation is required; do not route back to Takeover.643. If the feature is missing or listed as `out_of_scope` in `cli-plan.yml`,65 route back to the Plan stage to update the CLI contract first. Do not add66 code before the plan allows it.674. Follow [`./instructions/add-feature.md`](./instructions/add-feature.md).685. Expand exactly the requested templates from `./templates/`69 (e.g., `stream.rs.tpl`, `repl.rs.tpl`, or `daemon.rs.tpl`).706. Run integration updates safely:71 - add the relevant flags to the args struct72 - wire the subsystem branch into the `match` loop73 - add matching struct format assertions in tests74 - update standard `SKILL.md` boundaries, help text, and README wording757. Require explicit compiler safety at every step using `cargo clippy`.768. Run the required verification boundaries from the generated project root:77 - `cargo build`78 - `cargo test`79 - `cargo clippy -- -D warnings`80 - `cargo fmt --check`819. Ensure `cli-plan.yml` correctly reflects the added capability as `in_scope`.8210. Generate `.cli-forge/extend-receipt.yml` using the template at83 [`./contracts/extend-receipt.yml.tpl`](./contracts/extend-receipt.yml.tpl).8485## Outputs8687- Extended source code and documentation88- Updated `.cli-forge/cli-plan.yml`89- `.cli-forge/extend-receipt.yml`9091## Exit Gate9293| # | Check |94| --- | ----------------------------------------------- |95| 1 | Feature files generated from template |96| 2 | Source, README, help, and tests correctly wired |97| 3 | `cli-plan.yml` updated and synced |98| 4 | `cargo build` passes |99| 5 | `cargo clippy -- -D warnings` passes |100| 6 | `cargo fmt --check` passes |101| 7 | `cargo test` passes |102| 8 | `extend-receipt.yml` generated |103104## Guardrails105106- Use templates EXCLUSIVELY from the bundled `./templates/` directory for this107 stage. Do not reach outside this skill package for extension templates.108- If the feature being added contradicts the `cli-plan.yml`, update the plan109 first. Scaffolded code and the CLI plan must remain perfectly aligned.110- A takeover-adopted project remains takeover-adopted even after extension.111 Keep `takeover-receipt.yml` as the baseline marker and add112 `extend-receipt.yml` as the feature-change record, but only after confirming113 the repository already matches the scaffold-compatible file layout and114 overlay-required API/dependency surface that this stage patches directly.115- If a takeover-adopted project does not have the scaffold-compatible files or116 overlay-required API/dependency surface this stage expects, stop and tell the117 user normalization or manual feature implementation is required. Do not route118 that case back through Takeover.119- If a project already has `design-contract.yml` and `cli-plan.yml` but lacks120 both baseline receipts, route to Takeover specifically for baseline121 establishment or contract refresh so the missing adopted baseline can be122 recorded without pretending the project was scaffolded.123- If the target project already declares daemon behavior in `cli-plan.yml`,124 preserve that documented daemon surface. `stream` and `repl` overlays must125 not silently rewrite daemon commands, routing flags, transport choices, or126 recovery semantics.127- Refuse to add unsupported features through this stage. This stage only128 handles `stream`, `repl`, and `daemon`.129130## Next Step131132Continue with [`../cli-forge-validate/SKILL.md`](../cli-forge-validate/SKILL.md)133to run the full compliance rule set.