> Extracted from implement/SKILL.md (Mode: implement) — moved verbatim 2026-08-25, ticket [org-internal #3381]. ### Mode: implement (default) The standard implementation workflow for work items from an approved iteration plan. Implement a single work item, guided by the approved design, and self-verify before passing to code review. #### Pre-flight The pre-flight self-check prompt format ([org-internal #2599]), prepended to the Developer sub-agent's task prompt when `routes.{Kind}.preflight` is non-empty: ``` Pre-flight self-check (evidence-based, from retrospective — verify each BEFORE writing code; if one is already satisfied, note why in impl-notes): 1. {item} (evidence: {evidence}) 2. ... ``` #### Process Overview Every diamond below is a gate agents rationalize skipping. None are optional. ```dot digraph implement { rankdir=TB; node [shape=box, fontname="Helvetica"]; pre [shape=diamond, label="Preconditions\n(artifacts + reviews\nconverged)?"]; abort [label="ABORT: list every\nmissing item"]; p1 [label="Phase 1: Parse Context"]; p2 [label="Phase 2: Plan\n(≤3 files per WI)"]; scope [shape=diamond, label="Scope ≤3 files\nAND maps to a\ndesign component?"]; gap [label="Flag design gap,\nDO NOT invent decisions"]; p3 [label="Phase 3: Implement\n(design-exact, tests cover AC)"]; p4 [label="Phase 4: Self-Check\n(typecheck + lint +\ntest:changed + review checklist)"]; clean [shape=diamond, label="0 BLOCKERs\nand 0 MAJORs?"]; p5 [label="Phase 5: Report\n(AC → test traceability)"]; p6 [shape=doublecircle, label="Phase 6: Handoff\nto review-code"]; pre -> abort [label="no"]; pre -> p1 [label="yes"]; p1 -> p2; p2 -> scope; scope -> gap [label="no"]; scope -> p3 [label="yes"]; p3 -> p4; p4 -> clean; clean -> p4 [label="no: fix + re-run"]; clean -> p5 [label="yes"]; p5 -> p6; } ``` #### Tester focus for implement The Tester role in implement writes **boundary + contract tests**: - **Contract tests** — for every public API signature in `impl-notes.md`, verify the documented inputs/outputs, error paths, and side effects. Each acceptance criterion (node `acceptance_criteria` in `{epic-slug}/dag`; historically `04-plan-05-acceptance-criteria`) MUST map to at least one test. - **Boundary tests** — empty values, malformed input, permission boundaries, concurrency edges, and the edge cases the node spec's decision tables / state machines imply. - **Failure-path tests** — every error scenario the node's cross-session edge contracts (historically the interface design, `03-design-04-interface-design`) specify. The Developer's Phase 4 self-check (`bun run test:changed` to green) covers the happy path and existing tests; the Tester's job is the cases the Developer is structurally biased to miss. #### Preconditions > **Publish target (tiered targeting retired, [org-internal #3072] phase 3)**: the > `Size/*`-tiered publish rule (`rules/workflow-routing.md` §"Publish target > by Size/* tier — RETIRED") was retired with the legacy producer skills. > Artifacts publish where the live mode puts them: DAG task mode → node spec > in the frozen `{epic-slug}/dag` copy (see the DAG-mode input path below); > standalone bugfix → `{slug}/bugfix-report` + issue body per bugfix Phase 5. > Legacy tiered locations (`{slug}/02-03-req-design`, `{slug}/04-plan-*`, …) > stay readable for historical runs via `_shared/gitea-read-patterns.md`. > **DAG-mode input path** (DAG ticket pipeline — `Kind/Epic` / `Kind/Feature` > DAG parent, routes-table direct): > DAG-routed tickets **ignore `Size/*`** (`core/skills/analyze-dag/SKILL.md`). > When the ticket routes through the DAG pipeline, the tiered Preconditions > below are replaced by the node spec: the work item and its acceptance > criteria resolve from the **frozen DAG copy** wiki page `{epic-slug}/dag` > (and the `{epic-slug}/dag-nodes/{node-id}` subpages when AC detail is sunk) > plus the node ticket's issue body — there is no `{slug}/04-plan-*` page and > no `Size/*`-tiered req/design page. The design-space + iteration-plan review > convergence preconditions are replaced by the **review-dag single-gate > convergence**: `octopus review status --stage review-dag` must show state > `success` before the node is implemented. > **DAG-route read map** (applies to Phase 1 read inputs and the Phase 3/4 > artifact references below — mirror `verify/SKILL.md`'s DAG branch): when > DAG-routed, resolve each legacy tiered artifact reference (any mention below > of `{slug}/04-plan-*` / `{slug}/03-design-*` pages) from the frozen > DAG copy instead: > > - Work item — `{slug}/04-plan-04-iteration-assignment` / issue body → the > node spec in `{epic-slug}/dag` + the node ticket's issue body. > - Acceptance criteria — `{slug}/04-plan-05-acceptance-criteria` / issue body > → the node `acceptance_criteria` in `{epic-slug}/dag` (+ > `{epic-slug}/dag-nodes/{node-id}` subpages when AC detail is sunk) + the > node ticket's issue body. > - `test_id` (測試用例 ID) declared in `04-plan-05-acceptance-criteria` → the > `test_id` declared on the node AC in `{epic-slug}/dag`. > - Design sections — `{slug}/03-design-**` / `{slug}/02-03-req-design` → the > node spec + cross-session edge contracts in the frozen DAG copy (design > detail is folded into node AC + contracts; there is no `{slug}/03-design-*` > page). > - Interface design — `03-design-04-interface-design` → the node's > cross-session edge contracts in `{epic-slug}/dag`. > - Component mapping — `{slug}/03-design-08-traceability` → the node > `req_refs` + component field in `{epic-slug}/dag`. > > At Phase 6 handoff, pass `mode: "dag-task"` to review-code (its DAG Task > Mode keys off the same frozen-DAG-copy detection). Before starting implementation, confirm: > **Legacy pipeline preconditions retired ([org-internal #3072] phase 3, 2026-08-21)**: the > tier-dependent requirements/design/plan artifact-existence checks and the > design-space / iteration-plan review-convergence checks that used to head > this list belonged to the archived legacy pipeline (`/archive/`). > Live input modes: DAG task mode (node spec from the frozen > `{epic-slug}/dag` copy — see the DAG-mode input path above; convergence > precondition = `octopus review status --stage review-dag` shows `success`) > and standalone modes (bugfix / refactor / port — the request itself is the > spec). Historical req/design/plan pages stay readable via > `_shared/gitea-read-patterns.md`. - [ ] Work item is specified (DAG node ticket `{node-id}`, or a clear task description in standalone modes). - [ ] `core/checklists/implementation.md` is accessible. - [ ] `slug` matches the run's slug (DAG: `{epic-slug}`). - [ ] 跨阶段门控清单: `core/checklists/pipeline-gate.md` is accessible and its DAG 路由变体 section has been confirmed item by item. Specifically: the frozen DAG copy exists and the single gate has converged; the node's cross-session upstream dependencies are at terminal state (`ready`). If any dependency is not complete → abort, listing the blocked nodes. **If any precondition is unmet, abort and inform the user.** Refer to `core/checklists/pipeline-gate.md` for the complete gate checklist. List every missing artifact, every un-converged review, and every blocked dependency explicitly so the user knows exactly what upstream work remains before implementation can begin. Refer to the Recovery Protocol in `core/checklists/pipeline-gate.md` to determine the recovery action for each missing item. #### Work-item selection When the user requests implementation without specifying a work item, resolve the work-item list from the frozen DAG copy: the ready/pending task nodes in `{epic-slug}/dag` (via `wiki 读写 API(见 TERMINOLOGY)`), cross-checked against the node tickets on the Epic's `## DAG 状态` table. (Legacy tier-based resolution via `{slug}/04-plan-04-iteration-assignment` was archived 2026-08-21, [org-internal #3072] phase 3.) Present the current ready nodes for selection: ``` Current iteration: Iteration {N}: {Goal} Available work items: | Work Item | Description | Complexity | Status | |-----------|-------------|------------|--------| | WI-001 | ... | 3 | PENDING | | WI-002 | ... | 2 | PENDING | → Which work item should be implemented? ``` --- #### Phase 1 — Parse Context > **Pipeline stage**: if the source issue exists, move it to the `implement` > column on the Pipeline Stages board per `_shared/gitea-write-patterns.md` > Pattern 7.5. Skip if no source issue exists. Read the upstream artifacts to build a complete implementation context. Resolve inputs per the DAG-route read map (Preconditions above); standalone modes read the request/bug report instead: 1. **Work item** — the node spec in `{epic-slug}/dag` (+ the `{epic-slug}/dag-nodes/{node-id}` subpage when detail is sunk) and the node ticket's issue body: - Node id, title, complexity (`size_attrs`). - Requirements covered (`req_refs`). - Component(s) involved (node component field). 2. **Acceptance criteria** — the node `acceptance_criteria` in `{epic-slug}/dag` (+ sunk subpages) and the node ticket's issue body: - Every falsifiable AC (`AC-{n}`) and `NFR:` entry. - The declared 测试用例 ID (`test_id`) for each criterion — these drive the Red → Green test-first order in Phase 3 and are the handshake with `verify` (DOD-1.6). 3. **Design context** — the node spec + the node's cross-session edge contracts in the frozen DAG copy (design detail is folded into node AC + contracts; there is no separate design page). Historical `{slug}/03-design-*` pages from legacy runs stay readable. 4. **Existing codebase** — use `glob` and `grep` to locate: - Existing files in the component's directory. - Existing tests. - Existing type definitions, schemas, configuration files the work item touches. **Output**: internal only. The Developer MUST have read every referenced design file before writing a single line of code. --- #### Phase 2 — Plan Implementation Before writing code, produce a brief implementation plan: ```markdown ## Implementation Plan: {WI-ID} **Work item**: {description} **Files to create**: - `path/to/new/file.ts` — {purpose} **Files to modify**: - `path/to/existing/file.ts` — {what changes, why} **Design compliance**: - Component: {COMP-XXX} from {design-file} - Interface: {iface-name} from {design-file} - Data entity: {entity-name} from {design-file} **Acceptance criteria to satisfy**: - [ ] {criterion 1} - [ ] {criterion 2} ``` **Rules**: - If the implementation plan reveals that the work item touches > 3 files, pause and ask: "This work item spans {N} files. Is the scope correct, or should it be split?" The Builder (or user) MUST split it into smaller work items each touching ≤ 3 files before proceeding. - If the work item requires a file that doesn't map to any design component, flag a design gap and abort. Do NOT invent design decisions. Present the plan to the user: ``` Implementation plan for {WI-ID}: - {N} files to create, {M} files to modify - {K} acceptance criteria → Proceed? (yes / no / revise) ``` --- #### Phase 3 — Implement Write code following these rules: ##### Design Discipline - Component interfaces, method signatures, and return types MUST match the design document exactly. - Data model fields, types, and relationships MUST match the data design. - API endpoints, request/response schemas, and status codes MUST match the interface design. - If a design decision proves impossible in practice, stop and report the gap to the Builder. Do NOT silently deviate. ##### Code Quality - Follow existing project conventions (read neighbor files first to understand patterns). - Use existing libraries and utilities already in the codebase — do not introduce new dependencies without explicit justification. - Keep functions small and single-purpose — but per `rules/style-guide`, do NOT preemptively extract single-use helpers; inline at the call site unless the helper is reused, hides a genuinely complex boundary, or has a clear independent name that improves the caller. - Handle errors at the appropriate layer (matching the design's error handling strategy). - Write self-documenting code; add comments only for genuinely non-obvious logic. - Document all new/modified public APIs inline (JSDoc/TSDoc/pydoc/etc.) with parameter descriptions, return types, and thrown errors. - If the project has an API documentation file (e.g. OpenAPI spec, API.md), update it to reflect the new endpoints, schemas, or behavior changes. ##### Test Discipline - **Test-first (Red → Green) for declared test_ids.** For every acceptance criterion (node AC in `{epic-slug}/dag`, whose `test_id` mapping is declared inline; historically the `04-plan-05-acceptance-criteria` table) that declares a `test_id`, write that test FIRST and confirm it fails for the intended reason (Red) before writing the implementation that satisfies it (Green). The test's `file-path :: test-name` MUST match the declared `test_id` exactly — this is the implement-side handshake with `verify` (DOD-1.6). A `test_id` marked `MANUAL` or `BENCH: