/feature
End-to-end pipeline: GitHub Issue → Spec → Worktree → Implementation → PR.
Input: #42, 42, issue URL, or free-text description.
PHASE 0: RESUME CHECK
- •
Parse input:
- •Number or
#N→ ISSUE = N - •URL
https://github.com/.../issues/N→ extract N - •Free text → will create issue in Phase 1
- •Number or
- •
Verify GitHub CLI auth:
codegh auth status
- •FAIL →
❌ Error: Run 'gh auth login' first.
- •FAIL →
- •
If ISSUE exists, fetch it:
codegh issue view ISSUE --json number,title,body,state
- •Issue not found →
❌ Error: Issue #ISSUE not found. - •Issue closed → warn user, ask confirmation to proceed
- •Issue not found →
- •
Derive identifiers:
- •
SLUG= kebab-case of issue title, max 40 chars - •
BRANCH=feat/ISSUE-SLUG(e.g.feat/42-add-notifications) - •
REPO_ROOT=git rev-parse --show-toplevel - •
WT_ROOT=REPO_ROOT/../.worktrees/BRANCH
- •
- •
Check if worktree already exists:
codegit worktree list | grep BRANCH
- •EXISTS → Read
WT_ROOT/.claude/memory/project-state.md→ RESUME from pending phase - •NOT EXISTS → continue to Phase 1
- •EXISTS → Read
PHASE 1: INTAKE
Case A — Free-text description (no issue number):
gh issue create --title "TITLE" --body "BODY"
- •Capture the returned ISSUE number
- •Derive SLUG, BRANCH, WT_ROOT from the new issue
Case B — Existing issue:
- •Already have issue content from Phase 0
(No comment posted — session start info is included in the Spec comment.)
PHASE 2: SPEC
- •
Invoke planner agent with context:
- •Issue body (title + description)
- •
.claude/memory/architecture.md - •
.claude/memory/decisions/DEC-*.md - •
.claude/project.yml
- •
Planner produces structured spec:
- •Scope: 1-3 sentences describing the change
- •Tasks: decomposed into waves (ordered groups)
- •Files: to create/modify
- •Test strategy: what to test and how
- •Invariant check: which invariants are affected
- •
Post spec as issue comment (Comment 1/3):
codegh issue comment ISSUE --body "🚀 **Branch:** \`feat/ISSUE-SLUG\` ## Spec ### Scope ... ### Tasks - Wave 1: ... - Wave 2: ... ### Files ... ### Test Strategy ... "
- •
Write tasks to
project-state.mdwith metadata:codeskill: feature issue: #ISSUE branch: BRANCH phase: execution
PHASE 3: WORKTREE SETUP
- •
Sync local main with remote:
codegit fetch origin git switch main && git merge --ff-only origin/main
- •If merge fails (local has diverged) →
❌ Error: Local main has diverged from origin. Resolve manually.
- •If merge fails (local has diverged) →
- •
Create worktree directory:
codemkdir -p REPO_ROOT/../.worktrees git worktree add WT_ROOT -b BRANCH origin/main
- •
Copy state to worktree:
codecp REPO_ROOT/.claude/memory/project-state.md WT_ROOT/.claude/memory/project-state.md
- •
Initialize clean locks in worktree:
- •Write empty
WT_ROOT/.claude/memory/locks.md
- •Write empty
(No comment posted — progress is tracked in the living progress comment.)
PHASE 4: EXECUTION (inside worktree)
ISOLATION RULE — MANDATORY
From this phase until Phase 5 completes:
- •ALL reads and writes MUST use absolute paths under
WT_ROOT - •NEVER read from REPO_ROOT — the main checkout is off-limits
- •NEVER write to REPO_ROOT — no copying files back to main
- •NEVER
cdto REPO_ROOT — stay inside the worktree - •The worktree IS the project root. Treat
WT_ROOTas if REPO_ROOT does not exist.
If an agent or skill tries to reference a path outside WT_ROOT → STOP and fix the path.
Execution
- •Agents read config from:
WT_ROOT/.claude/stack.yml,WT_ROOT/.claude/memory/architecture.md - •Bash commands:
cd WT_ROOT && {command} - •State updates:
WT_ROOT/.claude/memory/project-state.md
For each task [ ] in WT_ROOT/.claude/memory/project-state.md:
- •Builder agent implements + tests
- •PASS → mark
[x], print✅ [task_number] task_description - •FAIL → retry (max 2 retries). 3rd failure → post blocker to issue, STOP:
code
gh issue comment ISSUE --body "🚫 Blocked: [task description]. Error: [details]"
After EVERY completed wave, run these 3 steps in order — NO EXCEPTIONS:
- •
Commit:
codecd WT_ROOT && git add -A && git commit -m "feat(SLUG): wave N — [summary]"
- •
Post/update progress comment (Comment 2/3):
codegh issue comment ISSUE --edit-last --body "## 📊 Progress ✅ Wave 1: [summary] ✅ Wave 2: [summary] ... ⏳ X/Y tasks complete"
If
--edit-lastfails (first wave, no previous comment), use--bodywithout--edit-last:codegh issue comment ISSUE --body "## 📊 Progress ✅ Wave 1: [summary] ⏳ X/Y tasks complete"
- •
Every 3 tasks: compress context via
/summarize-context
PHASE 5: INTEGRATION
- •
Verify ALL tasks are
[x]inWT_ROOT/.claude/memory/project-state.md - •
Run final validation (tests + build):
- •Read
WT_ROOT/.claude/stack.ymlfor validate command and exec_prefix - •Execute:
cd WT_ROOT && {exec_prefix} {stack.commands.validate} - •If
validatenot defined, run{stack.commands.test}then{stack.commands.build} - •Build step catches SSR/runtime errors (missing providers, import errors, type mismatches)
- •FAIL → create fix tasks, return to Phase 4
- •Read
- •
Push branch:
codecd WT_ROOT && git push -u origin BRANCH
- •Push rejected →
cd WT_ROOT && git pull --rebase origin BRANCH, retry once
- •Push rejected →
- •
Create PR:
codegh pr create --title "feat: ISSUE_TITLE" --body "Closes #ISSUE ## Summary [spec scope from Phase 2] ## Changes [list of files changed] ## Test plan [test strategy from Phase 2] " --head BRANCH --base main
- •
(PR URL is included in the final summary comment — Phase 6.)
PHASE 6: CLEANUP
- •
Archive state:
codemkdir -p REPO_ROOT/.claude/memory/archive/ cp WT_ROOT/.claude/memory/project-state.md REPO_ROOT/.claude/memory/archive/feature-ISSUE-$(date +%Y%m%d).md
- •
Post final summary to issue (Comment 3/3):
codegh issue comment ISSUE --body "## ✅ Feature Complete **PR:** PR_URL **Branch:** \`BRANCH\` **Tasks:** Y/Y complete <details><summary>Changes</summary> [list of files changed] </details> Ready for review."
- •
DO NOT remove worktree — may need fixes post-review
- •
Output:
✅ Feature #ISSUE delivered. PR: PR_URL
Error Handling
| Error | Action |
|---|---|
gh auth status fails | ❌ Error: Run 'gh auth login' first. |
| Issue not found | ❌ Error: Issue #ISSUE not found. |
| Push rejected | git pull --rebase origin BRANCH, retry once |
| Task fails 3x | Post blocker comment to issue, STOP |
| Session interrupted | Next /feature #ISSUE resumes automatically from pending phase |
| Worktree conflicts | cd WT_ROOT && git rebase origin/main, resolve conflicts |
Resumability
When /feature #N is invoked and a worktree for that issue already exists:
- •Read
WT_ROOT/.claude/memory/project-state.md - •Parse metadata:
skill,issue,branch,phase - •Find first uncompleted task
[ ] - •Resume from the appropriate phase:
- •All tasks
[ ]and no spec → Phase 2 - •Tasks exist but no worktree work started → Phase 4
- •Some tasks
[x], some[ ]→ Phase 4 (continue) - •All tasks
[x]→ Phase 5
- •All tasks
Conventions
- •One feature = one issue = one worktree = one branch
- •Branch naming:
feat/ISSUE-SLUG - •Worktree location:
REPO_ROOT/../.worktrees/feat/ISSUE-SLUG - •Commits inside worktree use conventional format:
feat(SLUG): description - •All GitHub communication via
ghCLI — no API tokens needed beyondgh auth