Nils CLI Deliver High Value Refactors
Contract
Prereqs:
- Run inside the
nils-cligit work tree. - Rust toolchain available on
PATH(cargo,rustfmt,clippy). git,gh,semantic-commit, andgit-scopeavailable when delivering the PR end-to-end.- Use this skill together with:
$deliver-feature-pras the canonical delivery policy.$create-feature-prand$close-feature-prthrough$deliver-feature-pr.
Inputs:
- Optional scope hints:
- target crate(s) to prioritize
- constraints (time, risk tolerance, out-of-scope areas)
- Optional quality priorities:
coverage-first,stability-first,shared-extraction-first
Outputs:
- One of two outcomes:
Implement: at least one high-value refactor is implemented with tests and validation evidence, then delivered via$deliver-feature-pr.No Action: no high-value target found; return concrete recommendations and potential issue list.
- Reporting split (strict):
Implement: use$deliver-feature-prdelivery contract end-to-end (open PR, wait CI green, close PR).No Action: use.agents/skills/nils-cli-deliver-high-value-refactors/references/NO_ACTION_RESPONSE_TEMPLATE.md.
Exit codes:
0: completed workflow (implemented changes or no-action report)1: command/runtime failure while executing workflow2: usage/scope ambiguity that blocks safe execution
Failure modes:
- No candidate passes the value gate (avoid refactor-for-refactor).
- Candidate requires behavior changes that break parity expectations.
- Shared extraction crosses crate boundaries with unclear ownership or high regression risk.
- Unable to run required validation commands in the current environment.
Scripts (only entrypoints)
.agents/skills/nils-cli-deliver-high-value-refactors/scripts/render-refactor-response-template.sh(No Actionresponse only)$AGENT_HOME/skills/workflows/pr/feature/deliver-feature-pr/scripts/deliver-feature-pr.sh(Implementdelivery only)
Workflow
- Build candidate inventory (all crates, evidence-first)
- Review each crate for:
- missing tests around observable behavior, edge cases, and error paths
- flaky or brittle logic (implicit assumptions, weak error handling, unstable output contracts)
- duplicated domain-neutral helpers that could move into shared foundations crates:
crates/nils-commoncrates/nils-termcrates/nils-test-support
- Capture each candidate with concrete evidence (file path + why it matters).
- Apply the value gate (must pass before any refactor)
- A candidate is implementable only if it satisfies at least one:
- improves correctness/stability for user-visible behavior
- adds meaningful coverage for uncovered critical paths
- removes duplicated logic used by 2+ crates via shared foundations extraction
- Reject candidates that are style-only, cosmetic-only, or low-impact churn.
- Decide branch
- If one or more candidates pass:
- choose smallest high-value slice
- implement with behavior parity preserved
- add/expand tests first or alongside code changes
- If none pass:
- do not refactor
- produce a no-action recommendations report using the no-action template
- Implementation rules (when branch is
Implement)
- Prefer characterization tests before moving logic.
- Keep crate-local adapters for user-facing messages/exit-code policy when extracting shared helpers.
- Extract only domain-neutral primitives into shared foundations crates.
- Avoid bundling unrelated cleanup in the same change set.
- Validation
- Run targeted tests for touched crates first.
- If scope is broad or cross-crate, run:
./.agents/skills/nils-cli-verify-required-checks/scripts/nils-cli-verify-required-checks.sh
- Report exact commands and pass/fail status.
- Delivery (required for implemented changes)
- Run branch-intent preflight:
deliver-feature-pr.sh preflight --base main
- Use
$create-feature-prto create branch/commit/open PR from confirmed base branch. - Wait for checks to become fully green:
deliver-feature-pr.sh wait-ci --pr <number>
- If checks fail, fix on the same feature branch, push, and re-run
wait-ciuntil green. - Close after CI is green:
deliver-feature-pr.sh close --pr <number>
- The
Implementbranch is not complete until$deliver-feature-prworkflow finishes successfully.
- Response contract (always required)
Implementpath: report$deliver-feature-prartifacts:- PR URL
- CI status summary
- merge commit SHA
- final branch state
No Actionpath: use the no-action template with concrete recommendation list and potential issues.- Render helpers:
./.agents/skills/nils-cli-deliver-high-value-refactors/scripts/render-refactor-response-template.sh --mode no-action
Converted and distributed by TomeVault — claim your Tome and manage your conversions.