supermind-claude 2.1.0 → 4.0.1
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.
- package/.claude-plugin/plugin.json +21 -0
- package/README.md +34 -46
- package/agents/code-reviewer.md +81 -0
- package/cli/commands/doctor.js +415 -79
- package/cli/commands/install.js +17 -18
- package/cli/commands/skill.js +164 -0
- package/cli/commands/uninstall.js +32 -3
- package/cli/commands/update.js +27 -5
- package/cli/index.js +16 -4
- package/cli/lib/agents.js +413 -0
- package/cli/lib/executor.js +365 -0
- package/cli/lib/hooks.js +8 -1
- package/cli/lib/logger.js +1 -1
- package/cli/lib/mcp.js +25 -5
- package/cli/lib/planning.js +502 -0
- package/cli/lib/platform.js +4 -0
- package/cli/lib/plugin.js +127 -0
- package/cli/lib/settings.js +2 -40
- package/cli/lib/skills.js +39 -2
- package/cli/lib/templates.js +48 -1
- package/cli/lib/vendor-skills.js +594 -0
- package/hooks/bash-permissions.js +196 -176
- package/hooks/context-monitor.js +79 -0
- package/hooks/improvement-logger.js +94 -0
- package/hooks/pre-merge-checklist.js +102 -0
- package/hooks/session-start.js +109 -5
- package/hooks/statusline-command.js +123 -29
- package/package.json +4 -2
- package/skills/anti-rationalization/SKILL.md +38 -0
- package/skills/brainstorming/SKILL.md +165 -0
- package/skills/code-review/SKILL.md +144 -0
- package/skills/executing-plans/SKILL.md +138 -0
- package/skills/finishing-branches/SKILL.md +144 -0
- package/skills/project/SKILL.md +533 -0
- package/skills/quick/SKILL.md +178 -0
- package/skills/supermind/SKILL.md +58 -4
- package/skills/supermind-init/SKILL.md +48 -2
- package/skills/systematic-debugging/SKILL.md +129 -0
- package/skills/tdd/SKILL.md +179 -0
- package/skills/using-git-worktrees/SKILL.md +138 -0
- package/skills/verification-before-completion/SKILL.md +54 -0
- package/skills/writing-plans/SKILL.md +169 -0
- package/templates/CLAUDE.md +124 -61
- package/cli/lib/plugins.js +0 -23
|
@@ -1,13 +1,67 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: supermind
|
|
3
|
-
description: "
|
|
3
|
+
description: "Complexity router — auto-detects task scope and routes to /quick or /project mode"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Supermind
|
|
6
|
+
# Supermind — Complexity Router
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
This skill activates at the start of every task. It decides how much ceremony the task needs, then routes to the appropriate mode.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
**This is a meta-skill. It does NOT do any work itself.** It:
|
|
11
|
+
1. Reads the user's prompt
|
|
12
|
+
2. Decides Quick or Project
|
|
13
|
+
3. Invokes the appropriate skill (`/quick` or `/project`)
|
|
14
|
+
4. Passes through all flags and the original prompt
|
|
15
|
+
|
|
16
|
+
## Auto-Detection Signals
|
|
17
|
+
|
|
18
|
+
### Quick Signals (route to `/quick`)
|
|
19
|
+
|
|
20
|
+
- **Keywords:** "fix", "rename", "typo", "update config", "add test for", "add", "change X to Y", "remove", "delete", "bump", "move"
|
|
21
|
+
- **Scope:** single file mentioned, specific function/variable named
|
|
22
|
+
- **Clarity:** the request is unambiguous — you know exactly what to do
|
|
23
|
+
- **Size:** trivially small change
|
|
24
|
+
|
|
25
|
+
### Project Signals (route to `/project`)
|
|
26
|
+
|
|
27
|
+
- **Keywords:** "build", "implement", "create", "add feature", "refactor", "redesign", "new", "architect", "migrate", "integrate"
|
|
28
|
+
- **Scope:** multiple files, multiple systems, or scope is unclear
|
|
29
|
+
- **Ambiguity:** requirements need clarification
|
|
30
|
+
- **Size:** non-trivial — multiple behaviors, new abstractions, integration work
|
|
31
|
+
|
|
32
|
+
## Routing Behavior
|
|
33
|
+
|
|
34
|
+
1. Analyze the user's prompt against the signal lists above
|
|
35
|
+
2. Make a decision
|
|
36
|
+
3. Announce it with an escape hatch:
|
|
37
|
+
- **Quick:** *"This looks like a quick task — running in quick mode. Say `/project` if you want the full lifecycle."*
|
|
38
|
+
- **Project:** *"This looks like a multi-step project — running in project mode. Say `/quick` if this is simpler than I think."*
|
|
39
|
+
4. Invoke the chosen skill immediately via the Skill tool — `/quick` or `/project`. The user can override at any time.
|
|
40
|
+
|
|
41
|
+
## Explicit Overrides (always respected)
|
|
42
|
+
|
|
43
|
+
These bypass auto-detection entirely:
|
|
44
|
+
|
|
45
|
+
| User input | Action |
|
|
46
|
+
|-----------|--------|
|
|
47
|
+
| `quick: <task>` or `/quick` | Quick Mode, no questions asked |
|
|
48
|
+
| `/project` | Project Mode, no questions asked |
|
|
49
|
+
| `/project --assumptions` | Project Mode with assumptions |
|
|
50
|
+
| `/project --skip-discuss` | Project Mode starting at research |
|
|
51
|
+
| `/project --skip-research` | Project Mode starting at plan |
|
|
52
|
+
| `/project --max-parallel N` | Project Mode with custom parallelism |
|
|
53
|
+
| `/quick --with-research` | Quick Mode with pre-dispatch research |
|
|
54
|
+
| `/quick --with-discuss` | Quick Mode with clarifying questions |
|
|
55
|
+
|
|
56
|
+
All composable flags from Quick and Project modes pass through unchanged.
|
|
57
|
+
|
|
58
|
+
## Edge Cases
|
|
59
|
+
|
|
60
|
+
- **Not a task** (greeting, question, discussion): respond normally — do NOT route
|
|
61
|
+
- **Active `.planning/` session** (user references it or says "continue"/"resume"): resume Project Mode at the last checkpoint
|
|
62
|
+
- **Ambiguous** (could be quick or project): default to **quick** — less ceremony, and the user can escalate with `/project`
|
|
63
|
+
|
|
64
|
+
## Available Sub-Commands
|
|
11
65
|
|
|
12
66
|
- `/supermind-init` — Initialize a project: CLAUDE.md setup, ARCHITECTURE.md/DESIGN.md generation, health checks, and optional skill/MCP discovery
|
|
13
67
|
- `/supermind-living-docs` — Manually sync ARCHITECTURE.md and DESIGN.md with the current codebase
|
|
@@ -24,7 +24,9 @@ Section-level merging preserves your project-specific customizations while keepi
|
|
|
24
24
|
|
|
25
25
|
**Infrastructure** (replaced from template on every run):
|
|
26
26
|
- Shell & Git Permissions
|
|
27
|
-
-
|
|
27
|
+
- Subagent Strategy
|
|
28
|
+
- Development Lifecycle
|
|
29
|
+
- Vendor Skills
|
|
28
30
|
- MCP Servers
|
|
29
31
|
- UI Changes
|
|
30
32
|
- Living Documentation
|
|
@@ -63,6 +65,50 @@ Section-level merging preserves your project-specific customizations while keepi
|
|
|
63
65
|
|
|
64
66
|
---
|
|
65
67
|
|
|
68
|
+
## Phase 1.5: Project-Local Config Scaffolding
|
|
69
|
+
|
|
70
|
+
Generate project-specific Claude Code configuration files to streamline permissions and MCP server setup.
|
|
71
|
+
|
|
72
|
+
### Steps
|
|
73
|
+
|
|
74
|
+
7a. **Generate `.claude/settings.local.json`** (only if file does not exist):
|
|
75
|
+
|
|
76
|
+
a. Detect project stack from manifest files:
|
|
77
|
+
- `package.json` present: Node.js stack
|
|
78
|
+
- `Cargo.toml` present: Rust stack
|
|
79
|
+
- `go.mod` present: Go stack
|
|
80
|
+
- `requirements.txt` or `pyproject.toml` present: Python stack
|
|
81
|
+
- `Gemfile` present: Ruby stack
|
|
82
|
+
|
|
83
|
+
b. Build permission allows based on detected stack:
|
|
84
|
+
|
|
85
|
+
| Stack | Permissions |
|
|
86
|
+
|-------|------------|
|
|
87
|
+
| Node.js | Bash(npm install:*), Bash(npm run:*), Bash(npm test:*), Bash(npx:*), Bash(node:*), Bash(tsc:*) |
|
|
88
|
+
| Python | Bash(pip install:*), Bash(pytest:*), Bash(python:*), Bash(uv:*) |
|
|
89
|
+
| Rust | Bash(cargo build:*), Bash(cargo test:*), Bash(cargo run:*), Bash(cargo clippy:*) |
|
|
90
|
+
| Go | Bash(go build:*), Bash(go test:*), Bash(go run:*), Bash(go vet:*) |
|
|
91
|
+
| Ruby | Bash(bundle install:*), Bash(bundle exec:*), Bash(rake:*), Bash(rspec:*) |
|
|
92
|
+
|
|
93
|
+
c. Always include: `WebSearch`, `mcp__plugin_semgrep-plugin_semgrep__semgrep_scan`
|
|
94
|
+
|
|
95
|
+
d. Write the file using the Write tool. Tell the user what was generated.
|
|
96
|
+
|
|
97
|
+
7b. **Generate `.mcp.json`** (only if file does not exist):
|
|
98
|
+
|
|
99
|
+
a. Scan for service indicators in package.json dependencies and .env.example:
|
|
100
|
+
- `@supabase/supabase-js` -> suggest Supabase MCP
|
|
101
|
+
- `railway` in scripts -> suggest Railway MCP
|
|
102
|
+
- Database connection strings -> suggest relevant DB MCP
|
|
103
|
+
|
|
104
|
+
b. If indicators found, ask the user which MCP servers to enable.
|
|
105
|
+
|
|
106
|
+
c. Write `.mcp.json` with selected servers. If no indicators found, skip this step.
|
|
107
|
+
|
|
108
|
+
d. Check if `.mcp.json` should be in `.gitignore` (if it would contain API keys). If so, add it.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
66
112
|
## Phase 2: Living Documentation
|
|
67
113
|
|
|
68
114
|
ARCHITECTURE.md uses tables-over-prose because it saves tokens — the AI reads the file index instead of scanning the entire project. This phase generates AI-optimized documentation from a deep codebase scan.
|
|
@@ -163,7 +209,7 @@ Different projects benefit from different tools. A database-heavy project might
|
|
|
163
209
|
c. **Research relevant tools** — dispatch **two parallel agents**:
|
|
164
210
|
|
|
165
211
|
**Agent 1: Skills research**
|
|
166
|
-
- Search for
|
|
212
|
+
- Search for vendor skills and MCP servers relevant to the detected tech stack
|
|
167
213
|
- Consider the project's language, framework, testing approach, and deployment target
|
|
168
214
|
- Check installed vs. available skills and identify gaps
|
|
169
215
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Adapted for Supermind executor injection. -->
|
|
2
|
+
---
|
|
3
|
+
name: systematic-debugging
|
|
4
|
+
description: Four-phase root-cause debugging methodology — injected into fix-bug executors
|
|
5
|
+
injects_into: [fix-bug]
|
|
6
|
+
forked_from: obra/superpowers (MIT)
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Systematic Debugging
|
|
10
|
+
|
|
11
|
+
## The Iron Law
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
ALWAYS FIND ROOT CAUSE BEFORE ATTEMPTING FIXES. SYMPTOM FIXES ARE FAILURE.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This is not a suggestion. This is a constraint. Violate it and the completion contract fails.
|
|
18
|
+
|
|
19
|
+
"It looks like the problem is..." without reproduction is a GUESS, not a diagnosis. Guessing is not debugging — it's gambling.
|
|
20
|
+
|
|
21
|
+
## Four Phases
|
|
22
|
+
|
|
23
|
+
You MUST complete each phase before proceeding to the next. No skipping. No shortcuts.
|
|
24
|
+
|
|
25
|
+
### Phase 1 — REPRODUCE
|
|
26
|
+
|
|
27
|
+
Reproduce the bug with a concrete test case or command that shows the failure.
|
|
28
|
+
|
|
29
|
+
**Requirements:**
|
|
30
|
+
- What input triggers the bug?
|
|
31
|
+
- What is the expected output?
|
|
32
|
+
- What is the actual output?
|
|
33
|
+
- Can you trigger it reliably?
|
|
34
|
+
|
|
35
|
+
If you can't reproduce it, you can't fix it. Gather more information — don't guess.
|
|
36
|
+
|
|
37
|
+
**How to reproduce:**
|
|
38
|
+
1. Read error messages carefully. Don't skip past errors or warnings. Read stack traces completely. Note line numbers, file paths, error codes.
|
|
39
|
+
2. Write a minimal reproduction — a test case, a script, or a shell command that demonstrates the failure.
|
|
40
|
+
3. Run it. Watch it fail. Confirm the failure matches the reported symptoms.
|
|
41
|
+
|
|
42
|
+
If the bug is intermittent, gather more data until you can trigger it on demand. Intermittent doesn't mean random — it means you don't understand the conditions yet.
|
|
43
|
+
|
|
44
|
+
### Phase 2 — ISOLATE
|
|
45
|
+
|
|
46
|
+
Narrow down WHERE the bug lives.
|
|
47
|
+
|
|
48
|
+
**Binary search strategy:** eliminate half the codebase at each step.
|
|
49
|
+
|
|
50
|
+
1. **Read the actual code path.** Don't assume. Follow the execution from input to failure point.
|
|
51
|
+
2. **Check recent changes.** `git log`, `git blame`, `git diff` — what changed that could cause this?
|
|
52
|
+
3. **Read error messages carefully.** They describe symptoms, but they point at locations. Start there.
|
|
53
|
+
4. **Trace data flow.** Where does the bad value originate? What called this function with the bad value? Keep tracing upstream until you find the source.
|
|
54
|
+
5. **Check edge cases** in the specific code path — null values, empty arrays, off-by-one, type coercion, missing config.
|
|
55
|
+
|
|
56
|
+
**Form a hypothesis about root cause. Write it down explicitly.**
|
|
57
|
+
|
|
58
|
+
State clearly: "I think X is the root cause because Y." Be specific, not vague. If your hypothesis is "something is wrong with the config" — that's not a hypothesis, that's a shrug.
|
|
59
|
+
|
|
60
|
+
### Phase 3 — FIX
|
|
61
|
+
|
|
62
|
+
Fix the ROOT CAUSE, not the symptom. The fix should be minimal — change as little as possible.
|
|
63
|
+
|
|
64
|
+
1. **Write a test that fails WITHOUT the fix and passes WITH it.** This proves the fix addresses the actual bug, not a coincidence.
|
|
65
|
+
2. **Implement the smallest possible change** that fixes the root cause. One change at a time. No "while I'm here" improvements. No bundled refactoring.
|
|
66
|
+
3. **If the fix is larger than expected, re-evaluate.** A large fix often means you're fixing a symptom, not the root cause. Return to Phase 2.
|
|
67
|
+
|
|
68
|
+
### Phase 4 — VERIFY
|
|
69
|
+
|
|
70
|
+
1. **Run the reproduction case.** Does it pass now?
|
|
71
|
+
2. **Run the full test suite.** Did the fix break anything else?
|
|
72
|
+
3. **Check related code paths.** Could the same root cause exist elsewhere? If the same pattern exists in other places, fix all instances — don't leave landmines.
|
|
73
|
+
4. **If the same bug pattern recurs,** consider whether the design makes it too easy to introduce. A defensive fix at the right abstraction layer prevents the entire class of bugs.
|
|
74
|
+
|
|
75
|
+
## Anti-Patterns
|
|
76
|
+
|
|
77
|
+
| Anti-Pattern | Why It's Wrong |
|
|
78
|
+
|-------------|---------------|
|
|
79
|
+
| "I think I see the issue, let me just change this" | Reproduce first. Phase 1 is not optional. You're guessing. |
|
|
80
|
+
| "The error message says X, so the fix is Y" | Error messages describe symptoms. Find the cause. |
|
|
81
|
+
| "Let me try this fix and see if it works" | Trial-and-error is not debugging. It's gambling. |
|
|
82
|
+
| "This is probably a race condition / timing issue" | "Probably" means you haven't proven it. Prove it. |
|
|
83
|
+
| "I'll add a null check here" | Why is it null? That's the real question. Null checks hide bugs. |
|
|
84
|
+
| "It works now after my change" | Does the test prove it works? Does the test prove WHY it was broken? |
|
|
85
|
+
| "Quick fix for now, investigate later" | "Later" never comes. Fix it right the first time. |
|
|
86
|
+
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. Wastes more time than it saves. |
|
|
87
|
+
| "I'll skip the test, I can verify manually" | Manual verification is ad-hoc. No record, can't re-run, easy to miss cases. |
|
|
88
|
+
|
|
89
|
+
## Red Flags — STOP and Return to Phase 1
|
|
90
|
+
|
|
91
|
+
If you catch yourself thinking any of these, STOP:
|
|
92
|
+
|
|
93
|
+
- "Just try changing X and see if it works"
|
|
94
|
+
- "Add multiple changes, run tests"
|
|
95
|
+
- "Skip the test, I'll manually verify"
|
|
96
|
+
- "It's probably X, let me fix that"
|
|
97
|
+
- "I don't fully understand but this might work"
|
|
98
|
+
- "One more fix attempt" (when already tried 2+)
|
|
99
|
+
- "Here are the main problems: [lists fixes without investigation]"
|
|
100
|
+
- Proposing solutions before tracing data flow
|
|
101
|
+
|
|
102
|
+
**ALL of these mean: STOP. Go back to Phase 1.**
|
|
103
|
+
|
|
104
|
+
**If 3+ fix attempts have failed:** Stop fixing. The root cause is not what you think it is — or the design itself is the problem. Re-examine your assumptions from scratch.
|
|
105
|
+
|
|
106
|
+
## Escalation Rule
|
|
107
|
+
|
|
108
|
+
If you have attempted 3 or more fixes and none resolved the bug:
|
|
109
|
+
|
|
110
|
+
1. **Stop.** Do not attempt fix #4.
|
|
111
|
+
2. **Summarize** what you tried and what you learned from each attempt.
|
|
112
|
+
3. **Question fundamentals.** Is this the right approach? Is the architecture sound? Is there a deeper design problem?
|
|
113
|
+
4. **Report** your findings. The bug may require a different approach entirely.
|
|
114
|
+
|
|
115
|
+
Each failed fix that reveals a new problem in a different place is a signal that you're treating symptoms of a design issue, not a single bug.
|
|
116
|
+
|
|
117
|
+
## Verification Checklist
|
|
118
|
+
|
|
119
|
+
Before reporting the bug as fixed:
|
|
120
|
+
|
|
121
|
+
- [ ] Reproduced the bug with a concrete test case (Phase 1)
|
|
122
|
+
- [ ] Identified and stated the root cause explicitly (Phase 2)
|
|
123
|
+
- [ ] Wrote a test that fails without the fix and passes with it (Phase 3)
|
|
124
|
+
- [ ] Fix addresses the root cause, not a symptom (Phase 3)
|
|
125
|
+
- [ ] Reproduction case passes (Phase 4)
|
|
126
|
+
- [ ] Full test suite passes (Phase 4)
|
|
127
|
+
- [ ] Checked for same pattern in related code paths (Phase 4)
|
|
128
|
+
|
|
129
|
+
Can't check all boxes? You skipped a phase. Go back.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
<!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Adapted for Supermind executor injection. -->
|
|
2
|
+
---
|
|
3
|
+
name: tdd
|
|
4
|
+
description: Strict RED-GREEN-REFACTOR test-driven development — injected into write-feature and write-test executors
|
|
5
|
+
injects_into: [write-feature, write-test]
|
|
6
|
+
forked_from: obra/superpowers (MIT)
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Test-Driven Development
|
|
10
|
+
|
|
11
|
+
## The Iron Law
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This is not a suggestion. This is a constraint. Violate it and the completion contract fails.
|
|
18
|
+
|
|
19
|
+
Write code before the test? Delete it. Start over. No exceptions — don't keep it as "reference," don't "adapt" it, don't look at it. Delete means delete.
|
|
20
|
+
|
|
21
|
+
## Scope
|
|
22
|
+
|
|
23
|
+
**Always use TDD for:** new features, bug fixes, refactoring, behavior changes.
|
|
24
|
+
|
|
25
|
+
**Legitimate exceptions:** configuration-only changes (no logic), generated code (codegen output), throwaway prototypes (delete before real implementation). If a task is purely config and has no testable behavior, skip TDD — but if it has logic, it gets tests.
|
|
26
|
+
|
|
27
|
+
## Step Zero: Detect the Test Framework
|
|
28
|
+
|
|
29
|
+
Before writing any code or tests, detect the project's test setup:
|
|
30
|
+
|
|
31
|
+
- **Node.js:** Check `package.json` scripts for `test`, `jest`, `vitest`, `mocha`, `tap`, `ava`
|
|
32
|
+
- **Python:** Look for `pytest.ini`, `setup.cfg`, `pyproject.toml` (`[tool.pytest]`), or `tox.ini`
|
|
33
|
+
- **Rust:** Check `Cargo.toml` — `cargo test` is built in
|
|
34
|
+
- **Go:** Built-in `go test`
|
|
35
|
+
- **Other:** Look for existing test files and follow their naming conventions
|
|
36
|
+
|
|
37
|
+
If no test framework exists, **set one up before writing any code.** That is step zero, not step one.
|
|
38
|
+
|
|
39
|
+
Follow existing test file naming conventions (e.g., `*.test.ts`, `*_test.go`, `test_*.py`). Match what the project already uses.
|
|
40
|
+
|
|
41
|
+
## The Cycle
|
|
42
|
+
|
|
43
|
+
Follow this exact order. Every time. No shortcuts.
|
|
44
|
+
|
|
45
|
+
### 1. RED — Write a Failing Test
|
|
46
|
+
|
|
47
|
+
Write one test for one behavior. Not one function, not one file — one **behavior**.
|
|
48
|
+
|
|
49
|
+
**Requirements:**
|
|
50
|
+
- Clear name that describes the behavior being tested
|
|
51
|
+
- Tests real code, not mocks (unless external dependencies make mocks unavoidable)
|
|
52
|
+
- One assertion per behavior — "and" in a test name means split it
|
|
53
|
+
|
|
54
|
+
Run the test. **Watch it fail.**
|
|
55
|
+
|
|
56
|
+
Confirm:
|
|
57
|
+
- It fails (not errors — a compilation error is not a failing test)
|
|
58
|
+
- The failure message matches what you expect
|
|
59
|
+
- It fails because the feature is missing, not because of a typo
|
|
60
|
+
|
|
61
|
+
If the test passes immediately, you are testing existing behavior. Fix the test.
|
|
62
|
+
|
|
63
|
+
### 2. GREEN — Write Minimum Code to Pass
|
|
64
|
+
|
|
65
|
+
Write the **literally minimum** code to make the test pass. Hardcode a return value if that passes. The next test will force generalization.
|
|
66
|
+
|
|
67
|
+
Do not:
|
|
68
|
+
- Add features the test doesn't require
|
|
69
|
+
- Refactor other code
|
|
70
|
+
- "Improve" beyond what the test demands
|
|
71
|
+
- Add options, configurability, or extensibility
|
|
72
|
+
|
|
73
|
+
Run the test. **Watch it pass.** Confirm all other tests still pass too.
|
|
74
|
+
|
|
75
|
+
If the test fails, fix the production code — not the test.
|
|
76
|
+
|
|
77
|
+
### 3. REFACTOR — Clean Up While Green
|
|
78
|
+
|
|
79
|
+
After green (and only after green):
|
|
80
|
+
- Remove duplication
|
|
81
|
+
- Improve names
|
|
82
|
+
- Extract helpers
|
|
83
|
+
- Simplify logic
|
|
84
|
+
|
|
85
|
+
Run the tests after every change. Still green? Good. Tests went red? You changed behavior — **revert and try again.** Refactor means improve structure without changing behavior.
|
|
86
|
+
|
|
87
|
+
### 4. REPEAT
|
|
88
|
+
|
|
89
|
+
Go back to RED for the next behavior. One test at a time. Always.
|
|
90
|
+
|
|
91
|
+
## Rules
|
|
92
|
+
|
|
93
|
+
- **One behavior per test.** Not one function, not one file — one behavior.
|
|
94
|
+
- **Never write two tests at once.** RED-GREEN-REFACTOR is a single-test loop.
|
|
95
|
+
- **If you didn't watch the test fail, you don't know if it tests the right thing.**
|
|
96
|
+
- **"Minimum code to pass" means literally minimum.** Hardcode if that passes. The next test will force generalization.
|
|
97
|
+
- **If you're writing production code and realize you need another behavior, STOP.** Write the test first.
|
|
98
|
+
- **Refactor means improve structure without changing behavior.** If tests go red during refactor, you changed behavior — revert and try again.
|
|
99
|
+
|
|
100
|
+
## Anti-Patterns
|
|
101
|
+
|
|
102
|
+
| Anti-Pattern | Why It's Wrong |
|
|
103
|
+
|-------------|---------------|
|
|
104
|
+
| "Let me write all the tests first, then implement" | You lose the design feedback loop. Each RED tells you something about the API. Batch-writing tests means guessing. |
|
|
105
|
+
| "This is obvious, I'll write the code and tests together" | Test first. Always. "Obvious" code is where the sneakiest bugs hide. |
|
|
106
|
+
| "I'll add tests after I get the code working" | This is not TDD. This is test-after. Tests written after code pass immediately — proving nothing. You lose the proof that the test catches the bug. |
|
|
107
|
+
| "The test framework isn't set up yet, I'll write code first" | Set up the framework first. That's step zero. No production code without a failing test first. |
|
|
108
|
+
| "I need to explore first" | Fine. Throw away the exploration. Then start with TDD. Exploration code is not production code. |
|
|
109
|
+
| "Tests are too hard to write for this" | Hard-to-test code is hard-to-use code. Listen to the test — it's telling you the design needs work. |
|
|
110
|
+
| "I already manually tested it" | Manual testing is ad-hoc. No record, can't re-run, easy to forget cases. Automated tests are systematic. |
|
|
111
|
+
|
|
112
|
+
## Mocking Rules
|
|
113
|
+
|
|
114
|
+
Mocks are a last resort, not a convenience. Three rules:
|
|
115
|
+
|
|
116
|
+
1. **Never test mock behavior.** If your assertion verifies what a mock returns, you are testing your test setup, not your code. Assert against real output.
|
|
117
|
+
2. **Never add test-only methods to production code.** No `_testReset()`, no `setForTesting()`. If you need to observe internal state, the design is wrong — expose behavior, not internals.
|
|
118
|
+
3. **Never mock what you don't understand.** If you can't explain what the real dependency does, you can't write a meaningful mock. Understand first, then decide if a mock is truly needed.
|
|
119
|
+
|
|
120
|
+
Mocks are acceptable only for: external network services, system clocks, and non-deterministic inputs. Everything else should use real code.
|
|
121
|
+
|
|
122
|
+
## Why Order Matters
|
|
123
|
+
|
|
124
|
+
Tests written after code pass immediately. Passing immediately proves nothing:
|
|
125
|
+
- Might test the wrong thing
|
|
126
|
+
- Might test implementation, not behavior
|
|
127
|
+
- Might miss edge cases you forgot
|
|
128
|
+
- You never saw it catch the bug
|
|
129
|
+
|
|
130
|
+
Test-first forces you to see the test fail, proving it actually tests something.
|
|
131
|
+
|
|
132
|
+
"Tests after achieve the same goals" is false. Tests-after answer "what does this code do?" Tests-first answer "what should this code do?" Tests-after are biased by your implementation.
|
|
133
|
+
|
|
134
|
+
## Red Flags — STOP and Start Over
|
|
135
|
+
|
|
136
|
+
If any of these happen, delete the code and restart with TDD:
|
|
137
|
+
|
|
138
|
+
- Code written before test
|
|
139
|
+
- Test passes immediately on first run
|
|
140
|
+
- Can't explain why the test failed
|
|
141
|
+
- Tests added "later"
|
|
142
|
+
- "Just this once" rationalization
|
|
143
|
+
- "Keep as reference" or "adapt existing code"
|
|
144
|
+
- "I already manually tested it"
|
|
145
|
+
- "This is different because..."
|
|
146
|
+
|
|
147
|
+
## Bug Fix Flow
|
|
148
|
+
|
|
149
|
+
Bug found? TDD applies:
|
|
150
|
+
|
|
151
|
+
1. **RED:** Write a test that reproduces the bug. Watch it fail.
|
|
152
|
+
2. **GREEN:** Fix the bug with minimum code. Watch the test pass.
|
|
153
|
+
3. **REFACTOR:** Clean up if needed. Tests stay green.
|
|
154
|
+
|
|
155
|
+
The test proves the fix works and prevents regression. Never fix bugs without a test.
|
|
156
|
+
|
|
157
|
+
## When Stuck
|
|
158
|
+
|
|
159
|
+
| Problem | Solution |
|
|
160
|
+
|---------|----------|
|
|
161
|
+
| Don't know how to test | Write the API you wish existed. Write the assertion first. |
|
|
162
|
+
| Test too complicated | Design too complicated. Simplify the interface. |
|
|
163
|
+
| Must mock everything | Code too coupled. Use dependency injection. |
|
|
164
|
+
| Test setup huge | Extract helpers. Still complex? Simplify design. |
|
|
165
|
+
|
|
166
|
+
## Verification Checklist
|
|
167
|
+
|
|
168
|
+
Before reporting task completion:
|
|
169
|
+
|
|
170
|
+
- [ ] Every new function/method has a test
|
|
171
|
+
- [ ] Watched each test fail before implementing
|
|
172
|
+
- [ ] Each test failed for the expected reason (feature missing, not typo)
|
|
173
|
+
- [ ] Wrote minimal code to pass each test
|
|
174
|
+
- [ ] All tests pass
|
|
175
|
+
- [ ] Test output is clean (no errors, no warnings)
|
|
176
|
+
- [ ] Tests use real code (mocks only when unavoidable)
|
|
177
|
+
- [ ] Edge cases and error paths covered
|
|
178
|
+
|
|
179
|
+
Can't check all boxes? You skipped TDD. Start over.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Adapted for Supermind executor injection. -->
|
|
2
|
+
---
|
|
3
|
+
name: using-git-worktrees
|
|
4
|
+
description: Automated worktree creation with safety checks — used by executors for isolated development
|
|
5
|
+
injects_into: [write-feature, fix-bug, refactor]
|
|
6
|
+
forked_from: obra/superpowers (MIT)
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Using Git Worktrees
|
|
10
|
+
|
|
11
|
+
## When to Use a Worktree
|
|
12
|
+
|
|
13
|
+
- Task touches more than 2-3 files
|
|
14
|
+
- Task involves logic changes (not just config/docs)
|
|
15
|
+
- Task follows an implementation plan with multiple steps
|
|
16
|
+
- Multiple executors running in parallel (each gets its own worktree)
|
|
17
|
+
- When in doubt, use a worktree — the cost is low, the safety is high
|
|
18
|
+
|
|
19
|
+
## Setup Process
|
|
20
|
+
|
|
21
|
+
### 1. Choose Directory
|
|
22
|
+
|
|
23
|
+
Use `.worktrees/` in the project root.
|
|
24
|
+
|
|
25
|
+
- Create `.worktrees/` if it doesn't exist
|
|
26
|
+
- Branch name: `worktree/<task-description-slug>` (e.g., `worktree/add-auth-middleware`)
|
|
27
|
+
|
|
28
|
+
### 2. Verify .gitignore Safety
|
|
29
|
+
|
|
30
|
+
**MUST happen before creating the worktree.**
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Check if .worktrees/ is already ignored
|
|
34
|
+
git check-ignore -q .worktrees 2>/dev/null
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**If NOT ignored:**
|
|
38
|
+
1. Add `.worktrees/` to `.gitignore`
|
|
39
|
+
2. Commit: `chore: add .worktrees/ to .gitignore`
|
|
40
|
+
3. Then proceed with worktree creation
|
|
41
|
+
|
|
42
|
+
**Why critical:** Prevents accidentally committing worktree contents to the repository.
|
|
43
|
+
|
|
44
|
+
### 3. Create Worktree
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git worktree add .worktrees/<name> -b worktree/<name>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- Always branch from `HEAD` (current local branch), never from a remote ref
|
|
51
|
+
- The worktree branch tracks the local branch it was created from
|
|
52
|
+
|
|
53
|
+
### 4. Install Dependencies (Auto-Detect)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Node.js — detect lockfile to choose package manager
|
|
57
|
+
if [ -f package-lock.json ]; then npm install
|
|
58
|
+
elif [ -f yarn.lock ]; then yarn install
|
|
59
|
+
elif [ -f pnpm-lock.yaml ]; then pnpm install
|
|
60
|
+
elif [ -f package.json ]; then npm install
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Rust
|
|
64
|
+
if [ -f Cargo.toml ]; then cargo build; fi
|
|
65
|
+
|
|
66
|
+
# Python
|
|
67
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
68
|
+
if [ -f pyproject.toml ]; then pip install -e .; fi
|
|
69
|
+
|
|
70
|
+
# Go
|
|
71
|
+
if [ -f go.mod ]; then go mod download; fi
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 5. Baseline Test Verification
|
|
75
|
+
|
|
76
|
+
Run the project's test suite in the worktree:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Use the project-appropriate command
|
|
80
|
+
npm test # Node.js
|
|
81
|
+
cargo test # Rust
|
|
82
|
+
pytest # Python
|
|
83
|
+
go test ./... # Go
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- Report any pre-existing failures BEFORE starting work
|
|
87
|
+
- This establishes the baseline — the executor is not blamed for pre-existing failures
|
|
88
|
+
- If tests fail: report failures and note them as pre-existing, then proceed
|
|
89
|
+
|
|
90
|
+
## Working in the Worktree
|
|
91
|
+
|
|
92
|
+
- All file operations happen inside the worktree directory
|
|
93
|
+
- Commit frequently — small, atomic commits
|
|
94
|
+
- Stay on the worktree branch
|
|
95
|
+
- Do not modify files outside the worktree directory
|
|
96
|
+
|
|
97
|
+
## Completion
|
|
98
|
+
|
|
99
|
+
When the executor finishes its task:
|
|
100
|
+
|
|
101
|
+
1. Commit final state in the worktree
|
|
102
|
+
2. Report back to the orchestrator:
|
|
103
|
+
- Branch name
|
|
104
|
+
- Commit hash
|
|
105
|
+
- Files changed
|
|
106
|
+
- Test results
|
|
107
|
+
3. The orchestrator handles merge — **not the executor**
|
|
108
|
+
|
|
109
|
+
## Cleanup
|
|
110
|
+
|
|
111
|
+
Cleanup is handled by the orchestrator or the finishing skill, never by the executor:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git worktree remove .worktrees/<name>
|
|
115
|
+
git branch -d worktree/<name>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Quick Reference
|
|
119
|
+
|
|
120
|
+
| Situation | Action |
|
|
121
|
+
|-----------|--------|
|
|
122
|
+
| `.worktrees/` exists | Use it (verify ignored) |
|
|
123
|
+
| `.worktrees/` doesn't exist | Create it, verify ignored |
|
|
124
|
+
| Directory not in .gitignore | Add to .gitignore + commit first |
|
|
125
|
+
| Tests fail during baseline | Report as pre-existing, proceed |
|
|
126
|
+
| No package.json/Cargo.toml/etc. | Skip dependency install |
|
|
127
|
+
| Task touches <= 2 files, no logic changes | Skip worktree, work in place |
|
|
128
|
+
| Multiple executors in parallel | Each gets its own worktree |
|
|
129
|
+
|
|
130
|
+
## Common Mistakes
|
|
131
|
+
|
|
132
|
+
| Mistake | Problem | Fix |
|
|
133
|
+
|---------|---------|-----|
|
|
134
|
+
| Skipping .gitignore check | Worktree contents get tracked, pollute git status | Always `git check-ignore` before creating |
|
|
135
|
+
| Branching from remote ref | Creates tracking mismatches | Always branch from `HEAD` |
|
|
136
|
+
| Executor merging its own branch | Conflicts with orchestrator's merge strategy | Report completion; orchestrator merges |
|
|
137
|
+
| Skipping baseline tests | Can't distinguish new bugs from pre-existing | Always run tests before starting work |
|
|
138
|
+
| Hardcoding setup commands | Breaks on projects using different tools | Auto-detect from lockfiles and project files |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!-- Forked from obra/superpowers (MIT license) by Jesse Vincent and Prime Radiant. Adapted for Supermind executor injection. -->
|
|
2
|
+
---
|
|
3
|
+
name: verification-before-completion
|
|
4
|
+
description: Requires command output evidence before task completion — injected into all executors
|
|
5
|
+
injects_into: [all]
|
|
6
|
+
forked_from: obra/superpowers (MIT)
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Verification Before Completion
|
|
10
|
+
|
|
11
|
+
You MUST run verification commands and show their output before reporting completion. No exceptions.
|
|
12
|
+
|
|
13
|
+
## What Counts as Verification
|
|
14
|
+
|
|
15
|
+
| Claim | Required Evidence |
|
|
16
|
+
|-------|------------------|
|
|
17
|
+
| Tests pass | Show test runner output |
|
|
18
|
+
| Code compiles/lints | Show compiler or linter output |
|
|
19
|
+
| Feature works | Show command output or test demonstrating the behavior |
|
|
20
|
+
| Bug is fixed | Show the previously-failing test now passing |
|
|
21
|
+
|
|
22
|
+
## What Does NOT Count
|
|
23
|
+
|
|
24
|
+
- "I believe this works" — not evidence
|
|
25
|
+
- "The code looks correct" — not evidence
|
|
26
|
+
- "This should work because..." — not evidence
|
|
27
|
+
- Reading the code and asserting correctness — not evidence
|
|
28
|
+
|
|
29
|
+
Evidence means **command output**. If you didn't run it, you didn't verify it.
|
|
30
|
+
|
|
31
|
+
## Completion Report
|
|
32
|
+
|
|
33
|
+
Every executor must end with this report. Fill every section — empty sections mean incomplete work.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
## Completion Report
|
|
37
|
+
|
|
38
|
+
### Files Changed
|
|
39
|
+
- list of files with what changed
|
|
40
|
+
|
|
41
|
+
### Tests
|
|
42
|
+
- tests added or modified
|
|
43
|
+
- test output (pasted, not summarized)
|
|
44
|
+
|
|
45
|
+
### Verification
|
|
46
|
+
- commands run and their output
|
|
47
|
+
|
|
48
|
+
### Issues
|
|
49
|
+
- any concerns or follow-ups (or "None")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## The Rule
|
|
53
|
+
|
|
54
|
+
No completion report = no completion. A report without pasted command output = no completion. An executor that skips this fails the completion contract.
|