[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M759TZJR5C70SAATEY5VWMGK":3,"skill-same:01M759TZJR5C70SAATEY5VWMGK":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":27,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M759TZJR5C70SAATEY5VWMGK","implement-issue",null,"Implement one TDD-ready GitHub issue (a sub-issue, or an undecomposed parent that is its own slice) by driving it to green via the tdd skill, bracketed by branch \u002F draft-PR \u002F issue lifecycle. Use when picking a single ready issue off the board to implement. For a parent with open sub-issues, use develop instead.","harmoniqs\u002Famicode","harmoniqs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F199011497?v=4","01M759PQCJ9Y093EC5HC3344DW","Harmoniqs","01M759PQD5S85W68FZKV3XD1X0",7,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Fskills\u002Fimplement-issue\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: implement-issue\ndescription: Implement one TDD-ready GitHub issue (a sub-issue, or an undecomposed parent that is its own slice) by driving it to green via the tdd skill, bracketed by branch \u002F draft-PR \u002F issue lifecycle. Use when picking a single ready issue off the board to implement. For a parent with open sub-issues, use develop instead.\nagents: []\nsurface: public\nsource: amicode\nrevision: 2\n---\n\n# Implement an Issue\n\nThe **leaf executor** of issue-driven development. Take **one** TDD-ready slice and drive it to green by *calling* the `tdd` skill, bracketed by branch \u002F draft-PR \u002F issue lifecycle. This skill composes `tdd` — it never reimplements the RED→GREEN loop.\n\nIt is the development counterpart to the design pipeline (`brainstorming` → `write-an-issue` → `break-into-subissues`): that pipeline publishes TDD-ready issues; this skill picks one up and implements it.\n\n**Announce at start:** \"I'm using the implement-issue skill to implement #\\\u003Cn\\> via TDD.\"\n\n## When to use \u002F not use\n\n- **One ready issue** — a sub-issue, an undecomposed parent, or a lone issue → use this skill.\n- **A parent with open sub-issues** → use `develop` (it walks the sub-issue DAG, dispatching this skill per slice). This skill takes a **single** slice only; handed such a parent it stops and advises `develop` (see Step 2).\n- **No resolved design yet** → STOP and use `brainstorming`. This skill implements a *published* issue; it does not design.\n\n## Usage\n\n```\n\u002Fimplement-issue \u003Cissue-number-or-url> [--branch \u003Cname>] [--base \u003Cbranch>] [--orchestrated]\n```\n\n- `\u003Cissue>` — the single issue to implement (required).\n- `--branch` \u002F `--base` — branch override (see Step 3); rarely needed, the default is correct.\n- `--orchestrated` — set by `develop` only; the slice runs on the caller-provided worktree branch (the branch already checked out). See Modes.\n\n## Modes\n\n| | **Standalone** (default) | **Orchestrated** (`--orchestrated`) |\n|---|---|---|\n| Invoked by | a human off the board, in the main session | `develop`, one slice per worktree (spawned via `amicode_session` with `workspace: \"create\"`) |\n| Branch | this skill creates it (Step 3) | use the caller-provided `opencode\u002F\u003Cslug>` worktree branch; skip creation |\n| Bootstrap | not needed (main checkout) | **required** — `pnpm install` (or equivalent) before any build\u002Ftest (see Worktree contract) |\n| PR | opens a draft PR, drives it to ready\u002Fmerge | **opens no PR, performs no merge** |\n| Terminus | AFK→merge \u002F HITL→review (Step 6) | return the branch; `develop` merges + integration-tests |\n\nOrchestrated mode is dispatched by `develop` (one slice per worktree, via the Engineer). It can also be invoked directly to exercise the seam.\n\n### Worktree contract (orchestrated mode)\n\nWhen the session was spawned with `workspace: \"create\"`, the implementer operates in an isolated worktree. Four rules:\n\n1. **Bootstrap first.** The worktree is a fresh checkout — dependencies are not installed. The implementer's first action before any build or test is project bootstrap: `pnpm install` (or the project's package manager equivalent — `npm install`, `yarn`, `pip install -e .`, `julia --project=. -e 'using Pkg; Pkg.instantiate()'`, etc.). Detect the package manager from the lock file present in the worktree root.\n\n2. **Stay on the worktree branch.** Commits land on the worktree's `opencode\u002F\u003Cslug>` branch — the branch created by the worktree API and already checked out. **Do not** create new branches, switch branches, or check out other refs. The parent `develop` session owns branch topology; the implementer only commits to what is already checked out.\n\n3. **`index.lock` retry.** Concurrent worktrees sharing the same `.git` directory may contend on `.git\u002Findex.lock`. If `git add` or `git commit` fails with `Unable to create '…\u002F.git\u002Findex.lock': File exists`, **retry once** after a 2-second wait. If the retry also fails, report the lock contention error — do not delete the lock file.\n\n4. **Engine-overlay slices bootstrap and test differently.** When a slice edits the engine overlay (any path under `packages\u002Fapp-bundle\u002Foverlay\u002F...`), rules 1 and the develop loop's default verify command (`pnpm --filter amicode test`) are **misleading** — the overlay is not part of the outer pnpm workspace, so that filter finds zero tests and exits 0 (it runs the *extension's* vitest suite, a different surface). A false \"no tests ran, exit 0\" pass is the trap. Instead:\n\n   - **Bootstrap + test through the materialize path**, not the pnpm filter:\n\n     ```\n     node packages\u002Fapp-bundle\u002Fscripts\u002Fmaterialize.mjs --out packages\u002Fapp-bundle\u002F.materialized\n     cd packages\u002Fapp-bundle\u002F.materialized && bun install --ignore-scripts\n     cd packages\u002Fopencode && bun test test\u002F\u003Cpath>\u002F\u003Cfile>.test.ts\n     ```\n\n     The `bun test` **must** run from within `packages\u002Fopencode` — a `do-not-run-tests-from-root` guard blocks the materialized root (`Failed to scan non-existent root directory for tests`). `.materialized` is a gitignored build artifact; only the committed `overlay\u002F` files are the source of truth.\n\n   - **Refresh the manifest hash after editing a manifest-tracked overlay file.** `build-binary` CI runs `materialize.mjs`, which `exit 1`s when a listed file's sha256 diverges from `packages\u002Fapp-bundle\u002Fmanifest.json` (locally it may only WARN, so the failure first surfaces in CI). Fix by patching **only the changed file's hash** in the manifest's `files` (or its `exceptions`) entry. **Never full-refresh** with `refresh_manifest.mjs` for a targeted edit — it is not exceptions-aware and folds the quarantined `exceptions` entries into `files`, duplicating them and reddening `app-bundle-gate` (`drift_gate.mjs`).\n\n---\n\n## Procedure\n\n### 1. Read the issue and its context\n\n- `gh issue view \u003Cn> --json title,body,labels,number,url` (in the code-owning repo).\n- Parse the body's `## Acceptance Criteria` (the RED list), `## Testing Decisions` (the reuse map, if present), `## Key Decisions`, `## Constraints & Invariants`, and `Prior Art`.\n- If the body carries `Part of #N`, read the **parent** and load its **decision surface** (Problem \u002F Approach \u002F Constraints) as cross-cutting context — it is referenced by the sub-issue, not duplicated onto it.\n- The issue carries no file paths or code by design; use `Prior Art` to find the modules to read, then read the **current** code.\n\n### 1.5 Render the spec (standalone + interactive only)\n\nBefore checking eligibility, present the issue back to the user as the brief it was written to be — **never a raw body dump**:\n\n- **Header** — `#\u003Cn> \u003Ctitle>`, the repo, the board status, and the `afk`\u002F`hitl` signal.\n- **Decision surface** — the `> [!IMPORTANT]` block reproduced as the skimmable card it is (Problem \u002F Approach \u002F Scope \u002F Assumptions).\n- **Acceptance Criteria** — as a checklist; these are the RED list, so the done-definition is visible up front.\n- **Key Decisions \u002F Constraints & Invariants** — tight bullets.\n- **Prior Art** — the modules-to-read-first list.\n- **Parent context** — when the body carries `Part of #N`, fold the parent's Problem\u002FApproach into a line or two.\n\n**Math renders as math.** When the issue carries mathematical content — objectives, Hamiltonians, bounds, error models — typeset it: inline LaTeX for symbols ($\\hat H$, $\\Omega_{\\max}$, $F \\geq 0.999$), display equations for objectives and derivations, and quantities exactly as the researcher writes them (infidelity as `2.1e-4`, tabular-nums where digits align). An issue in the physics vein gets elegant mathematical exposition, not prose-paraphrased formulas. Non-mathematical issues just get the clean card — no ceremony.\n\n**Skip conditions:** `--orchestrated` mode (no human in the loop); non-interactive\u002FAFK runs; **chore-tier** bodies (one line: number, title, problem — the record is already that short). This render is the same presentation `write-an-issue` uses at its approval gate — the approver and the implementer see the same brief.\n\n### 2. Check eligibility\n\n- **Parent guard:** if this issue has **open sub-issues**, it is not a single slice. Create nothing, comment advising `develop` (a sibling skill in the armed set — it walks the sub-issue DAG, dispatching this skill per slice), and return `blocked`.\n- **Blocked-by gate:** read `Blocked by` from GitHub's native issue-dependency relationships via GraphQL — `gh api graphql` over `Issue.blockedBy(first:50){ nodes{ number state } }` (no native `gh` subcommand or `gh issue view --json` field exposes these; never read a body section). A blocker in `state: CLOSED` is satisfied. If any blocker is still open, create no branch, comment the unmet dependency on the issue, set its board card to **Blocked** (see `write-an-issue` step 7e), and return `blocked`. An explicit user \"run anyway\" is the only thing that overrides this gate.\n\n### 3. Resolve the branch (override ladder)\n\nHighest precedence wins:\n\n1. **Explicit arg** — `--branch` \u002F `--base` from the invocation.\n2. **Repo convention** — a branch naming\u002Fbase convention declared in the repo's `AGENTS.md` (or `CLAUDE.md`, whichever the repo carries).\n3. **Default** — `gh issue develop \u003Cn>` (creates an issue-linked branch) cut from the current tip of `main`.\n\nBranch from `main` (standalone) — blockers are merged first, so there is no stacking. An override may set the name\u002Fbase\u002Freuse-existing; it does **not** silently bypass the Blocked-by gate (Step 2).\n\n**Orchestrated:** skip this step entirely — work on the caller-provided worktree branch.\n\n### 4. Run the `tdd` loop\n\nInvoke the **`tdd`** skill and let it run the RED→GREEN tracer-bullet loop. Supply:\n\n- the issue's `## Acceptance Criteria` as the **RED list** — one tracer-bullet cycle per criterion;\n- `## Testing Decisions` (when present) as the **reuse map** — which suites to extend (`reuse-first`). This is advisory: the modify-vs-create call stays in the `tdd` loop against the real suite.\n\n**Planning gate:** `tdd`'s Planning step is an interactive human-approval gate. In a **non-interactive run** (AFK, or `--orchestrated`) it is **pre-satisfied by the published issue** — its Acceptance Criteria + Testing Decisions + the parent decision surface *are* the approved plan, ratified when the issue was published. Pass them to `tdd` in lieu of the interview and proceed. In an interactive standalone run you may still surface Planning to the user.\n\n- **First commit → open the draft PR** (standalone, Step 5).\n- Retries: a RED that won't go green is retried up to **2 cycles** before being declared stuck (Step 6). An Acceptance Criterion you cannot express as a test routes through that same stuck path — never silently skip it.\n- **No test surface?** If the deliverable is prose (a skill, ADR, or config) or the repo has no executable suite, there is nothing to RED→GREEN — `tdd` degrades to **author-then-review against the Acceptance Criteria as a checklist**. \"Done = green\" then reads as \"every AC satisfied by inspection,\" verified by walking representative scenarios. Single-artifact *code* (one script) still TDDs incrementally within this one issue.\n\n### 5. Draft PR (standalone only)\n\n- At the **first commit**, open a **draft** PR: `gh pr create --draft --title \u003C…> --body \u003C…>`. Link it to the invoked issue with `Closes #\u003Cinvoked-issue>`. (Closing a sub-issue does **not** close its parent — parent closure is the orchestration layer's job.)\n- On opening the draft PR, advance the issue's board card to **In Progress** (the standalone \"work started\" signal; see `write-an-issue` step 7e for the mechanism).\n- The draft PR is the live surface: CI runs incrementally, RED-during-loop is expected, and on failure it becomes the WIP\u002Fescalation artifact (Step 6).\n- Mark it ready (`gh pr ready`) **only** once the full suite is green.\n- **Never** create the PR before the first commit (the branch itself is created in Step 3), and never in `--orchestrated` mode.\n\n### 6. Terminal state\n\nA slice is **done = green** (all its tests pass; demoable on its own). Status is `complete` **iff every** Acceptance Criterion is green; any non-green criterion → `failed`.\n\n**Orchestrated:** skip the AFK\u002FHITL terminus below — there is no PR, no merge, no push, and **no board-status change** (`develop` owns the card's In Progress \u002F In Review \u002F Done transitions for orchestrated slices). Once green, go to Step 7 and return the branch; `develop` merges, integration-tests, and decides the terminus. On failure, leave WIP committed on the branch and return `failed` (no PR, no comment-on-issue — `develop` owns escalation).\n\n**Standalone** — read the AFK\u002FHITL signal from the issue's `afk` \u002F `hitl` label (**absent → treat as HITL**, the safe default).\n\n**Standalone, green:**\n\n| Tag | Action |\n|---|---|\n| **AFK** | mark PR ready → merge gated on CI: `gh pr merge --auto` where the repo has auto-merge enabled (merges *when* CI is green); where it doesn't (`--auto` is rejected), wait for CI to pass — or, in a repo with no CI, proceed directly — then plain `gh pr merge` → on merge, the issue closes (via `Closes`) and the board's **\"Item closed\" auto-workflow moves the card to Done** (never set Done manually). |\n| **HITL** \u002F untagged | mark PR ready → request review → set the board card to **In Review** as the *final* step, then re-read and re-set if the board's async \"PR linked → In Progress\" workflow clobbered it (see `write-an-issue` 7e) → **stop** (no merge). |\n\n**AFK that cannot merge cleanly** (CI fails, or branch conflicts) → **downgrade to HITL**: do not merge, comment, leave the issue open.\n\n**Failure** (the `tdd` loop stays RED after its 2 cycles, a `Key Decision` proves infeasible, an Acceptance Criterion is untestable, or a Blocked-by dep turns out unmerged):\n\n- Stop. Push WIP to the (draft) PR.\n- Comment the **precise** blocker on the issue (which criterion \u002F decision \u002F dependency, and why).\n- Leave the issue open. Return `failed`.\n- **Never** merge partial or non-green work. **Never** bounce into the design phase — escalate to a human (standalone) or to `develop` (orchestrated), which decide next.\n\n### 7. Return\n\nReturn a structured result in all modes:\n\n```yaml\nissue: \u003Cnumber>            # the invoked issue's number\nstatus: complete | blocked | failed\nbranch: \u003Cbranch-name>\ncommit_shas: [\u003Csha>, ...]\nac_results:\n  - {criterion: \"\u003Ctext>\", green: true|false}\nskill_findings: []        # optional: skill-vs-reality conflicts hit this slice\n                          # (findings-file paths or terse one-liners → ledger amicode\u002Fskills-integrity\u002F)\nnotes: \"\u003Cblocker \u002F deviation \u002F escalation detail>\"\n```\n\nIn `--orchestrated` mode `branch` is always set and **no PR exists** — `develop` consumes this to merge the branch, integration-test, and checkpoint (close the issue \u002F move its card).\n\n---\n\n## Invariants\n\n- Never merge partial or non-green work.\n- Never auto-merge a HITL or untagged slice; auto-merge only an explicit `afk` slice, and only conditionally on CI.\n- Never open a PR or merge in `--orchestrated` mode.\n- Never create a branch or PR at issue-creation time; the draft PR is born at the first commit.\n- Never reimplement the TDD loop inline — always call `tdd`.\n- Inherit `tdd`'s test-protection rules: never delete, skip, or mark-broken tests to force green.\n- **Skill-reality conflicts are findings, not workarounds.** If a skill instruction (an API name, path, constant, command) doesn't match observed reality, do the work AND record the conflict — quote the skill line, state the deviation — in the return's `skill_findings:` list, so the campaign ledger (`amicode\u002Fskills-integrity\u002F`, personal vault) never depends on the implementer's filesystem reach.\n- `complete` only when **every** Acceptance Criterion is green — no \"complete minus one\".\n\n## Source of truth\n\n- **Status** of the work → the **org GitHub Projects board** (this skill moves the card).\n- **Task content \u002F canonical issue state** → the **issue** in the code-owning repo (`Closes #N` ties the PR to it).\n- **The *why*** → the spec\u002FADR the issue's `## Source` references; this skill does not restate it.\n\n## Composition\n\n- Implements issues produced by `break-into-subissues` (slices) or `write-an-issue` (lone issues).\n- Calls **`tdd`** for the RED→GREEN loop. Stack: `implement-issue` (read issue, bracket lifecycle) → `tdd` (loop, reuse-first, refactor).\n- Dispatched per slice by **`develop`** (`--orchestrated`), which walks an issue-DAG; or used **standalone** on a single issue.\n\n## Related skills\n\n- **tdd** — the RED→GREEN loop this skill brackets.\n- **write-an-issue** \u002F **break-into-subissues** — produce the issues this skill consumes.\n- **develop** — the orchestration layer above this leaf (walks a multi-issue DAG).\n","# Implement an Issue\n\nThe **leaf executor** of issue-driven development. Take **one** TDD-ready slice and drive it to green by *calling* the `tdd` skill, bracketed by branch \u002F draft-PR \u002F issue lifecycle. This skill composes `tdd` — it never reimplements the RED→GREEN loop.\n\nIt is the development counterpart to the design pipeline (`brainstorming` → `write-an-issue` → `break-into-subissues`): that pipeline publishes TDD-ready issues; this skill picks one up and implements it.\n\n**Announce at start:** \"I'm using the implement-issue skill to implement #\\\u003Cn\\> via TDD.\"\n\n## When to use \u002F not use\n\n- **One ready issue** — a sub-issue, an undecomposed parent, or a lone issue → use this skill.\n- **A parent with open sub-issues** → use `develop` (it walks the sub-issue DAG, dispatching this skill per slice). This skill takes a **single** slice only; handed such a parent it stops and advises `develop` (see Step 2).\n- **No resolved design yet** → STOP and use `brainstorming`. This skill implements a *published* issue; it does not design.\n\n## Usage\n\n```\n\u002Fimplement-issue \u003Cissue-number-or-url> [--branch \u003Cname>] [--base \u003Cbranch>] [--orchestrated]\n```\n\n- `\u003Cissue>` — the single issue to implement (required).\n- `--branch` \u002F `--base` — branch override (see Step 3); rarely needed, the default is correct.\n- `--orchestrated` — set by `develop` only; the slice runs on the caller-provided worktree branch (the branch already checked out). See Modes.\n\n## Modes\n\n| | **Standalone** (default) | **Orchestrated** (`--orchestrated`) |\n|---|---|---|\n| Invoked by | a human off the board, in the main session | `develop`, one slice per worktree (spawned via `amicode_session` with `workspace: \"create\"`) |\n| Branch | this skill creates it (Step 3) | use the caller-provided `opencode\u002F\u003Cslug>` worktree branch; skip creation |\n| Bootstrap | not needed (main checkout) | **required** — `pnpm install` (or equivalent) before any build\u002Ftest (see Worktree contract) |\n| PR | opens a draft PR, drives it to ready\u002Fmerge | **opens no PR, performs no merge** |\n| Terminus | AFK→merge \u002F HITL→review (Step 6) | return the branch; `develop` merges + integration-tests |\n\nOrchestrated mode is dispatched by `develop` (one slice per worktree, via the Engineer). It can also be invoked directly to exercise the seam.\n\n### Worktree contract (orchestrated mode)\n\nWhen the session was spawned with `workspace: \"create\"`, the implementer operates in an isolated worktree. Four rules:\n\n1. **Bootstrap first.** The worktree is a fresh checkout — dependencies are not installed. The implementer's first action before any build or test is project bootstrap: `pnpm install` (or the project's package manager equivalent — `npm install`, `yarn`, `pip install -e .`, `julia --project=. -e 'using Pkg; Pkg.instantiate()'`, etc.). Detect the package manager from the lock file present in the worktree root.\n\n2. **Stay on the worktree branch.** Commits land on the worktree's `opencode\u002F\u003Cslug>` branch — the branch created by the worktree API and already checked out. **Do not** create new branches, switch branches, or check out other refs. The parent `develop` session owns branch topology; the implementer only commits to what is already checked out.\n\n3. **`index.lock` retry.** Concurrent worktrees sharing the same `.git` directory may contend on `.git\u002Findex.lock`. If `git add` or `git commit` fails with `Unable to create '…\u002F.git\u002Findex.lock': File exists`, **retry once** after a 2-second wait. If the retry also fails, report the lock contention error — do not delete the lock file.\n\n4. **Engine-overlay slices bootstrap and test differently.** When a slice edits the engine overlay (any path under `packages\u002Fapp-bundle\u002Foverlay\u002F...`), rules 1 and the develop loop's default verify command (`pnpm --filter amicode test`) are **misleading** — the overlay is not part of the outer pnpm workspace, so that filter finds zero tests and exits 0 (it runs the *extension's* vitest suite, a different surface). A false \"no tests ran, exit 0\" pass is the trap. Instead:\n\n   - **Bootstrap + test through the materialize path**, not the pnpm filter:\n\n     ```\n     node packages\u002Fapp-bundle\u002Fscripts\u002Fmaterialize.mjs --out packages\u002Fapp-bundle\u002F.materialized\n     cd packages\u002Fapp-bundle\u002F.materialized && bun install --ignore-scripts\n     cd packages\u002Fopencode && bun test test\u002F\u003Cpath>\u002F\u003Cfile>.test.ts\n     ```\n\n     The `bun test` **must** run from within `packages\u002Fopencode` — a `do-not-run-tests-from-root` guard blocks the materialized root (`Failed to scan non-existent root directory for tests`). `.materialized` is a gitignored build artifact; only the committed `overlay\u002F` files are the source of truth.\n\n   - **Refresh the manifest hash after editing a manifest-tracked overlay file.** `build-binary` CI runs `materialize.mjs`, which `exit 1`s when a listed file's sha256 diverges from `packages\u002Fapp-bundle\u002Fmanifest.json` (locally it may only WARN, so the failure first surfaces in CI). Fix by patching **only the changed file's hash** in the manifest's `files` (or its `exceptions`) entry. **Never full-refresh** with `refresh_manifest.mjs` for a targeted edit — it is not exceptions-aware and folds the quarantined `exceptions` entries into `files`, duplicating them and reddening `app-bundle-gate` (`drift_gate.mjs`).\n\n---\n\n## Procedure\n\n### 1. Read the issue and its context\n\n- `gh issue view \u003Cn> --json title,body,labels,number,url` (in the code-owning repo).\n- Parse the body's `## Acceptance Criteria` (the RED list), `## Testing Decisions` (the reuse map, if present), `## Key Decisions`, `## Constraints & Invariants`, and `Prior Art`.\n- If the body carries `Part of #N`, read the **parent** and load its **decision surface** (Problem \u002F Approach \u002F Constraints) as cross-cutting context — it is referenced by the sub-issue, not duplicated onto it.\n- The issue carries no file paths or code by design; use `Prior Art` to find the modules to read, then read the **current** code.\n\n### 1.5 Render the spec (standalone + interactive only)\n\nBefore checking eligibility, present the issue back to the user as the brief it was written to be — **never a raw body dump**:\n\n- **Header** — `#\u003Cn> \u003Ctitle>`, the repo, the board status, and the `afk`\u002F`hitl` signal.\n- **Decision surface** — the `> [!IMPORTANT]` block reproduced as the skimmable card it is (Problem \u002F Approach \u002F Scope \u002F Assumptions).\n- **Acceptance Criteria** — as a checklist; these are the RED list, so the done-definition is visible up front.\n- **Key Decisions \u002F Constraints & Invariants** — tight bullets.\n- **Prior Art** — the modules-to-read-first list.\n- **Parent context** — when the body carries `Part of #N`, fold the parent's Problem\u002FApproach into a line or two.\n\n**Math renders as math.** When the issue carries mathematical content — objectives, Hamiltonians, bounds, error models — typeset it: inline LaTeX for symbols ($\\hat H$, $\\Omega_{\\max}$, $F \\geq 0.999$), display equations for objectives and derivations, and quantities exactly as the researcher writes them (infidelity as `2.1e-4`, tabular-nums where digits align). An issue in the physics vein gets elegant mathematical exposition, not prose-paraphrased formulas. Non-mathematical issues just get the clean card — no ceremony.\n\n**Skip conditions:** `--orchestrated` mode (no human in the loop); non-interactive\u002FAFK runs; **chore-tier** bodies (one line: number, title, problem — the record is already that short). This render is the same presentation `write-an-issue` uses at its approval gate — the approver and the implementer see the same brief.\n\n### 2. Check eligibility\n\n- **Parent guard:** if this issue has **open sub-issues**, it is not a single slice. Create nothing, comment advising `develop` (a sibling skill in the armed set — it walks the sub-issue DAG, dispatching this skill per slice), and return `blocked`.\n- **Blocked-by gate:** read `Blocked by` from GitHub's native issue-dependency relationships via GraphQL — `gh api graphql` over `Issue.blockedBy(first:50){ nodes{ number state } }` (no native `gh` subcommand or `gh issue view --json` field exposes these; never read a body section). A blocker in `state: CLOSED` is satisfied. If any blocker is still open, create no branch, comment the unmet dependency on the issue, set its board card to **Blocked** (see `write-an-issue` step 7e), and return `blocked`. An explicit user \"run anyway\" is the only thing that overrides this gate.\n\n### 3. Resolve the branch (override ladder)\n\nHighest precedence wins:\n\n1. **Explicit arg** — `--branch` \u002F `--base` from the invocation.\n2. **Repo convention** — a branch naming\u002Fbase convention declared in the repo's `AGENTS.md` (or `CLAUDE.md`, whichever the repo carries).\n3. **Default** — `gh issue develop \u003Cn>` (creates an issue-linked branch) cut from the current tip of `main`.\n\nBranch from `main` (standalone) — blockers are merged first, so there is no stacking. An override may set the name\u002Fbase\u002Freuse-existing; it does **not** silently bypass the Blocked-by gate (Step 2).\n\n**Orchestrated:** skip this step entirely — work on the caller-provided worktree branch.\n\n### 4. Run the `tdd` loop\n\nInvoke the **`tdd`** skill and let it run the RED→GREEN tracer-bullet loop. Supply:\n\n- the issue's `## Acceptance Criteria` as the **RED list** — one tracer-bullet cycle per criterion;\n- `## Testing Decisions` (when present) as the **reuse map** — which suites to extend (`reuse-first`). This is advisory: the modify-vs-create call stays in the `tdd` loop against the real suite.\n\n**Planning gate:** `tdd`'s Planning step is an interactive human-approval gate. In a **non-interactive run** (AFK, or `--orchestrated`) it is **pre-satisfied by the published issue** — its Acceptance Criteria + Testing Decisions + the parent decision surface *are* the approved plan, ratified when the issue was published. Pass them to `tdd` in lieu of the interview and proceed. In an interactive standalone run you may still surface Planning to the user.\n\n- **First commit → open the draft PR** (standalone, Step 5).\n- Retries: a RED that won't go green is retried up to **2 cycles** before being declared stuck (Step 6). An Acceptance Criterion you cannot express as a test routes through that same stuck path — never silently skip it.\n- **No test surface?** If the deliverable is prose (a skill, ADR, or config) or the repo has no executable suite, there is nothing to RED→GREEN — `tdd` degrades to **author-then-review against the Acceptance Criteria as a checklist**. \"Done = green\" then reads as \"every AC satisfied by inspection,\" verified by walking representative scenarios. Single-artifact *code* (one script) still TDDs incrementally within this one issue.\n\n### 5. Draft PR (standalone only)\n\n- At the **first commit**, open a **draft** PR: `gh pr create --draft --title \u003C…> --body \u003C…>`. Link it to the invoked issue with `Closes #\u003Cinvoked-issue>`. (Closing a sub-issue does **not** close its parent — parent closure is the orchestration layer's job.)\n- On opening the draft PR, advance the issue's board card to **In Progress** (the standalone \"work started\" signal; see `write-an-issue` step 7e for the mechanism).\n- The draft PR is the live surface: CI runs incrementally, RED-during-loop is expected, and on failure it becomes the WIP\u002Fescalation artifact (Step 6).\n- Mark it ready (`gh pr ready`) **only** once the full suite is green.\n- **Never** create the PR before the first commit (the branch itself is created in Step 3), and never in `--orchestrated` mode.\n\n### 6. Terminal state\n\nA slice is **done = green** (all its tests pass; demoable on its own). Status is `complete` **iff every** Acceptance Criterion is green; any non-green criterion → `failed`.\n\n**Orchestrated:** skip the AFK\u002FHITL terminus below — there is no PR, no merge, no push, and **no board-status change** (`develop` owns the card's In Progress \u002F In Review \u002F Done transitions for orchestrated slices). Once green, go to Step 7 and return the branch; `develop` merges, integration-tests, and decides the terminus. On failure, leave WIP committed on the branch and return `failed` (no PR, no comment-on-issue — `develop` owns escalation).\n\n**Standalone** — read the AFK\u002FHITL signal from the issue's `afk` \u002F `hitl` label (**absent → treat as HITL**, the safe default).\n\n**Standalone, green:**\n\n| Tag | Action |\n|---|---|\n| **AFK** | mark PR ready → merge gated on CI: `gh pr merge --auto` where the repo has auto-merge enabled (merges *when* CI is green); where it doesn't (`--auto` is rejected), wait for CI to pass — or, in a repo with no CI, proceed directly — then plain `gh pr merge` → on merge, the issue closes (via `Closes`) and the board's **\"Item closed\" auto-workflow moves the card to Done** (never set Done manually). |\n| **HITL** \u002F untagged | mark PR ready → request review → set the board card to **In Review** as the *final* step, then re-read and re-set if the board's async \"PR linked → In Progress\" workflow clobbered it (see `write-an-issue` 7e) → **stop** (no merge). |\n\n**AFK that cannot merge cleanly** (CI fails, or branch conflicts) → **downgrade to HITL**: do not merge, comment, leave the issue open.\n\n**Failure** (the `tdd` loop stays RED after its 2 cycles, a `Key Decision` proves infeasible, an Acceptance Criterion is untestable, or a Blocked-by dep turns out unmerged):\n\n- Stop. Push WIP to the (draft) PR.\n- Comment the **precise** blocker on the issue (which criterion \u002F decision \u002F dependency, and why).\n- Leave the issue open. Return `failed`.\n- **Never** merge partial or non-green work. **Never** bounce into the design phase — escalate to a human (standalone) or to `develop` (orchestrated), which decide next.\n\n### 7. Return\n\nReturn a structured result in all modes:\n\n```yaml\nissue: \u003Cnumber>            # the invoked issue's number\nstatus: complete | blocked | failed\nbranch: \u003Cbranch-name>\ncommit_shas: [\u003Csha>, ...]\nac_results:\n  - {criterion: \"\u003Ctext>\", green: true|false}\nskill_findings: []        # optional: skill-vs-reality conflicts hit this slice\n                          # (findings-file paths or terse one-liners → ledger amicode\u002Fskills-integrity\u002F)\nnotes: \"\u003Cblocker \u002F deviation \u002F escalation detail>\"\n```\n\nIn `--orchestrated` mode `branch` is always set and **no PR exists** — `develop` consumes this to merge the branch, integration-test, and checkpoint (close the issue \u002F move its card).\n\n---\n\n## Invariants\n\n- Never merge partial or non-green work.\n- Never auto-merge a HITL or untagged slice; auto-merge only an explicit `afk` slice, and only conditionally on CI.\n- Never open a PR or merge in `--orchestrated` mode.\n- Never create a branch or PR at issue-creation time; the draft PR is born at the first commit.\n- Never reimplement the TDD loop inline — always call `tdd`.\n- Inherit `tdd`'s test-protection rules: never delete, skip, or mark-broken tests to force green.\n- **Skill-reality conflicts are findings, not workarounds.** If a skill instruction (an API name, path, constant, command) doesn't match observed reality, do the work AND record the conflict — quote the skill line, state the deviation — in the return's `skill_findings:` list, so the campaign ledger (`amicode\u002Fskills-integrity\u002F`, personal vault) never depends on the implementer's filesystem reach.\n- `complete` only when **every** Acceptance Criterion is green — no \"complete minus one\".\n\n## Source of truth\n\n- **Status** of the work → the **org GitHub Projects board** (this skill moves the card).\n- **Task content \u002F canonical issue state** → the **issue** in the code-owning repo (`Closes #N` ties the PR to it).\n- **The *why*** → the spec\u002FADR the issue's `## Source` references; this skill does not restate it.\n\n## Composition\n\n- Implements issues produced by `break-into-subissues` (slices) or `write-an-issue` (lone issues).\n- Calls **`tdd`** for the RED→GREEN loop. Stack: `implement-issue` (read issue, bracket lifecycle) → `tdd` (loop, reuse-first, refactor).\n- Dispatched per slice by **`develop`** (`--orchestrated`), which walks an issue-DAG; or used **standalone** on a single issue.\n\n## Related skills\n\n- **tdd** — the RED→GREEN loop this skill brackets.\n- **write-an-issue** \u002F **break-into-subissues** — produce the issues this skill consumes.\n- **develop** — the orchestration layer above this leaf (walks a multi-issue DAG).\n",{"name":5,"agents":24,"source":25,"surface":26,"revision":27,"description":7},[],"amicode","public",2,"main","bf84fdd4c1494800695bd5881702b3118dbf98be","packages\u002Fextension\u002Fskills\u002Fimplement-issue","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode","https:\u002F\u002Fgithub.com\u002Fharmoniqs","harmoniqs.ai","research tools, for researchers, by reseachers","2026-11-12 14:46:24",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add harmoniqs\u002Famicode --skill implement-issue",{"tool":42,"command":43},"bunx","bunx skills add harmoniqs\u002Famicode --skill implement-issue",{"tool":45,"command":46},"pnpm","pnpm dlx skills add harmoniqs\u002Famicode --skill implement-issue","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Fskills\u002Fimplement-issue\u002FSKILL.md",true,[],[51,58,65,71,78,85],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M759XGHEQRJ1GWZTPRFF9Z1W","malformed","Frontmatter that parses as YAML but is missing the required name field.","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Ftest\u002Ffixtures\u002Fskill-drift\u002Fskills\u002Fmalformed\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M759XDVQ1PYPMT876X8J21TQ","duplicated","Second skill carrying the duplicated frontmatter name.","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Ftest\u002Ffixtures\u002Fskill-drift\u002Fskills\u002Fdup-two\u002FSKILL.md",[],[],{"skillNo":66,"name":60,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M759XBZYBHF38JDWSRHAC6E1","First skill carrying the duplicated frontmatter name.","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Ftest\u002Ffixtures\u002Fskill-drift\u002Fskills\u002Fdup-one\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M759XAQBSP29BKTTXR1WF2D7","drifted","A skill whose API claims have drifted from the fixture packages.","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Ftest\u002Ffixtures\u002Fskill-drift\u002Fskills\u002Fdrifted\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M759X8CNBPVK98C6M45D0QMB","clean","A clean skill whose every extracted claim resolves against the fixture packages.","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Ftest\u002Ffixtures\u002Fskill-drift\u002Fskills\u002Fclean\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M759X73H6N2G0VDH8CJ5TF11","broken-paths","A skill with a broken relative link and a broken cited package path.","https:\u002F\u002Fgithub.com\u002Fharmoniqs\u002Famicode\u002Fblob\u002Fmain\u002Fpackages\u002Fextension\u002Ftest\u002Ffixtures\u002Fskill-drift\u002Fskills\u002Fbroken-paths\u002FSKILL.md",[],[]]