|
| 1 | +--- |
| 2 | +name: implement |
| 3 | +description: "Implement a GitHub issue: fetch, branch, code, validate. Usage: /implement [#N]" |
| 4 | +--- |
| 5 | + |
| 6 | +# /implement |
| 7 | + |
| 8 | +Implements a GitHub issue from start to validated code. Handles sub-tasks, Figma designs, and runs all quality gates. |
| 9 | + |
| 10 | +## Arguments |
| 11 | + |
| 12 | +`$ARGUMENTS` — optional: GitHub issue number (`#123`), URL, or just `123`. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +# Step 0 — Detect state |
| 17 | + |
| 18 | +Run this **before anything else** to figure out where we are: |
| 19 | + |
| 20 | +```bash |
| 21 | +BRANCH=$(git branch --show-current) |
| 22 | +git diff origin/master...HEAD --name-only |
| 23 | +git diff --name-only HEAD |
| 24 | +``` |
| 25 | + |
| 26 | +Also try to infer the issue number from the branch name if no `$ARGUMENTS` given (e.g. `feat/issue-{N}-*`). |
| 27 | + |
| 28 | +### Routing |
| 29 | + |
| 30 | +| State | Action | |
| 31 | +|---|---| |
| 32 | +| Issue number given + no changes on branch | **Phase 1** — implement | |
| 33 | +| Issue number given + changes already exist | **Phase 2** — validate | |
| 34 | +| No arg + changes exist + no open PR | **Phase 2** — validate (infer issue from branch) | |
| 35 | +| No arg + no changes | Ask: "Which issue? (`#123`)" | |
| 36 | + |
| 37 | +**Always announce** which phase was detected: |
| 38 | +> "Branch `feat/issue-42-...`, no changes yet. Starting at **Phase 1 — Implement**." |
| 39 | +
|
| 40 | +--- |
| 41 | + |
| 42 | +# Phase 1 — Implement |
| 43 | + |
| 44 | +## 1.1 — Resolve issue |
| 45 | + |
| 46 | +1. Extract issue number from `$ARGUMENTS` (URL, `#N`, or `N`) |
| 47 | +2. If owner/repo not in URL: `git remote get-url origin` |
| 48 | + |
| 49 | +## 1.2 — Fetch issue and detect tasks |
| 50 | + |
| 51 | +```bash |
| 52 | +gh issue view {N} --json number,title,body,state,labels,comments |
| 53 | +``` |
| 54 | + |
| 55 | +Treat **comments** as part of the context (requirements, Figma links, acceptance criteria). |
| 56 | + |
| 57 | +Detect sub-tasks in order: |
| 58 | + |
| 59 | +1. **Native sub-issues**: `gh api repos/{owner}/{repo}/issues/{N}/sub_issues` |
| 60 | +2. **Checkboxes**: `- [ ] task` in body + comments |
| 61 | +3. **Single task**: the issue itself |
| 62 | + |
| 63 | +Present the task list with `AskUserQuestion` and ask for confirmation. |
| 64 | + |
| 65 | +## 1.3 — Branch |
| 66 | + |
| 67 | +Ask with `AskUserQuestion`: |
| 68 | +> "Create branch `feat/issue-{N}-{slug}` or stay on `{current_branch}`?" |
| 69 | +
|
| 70 | +## 1.4 — Task loop |
| 71 | + |
| 72 | +For each pending task: |
| 73 | + |
| 74 | +### Fetch details |
| 75 | +- Sub-issue: `gh issue view {task_number} --json number,title,body,labels,comments` |
| 76 | +- Checkbox: use text as description |
| 77 | + |
| 78 | +### Analyze scope |
| 79 | +- Identify affected files, modules, patterns |
| 80 | +- Load `packages/app/CLAUDE.md` if working in app |
| 81 | +- **Figma**: if UI task + Figma URL in body/comments -> `get_design_context`. If UI task + no URL -> ask user for link. |
| 82 | + |
| 83 | +### Implement |
| 84 | +- Follow all conventions from `CLAUDE.md` and `packages/app/CLAUDE.md` |
| 85 | +- Write code, tests, migrations |
| 86 | +- Use existing codebase patterns |
| 87 | + |
| 88 | +### Report progress |
| 89 | +``` |
| 90 | +[{current}/{total}] #{task_number} {task_title} DONE |
| 91 | +``` |
| 92 | + |
| 93 | +-> Continue to **Phase 2**. |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +# Phase 2 — Validate |
| 98 | + |
| 99 | +## 2.1 — Scope |
| 100 | + |
| 101 | +```bash |
| 102 | +git diff origin/master...HEAD --name-only |
| 103 | +``` |
| 104 | +Fallback: `git diff --name-only HEAD` |
| 105 | + |
| 106 | +## 2.2 — Launch 4 parallel agents |
| 107 | + |
| 108 | +1. **Validator** — `.claude/agents/validator/AGENT.md` (typecheck + test + lint + format) |
| 109 | +2. **Structural auditor** — `.claude/agents/structural-auditor/AGENT.md` on all changed files |
| 110 | +3. **RGAA auditor** — `.claude/agents/rgaa-auditor/AGENT.md` on changed `.tsx`. Auto-fix `[ERROR]`. |
| 111 | +4. **Security auditor** — `.claude/agents/security-auditor/AGENT.md` on changed `.ts/.tsx`. Auto-fix `[CRITICAL]` and `[HIGH]`. |
| 112 | + |
| 113 | +## 2.3 — Fix loop |
| 114 | + |
| 115 | +1. Fix all violations |
| 116 | +2. Re-run only failing agents |
| 117 | +3. If auto-fixes applied, re-run validator too |
| 118 | +4. **Loop until zero violations** |
| 119 | + |
| 120 | +## 2.4 — Lighthouse (if dev server running) |
| 121 | + |
| 122 | +```bash |
| 123 | +pnpm test:lighthouse # must score 100% accessibility |
| 124 | +``` |
| 125 | + |
| 126 | +## 2.5 — Report |
| 127 | + |
| 128 | +``` |
| 129 | +## Validation: PASS |
| 130 | +| Check | Status | |
| 131 | +|------------|--------| |
| 132 | +| Typecheck | PASS | |
| 133 | +| Tests | PASS | |
| 134 | +| Lint | PASS | |
| 135 | +| Structure | PASS | |
| 136 | +| RGAA | PASS | |
| 137 | +| Security | SECURE | |
| 138 | +``` |
| 139 | + |
| 140 | +Done. Code is validated and ready to ship via `/ship`. |
0 commit comments