agentleFS
vltingvlting/claude-skills/skills/scope/SKILL.md

scope

Skill2 starsChanged 9 months agoMITView on GitHub

Interactive planning + orchestration. Approval-gated workflow covering saga→epic→task hierarchy via progressive scoping.

  • Deletes or force-pushes
  • Commits and pushes

25 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use develop, document and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • bamechoSkill

    develop

    开发实施阶段详细规则;进入开发实施时读取;包含执行流程、代码规范、一致性审计、方案包迁移

    Also in 6 projects that use this

  • nicolasestremSkill

    document

    Create focused documentation for specific components or features

    Also in 5 projects that use this

  • MicrosoftSkill

    sync

    Sync the current session branch with its upstream branch, or publish the current session branch to a remote. Use when the user asks to sync a branch, pull latest changes, rebase onto upstream, push current branch, publish branch, or set upstream.

    Also in 6 projects that use this

  • kt057Skill

    check

    lint, typecheck, test を一括実行して結果をサマリーする

    Also in 5 projects that use this

  • jdonohooSkill

    architect

    Architect Vern - Systems design, scalable architecture, production-grade thinking. The blueprints before the build.

    Also in 8 projects that use this

  • AnthropicSkill

    debug

    Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.

    Also in 9 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

79 rules. 0 are common, 35 are distinctive, and 44 are very specific to this project.

  • 0

    Common

    Most of the 24 edited versions we read keep these.

  • 35

    Distinctive

    This author's own choices. Worth a look.

  • 44

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every gate = Review Card. User must approve before proceeding.

    line 36
  2. Very specific:

    Always full deliberation (4-7 personas).

    line 61
  3. Very specific:

    Call mcp__state__session_resume(skill: "scope", repo: {cwd}) — checks for ANY active scope session.

    line 74
  4. Very specific:

    If found → use the session's scope field (the initiative slug) to go straight to the right roadmap.

    line 75
  5. Distinctive:

    If not found → fall through to normal roadmap scan / SCOPE.md detection.

    line 76
  6. Distinctive:

    When presenting multiple items at same level (e.g., 8 tasks):

    line 157
  7. Very specific:

    After 3 → suggest: (o) open in IDE for manual edit

    line 168
  8. Distinctive:

    Never re-plan already-approved items

    line 169
  9. Very specific:

    Loading: When an abstract action is needed (e.g., "create tracking ticket"), check config.yml.

    line 182
  10. Very specific:

    First-run detection: If .ai-plans/config.yml doesn't exist, auto-detect available CLIs (gh, linear, jira), ask user which to activate, …

    line 195
  11. Very specific:

    Create epic branch: git checkout main && git pull && git checkout -b epic/{slug}

    line 236
  12. Distinctive:

    Commit roadmap to main

    line 237
  13. Very specific:

    If integration configured: create tracking ticket, create draft PR linking to roadmap, add to project board in Planning status.

    line 238
  14. Distinctive:

    Ensure relay is running (see Relay section)

    line 239
  15. Very specific:

    Create stage branch: git checkout -b {prefix}/{slug}/{stage-slug}

    line 269
  16. Very specific:

    Write task instruction files to .ai-queue/:

    line 271
  17. Very specific:

    Update roadmap: stage status → in-progress, phase → execute

    line 283
  18. Very specific:

    Dependency markers: Add <!-- depends-on: NNN --> upfront when task ordering matters.

    line 287
  19. Distinctive:

    Verify workers are running: Check relay for connected workers.

    line 295
  20. Distinctive:

    Do NOT proceed to implement the tasks yourself.

    line 300
  21. Very specific:

    Completion: All tasks archived in _completed/ → proceed to VERIFY.

    line 341
  22. Distinctive:

    Cleanup: Update roadmap status. Commit.

    line 427
  23. Distinctive:

    Create epic branch, run the full SCOPE → BREAKDOWN → EXECUTE → VERIFY → ADVANCE → SHIP cycle.

    line 487
  24. Distinctive:

    Read roadmap to determine current stage, total task count, and stage issue number.

    line 557
  25. Very specific:

    If workers disconnect (no progress for 2+ cycles), re-send work-queued via relay

    line 562
  26. Very specific:

    All tasks moved to _completed/ → proceed to Phase B

    line 564
  27. Very specific:

    After clean completes, resume as if /scope watch was called fresh:

    line 575
  28. Very specific:

    If phase is still execute and tasks remain → return to Phase A (monitor again)

    line 577
  29. Very specific:

    If all tasks complete → transition to VERIFY — run build/lint/test, check acceptance criteria

    line 578
  30. Very specific:

    Use the /loop skill pattern internally — but /scope watch is a single invocation, not recurring.

    line 592
  31. Distinctive:

    No user interaction during Phase A/B: Only Phase C (VERIFY gate) requires approval.

    line 596
  32. Distinctive:

    Re-send relay events: if workers appear stalled (no new completions for 2+ minutes).

    line 597
  33. Distinctive:

    9-minute ceiling is soft: If 6/7 tasks done at 9 min, extend 3 min automatically.

    line 598
  34. Very specific:

    Phase B is mandatory: Never skip /scope clean after workers finish, even if all tasks completed quickly.

    line 599
  35. Distinctive:

    Phase C re-evaluates: After clean, re-read roadmap state — don't assume tasks are still complete.

    line 600
  36. Distinctive:

    Update all local tracking branches to match their remote counterparts, then sync epic branches with main:

    line 618
  37. Very specific:

    Update roadmap current_epic/current_stage/phase frontmatter to reflect actual state.

    line 638
  38. Distinctive:

    Commit roadmap changes if any.

    line 639
  39. Very specific:

    If roadmap has Issue: #N — verify issue exists, has correct label (epic/stage), is open/closed appropriately (done → closed, in-progress → …

    line 644
  40. Distinctive:

    If roadmap has NO issue reference — create missing issue, link to parent, add label, set board status, write issue # back to roadmap

    line 645
  41. Distinctive:

    Verify epic issue body lists all stages in checklist format

    line 646
  42. Distinctive:

    Verify saga issue body lists all epics in checklist format

    line 647
  43. Very specific:

    Create the epic PR targeting main from epic/{slug}

    line 653
  44. Distinctive:

    Write PR number back to roadmap metadata

    line 657
  45. Distinctive:

    If epic PR exists: Verify PR body has all stages in checklist format

    line 658
  46. Distinctive:

    No user interaction. Fix everything, report at end.

    line 691
  47. Very specific:

    Read config.yml for integration.

    line 692
  48. Very specific:

    Read integrations/github.md for concrete commands.

    line 693
  49. Distinctive:

    Apply changes: Write updated roadmap. Preserve all execution metadata: PR numbers, issue IDs, iteration counts, checkmarks.

    line 717
  50. Distinctive:

    Do NOT delete branches, roadmaps, or completed work.

    line 736
  51. Distinctive:

    If integration: close ticket with "Aborted.

    line 739
  52. Very specific:

    Ensure .gitignore contains these entries (append if missing, don't duplicate):

    line 759
  53. Very specific:

    If SCOPE.md doesn't exist at repo root, create it empty.

    line 772
  54. Very specific:

    If .ai-plans/config.yml doesn't exist:

    line 776
  55. Very specific:

    If gh is available and authenticated (gh auth status):

    line 783
  56. Very specific:

    Ask user for project_number (or skip if no project board)

    line 785
  57. Very specific:

    If project_number provided: resolve project_node_id, status_field_id, status_options via:

    line 786
  58. Very specific:

    Ensure labels exist: gh label create epic --repo OWNER/REPO 2>/dev/null || true (repeat for saga, stage)

    line 790
  59. Very specific:

    If no CLI detected: write config.yml with integrations: []

    line 792
  60. Very specific:

    If .ai-plans/config.yml exists: validate it (same as config validation on every run).

    line 794
  61. Distinctive:

    Start the relay if not running (standard relay startup sequence).

    line 798
  62. Distinctive:

    Never destructive — never overwrites existing config, roadmaps, or queue files.

    line 820
  63. Distinctive:

    Only asks one question: project board number (if GitHub detected and no config exists).

    line 821
  64. Very specific:

    If config exists but is incomplete (e.g., missing status_options), auto-resolve the missing fields without asking.

    line 822
  65. Distinctive:

    If one → resume: read YAML frontmatter → determine current phase → re-enter flow at correct gate

    line 833
  66. Very specific:

    If multiple → AskUserQuestion which to resume

    line 834
  67. Very specific:

    If SCOPE.md has content → read contents into $GOAL, immediately empty SCOPE.md, then AskUserQuestion: resume active initiative or start new …

    line 835
  68. Very specific:

    No active roadmap: Check SCOPE.md at repo root

    line 836
  69. Distinctive:

    Ensure relay is running

    line 839
  70. Very specific:

    Auto-store on Review Card rejection: When user responds n + feedback containing a directive (negation, "don't", "always", "never", …

    line 886
  71. Very specific:

    Attribution: When a recalled memory influences a decision, annotate the bullet in the Review Card with [mem:short-name].

    line 888
  72. Distinctive:

    Never execute without approval: Every gate requires a review card.

    line 907
  73. Distinctive:

    Brevity in cards: No paragraphs. Bullets only.

    line 910
  74. Very specific:

    Progressive disclosure: Default = compressed. Detail on demand via ?

    line 912
  75. Distinctive:

    Relay required: No fallback polling — relay must be running for worker coordination.

    line 918
  76. Very specific:

    Integration side-effects are mandatory: When config.yml lists an integration, every ADVANCE and SHIP phase MUST execute all side-effects …

    line 919
  77. Very specific:

    Labels are mandatory: Every saga issue gets saga label.

    line 920
  78. Very specific:

    Checklist links are mandatory: When checking off a stage in an epic PR/issue body, or an epic in a saga issue body, ALWAYS include the PR …

    line 921
  79. Distinctive:

    Verify after every side-effect: After updating a PR body, issue body, or board status, re-read the target to confirm the change took effect.

    line 923

“Common” is measured: kept by at least 6 in 10 of the 24 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Scope

Interactive, approval-gated planning and orchestration. Every unit of work is reviewed before creation and before merge.

/scope {goal}          — start new initiative
/scope                 — resume active initiative; if none, read SCOPE.md (non-empty) from repo root
/scope setup           — scaffold repo for scope + q workflows (run once per repo)
/scope status          — show hierarchy dashboard
/scope update          — modify an active roadmap
/scope watch           — monitor workers, verify tracking, then auto-resume
/scope clean           — audit + fix all PM tracking (roadmap, issues, PRs, board)
/scope abort           — abort (preserves all work)

Flow

SCOPE → BREAKDOWN → EXECUTE → VERIFY → ADVANCE
  ↑        ↑          ↑         ↑         ↑
  gate     gate      (q runs)   gate      gate

Every gate = Review Card. User must approve before proceeding.


Scope Detection

Determine hierarchy depth from the goal:

ScopeDetectionFlow
SmallSingle task, clear filesSkip to EXECUTE
MediumMulti-stage, one epicBREAKDOWN into tasks
LargeMulti-epic initiativeSCOPE into epics first

Always announce: "Detected {scope} scope. {plan}." User can override: "Actually, just one epic."


Council Integration (Mandatory)

/council is the quality firewall. Invoke via the Skill tool at these points:

  • SCOPE phase: /council {goal} --subroutine — full deliberation on initiative design
  • BREAKDOWN phase: /council "Plan stage: {title}" --subroutine — per-stage approach

Always full deliberation (4-7 personas). --subroutine returns the plan directly without user interaction — /scope handles all user gates via Review Cards.


State

Session persistence (state MCP)

In addition to the roadmap file, /scope registers with the state MCP server for cross-conversation session tracking.

Scope key: skill: "scope", repo: {cwd}, scope: {slug} (the initiative slug — allows parallel initiatives).

On startup (before roadmap scan):

  1. Call mcp__state__session_resume(skill: "scope", repo: {cwd}) — checks for ANY active scope session.
  2. If found → use the session's scope field (the initiative slug) to go straight to the right roadmap. Skip the .ai-plans/ scan + user disambiguation.
  3. If not found → fall through to normal roadmap scan / SCOPE.md detection.

On SCOPE approval: mcp__state__session_start(skill: "scope", repo: {cwd}, scope: {slug})

At each phase transition (BREAKDOWN, EXECUTE, VERIFY, ADVANCE, SHIP): mcp__state__session_checkpoint(session_id, phase: {phase}, state_json: {slug, current_epic, current_stage}, git_ref: {HEAD SHA if commit was made})

On SHIP (all epics done): mcp__state__session_complete(session_id)

On abort: mcp__state__session_abandon(session_id)

The roadmap file remains the source of truth for initiative structure. The session DB is a fast-path index for "what's active?" and "where was I?"

Roadmap file

Single roadmap file per initiative: .ai-plans/{slug}/roadmap.md

---
slug: {slug}
status: scoping | planning | in-progress | verifying | done | aborted
scope: small | medium | large
created: YYYY-MM-DD
current_epic: 1
current_stage: 1
phase: scope | breakdown | execute | verify | advance
---
# {Title}

## Overview
{Goals, scope, key decisions — from council}

## Metadata
- **Epic branch:** epic/{slug}
- **PR:** #{N}
- **Created:** YYYY-MM-DD
- **Integrations:** {from config.yml or "none"}
- **Risk summary:** {from council}

## Epic 1: {title}
**Status:** pending | in-progress | done

### Stage 1.1: {title}
**Status:** pending | in-progress | done
**Branch:** feat/{slug}/{stage-slug}
**Acceptance criteria:**
- [ ] {criterion}
**Tasks:**
- [ ] {task description} → {files}

Committed to git — survives /clear. Everything else is derived.

For small scope (single task): roadmap has no epics/stages — just a task section. For medium scope (single epic): roadmap has stages but no epic grouping.


The Review Card

Universal format at every gate, every level. Use AskUserQuestion to present.

[LEVEL] Title
─────────────────────────────
Summary:  • bullet 1  • bullet 2  • bullet 3
Scope:    files/areas affected
SoW:      what the AI will do if approved (one line, active voice)
Risk:     one line

(y) approve  (n) reject + feedback  (?) expand  (o) open in IDE

Rules

  • ≤7 lines default view. Scannable in <5 seconds.
  • ? expands: acceptance criteria, alternatives considered, full detail
  • ?3 drills into item 3
  • [LEVEL] prefix: [SAGA], [EPIC], [STAGE], [TASK]
  • Auto-expand for high risk items

Batch Review

When presenting multiple items at same level (e.g., 8 tasks):

  1. Show numbered list (one line each)
  2. Options: (a) approve all, (1-8) drill into one, (w) walkthrough sequentially
  3. Batch summary highlights outliers (highest risk, largest scope)

Rejection Flow

User responds n + feedback:

  1. Refine ONLY the rejected item
  2. Re-present its card
  3. Max 3 iterations per item
  4. After 3 → suggest: (o) open in IDE for manual edit
  5. Never re-plan already-approved items

Integrations

Core scope is PM-agnostic. Integrations are optional plugins that map abstract actions to concrete CLI commands.

Config: .ai-plans/config.yml

integrations: [github]   # or: [] or omit entirely

Loading: When an abstract action is needed (e.g., "create tracking ticket"), check config.yml. If an integration is listed, read ~/.claude/skills/scope/integrations/{name}.md for the concrete commands. If no integration configured → skip the action silently.

Abstract actions (referenced throughout phases):

  • create-ticket — create a tracking issue/ticket
  • create-pr — create a draft PR (git fallback: gh pr create --draft)
  • link-ticket — link a sub-ticket to a parent
  • close-ticket — close a ticket with comment
  • move-status — update ticket status on a board
  • update-epic-pr — check off completed stage in epic PR body
  • update-epic-issue — check off completed stage in epic issue body
  • update-saga-issue — check off completed epic in saga issue body
  • move-to-done — move issue to Done on project board

First-run detection: If .ai-plans/config.yml doesn't exist, auto-detect available CLIs (gh, linear, jira), ask user which to activate, write config. Subsequent runs read config directly.

Config validation (every run): When config.yml lists an integration (e.g., github), verify the config block is complete. For GitHub: owner, repo, project_number, project_node_id, status_field_id, status_options must all be present. If missing → resolve field IDs via gh project field-list and write them. Never proceed with a half-configured integration — it causes silent side-effect failures in ADVANCE and SHIP.


Phase 1: SCOPE

  1. Invoke /council {goal} --subroutine via the Skill tool — full deliberation
  2. Parse council output — extract plan steps, key decisions, risks
  3. Detect scope (small/medium/large) from council's plan structure
  4. Present Review Card:

For large scope (multi-epic):

[SAGA] {Title}
─────────────────────────────
Summary:  • {what}  • {why}  • {approach}
Scope:    {packages/areas affected}
SoW:      Break into {N} epics, execute sequentially
Risk:     {from council risk summary}

(y) approve  (n) reject + feedback  (?) expand

For medium scope (single epic):

[EPIC] {Title}
─────────────────────────────
Summary:  • {what}  • {why}
Scope:    {areas affected}
SoW:      Break into {N} stages
Risk:     {one line}

(y) approve  (n) reject + feedback  (?) expand

For small scope: present a [TASK] card and skip directly to EXECUTE.

  1. On approval:
    • Create .ai-plans/{slug}/roadmap.md
    • Create epic branch: git checkout main && git pull && git checkout -b epic/{slug}
    • Commit roadmap to main
    • If integration configured: create tracking ticket, create draft PR linking to roadmap, add to project board in Planning status. Otherwise: gh pr create --draft
    • Ensure relay is running (see Relay section)
    • Proceed to BREAKDOWN for first stage (or EXECUTE for small scope)

Phase 2: BREAKDOWN (per stage)

  1. Invoke /council "Plan stage: {title}" --subroutine — deliberation on approach
  2. Research the codebase — read relevant files, understand current state
  3. Segment into file-disjoint tasks — each task touches different files (parallel-safe)
  4. Present batch Review Card:
Stage {N}: {title} — {count} tasks
─────────────────────────────
1. {task title} — {files}
2. {task title} — {files}
3. {task title} — {files}
4. Integration task — {wiring}

(a) approve all  (1-4) drill into one  (w) walkthrough
  1. On approval:
    • Sync local epic branch before branching:
      git fetch origin epic/{slug}
      git checkout epic/{slug}
      git reset --hard origin/epic/{slug}
    • Create stage branch: git checkout -b {prefix}/{slug}/{stage-slug}
    • Integration: create stage sub-ticket — create-ticket for the stage, linking to parent epic issue. Add to project board in Todo status.
    • Write task instruction files to .ai-queue/:
      <!-- auto-queue -->
      <!-- target-branch: {prefix}/{slug}/{stage-slug} -->
      <!-- no-merge -->
      <!-- depends-on: NNN -->
      # Task: {title}
      {Implementation instructions with file paths and acceptance criteria}
      <!-- no-merge --> is mandatory. /scope owns all merges — workers must never self-merge.
    • Integration: move stage ticket to In Progress on board
    • Send work-queued event via relay
    • Update roadmap: stage status → in-progress, phase → execute

Branch prefix: feat/, fix/, chore/, or docs/ based on stage nature.

Dependency markers: Add <!-- depends-on: NNN --> upfront when task ordering matters. Workers respect these — a task with unmet dependencies stays pending.


Phase 3: EXECUTE

The orchestrator does NOT implement. Workers (/q) claim and execute tasks in worktrees. The orchestrator owns all merges — workers never self-merge (enforced by <!-- no-merge --> directive).

  1. Verify workers are running. Check relay for connected workers. If none:
    ⚠ No workers connected. Start /q in 1-3 separate terminals to begin execution.
    Waiting for workers...
    Do NOT proceed to implement the tasks yourself. Wait.
  2. Monitor + Merge loop. Listen for relay events: task-ready, task-completed, worker-disconnected.

    On task-ready event: A worker has committed and is waiting for merge. The orchestrator merges sequentially:

    a. Scan .ai-queue/ for active task files (XXX-active.md). Read <!-- worktree: ... --> and <!-- branch: ... --> headers to identify the ready branch.

    b. Merge the worker's branch to the target branch:

    TARGET={target-branch from task file}
    WORKER_BRANCH=q-{NNN}
    
    cd {repo-root}
    git checkout $TARGET
    git fetch origin $TARGET 2>/dev/null || true
    git rebase origin/$TARGET 2>/dev/null || true
    
    # Rebase worker branch onto latest target
    git checkout $WORKER_BRANCH
    git rebase $TARGET
    git checkout $TARGET
    
    # Merge with merge commit
    git merge --no-ff $WORKER_BRANCH -m "merge: $WORKER_BRANCH {task-title}"
    git push origin $TARGET

    c. Send merge-done:{NNN} event via relay (unblocks the worker to clean up):

    node -e "
    const s = require('net').connect(process.argv[1]);
    s.write(JSON.stringify({type:'event',event:process.argv[2]})+'\n');
    setTimeout(() => s.destroy(), 500);
    " "$RELAY_SOCK" "merge-done:{NNN}"

    d. On merge conflict: skip this task, log the conflict, continue with other task-ready events. Report conflicts at VERIFY.

  3. Print progress: [{completed}/{total}] Stage {N}: {title}
  4. Completion: All tasks archived in _completed/ → proceed to VERIFY.

Phase 4: VERIFY

  1. Checkout the stage branch. Pull latest.
  2. Run verification: npm run build, npm run lint, npm test (or project equivalents)
  3. Check acceptance criteria from roadmap — check off each that passes
  4. Present Review Card:
[VERIFY] Stage {N}: {title}
─────────────────────────────
Summary:  • {N}/{M} criteria pass  • {build/lint/test status}
Scope:    {files changed in this stage}
SoW:      Merge stage to epic branch (or iterate on failures)
Risk:     {assessment}

(y) approve + advance  (n) reject + feedback  (?) expand
  1. All pass + approved → ADVANCE
  2. Failures → ITERATE: analyze failures, write fix tasks to .ai-queue/, send work-queued, return to EXECUTE
  3. Iteration limit: 5 per stage, 20 total across all stages. Exceeding → present card explaining failures, ask user.

Phase 5: ADVANCE

Protocol: Read references/branch-protocol.md before creating any PR. Stage PRs MUST target epic/{slug}, never main.

  1. Validate PR target — assert base branch is epic/{slug}, sync local:
    BASE="epic/${SLUG}"
    git fetch origin "$BASE" || { echo "ERROR: epic branch $BASE not found"; exit 1; }
    git checkout "$BASE"
    git reset --hard "origin/$BASE"
  2. Create stage PR to epic branch:
    gh pr create --base epic/{slug} --head {prefix}/{slug}/{stage-slug} \
      --title "Stage {N}: {title}" --body "Closes stage {N} of {slug}"
  3. Merge stage PR:
    gh pr merge --merge --delete-branch
  4. Update roadmap: Mark stage done (criteria already checked from VERIFY).
  5. Integration side-effects (mandatory when configured):
    • update-epic-pr — check off - [x] Stage {N}: {title} (#{stage_pr}) in epic PR body
    • close-ticket — close the stage sub-issue with "Completed."
    • move-to-done — move stage sub-issue to Done on project board
  6. More stages? → BREAKDOWN for next stage. All stages done? → SHIP.

SHIP (epic complete)

  1. Rebase epic branch on main:
    git checkout epic/{slug} && git fetch origin main && git rebase origin/main
    git push --force-with-lease origin epic/{slug}
  2. Present final Review Card:
    [SHIP] {Epic title}
    ─────────────────────────────
    Summary:  • {stages completed}  • {key outcomes}
    Scope:    {total files changed}
    SoW:      Merge epic/{slug} to main
    Risk:     {one line}
    
    (y) merge  (n) hold  (?) expand with full diff
  3. On approval: Mark PR ready for review. Wait for CI. If green → merge.
  4. Integration side-effects (mandatory when configured):
    • update-saga-issue — check off - [x] Epic {N}: {title} (#{epic_pr}) in saga issue body
    • update-epic-pr — verify all stages checked off in epic PR body (should already be done in ADVANCE)
    • move-to-done — move epic PR to Done on project board (epics go from Planning → Done, never In Progress)
  5. Cleanup: Update roadmap status. Commit.
  6. Multi-epic: proceed to next epic's BREAKDOWN instead of sending epic-done.
  7. All epics done: send epic-done via relay. Move saga issue + saga PR to Done on board. Print summary.

Multi-Epic Mode

For broad goals that decompose into multiple epics.

Planning (multi-epic)

Council is invoked once for the full initiative. The reconciled plan identifies natural epic boundaries. Scope converts these into the multi-epic roadmap format.

For each epic, council may be re-invoked for detailed stage planning:

  • Simple epic (1-2 stages) → derive stages directly from council plan
  • Complex epic (3+ stages) → /council "Detail stages for epic: {title}" --subroutine

Roadmap format (multi-epic)

---
slug: {slug}
status: in-progress
scope: large
created: YYYY-MM-DD
current_epic: 1
current_stage: 1
phase: breakdown
---
# {Title}

## Overview
{Goals, scope, key decisions from council plan}

## Metadata
- **Created:** YYYY-MM-DD
- **Integrations:** github

## Epic 1: {title}
**Objective:** {what this delivers}
**Dependencies:** none
**Epic slug:** {epic-slug}
**Epic branch:** epic/{epic-slug}
**Status:** pending | in-progress | complete | skipped

### Stage 1.1: {title}
**Branch prefix:** feat
**Acceptance criteria:**
- [ ] {criterion}
**Status:** pending

## Epic 2: {title}
**Dependencies:** Epic 1
...

Execution

  1. Sequentially execute epics in dependency order. For each epic:
    • Create epic branch, run the full SCOPE → BREAKDOWN → EXECUTE → VERIFY → ADVANCE → SHIP cycle.
    • Between epics: /clear context. Compare output against Overview (drift check).
  2. Worker lifecycle: Between epics send work-queued (keeps workers alive). Only send epic-done after the last epic completes.
  3. Drift check: Minor drift → log and continue. Significant drift → pause, present card to user.

Relay Integration

Fixed socket path: ~/.claude/relay.sock. One relay per machine, started on first use.

Start relay (if not running):

RELAY_SOCK="$HOME/.claude/relay.sock"
RELAY_PID="$HOME/.claude/relay.pid"
if ! ([ -f "$RELAY_PID" ] && kill -0 "$(cat "$RELAY_PID")" 2>/dev/null && [ -S "$RELAY_SOCK" ]); then
  nohup node ~/.claude/skills/relay/server.js > ~/.claude/relay.log 2>&1 &
  # Wait up to 2s for relay.sock to appear
fi

Send event:

node -e "
const s = require('net').connect(process.argv[1]);
s.write(JSON.stringify({type:'event',event:process.argv[2]})+'\n');
setTimeout(() => s.destroy(), 500);
" "$RELAY_SOCK" "{event-name}"

**Events sent by /scope **

  • work-queued — after writing task files to .ai-queue/ (wakes workers)
  • epic-done — after all epics complete (workers exit)

/scope status

{Title} ({scope})
Status: {phase} — {status}

Epics:
  1. {title} — done ✓
  2. {title} — in-progress
     Stage 2.1: {title} — done ✓
     Stage 2.2: {title} — in-progress [3/5 tasks]
     Stage 2.3: {title} — pending
  3. {title} — pending

For single-epic: omit epic grouping, show stages directly. For small scope: show task status.

Reads from .ai-plans/ — scan for all roadmaps, display active ones.


/scope watch

Autonomous monitor → verify → resume cycle. Use during EXECUTE phase when workers are processing tasks.

Behavior

Three sequential phases, fully autonomous (no user interaction until next gate):

Phase A: Monitor (up to 9 minutes)

  1. Read roadmap to determine current stage, total task count, and stage issue number.
  2. Poll .ai-queue/ and .ai-queue/_completed/ every 60 seconds:
    • Count remaining vs completed tasks
    • Print progress: [{completed}/{total}] Stage {N}: {title} — {elapsed}
    • Listen for task-ready events and merge worker branches sequentially (same merge protocol as EXECUTE phase — rebase onto target, merge --no-ff, push, send merge-done:{NNN})
    • If workers disconnect (no progress for 2+ cycles), re-send work-queued via relay
  3. Exit conditions:
    • All tasks moved to _completed/ → proceed to Phase B
    • 9 minutes elapsed with tasks remaining → print status, ask user whether to extend or intervene

Phase B: Clean

Once all tasks complete, run /scope clean (the full 5-pass audit) before doing anything else. Workers often leave tracking gaps — stale board statuses, missing PR checkoffs, roadmap drift. Clean fixes all of it.

This is not a lightweight check. It is the real /scope clean — Pass 0 through Pass 4, autonomous, no user interaction.

Phase C: Resume Flow

After clean completes, resume as if /scope watch was called fresh:

  1. Re-read roadmap frontmatter (clean may have updated it)
  2. If phase is still execute and tasks remain → return to Phase A (monitor again)
  3. If all tasks complete → transition to VERIFY — run build/lint/test, check acceptance criteria
  4. Present the [VERIFY] Review Card for user approval
  5. On approval → ADVANCE → next stage BREAKDOWN (or SHIP if final stage)

This is the standard /scope resume flow from Phase 4 onward — watch simply automates the wait.

Polling implementation

# Count remaining tasks (non-hidden files in .ai-queue/, excluding _completed/)
REMAINING=$(find .ai-queue -maxdepth 1 -name '*.md' | wc -l | tr -d ' ')
COMPLETED=$(find .ai-queue/_completed -maxdepth 1 -name '*.md' 2>/dev/null | wc -l | tr -d ' ')

Use the /loop skill pattern internally — but /scope watch is a single invocation, not recurring. The polling loop runs within the single command execution.

Rules

  • No user interaction during Phase A/B. Only Phase C (VERIFY gate) requires approval.
  • Re-send relay events if workers appear stalled (no new completions for 2+ minutes).
  • 9-minute ceiling is soft. If 6/7 tasks done at 9 min, extend 3 min automatically. Only prompt if <50% done at 9 min.
  • Phase B is mandatory. Never skip /scope clean after workers finish, even if all tasks completed quickly. Workers leave messes.
  • Phase C re-evaluates. After clean, re-read roadmap state — don't assume tasks are still complete. If clean revealed issues, loop back to Phase A.

/scope clean

Full-initiative audit + repair. Derives truth from shipped code (merged PRs, branch state), then reconciles roadmap + GH artifacts to match.

Source of truth hierarchy:

  1. Merged code — PRs merged, branches merged = work is done
  2. Roadmap — updated to reflect merged code
  3. GH issues/PRs — updated to reflect roadmap
  4. Board — updated to reflect issue/PR state

Five Audit Passes (all autonomous, no user interaction)

Pass 0: Sync Local Branches

Update all local tracking branches to match their remote counterparts, then sync epic branches with main:

git fetch origin
# For each epic branch referenced in roadmap:
git checkout epic/{slug} && git reset --hard origin/epic/{slug}
# Merge main into epic branch to keep it current:
git merge main --no-edit
git push origin epic/{slug}
# For the current stage branch (if exists):
git checkout {prefix}/{slug}/{stage-slug} && git reset --hard origin/{prefix}/{slug}/{stage-slug}
# Return to original branch
git checkout {original-branch}

This prevents stale local branches from causing incorrect audit results or bad rebases. Merging main into epic branches ensures stage PRs won't have stale bases.

Pass 1: Code → Roadmap

Scan merged PRs and branch state to determine what's actually shipped:

  • For each stage: check if its branch was merged to epic branch (or PR merged). If merged but roadmap says pending/in-progress → mark done, check off acceptance criteria.
  • For each epic: if all stages done but epic says in-progress → check if epic branch merged to main. If so → mark done.
  • Update roadmap current_epic/current_stage/phase frontmatter to reflect actual state.
  • Commit roadmap changes if any.

Pass 2: Roadmap → GitHub Issues

For each epic/stage in the roadmap:

  1. If roadmap has Issue: #N — verify issue exists, has correct label (epic/stage), is open/closed appropriately (done → closed, in-progress → open)
  2. If roadmap has NO issue reference — create missing issue, link to parent, add label, set board status, write issue # back to roadmap
  3. Verify epic issue body lists all stages in checklist format
  4. Verify saga issue body lists all epics in checklist format

Pass 3: Roadmap → GitHub PRs

For each epic in the roadmap:

  1. If NO epic PR exists (check gh pr list --head epic/{slug}):
    • Create the epic PR targeting main from epic/{slug}
    • Title: the epic title from the roadmap (or parent issue)
    • Body: summary from roadmap/issue + stages checklist (- [ ] Stage N: title for each stage) + Closes #{epic_issue} if issue exists
    • Label the PR with epic
    • Write PR number back to roadmap metadata
  2. If epic PR exists: Verify PR body has all stages in checklist format
  3. Done stages checked off with PR link: - [x] Stage N: title (#PR)
  4. In-progress/pending stages unchecked: - [ ] Stage N: title
  5. Fix mismatches (missing checkoffs, missing PR links, missing stage entries)

Pass 4: Board Status

For each tracked issue:

  1. Epic/saga issues: Planning (active) or Done (complete). Never Todo/InProgress/InReview.
  2. Stage issues: pending → Todo, in-progress → In Progress, has PR → In Review, done → Done
  3. Fix status mismatches

Output

/scope clean — {title}
──────────────────────────────────
Fixed:
  • Roadmap: marked Stage 6.1 done (PR #209 merged)
  • Created missing issue for Stage 6.2 (#211)
  • Checked off Stage 6.1 in epic PR #209 body
  • Moved #208 from In Progress → Done
  • Added 'stage' label to #211

Clean:
  • Epic issue #206 ✓
  • Roadmap frontmatter ✓

{or "All clean — nothing to fix."}

Rules

  • No user interaction. Fix everything, report at end.
  • Read config.yml for integration. No integration → "No integration configured, nothing to audit."
  • Read integrations/github.md for concrete commands.
  • Idempotent — safe to run repeatedly.
  • CAN update roadmap (statuses, issue/PR references, frontmatter). Shipped code is ground truth.
  • Commits roadmap changes if modified.

/scope update

Interactively modify an active roadmap.

  1. List active roadmaps. Scan .ai-plans/ for roadmaps where status is not done or aborted. If none → "No active roadmaps." Otherwise AskUserQuestion with numbered list.
  2. Read selected roadmap. Parse type (saga vs single-epic), full structure, per-stage/epic statuses.
  3. Prompt for changes. AskUserQuestion: "What changes do you want to make to this roadmap?"
  4. Generate diff summary. Compact before/after:
    • + additions (new stages/epics/criteria)
    • ~ modifications (title, criteria, or scope changes)
    • - removals (deleted pending stages/epics/criteria)
  5. Confirm loop. AskUserQuestion: "Apply these changes?" Max 3 loops → stop and print diff for manual editing.
  6. Apply changes. Write updated roadmap. Preserve all execution metadata: PR numbers, issue IDs, iteration counts, checkmarks.
  7. Side-effects:
    • Adjust current_stage / current_epic in frontmatter if structure shifted
    • New epics: create branch, create tracking ticket if integration configured
    • Title changes: gh issue edit if GitHub integration active
    • Removed pending items: close associated tickets with "Removed from roadmap."
  8. Commit. Roadmap to main.

Constraints

  • Cannot update done or aborted roadmaps.
  • Cannot remove or reorder in-progress or done stages/epics — only pending items.
  • Editing titles/criteria on in-progress stages is allowed (scope refinement).

/scope abort

  1. Do NOT delete branches, roadmaps, or completed work.
  2. Set roadmap status to aborted.
  3. mcp__state__session_abandon(session_id) — mark session abandoned.
  4. If integration: close ticket with "Aborted. Work preserved."
  5. Send epic-done via relay (workers exit).
  6. Print where to find preserved work.

/scope setup

One-time repo scaffolding for /scope + /q workflows. Safe to re-run — idempotent.

Steps (all autonomous, no user interaction until summary)

1. Create directories

mkdir -p .ai-plans .ai-queue/_completed

2. Gitignore entries

Ensure .gitignore contains these entries (append if missing, don't duplicate):

# AI orchestration
.ai-queue/
.worktrees/
SCOPE.md

.ai-plans/ is NOT gitignored — roadmaps are committed.

3. Create SCOPE.md

If SCOPE.md doesn't exist at repo root, create it empty. (It's the scratch pad for new initiatives — gitignored, never committed.)

4. Configure integration

If .ai-plans/config.yml doesn't exist:

  1. Auto-detect available CLIs:
    command -v gh &>/dev/null && echo "github"
    command -v linear &>/dev/null && echo "linear"
  2. If gh is available and authenticated (gh auth status):
    • Detect owner and repo from git remote: gh repo view --json owner,name
    • Ask user for project_number (or skip if no project board)
    • If project_number provided: resolve project_node_id, status_field_id, status_options via:
      gh project field-list $PROJECT_NUMBER --owner $OWNER --format json
    • Ensure labels exist: gh label create epic --repo OWNER/REPO 2>/dev/null || true (repeat for saga, stage)
    • Write complete config.yml
  3. If no CLI detected: write config.yml with integrations: []

If .ai-plans/config.yml exists: validate it (same as config validation on every run). Fix incomplete fields.

5. Verify relay

Start the relay if not running (standard relay startup sequence). Verify socket is responsive.

6. Print summary

/scope setup — complete
─────────────────────────────
  ✓ .ai-plans/          created (or exists)
  ✓ .ai-queue/          created (or exists)
  ✓ .gitignore          updated (or already correct)
  ✓ SCOPE.md            created (or exists)
  ✓ config.yml          github (owner/repo, project #N)
  ✓ Labels              epic, saga, stage verified
  ✓ Relay               running (pid XXXX)

Ready. Run `/scope {goal}` to start an initiative,
or `/q` in a separate terminal to start a worker.

Rules

  • Idempotent — safe to run multiple times.
  • Never destructive — never overwrites existing config, roadmaps, or queue files.
  • Only asks one question: project board number (if GitHub detected and no config exists). Everything else is auto-resolved.
  • If config exists but is incomplete (e.g., missing status_options), auto-resolve the missing fields without asking.

/scope (resume / SCOPE.md)

SCOPE.md at repo root is the user's scratch pad for defining new initiatives. Empty SCOPE.md = no pending scope (equivalent to the file not existing). Never delete SCOPE.md — only empty it.

  1. Scan .ai-plans/ for roadmaps with status not done or aborted
  2. Sync local branches: git fetch origin, then for each epic/stage branch in the active roadmap, update local to match remote (git checkout {branch} && git reset --hard origin/{branch}). Return to original branch.
  3. Active roadmap(s) found:
    • If one → resume: read YAML frontmatter → determine current phase → re-enter flow at correct gate
    • If multiple → AskUserQuestion which to resume
    • If SCOPE.md has content → read contents into $GOAL, immediately empty SCOPE.md, then AskUserQuestion: resume active initiative or start new one?
  4. No active roadmap: Check SCOPE.md at repo root
    • Has content → read full contents into $GOAL, then immediately overwrite SCOPE.md with an empty file (Write tool, empty string). Proceed with $GOAL into Phase 1 (SCOPE).
    • Empty or missing → "No active initiative. Run /scope {goal} or write your goal in SCOPE.md."
  5. Ensure relay is running

SCOPE.md lifecycle

Clear on read: the moment /scope reads SCOPE.md content, it empties the file immediately (before any council invocation or user interaction). The content is in the conversation context — the file is free for the next initiative. Same pattern as /do with DO.md.


Branch Strategy

main
└── epic/{slug}
    ├── feat/{slug}/{stage-1-slug}
    ├── fix/{slug}/{stage-2-slug}
    └── chore/{slug}/{stage-3-slug}

Epic branches merge to main. Stage branches merge to epic. Worker branches (q-NNN) merge to stage.


Error Handling

ErrorAction
Stage iteration limit (5)Present card explaining failures, ask user
Total iteration limit (20)Present card explaining failures, ask user
Merge conflictAttempt rebase. If unresolvable → present card
CI failurePresent verification card with failures
Dependency deadlock (multi-epic)Present card, ask user

Memory Integration

Recall at phase entries. Store on outcomes. Reinforce on use. Read ~/.claude/skills/memory/MEMORY_OPS.md for tool call templates.

PhaseAction
SCOPE entryrecall-prior-art with goal keywords + recall-constraints with "scope orchestrator"
BREAKDOWN entryrecall-checklist with "breakdown github tracking tickets"
EXECUTE entryrecall-constraints with "scope never implement execute monitor workers". Reinforce any recalled feedback memories.
VERIFYrecall-prior-art with test/lint patterns for this project
ADVANCErecall-checklist with "advance integration side-effects PR board". Reinforce recalled checklist memories.
SHIPrecall-checklist with "ship merge saga close". store-outcome summarizing the initiative.

Auto-store on Review Card rejection: When user responds n + feedback containing a directive (negation, "don't", "always", "never", corrective language), auto-store as store-feedback.

Attribution: When a recalled memory influences a decision, annotate the bullet in the Review Card with [mem:short-name]. Cap at 3 per section. In ? expanded view, show full memory content.


!! ROLE BOUNDARY !!

Scope is orchestration-only. A /scope orchestrator:

  • NEVER implements code directly — no writing/modifying source files, components, tests, or application code
  • NEVER skips the queue — ALL implementation work MUST go through .ai-queue/ for /q workers
  • Only writes: roadmap files, .ai-queue/ task files, config.yml, and git/GitHub operations
  • EXECUTE phase = monitoring only — block on relay events, print progress, wait for workers
  • If no workers are running: tell the user to start /q workers in separate terminals. Do NOT do the work yourself.

This boundary exists because the orchestrator and workers operate in separate contexts. The orchestrator manages the lifecycle; workers do the implementation. Violating this boundary means work happens without proper isolation, worktree safety, or parallel execution.


Rules

  1. Never execute without approval. Every gate requires a review card.
  2. Council before code. SCOPE and BREAKDOWN always invoke /council --subroutine.
  3. Never implement code. Scope writes task files. Workers implement. No exceptions.
  4. Brevity in cards. No paragraphs. Bullets only. Active voice.
  5. Consistent hierarchy. Summary > Scope > SoW > Risk > Action. Always this order.
  6. Progressive disclosure. Default = compressed. Detail on demand via ?.
  7. Iterate, don't restart. Rejection refines the item, not the whole plan.
  8. Level tags always. [SAGA]/[EPIC]/[STAGE]/[TASK] prefix.
  9. One roadmap file. .ai-plans/{slug}/roadmap.md — single source of truth.
  10. File-disjoint tasks. Parallel-safe by construction.
  11. Commit state to git. Roadmap survives /clear.
  12. Relay required. No fallback polling — relay must be running for worker coordination.
  13. Integration side-effects are mandatory. When config.yml lists an integration, every ADVANCE and SHIP phase MUST execute all side-effects (update PR body, update issue body, move board status). Never skip silently.
  14. Labels are mandatory. Every saga issue gets saga label. Every epic issue gets epic label. Every stage issue gets stage label. Verify after creation.
  15. Checklist links are mandatory. When checking off a stage in an epic PR/issue body, or an epic in a saga issue body, ALWAYS include the PR number: - [x] Stage N: title (#PR_NUMBER). Never check off without linking.
  16. Board status transitions are mandatory. Sagas/epics: Planning on creation → Done on merge (no other statuses ever). Stages: Todo → In Progress → In Review → Done. Never skip transitions.
  17. Verify after every side-effect. After updating a PR body, issue body, or board status, re-read the target to confirm the change took effect. If it didn't, fix it immediately.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.