supermind-claude 2.1.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/.claude-plugin/plugin.json +21 -0
  2. package/README.md +34 -46
  3. package/agents/code-reviewer.md +81 -0
  4. package/cli/commands/doctor.js +415 -79
  5. package/cli/commands/install.js +16 -17
  6. package/cli/commands/skill.js +164 -0
  7. package/cli/commands/uninstall.js +32 -3
  8. package/cli/commands/update.js +25 -4
  9. package/cli/index.js +16 -4
  10. package/cli/lib/agents.js +413 -0
  11. package/cli/lib/executor.js +365 -0
  12. package/cli/lib/hooks.js +8 -1
  13. package/cli/lib/logger.js +1 -1
  14. package/cli/lib/planning.js +502 -0
  15. package/cli/lib/platform.js +4 -0
  16. package/cli/lib/plugin.js +127 -0
  17. package/cli/lib/settings.js +2 -40
  18. package/cli/lib/skills.js +39 -2
  19. package/cli/lib/vendor-skills.js +594 -0
  20. package/hooks/bash-permissions.js +196 -176
  21. package/hooks/context-monitor.js +79 -0
  22. package/hooks/improvement-logger.js +94 -0
  23. package/hooks/pre-merge-checklist.js +102 -0
  24. package/hooks/session-start.js +109 -5
  25. package/hooks/statusline-command.js +115 -29
  26. package/package.json +4 -2
  27. package/skills/anti-rationalization/SKILL.md +38 -0
  28. package/skills/brainstorming/SKILL.md +165 -0
  29. package/skills/code-review/SKILL.md +144 -0
  30. package/skills/executing-plans/SKILL.md +138 -0
  31. package/skills/finishing-branches/SKILL.md +144 -0
  32. package/skills/project/SKILL.md +533 -0
  33. package/skills/quick/SKILL.md +178 -0
  34. package/skills/supermind/SKILL.md +58 -4
  35. package/skills/supermind-init/SKILL.md +48 -2
  36. package/skills/systematic-debugging/SKILL.md +129 -0
  37. package/skills/tdd/SKILL.md +179 -0
  38. package/skills/using-git-worktrees/SKILL.md +138 -0
  39. package/skills/verification-before-completion/SKILL.md +54 -0
  40. package/skills/writing-plans/SKILL.md +169 -0
  41. package/templates/CLAUDE.md +124 -62
  42. package/cli/lib/plugins.js +0 -23
@@ -0,0 +1,165 @@
1
+ <!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Assumptions mode inspired by gsd-build/get-shit-done (MIT license). Adapted for Supermind orchestrator. -->
2
+ ---
3
+ name: brainstorming
4
+ description: Pre-implementation design exploration with interactive and assumptions modes — used by orchestrator Discuss phase
5
+ injects_into: [orchestrator-discuss]
6
+ forked_from: obra/superpowers (MIT)
7
+ ---
8
+
9
+ # Brainstorming Ideas Into Designs
10
+
11
+ Pre-implementation design exploration. Used by the orchestrator during the Discuss phase of Project Mode. Ensures Claude understands what to build before building it.
12
+
13
+ <HARD-GATE>
14
+ Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until a design is presented and the user has approved it. This applies to EVERY project regardless of perceived simplicity.
15
+ </HARD-GATE>
16
+
17
+ ## Anti-Pattern: "This Is Too Simple To Need A Design"
18
+
19
+ Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.
20
+
21
+ ## Modes
22
+
23
+ ### MODE 1 — Interactive (default)
24
+
25
+ The default mode. Ask clarifying questions to understand what the user wants.
26
+
27
+ - Ask questions **one at a time** — never batch multiple questions
28
+ - Prefer **multiple choice** when possible — easier to answer than open-ended
29
+ - Focus on: **purpose**, **constraints**, **success criteria**, **scope**
30
+ - Only one question per message — if a topic needs more exploration, break it into multiple questions
31
+
32
+ ### MODE 2 — Assumptions (triggered by `--assumptions` flag)
33
+
34
+ For users who know what they want and work in a codebase Claude can read. Instead of interviewing the user, analyze the codebase and present assumptions for correction.
35
+
36
+ 1. Read relevant files, recent commits, existing patterns, ARCHITECTURE.md, DESIGN.md
37
+ 2. Analyze the request against the codebase context
38
+ 3. Present a numbered list of assumptions:
39
+ > "Based on the codebase, here's what I think you want..."
40
+ >
41
+ > 1. **Location:** New code goes in `src/components/` following the existing pattern
42
+ > 2. **Pattern:** Uses the same factory pattern as `src/components/button.js`
43
+ > 3. **Testing:** Jest tests matching `*.test.js` convention
44
+ > 4. **Scope:** Only modifies the rendering pipeline, no API changes
45
+ > ...
46
+ 4. User corrects or confirms each assumption
47
+ 5. For anything the codebase can't answer, fall back to Interactive mode for those specific questions
48
+
49
+ Assumptions mode is faster but requires a readable codebase. If the codebase lacks clear patterns or the request is highly ambiguous, fall back to Interactive mode entirely.
50
+
51
+ ## Process Flow
52
+
53
+ ```
54
+ 1. Explore project context (files, docs, recent commits)
55
+ 2. Detect scope (single feature vs. multi-system)
56
+ 3. Choose mode (interactive or assumptions based on flag)
57
+ 4. Build understanding of what to build
58
+ 5. Propose 2-3 approaches with trade-offs
59
+ 6. Present design, get user approval section by section
60
+ 7. Output: structured design document → .planning/phases/phase-N/discussion.md
61
+ ```
62
+
63
+ ### Step 1: Explore Project Context
64
+
65
+ Before asking any questions or making assumptions, understand the project:
66
+
67
+ - Check existing files, directory structure, and patterns
68
+ - Read ARCHITECTURE.md and DESIGN.md if they exist
69
+ - Review recent commits for current direction and momentum
70
+ - Note conventions: naming, file organization, test patterns
71
+
72
+ ### Step 2: Detect Scope
73
+
74
+ Before refining details, assess scope. If the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"), flag this immediately:
75
+
76
+ > "This looks like it has N independent subsystems. Rather than designing a monolith, let's break it into sub-projects that each get their own design cycle."
77
+
78
+ Help decompose into sub-projects:
79
+ - What are the independent pieces?
80
+ - How do they relate?
81
+ - What order should they be built?
82
+
83
+ Then brainstorm the first sub-project through the normal design flow. Each sub-project gets its own discussion → plan → execution cycle.
84
+
85
+ ### Step 3: Choose Mode
86
+
87
+ - **No flag or `--interactive`:** Use Interactive mode (Step 4a)
88
+ - **`--assumptions` flag:** Use Assumptions mode (Step 4b)
89
+
90
+ ### Step 4a: Interactive — Build Understanding
91
+
92
+ Ask questions one at a time to understand:
93
+ - **Purpose:** What problem does this solve? Who is it for?
94
+ - **Constraints:** Performance, compatibility, timeline, tech stack requirements?
95
+ - **Success criteria:** How do we know it works?
96
+ - **Scope:** What's explicitly out of scope?
97
+
98
+ Keep asking until you have enough to propose approaches. Don't over-question simple projects.
99
+
100
+ ### Step 4b: Assumptions — Build Understanding
101
+
102
+ Analyze the codebase and present assumptions (see MODE 2 above). After corrections, you should have the same understanding as the interactive path.
103
+
104
+ ### Step 5: Propose Approaches
105
+
106
+ Propose 2-3 different approaches with trade-offs:
107
+ - Lead with your recommended option and explain why
108
+ - Include at least one simpler alternative
109
+ - Be concrete: name files, patterns, dependencies
110
+ - Call out what each approach trades off (complexity, flexibility, speed)
111
+
112
+ ### Step 6: Present Design
113
+
114
+ Once the user picks an approach (or you've converged on one):
115
+ - Present the design **section by section**
116
+ - Scale detail to complexity: a few sentences if straightforward, paragraphs if nuanced
117
+ - Ask after each section whether it looks right so far
118
+ - Cover as appropriate: architecture, components, data flow, error handling, testing approach
119
+ - Revise any section the user pushes back on before moving forward
120
+
121
+ ### Step 7: Output
122
+
123
+ Save the validated design as a structured Markdown document to `.planning/phases/phase-N/discussion.md` (the orchestrator determines the phase number).
124
+
125
+ The document should capture:
126
+ - The problem statement
127
+ - Key decisions and their rationale
128
+ - The chosen approach
129
+ - Component breakdown
130
+ - Any constraints or non-goals identified during discussion
131
+
132
+ ## Key Principles
133
+
134
+ - **One question at a time** — don't overwhelm with multiple questions
135
+ - **Multiple choice preferred** — easier to answer than open-ended when possible
136
+ - **YAGNI ruthlessly** — remove unnecessary features from designs. If the user didn't ask for it and the system doesn't need it, cut it
137
+ - **Explore alternatives** — always propose 2-3 approaches before settling
138
+ - **Design for isolation and clarity** — break into smaller units with one clear purpose, well-defined interfaces, and independent testability
139
+ - **In existing codebases, follow existing patterns** — explore the current structure before proposing changes. Only deviate when existing patterns actively prevent the goal
140
+ - **Incremental validation** — present design sections, get approval before moving on
141
+ - **Scale to complexity** — a trivial change gets a few sentences of design; a system redesign gets paragraphs
142
+
143
+ ## Red Flags — STOP and Reassess
144
+
145
+ | Signal | Action |
146
+ |--------|--------|
147
+ | Request describes 3+ independent subsystems | Decompose into sub-projects first |
148
+ | User says "just build it" | Present a minimal design anyway — the HARD GATE applies |
149
+ | You're designing features the user didn't mention | YAGNI — cut them |
150
+ | Design requires modifying half the codebase | Scope is too large — decompose |
151
+ | You can't explain a component's purpose in one sentence | Boundary is wrong — rethink |
152
+ | Existing codebase has a pattern for this and you're ignoring it | Follow the pattern unless it's actively broken |
153
+
154
+ ## Verification Checklist
155
+
156
+ Before transitioning to the Plan phase:
157
+
158
+ - [ ] Project context explored (files, docs, recent commits)
159
+ - [ ] Scope assessed — multi-system requests decomposed into sub-projects
160
+ - [ ] User understands the problem and constraints
161
+ - [ ] 2-3 approaches proposed with trade-offs
162
+ - [ ] Design presented section by section with user approval
163
+ - [ ] No unnecessary features in design (YAGNI applied)
164
+ - [ ] Design follows existing codebase patterns where applicable
165
+ - [ ] Structured design document saved to `.planning/phases/phase-N/discussion.md`
@@ -0,0 +1,144 @@
1
+ <!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Adapted for Supermind executor injection. -->
2
+ ---
3
+ name: code-review
4
+ description: Structured code review methodology for the Verify phase — review criteria, issue classification, and anti-performative-agreement
5
+ injects_into: [orchestrator-verify]
6
+ forked_from: obra/superpowers (MIT)
7
+ ---
8
+
9
+ # Code Review
10
+
11
+ ## Review Process
12
+
13
+ Follow these steps in order. Do not skip steps.
14
+
15
+ ### 1. Understand the Intent
16
+
17
+ Read the plan or task spec first. Understand what was supposed to be built before looking at code. If there is no plan, infer intent from commit messages and the diff itself — but flag the missing spec as a concern.
18
+
19
+ ### 2. Read All Changed Files
20
+
21
+ Get the full diff against the base branch (`git diff <base>...HEAD`). Read every changed file completely — not just the diff hunks. Context around changes matters.
22
+
23
+ ### 3. Evaluate Against Criteria
24
+
25
+ Check every change against all six criteria. Do not skip criteria because "it looks fine."
26
+
27
+ #### a. Spec Compliance
28
+
29
+ Does the code do what the plan said? Check each acceptance criterion. If a criterion is unmet, that is a critical issue regardless of code quality.
30
+
31
+ #### b. Correctness
32
+
33
+ - Logic errors, off-by-ones, fence-post errors
34
+ - Edge cases: empty inputs, null/undefined, boundary values, overflow
35
+ - Error handling: are errors caught? Are they handled correctly or silently swallowed?
36
+ - Async correctness: race conditions, unhandled rejections, missing awaits
37
+
38
+ #### c. Test Coverage
39
+
40
+ - Are the important behaviors tested?
41
+ - Are edge cases and error paths covered?
42
+ - Do tests verify behavior, not implementation details?
43
+ - Do tests actually fail when the feature is broken? (Not just "passes when correct")
44
+ - Missing tests for new public functions or changed behavior = important issue
45
+
46
+ #### d. Security
47
+
48
+ - Injection: command injection, SQL injection, XSS, template injection
49
+ - Path traversal: unsanitized user input in file paths
50
+ - Secrets: API keys, passwords, tokens hardcoded or logged
51
+ - Unsafe operations: eval, exec with unsanitized input, deserialization of untrusted data
52
+ - Permissions: missing access checks, privilege escalation
53
+
54
+ #### e. Maintainability
55
+
56
+ - Clear naming: can you understand the code without reading the commit message?
57
+ - Reasonable file sizes: single files doing too many things
58
+ - No unnecessary complexity: abstractions that serve no current purpose, premature generalization
59
+ - Comments where logic isn't self-evident (and no comments where it is)
60
+
61
+ #### f. Consistency
62
+
63
+ - Follows existing codebase patterns (naming conventions, module structure, export style)
64
+ - Uses existing utilities instead of reimplementing
65
+ - Matches the project's error handling pattern
66
+ - Follows the project's test structure and naming
67
+
68
+ ## Issue Classification
69
+
70
+ Every finding gets exactly one classification:
71
+
72
+ | Classification | Meaning | Action Required |
73
+ |---------------|---------|-----------------|
74
+ | **Critical** | Must fix before merge. Bugs, security issues, spec violations, missing tests for core behavior. | Fix immediately. |
75
+ | **Important** | Should fix before merge. Poor naming, missing edge case tests, unclear logic, inconsistency with codebase patterns. | Fix unless you can justify why not. |
76
+ | **Suggestion** | Nice to have. Style preferences, minor simplifications, alternative approaches. | Optional — address if they improve clarity. |
77
+
78
+ Rules:
79
+ - If you're unsure whether something is Critical or Important, make it Critical. Err on the side of strictness.
80
+ - A finding with no file/line reference is incomplete. Always include location.
81
+ - "This could be better" without a concrete suggestion is not a finding. Say what to change.
82
+
83
+ ## Output Format
84
+
85
+ ```
86
+ ## Code Review: [task/feature name]
87
+
88
+ ### Summary
89
+ One paragraph: overall assessment, confidence level, key observations.
90
+
91
+ ### Critical Issues
92
+ - [file:line] Description. Why it matters. Suggested fix.
93
+
94
+ ### Important Issues
95
+ - [file:line] Description. Why it matters. Suggested fix.
96
+
97
+ ### Suggestions
98
+ - [file:line] Description.
99
+
100
+ ### Verdict
101
+ PASS | NEEDS FIXES | FAIL
102
+ ```
103
+
104
+ **Verdict rules:**
105
+ - **PASS**: Zero critical issues AND zero important issues. Suggestions are acceptable.
106
+ - **NEEDS FIXES**: Has critical or important issues that are fixable without redesign.
107
+ - **FAIL**: Fundamental problems — wrong approach, missing core functionality, security vulnerability that requires architectural change.
108
+
109
+ If a section is empty, write "None" — do not omit the section.
110
+
111
+ ## Receiving Review Feedback
112
+
113
+ When you receive review feedback (as the implementer, not the reviewer), apply these rules:
114
+
115
+ ### Do Not Blindly Agree
116
+
117
+ Performative agreement — accepting every finding without evaluation — is worse than pushing back. It produces bad fixes, wastes time, and erodes trust.
118
+
119
+ For each finding, ask:
120
+ 1. **Is this correct?** Does the finding accurately describe a real problem?
121
+ 2. **Is this important?** Even if technically valid, does it matter for this change?
122
+ 3. **Does the suggested fix make sense?** The reviewer may be right about the problem but wrong about the solution.
123
+
124
+ ### When to Push Back
125
+
126
+ - The finding misunderstands the code (reviewer missed context)
127
+ - The finding is technically valid but the fix would make things worse
128
+ - The suggestion conflicts with the plan/spec — the plan wins unless the suggestion reveals a flaw in the plan
129
+ - The finding is about style preference, not correctness or clarity
130
+
131
+ Push back with reasoning, not just "I disagree." Show why the current approach is correct or why the suggested change would cause problems.
132
+
133
+ ### When to Accept
134
+
135
+ - The finding is correct and the fix improves the code — just fix it, don't argue
136
+ - The finding reveals something you missed — acknowledge it and fix it
137
+ - The finding is about consistency with codebase patterns — consistency wins over personal preference
138
+
139
+ ### Fix Protocol
140
+
141
+ 1. Fix ALL critical and important issues. No negotiation on critical.
142
+ 2. Suggestions are optional but should be addressed if they improve clarity.
143
+ 3. After fixing, re-run verification (tests, linter, etc.) to ensure fixes don't break anything.
144
+ 4. If a fix introduces new concerns, flag them — don't silently create new problems.
@@ -0,0 +1,138 @@
1
+ <!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Adapted for Supermind orchestrator. -->
2
+ ---
3
+ name: executing-plans
4
+ description: Wave-based plan execution with progress tracking and failure handling — used by orchestrator Execute phase
5
+ injects_into: [orchestrator-execute]
6
+ forked_from: obra/superpowers (MIT)
7
+ ---
8
+
9
+ # Executing Plans
10
+
11
+ ## Overview
12
+
13
+ Guide the orchestrator through wave-based plan execution. Coordinate executor dispatch, track progress, handle failures. Every task runs in a fresh-context subagent — the orchestrator never executes code directly.
14
+
15
+ **Announce at start:** "Using executing-plans to run the implementation plan."
16
+
17
+ ## Execution Process
18
+
19
+ ### 1. Load the Plan
20
+
21
+ Read the plan and task specs from `.planning/phases/phase-N/`:
22
+ - `plans/plan.md` — the full plan with dependency graph
23
+ - `tasks/task-N.md` — individual task specs (one per executor)
24
+
25
+ Review critically before starting. If concerns exist, raise them before executing.
26
+
27
+ ### 2. Build the Wave Plan
28
+
29
+ Use the dependency graph from the plan to group tasks into waves. Tasks with no unresolved dependencies form the current wave. Use `buildWavePlan` from `executor.js` for topological sorting.
30
+
31
+ ```
32
+ Wave 1: [Task A, Task B, Task C] <- independent, parallel
33
+ Wave 2: [Task D (needs A), Task E] <- D waits for A, E independent
34
+ Wave 3: [Task F (needs D+E)] <- depends on wave 2
35
+ ```
36
+
37
+ ### 3. Execute Waves
38
+
39
+ For each wave:
40
+
41
+ **a. Dispatch executor subagents in parallel** (one per task, up to `maxParallel`):
42
+ - Each executor gets: task spec + injected methodology skills + completion contract
43
+ - Use `buildTaskPacket` from `executor.js` to assemble the task packet
44
+ - Use `executeTask` from `executor.js` to build the Agent tool invocation
45
+ - Respect `config.json` `maxParallel` setting (default: 3)
46
+
47
+ **b. Wait for all executors in the wave to complete**
48
+
49
+ **c. Record results in progress.md:**
50
+ Update `.planning/phases/phase-N/progress.md` after each task completes.
51
+
52
+ | Wave | Task | Status | Commit | Notes |
53
+ |------|------|--------|--------|-------|
54
+
55
+ Use `formatWaveProgress` from `executor.js` for the Markdown table.
56
+
57
+ **d. Handle failures** (see Failure Handling below)
58
+
59
+ ### 4. Between Waves
60
+
61
+ After each wave completes, before starting the next:
62
+ - Verify no conflicts between executor outputs (`git status`)
63
+ - Run the test suite to catch integration issues
64
+ - If tests fail, diagnose before proceeding to the next wave
65
+
66
+ ### 5. After All Waves
67
+
68
+ Run full verification:
69
+ - Complete test suite
70
+ - Lint check (if configured)
71
+ - Build check (if configured)
72
+ - Compare results against the original plan's acceptance criteria
73
+
74
+ ## Failure Handling
75
+
76
+ ### Single Task Failure
77
+ 1. Spawn a debugger executor with the error context (use `fix-bug` task type for systematic-debugging skill injection)
78
+ 2. Debugger gets: original task spec + error output + relevant file state
79
+ 3. If debugger succeeds: mark task as completed, continue
80
+ 4. If debugger also fails: mark task as **failed**, continue with remaining independent tasks, report to user
81
+
82
+ ### Multiple Task Failures in Same Wave
83
+ - Pause execution immediately
84
+ - Report full status: which tasks failed, which succeeded, error details
85
+ - Ask user for direction before continuing
86
+
87
+ ### Dependency Failure
88
+ - If a task fails and other tasks depend on it: skip all dependent tasks
89
+ - Report the cascade: "Task X failed. Skipping tasks Y, Z which depend on it."
90
+ - Continue with any independent tasks in subsequent waves
91
+
92
+ ## Progress Tracking
93
+
94
+ Update `.planning/phases/phase-N/progress.md` after each task completes:
95
+
96
+ ```markdown
97
+ # Execution Progress
98
+
99
+ **Phase:** N
100
+ **Started:** YYYY-MM-DD HH:MM
101
+ **Status:** in_progress | completed | blocked
102
+
103
+ | Wave | Task | Status | Commit | Notes |
104
+ |------|------|--------|--------|-------|
105
+ | 1 | Task description | completed | abc1234 | |
106
+ | 1 | Task description | completed | def5678 | |
107
+ | 2 | Task description | in_progress | | |
108
+ | 2 | Task description | pending | | |
109
+
110
+ ## Failures
111
+ - [task-id]: [error summary and resolution or escalation status]
112
+ ```
113
+
114
+ Valid statuses: `pending`, `in_progress`, `completed`, `failed`, `skipped`
115
+
116
+ ## Completion
117
+
118
+ When all waves are done and verification passes:
119
+ - Update `progress.md` status to `completed`
120
+ - Report summary: tasks completed, tasks failed/skipped, test results
121
+ - Hand off to the finishing-branches skill for the Ship phase
122
+
123
+ ## When to Stop and Ask
124
+
125
+ - Multiple failures in the same wave
126
+ - Verification reveals regressions not caused by the current changes
127
+ - A task's acceptance criteria are ambiguous and the executor can't resolve it
128
+ - The plan has gaps that weren't caught during planning
129
+
130
+ **Ask for clarification rather than guessing.**
131
+
132
+ ## Key Principles
133
+
134
+ - **Fresh context per task.** Every executor starts clean. The task packet must be self-contained.
135
+ - **Never execute code in the orchestrator.** All implementation happens in subagents.
136
+ - **Atomic commits.** Each task produces exactly one commit.
137
+ - **Fail fast, report clearly.** Don't silently retry — surface failures with context.
138
+ - **Respect maxParallel.** Don't launch more concurrent executors than configured.
@@ -0,0 +1,144 @@
1
+ <!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Adapted for Supermind orchestrator. -->
2
+ ---
3
+ name: finishing-branches
4
+ description: Ship phase — push branch, open PR, clean up worktrees. Never merges to main/master.
5
+ injects_into: [orchestrator-ship]
6
+ forked_from: obra/superpowers (MIT)
7
+ ---
8
+
9
+ # Finishing Branches
10
+
11
+ ## Overview
12
+
13
+ Handle the Ship phase — push the feature branch, open a PR, and clean up worktrees. The orchestrator picks the appropriate option based on context.
14
+
15
+ **Core principle:** Verify tests -> Choose option -> Execute -> Clean up.
16
+
17
+ **Announce at start:** "Using finishing-branches to complete this work."
18
+
19
+ ## Step 1: Verify Tests
20
+
21
+ Before anything else, run the project's test suite:
22
+
23
+ ```bash
24
+ npm test / cargo test / pytest / go test ./...
25
+ ```
26
+
27
+ **If tests fail:** Stop. Do not proceed. Report failures and fix them first.
28
+
29
+ **If tests pass:** Continue to Step 2.
30
+
31
+ ## Step 2: Choose Option
32
+
33
+ The orchestrator picks one of three options:
34
+
35
+ ### Option A: Create PR (default for Ship phase)
36
+
37
+ Push the feature branch and open a pull request.
38
+
39
+ ```bash
40
+ # Push feature branch to remote
41
+ git push -u origin <branch>
42
+ ```
43
+
44
+ ```bash
45
+ # Open PR with summary from .planning/
46
+ gh pr create --title "<title>" --body "$(cat <<'EOF'
47
+ ## Summary
48
+ <bullets: what was built, tasks completed>
49
+
50
+ ## Test Results
51
+ <test suite output summary>
52
+
53
+ ## Tasks Completed
54
+ <from .planning/phases/phase-N/progress.md>
55
+ EOF
56
+ )"
57
+ ```
58
+
59
+ - PR description auto-generated from `.planning/` state
60
+ - Never set auto-merge — user merges manually
61
+ - Clean up worktrees after PR is created (Step 3)
62
+
63
+ ### Option B: Keep Branch
64
+
65
+ Keep the branch for continued work later.
66
+
67
+ ```bash
68
+ # Stage and commit known files (avoid git add -A to prevent staging sensitive files)
69
+ git add <known-files> && git commit -m "wip: <description>"
70
+ ```
71
+
72
+ - Report branch name and current status
73
+ - Leave worktrees intact — do NOT clean up
74
+ - Report: "Keeping branch `<name>`. Worktree preserved at `<path>`."
75
+
76
+ ### Option C: Discard
77
+
78
+ Throw away the work. **Requires explicit user confirmation.**
79
+
80
+ ```
81
+ This will permanently delete:
82
+ - Branch: <name>
83
+ - All commits since branching
84
+ - Worktree at <path>
85
+
86
+ Type 'discard' to confirm.
87
+ ```
88
+
89
+ Wait for exact typed confirmation before proceeding.
90
+
91
+ If confirmed:
92
+ ```bash
93
+ git checkout <originating-branch>
94
+ git branch -D <feature-branch>
95
+ ```
96
+
97
+ Clean up worktrees after deletion (Step 3).
98
+
99
+ ## Step 3: Worktree Cleanup
100
+
101
+ **For Options A and C only** (not B):
102
+
103
+ ```bash
104
+ # Remove each worktree used during execution
105
+ git worktree remove .worktrees/<name>
106
+
107
+ # Prune stale worktree references
108
+ git worktree prune
109
+
110
+ # Delete merged worktree branches
111
+ git branch -d worktree/<name>
112
+ ```
113
+
114
+ ## Safety Rules
115
+
116
+ These are non-negotiable:
117
+
118
+ - **NEVER merge to main/master.** The PR is the integration mechanism.
119
+ - **NEVER force push.** No `--force`, no `--force-with-lease` unless the user explicitly requests it.
120
+ - **NEVER set auto-merge** on the PR.
121
+ - **Always verify tests** before offering any option.
122
+ - **Always get typed confirmation** for Option C (discard).
123
+
124
+ ## Quick Reference
125
+
126
+ | Option | Push | PR | Keep Worktree | Cleanup Branch |
127
+ |--------|------|------|---------------|----------------|
128
+ | A. Create PR | yes | yes | no | no (PR branch) |
129
+ | B. Keep Branch | no | no | yes | no |
130
+ | C. Discard | no | no | no | yes (force) |
131
+
132
+ ## Red Flags
133
+
134
+ **Never:**
135
+ - Proceed with failing tests
136
+ - Merge to main/master
137
+ - Delete work without typed confirmation
138
+ - Force-push without explicit user request
139
+
140
+ **Always:**
141
+ - Verify tests first
142
+ - Generate PR description from `.planning/` state
143
+ - Clean up worktrees for Options A and C
144
+ - Preserve worktrees for Option B