implement · git:20261118.581e4cd · 2026-11-18 · sha256 fac765cbadc53a22

implement git:20261118.581e4cdA

Immutable. This exact content never changes and is served at /api/v1/blob/fac765cbadc53a22.

No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_l7ca44r34ezt2enz/fac765cbadc53a22686e21a545b82976ddf79923fb6bed29b7b2a7f0e07c483b.json

Then /plugin install implement@markdownregistry-l7ca44r34ezt2enz in Claude Code. It installs this exact version, the one graded A here, pinned to the commit it was graded at, and leaves it there.

---
name: implement
description: Audits any ticket or PRD for ambiguity, designs modular/configurable/optimized solutions reusing shared UI and utilities, executes test-first production code, runs post-ticket independent review, and checkpoints cross-machine handover commits. Use when implementing any ticket, issue, or feature slice.
---

# Implement (Ambiguity Audit → Pre-Code Design → TDD → Post-Ticket Review & Handover)

Build **one ticket or vertical slice** to industrial production quality—never MVP stubs, hardcoded values, or unreviewed diffs.

## Decision tree

1. **Does the ticket/PRD/request pass Phase 0 (Ambiguity & Feasibility Audit)?**
   - **No (unclear rules, UI states, auth/tenancy, config keys, API contracts, or repo conflicts)** → **STOP. Do NOT write code and do NOT invent defaults.** Call `ask_question` with exact gaps and `(Recommended)` options.
   - **Yes** → Proceed to step 2.
2. **Is the ticket blocked by an unfinished ticket (`Blocked by` in `docs/sprint/SPRINT.md`)?**
   - **Yes** → Stop and report the blocking ticket first.
   - **No** → Proceed to step 3.
3. **Is `CONTEXT.md` populated for the target area of the codebase?**
   - **No** → Run `/index-project` (including `scan-repo.mjs`) first so you know exact dependencies, UI primitives, config/logging seams, and verification commands.
   - **Yes** → Execute Phases 1–3 below.

---

## Phase 0: Mandatory Ticket / PRD Ambiguity Audit (Anti-Yes-Man Gate)

Audit Jira/GitHub/Linear/chat/Sprint tickets against these 7 checks before designing or coding:
1. **Scope & Acceptance Criteria**: Is every expected behavior and exclusion testable?
2. **Actors & Auth**: Who can access/mutate this? What happens on `401`/`403`/`404` or cross-tenant access?
3. **Inputs & Edge Cases**: Required/optional fields, bounds, formats, empty/duplicate/idempotent cases?
4. **Data & API Contract**: Exact fields, status/error codes, schema migrations—and do referenced tables/endpoints exist?
5. **UI / UX States (if UI)**: Loading, empty, validation error, server/offline error, disabled/in-flight, responsive, disposal?
6. **Config, Logging & Failures**: Env/config keys, timeouts/retries, offline/partial failure behavior?
7. **Codebase Contradictions**: Does anything contradict `CONTEXT.md` or existing code?

**Hard rule:** If any behavior-changing detail is missing or contradictory, stop, cite `ticket/PRD` vs `file:line`, and call `ask_question`.

---

## Phase 1: Pre-Code Design, Config/Logging & Reuse Plan

Before editing any file:
1. **Reuse Search**: Search `components/`, `widgets/`, `ui/`, `shared/`, `lib/`, `utils/`, `hooks/`, `schemas/`, `api/` and read target primitives/helpers. Lock what you will **reuse or extend** (never duplicate).
2. **Callers Check**: Search all callers (`rg -n`) of any shared symbol/component you plan to modify.
3. **Engineering Design Check** (invoke `/codebase-design` if non-trivial):
   - Modularity & narrow DI seam at external I/O boundaries.
   - Performance optimization: zero N+1, optimal data structures, cursor pagination/`ListView.builder`, isolate/worker offload for heavy CPU, `dispose()`/`close()` plan.
   - Configurability: exact env, `--dart-define`, or typed config keys (zero hardcoded URLs, limits, or secrets).
   - Structured logging: events, `traceId`, and `<REDACTED>` secret/PII policy.

---

## Phase 2: TDD Execution & Optimization

1. Follow `/tdd`: write failing public-seam tests (happy path, `N-1`/`N`/`N+1`, invalid/empty, auth, idempotency, failure mode).
2. Implement complete production logic—zero stubs, mock stores, dummy data, hardcoded secrets/URLs, or stray `print`/`console.log`.
3. Run focused tests and static analyzer/typechecker (`dart analyze`, `tsc --noEmit`, etc.) after each step.

---

## Phase 3: Post-Ticket Re-Check, Independent Review & Handover Commit

1. **Ticket Re-Check**: Re-read the ticket/PRD line-by-line and confirm every acceptance criterion, UI state, config key, log event, and edge case is implemented.
2. **Black-Box Diff Audit & Full Verification**:
   ```bash
   node .agents/skills/implement/scripts/audit-diff.mjs --help
   node .agents/skills/implement/scripts/audit-diff.mjs
   ```
   Then run the project's full test, static analysis, lint, and build commands via `run_command` and confirm exit code `0`.
3. **Mandatory Post-Ticket Review**: Run `/code-review` (using `adversarial-reviewer` via `invoke_subagent` on multi-file diffs) to verify zero defects, zero secret leaks, zero DRY/UI duplication, and optimal performance.
4. **Cross-Machine Handover & Commit**:
   - Update `CONTEXT.md` if new shared UI, utilities, config vars, or seams were introduced.
   - Update the ticket completion log, `docs/sprint/SPRINT.md` (promote newly unblocked tickets), and run `/handoff` to update `docs/sprint/HANDOFF.md` + `.scratch/handoff.md`.
   - Create one atomic Conventional Commit (`feat(scope): ...`) containing this ticket + updated sprint/handover docs if commits were authorized in this session; otherwise present the verified file list and exact commit command/message for user approval.