Rig Implement
Read Evidence rules and Commit handoff. Follow Role dispatch for delegated work and the shared Optional command compression guidance for read-heavy commands.
Input
- A frozen
plan.mdfrom a completed, independently reviewedrig-planrun, with its run ID, digest,revision, and scope verdict table; or an inline mini-plan for aTRIVIALchange (under 3 files and 50 changed lines) with goal, owned paths, verdict table, steps, and acceptance checks. - Optional:
kind=feature,fix, orrefactor. Performance optimization routes torig-optimize.
No plan, no implementation: a
TRIVIALchange may use the inline mini-plan. Larger, ambiguous, orHIGH_RISKwork (auth, credentials, data, release, CI, or migrations) requiresrig-planfirst.
Workflow
- Start the run. Detect gates using
rig_gatewithaction: "detect". If there is no configured gate, passgate_exemptionnaming the reason and manual substitute at start. Callrig_evidencewithaction: "start",skill: "rig-implement", target paths, and bothplan_pathandplan_run_idfor a frozen plan; keep the returned run ID. For an inline mini-plan, omitplan_pathandplan_run_idand pass its complete text astrivial_planat start, before editing. - Verify the plan. For a frozen plan, use
rig_evidencewithaction: "inspect"and explicitrun_idfor both this run and the completed, independently reviewedrig-planrun. Compare the normalized project-relativeplan.pathvalues against the project root; equivalent spellings must not cause a false stop, and paths outside the project are rejected. Require digest equality between bothplan.digestvalues, the plan run'sreview.plan_digest, and the current plan file's SHA-256: useshasum -a 256orsha256sumon POSIX, orGet-FileHash -Algorithm SHA256on Windows, with the plan file as the argument; compare lowercase hex of the raw bytes without rebinding. Missing provenance, missing review, different normalized paths, or a digest mismatch stops implementation. The tool checks reviewed-plan provenance and unchanged plan bytes at start and finalization. Read the plan'srevisionand confirm the work stays inside itsin-scoperows. For an inline mini-plan, confirmTRIVIALeligibility and itsin-scoperows; the tool persists its text, while eligibility and semantic scope remain instruction-enforced. If source contradicts either plan, stop and report; do not rewrite the plan. - Establish a baseline. Run the narrowest relevant test or reproduction before editing. For a refactor, capture characterization tests first.
- Implement in batches. Group non-overlapping edits and their tests into one batch. Run the focused check after each batch. When a batch fails, bisect to the smallest edit so attribution is not lost. When the
in-scoperows decompose into disjoint ownership, run the pieces in parallel as bounded subagents: one owner per path, and serialise only rows that share a path. - Reconcile the scope. After the last edit and any formatter, call
rig_evidencewithaction: "refresh"and amessagenaming what changed. This is the only way the run adopts edited source. - Run configured gates. Call
rig_gatewithaction: "run"and the run ID. If no configured gate exists, execute and record the manual substitute named in the start-time exemption instead. Fix failures and rerun the same gate. Never retry a failing gate unchanged, and never substitute a manual claim for a failed check. If a gate rewrites files, refresh the scope and rerun that gate. - Record outputs.
rig_evidencewithaction: "record"for changed paths, limits, and any decision that future readers need. Map every changed path to anin-scoperow; a path outside the table stops the handoff, which waits for the user to approve a plan revision. - Finalize. For a frozen plan, recheck the plan's SHA-256 against both bound digests using a raw-bytes command from step 2; stop on any mismatch and never rebind an edited plan to bypass the check. For an inline mini-plan, recheck the actual task-owned diff: 3+ files, 50+ changed lines, ambiguity, or
HIGH_RISKscope stops the handoff and routes torig-plan. After the applicable check passes, callrig_evidencewithaction: "finalize". A failed gate or source drift blocks completion; never edit the record to bypass it. If step 7 detects source drift or finalization returnsstale, callrig_evidencewithaction: "refresh", the run ID and amessagegiving the reason, rerun the affected evidence and required checks, and finalize again; a completed or failed run cannot be refreshed, so start one replacement run with the old run ID in its startmessage. If drift recurs, stop and report incomplete. - Commit handoff. Propose the exact commit message and the paths grouped by plan row. Follow Commit handoff: honor explicit restrictions; a user-requested commit or valid existing grant needs no new conversational approval, and proposing this handoff alone does not authorize a commit. Without a grant, use the runtime shell permission prompt for the one-time Approve or Deny decision on that exact commit; do not ask for a conversational Approve first. Approve authorizes only the proposed commit without a persistent grant; Deny leaves changes unstaged. If the user wants persistent approval, offer Approve always separately: its option text states its repository-wide scope across worktrees, the 30-day lifetime, the exclusions, and how to revoke with
rig_git_grantwithaction: "revoke"before the user answers. Only Approve always recordsrig_git_grantwithaction: "approve", the user's literalApprove alwaysanswer inconfirm, andscope_acknowledged: trueonly after that answer accepts the stated scope. Never push.
Rules
- Do not touch paths outside the owned set; a path the verdict table does not mark
in-scopestops work until the user approves a plan revision. - Do not delete or weaken tests to reach green.
- Preserve unrelated working-tree changes.
- Never revert a path that is not in an
in-scoperow. Before reverting, discarding, or overwriting a change you did not author, establish whether it is intended; ask when the tree is shared. - Keep the change minimal: no opportunistic refactors outside the plan.
- Report incomplete work as incomplete; a partial fix with a clear stop is valid.
Output
Report run ID, changed paths grouped by plan row with digests, gate receipts, failed or skipped checks, remaining risks, and the commit handoff. Do not claim completion without a finalized run.
