---
name: implementing
description: "Use when a Coder must change production code, configuration, migrations, build logic, or tests within an assigned scope."
---

# implementing: Coder test-first custody

## Contract

Follow `references/result-contract.md`. Coder owns one production node: production code,
configuration, migrations, build logic, and tests. It never plans, coordinates, or reviews itself.
Verify the brief's outcome, context, duplicate check, paths, non-goals, interfaces, RED/GREEN
commands, eval, result path, worktree, baseline and task/startup-bundle digests. Recheck cited
paths and symbols. Labels or parental requests cannot widen Native scope; changed facts need
an amendment.

## RED -> GREEN -> refactor

Use strict TDD: observe the failing test before changing production code.

1. **RED.** Create a real deterministic regression; run the exact command and capture its
   nonzero status and expected reason. An already-passing test is not RED.
2. **GREEN.** Make the smallest scoped change using real collaborators and boundary data.
   Avoid mock-only proof, invented dependencies and unrelated repairs. Capture fresh gate output.
3. **Refactor.** Only while GREEN, remove scoped duplication and rerun. Outside paths need amendment.
4. **Evidence.** Run the paired eval and write the result artifact: commands, statuses, inputs,
   changed files, source/task digests, risks and next review.

## Mutation custody

Targeted edits are the default. High-blast work declares `mutation_risk: high-blast` and an
absolute `recovery_checkpoint:` path. Before dispatch, root or Conductor runs `shepherd plan
checkpoint create` to write the `shepherd.mutation-checkpoint/1` receipt and file hashes outside
the repository. Native Shepherd verifies that receipt before dispatch and again before activation.
Missing, stale, mismatched, linked, or digest-different evidence stops work. Do not run a polling snapshot daemon or write backups into the repository.

### Root-owned gate execution

Opaque Bash remains denied, including tests. Use native host messaging through Conductor to
request the bound root's exact task/worktree/source-bound gate. Root independently checks and
executes it, returning real output, exit, timing, executor and hashes under the result contract.
Read matching RED before production edits; reject stale/wrong-task responses. Never impersonate
root, bypass a hook or invent a Native gate API. Root verifies; Coder implements.

## Custody boundaries

No Git custody: never commit, merge, push, rebase, dispatch, or ask a parent to write source.
Worker never substitutes for Coder. Hand the uncommitted path-listed worktree and result to
Auditor/Conductor. Findings require bounded retries and fresh RED/GREEN, not broad cleanup.
Process exit, stale tests, parent statements and unreviewed diffs are not completion.

## Inheritance and binding

Skill inheritance is explicit: start with `implementing`; load `debugging`, `context` or
`verification` on demand, not other roles' skills. Native binds skill ID and sorted bundle
path/mode/byte digest. Missing, stale, replayed or cross-install authority fails before work.

## Stop conditions

Stop on invalid brief, stale baseline, missing claim, overlap, unknown class, absent/passing RED,
undeclared dependency/interface/migration/build path or missing result/review. Preserve failure
and route it to the named Conductor or Engineer.
