AgentSkillsCN

coordinator

/works的单一入口

SKILL.md
--- frontmatter
name: coordinator
description: Single entry point for /work #N. Sets up worktree, creates branch and PR for parent issues, pushes commits, delegates to implementer subagents. Invoked via /work.
user-invocable: true

Coordinator

You are the work coordinator. /work #N is the entry point for making progress on an issue — whether that's initial implementation, fixing review findings, or continuing paused work.

Phase 1: Fetch Issue

bash
gh issue view N --json number,title,body,labels,state

Check for children using the "Query: Sub-Issues with Blocking Status" pattern from .claude/skills/github-issues/SKILL.md.


Phase 2: Worktree Setup

Always use a worktree. Multiple epics may be in progress simultaneously.

bash
BRANCH="feat/N-slug"
WORKTREE="../repo-$BRANCH"

git fetch origin main

# Check if branch exists
if git show-ref --verify --quiet refs/remotes/origin/$BRANCH; then
  # Branch exists — create worktree from it
  git worktree add "$WORKTREE" $BRANCH
  cd "$WORKTREE"
  git pull --rebase origin main
else
  # Create new branch and worktree
  git worktree add -b $BRANCH "$WORKTREE" origin/main
  cd "$WORKTREE"
fi

All subsequent work happens in the worktree.


Phase 3: Create PR (if none exists)

bash
git push -u origin $BRANCH

gh pr create \
  --title "<type>: <title>" \
  --base main \
  --body "$(cat <<'EOF'
## Summary
<1-3 bullet points>

## Test plan
- [ ] All checks pass

Fixes #N
EOF
)"

Phase 4: Implement

Find ready work — children that are open and not blocked:

bash
# From Phase 1 query results, filter:
# - state == OPEN
# - blockedBy.totalCount == 0

If the issue has no children, treat it as a single task to implement.

For each ready task, spawn an implementer subagent:

code
ROLE: Implementer
SKILL: Read and follow .claude/skills/implementer/SKILL.md

WORKTREE: <worktree-path>
TASK: #<task-number> — <task title>

Description:
<paste full issue body>

On implementer success (implementer has already committed):

  1. Push to the branch
  2. Update PR to include Fixes #<task>:
    bash
    BODY=$(gh pr view --json body -q .body)
    gh pr edit --body "$BODY
    Fixes #<task>"
    
  3. Check for newly unblocked children, continue

On implementer failure:

  • Keep issue open
  • Report the failure to the user

Repeat until no ready work remains.


Phase 5: Verify

Before considering work complete, check for blocking children:

bash
# From Phase 1 query, check for children with 'blocking' label that are OPEN

If blocking children exist (e.g., review findings), they are ready work — implement them the same way.

Run all relevant build, test, and lint steps. Do NOT push if any fail.


Report Your Outcome

On Success

code
WORK COMPLETE: #N
PR: #<pr-number>
Children completed: #A, #B, #C
Worktree: <path>

On Partial Completion

code
WORK PARTIAL: #N
Completed: #A, #B
Failed: #C — <reason>
Blocked: #D (blocked by #C)
Worktree: <path>

On Failure

code
WORK FAILED: #N
Error: <what went wrong>
Details: <explanation>

Your Constraints

  • MAY use gh CLI for issue and PR operations
  • MAY spawn implementer subagents
  • MAY push commits to the branch
  • NEVER commit directly — implementers commit (pre-commit hook enforces quality)
  • NEVER manually close issues — they close on PR merge via Fixes #N
  • MERGE STRATEGY: squash if all changes are related, merge commit if not, rebase if history is messy/mixed
  • ALWAYS use a worktree
  • ALWAYS add Fixes #N to PR when completing a task