claude-raid 0.1.6 → 0.2.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.
Files changed (42) hide show
  1. package/bin/cli.js +13 -1
  2. package/package.json +1 -1
  3. package/src/descriptions.js +26 -25
  4. package/src/init.js +6 -10
  5. package/src/merge-settings.js +1 -22
  6. package/src/remove.js +18 -16
  7. package/src/ui.js +1 -1
  8. package/src/update.js +28 -13
  9. package/template/.claude/agents/archer.md +14 -109
  10. package/template/.claude/agents/rogue.md +15 -110
  11. package/template/.claude/agents/warrior.md +12 -108
  12. package/template/.claude/agents/wizard.md +15 -235
  13. package/template/.claude/dungeon-master-rules.md +210 -0
  14. package/template/.claude/hooks/raid-lib.sh +29 -2
  15. package/template/.claude/hooks/raid-pre-compact.sh +12 -1
  16. package/template/.claude/hooks/raid-session-end.sh +23 -13
  17. package/template/.claude/hooks/raid-session-start.sh +28 -16
  18. package/template/.claude/hooks/validate-commit.sh +15 -74
  19. package/template/.claude/hooks/validate-dungeon.sh +47 -13
  20. package/template/.claude/hooks/validate-file-naming.sh +6 -2
  21. package/template/.claude/hooks/validate-no-placeholders.sh +3 -3
  22. package/template/.claude/hooks/validate-write-gate.sh +47 -36
  23. package/template/.claude/party-rules.md +202 -0
  24. package/template/.claude/skills/raid-browser-chrome/SKILL.md +1 -1
  25. package/template/.claude/skills/{raid-design → raid-canonical-design}/SKILL.md +60 -14
  26. package/template/.claude/skills/{raid-implementation → raid-canonical-implementation}/SKILL.md +48 -11
  27. package/template/.claude/skills/{raid-implementation-plan → raid-canonical-implementation-plan}/SKILL.md +57 -15
  28. package/template/.claude/skills/raid-canonical-prd/SKILL.md +133 -0
  29. package/template/.claude/skills/raid-canonical-protocol/SKILL.md +211 -0
  30. package/template/.claude/skills/{raid-review → raid-canonical-review}/SKILL.md +86 -15
  31. package/template/.claude/skills/raid-debugging/SKILL.md +30 -5
  32. package/template/.claude/skills/raid-init/SKILL.md +130 -0
  33. package/template/.claude/skills/raid-tdd/SKILL.md +1 -1
  34. package/template/.claude/skills/raid-wrap-up/SKILL.md +184 -0
  35. package/template/.claude/hooks/raid-stop.sh +0 -68
  36. package/template/.claude/hooks/raid-task-completed.sh +0 -37
  37. package/template/.claude/hooks/raid-teammate-idle.sh +0 -28
  38. package/template/.claude/raid-rules.md +0 -30
  39. package/template/.claude/skills/raid-browser-playwright/SKILL.md +0 -163
  40. package/template/.claude/skills/raid-finishing/SKILL.md +0 -131
  41. package/template/.claude/skills/raid-git-worktrees/SKILL.md +0 -96
  42. package/template/.claude/skills/raid-protocol/SKILL.md +0 -335
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Raid lifecycle hook: TeammateIdle
3
- # Nudges idle agents to pick up unclaimed tasks.
4
- set -euo pipefail
5
-
6
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
- source "$SCRIPT_DIR/raid-lib.sh"
8
-
9
- if [ "$RAID_ACTIVE" != "true" ]; then
10
- exit 0
11
- fi
12
-
13
- if [ "$RAID_LIFECYCLE_NUDGE" != "true" ]; then
14
- exit 0
15
- fi
16
-
17
- raid_read_lifecycle_input
18
- TEAMMATE=$(echo "$RAID_HOOK_INPUT" | jq -r '.teammate_name // "Agent"')
19
-
20
- cat <<ENDJSON
21
- {
22
- "hookSpecificOutput": {
23
- "hookEventName": "TeammateIdle",
24
- "additionalContext": "$TEAMMATE: Unclaimed tasks remain on the board. Pick up the next available task and report your plan before starting."
25
- }
26
- }
27
- ENDJSON
28
- exit 0
@@ -1,30 +0,0 @@
1
- # Raid Team Rules
2
-
3
- Three pillars. Non-negotiable. Every agent, every phase, every interaction.
4
-
5
- ## Pillar 1: Intellectual Honesty
6
-
7
- - Every claim has evidence you gathered yourself. No exceptions.
8
- - If you haven't read the code or run the command this turn, you don't know what it says.
9
- - If you don't know, say so. Guessing is worse than silence.
10
- - Never respond to a finding you haven't independently verified. Read the code. Run the test. Form your own conclusion first. Then respond — with your evidence, not theirs.
11
- - "Reports lie" — including your own from prior turns. Verify fresh.
12
- - Never fabricate evidence, certainty, or findings.
13
-
14
- ## Pillar 2: Zero Ego Collaboration
15
-
16
- - When proven wrong, concede instantly. No face to save — only the output matters.
17
- - Defend with evidence, never with authority or repetition.
18
- - A teammate catching your mistake is a gift. Absorb the lesson, carry it forward.
19
- - Share findings immediately. Hoarding information serves ego, not quality.
20
- - Build on each other's work genuinely. The best findings come from combining perspectives — Warrior's stress test sharpened by Archer's pattern analysis weaponized by Rogue's attack scenario.
21
-
22
- ## Pillar 3: Discipline and Efficiency
23
-
24
- - Maximum effort on every task. No coasting, no rubber-stamping, no going through motions.
25
- - Every interaction carries work forward. If you're not adding new information or evidence, stop talking.
26
- - The Dungeon is a scoreboard, not a chat log. Pin only what survived challenge from at least two agents.
27
- - Agents talk directly to each other. The Wizard is not a relay.
28
- - Escalate to the Wizard only after you've tried to resolve it by reading code and discussing with teammates.
29
- - All agents participate actively at every step. Silence when you have nothing to add is fine — silence when you haven't investigated is laziness.
30
- - This team uses agent teams only. Never delegate to subagents.
@@ -1,163 +0,0 @@
1
- ---
2
- name: raid-browser-playwright
3
- description: "Playwright MCP automated browser test authoring. Extends TDD RED-GREEN-REFACTOR with .spec.ts files. Console + network assertions mandatory. Invoked from raid-tdd and raid-implementation during Phase 3."
4
- ---
5
-
6
- # Raid Browser Playwright — Automated Test Authoring
7
-
8
- Write browser tests as part of TDD. Use Playwright MCP to explore, then encode verified interactions into durable `.spec.ts` files.
9
-
10
- <HARD-GATE>
11
- Do NOT write browser tests without invoking `raid-browser` pre-flight first. Do NOT skip console/network assertions. Do NOT write tests without watching them fail first (TDD RED step). No subagents.
12
- </HARD-GATE>
13
-
14
- ## When to Write Browser Tests vs Unit Tests
15
-
16
- Not every task needs a browser test. The implementer decides and states reasoning. Challengers attack this decision.
17
-
18
- | Write Browser Test | Write Unit Test Only |
19
- |---|---|
20
- | New user-facing flow (signup, checkout) | Pure utility function |
21
- | UI interaction (drag-drop, modal, form) | API endpoint logic |
22
- | Client-side routing / navigation | Data transformation |
23
- | Visual state changes (loading, error, empty) | Business rule validation |
24
- | Integration between frontend and API | Database queries |
25
-
26
- **If unsure:** Write the browser test. It's easier to remove an unnecessary test than to find a bug in production.
27
-
28
- ## Browser TDD Cycle
29
-
30
- ### RED (browser)
31
-
32
- 1. Write Playwright test file: `tests/e2e/<feature>.spec.ts`
33
- 2. Test describes **user behavior**, not implementation:
34
- - Navigate to page
35
- - Interact (click, type, select, drag)
36
- - Assert visible outcome (text appears, redirect happens, element state changes)
37
- 3. Include mandatory infrastructure assertions (see below)
38
- 4. Run test → **MUST fail**
39
- 5. Verify it fails for the **RIGHT reason** (page/element missing — not test syntax error)
40
-
41
- ### GREEN (browser)
42
-
43
- 1. Implement the feature code
44
- 2. Run Playwright test → **MUST pass**
45
- 3. Run full test suite (unit + browser) → all green
46
-
47
- ### REFACTOR
48
-
49
- 1. Clean up implementation and test code
50
- 2. Re-run all tests → still green
51
-
52
- ## Using Playwright MCP During Test Authoring
53
-
54
- While writing the test, the implementer explores interactively to understand the current state and find correct selectors:
55
-
56
- | Tool | Purpose |
57
- |---|---|
58
- | `browser_navigate` | Load the page, see what's there |
59
- | `browser_snapshot` | Get DOM state, find correct selectors |
60
- | `browser_click` / `browser_fill_form` | Test interactions manually first |
61
- | `browser_console_messages` | Check for errors during interaction |
62
- | `browser_network_requests` | Verify API calls, check payloads |
63
- | `browser_take_screenshot` | Capture visual state for evidence |
64
-
65
- **The MCP tools are the exploratory scratchpad. The `.spec.ts` file is the durable artifact.**
66
-
67
- Encode what you verified interactively into the test file. The test must run headlessly in CI without MCP tools.
68
-
69
- ## Mandatory Assertions
70
-
71
- Every browser test file MUST include at least:
72
-
73
- ### 1. Console-Clean Assertion
74
-
75
- ```typescript
76
- test('no console errors during <feature> flow', async ({ page }) => {
77
- const errors: string[] = [];
78
- page.on('console', msg => {
79
- if (msg.type() === 'error') errors.push(msg.text());
80
- });
81
-
82
- // ... perform the feature flow ...
83
-
84
- expect(errors).toEqual([]);
85
- });
86
- ```
87
-
88
- ### 2. Network-Health Assertion
89
-
90
- ```typescript
91
- test('API calls succeed during <feature> flow', async ({ page }) => {
92
- const failures: string[] = [];
93
- page.on('response', response => {
94
- if (response.status() >= 400) {
95
- failures.push(`${response.status()} ${response.url()}`);
96
- }
97
- });
98
-
99
- // ... perform the feature flow ...
100
-
101
- expect(failures).toEqual([]);
102
- });
103
- ```
104
-
105
- **Missing either of these is an automatic challenge from any reviewer.**
106
-
107
- ## Selector Best Practices
108
-
109
- | Prefer | Avoid | Why |
110
- |---|---|---|
111
- | `data-testid="submit-btn"` | `button.btn-primary` | CSS classes change for styling reasons |
112
- | `getByRole('button', { name: 'Submit' })` | `#submit` | Accessible and resilient |
113
- | `getByText('Welcome back')` | `.header > div:nth-child(2)` | Structural selectors break on layout changes |
114
-
115
- ## Challenger Attacks on Browser Tests (Phase 3)
116
-
117
- **Warrior attacks:**
118
- - "You only tested the happy path — what happens with network failure?"
119
- - "No test for rapid double-submit on the form"
120
- - "What about a 10,000-character input in the name field?"
121
- - "You didn't test with JavaScript disabled / slow network"
122
-
123
- **Archer attacks:**
124
- - "Your selector `button[type=submit]` is fragile — use `data-testid`"
125
- - "No assertion on console errors — the feature works but throws warnings"
126
- - "Missing network assertion — you don't verify the POST payload"
127
- - "Tested at desktop width only — what about mobile viewport?"
128
-
129
- **Rogue attacks:**
130
- - "What happens if the user is already logged in and hits /register?"
131
- - "No test for XSS in the input fields"
132
- - "What if the API returns 200 but with an error body?"
133
- - "Race condition: what if the user navigates away during submission?"
134
-
135
- **Each challenger BOOTS their own app instance** (on their own port via `raid-browser`), runs the tests independently, and verifies they pass without flakiness.
136
-
137
- ## Running Browser Tests
138
-
139
- Use the test command from `.claude/raid.json`:
140
- - Read `project.execCommand` (e.g., `pnpm dlx`, `npx`, `bunx`)
141
- - Run: `{execCommand} playwright test`
142
- - For a specific test: `{execCommand} playwright test tests/e2e/<feature>.spec.ts`
143
-
144
- ## Test File Organization
145
-
146
- ```
147
- tests/
148
- e2e/
149
- <feature-name>.spec.ts # One file per feature/flow
150
- auth/
151
- login.spec.ts # Group related flows in directories
152
- registration.spec.ts
153
- ```
154
-
155
- ## Red Flags
156
-
157
- | Thought | Reality |
158
- |---------|---------|
159
- | "The feature is too simple for a browser test" | Simple features break in the browser. If it's user-facing, test it. |
160
- | "I'll add console assertions later" | Later never comes. Add them now. |
161
- | "The unit tests cover this" | Unit tests don't catch hydration mismatches, missing CSS, broken routing. |
162
- | "I tested it manually with MCP tools" | Manual verification isn't reproducible. Write the `.spec.ts`. |
163
- | "Selectors are fine, they work" | They work today. Will they work after a CSS refactor? Use `data-testid`. |
@@ -1,131 +0,0 @@
1
- ---
2
- name: raid-finishing
3
- description: "Use after Phase 4 review is approved. Agents debate completeness directly, fighting over what's truly done. Wizard closes with verdict, presents merge options, cleans up Dungeon files and session."
4
- ---
5
-
6
- # Raid Finishing — Complete the Development Branch
7
-
8
- Agents debate completeness directly. Verify. Present options. Execute. Clean up.
9
-
10
- **Violating the letter of this process is violating its spirit.**
11
-
12
- ## Mode Behavior
13
-
14
- - **Full Raid**: All 3 agents debate completeness directly. Full verification.
15
- - **Skirmish**: 1 agent + Wizard verify completeness.
16
- - **Scout**: Wizard verifies alone.
17
-
18
- ## Process Flow
19
-
20
- ```dot
21
- digraph finishing {
22
- "Wizard opens final debate" -> "Agents argue directly: truly done?";
23
- "Agents argue directly: truly done?" -> "Any agent says incomplete?" [shape=diamond];
24
- "Any agent says incomplete?" -> "Agent presents evidence, others attack" [label="yes"];
25
- "Agent presents evidence, others attack" -> "Wizard rules" [shape=diamond];
26
- "Wizard rules" -> "Return to Phase 3 or 4" [label="incomplete"];
27
- "Wizard rules" -> "Verify all tests pass (fresh run)" [label="complete"];
28
- "Any agent says incomplete?" -> "Verify all tests pass (fresh run)" [label="no, all agree"];
29
- "Verify all tests pass (fresh run)" -> "Tests pass?" [shape=diamond];
30
- "Tests pass?" -> "Fix first. Do not present options." [label="no"];
31
- "Fix first. Do not present options." -> "Verify all tests pass (fresh run)";
32
- "Tests pass?" -> "Present 4 options" [label="yes"];
33
- "Present 4 options" -> "Execute choice";
34
- "Execute choice" -> "Clean up: Dungeon files + worktree + raid-session";
35
- "Clean up: Dungeon files + worktree + raid-session" -> "Done" [shape=doublecircle];
36
- }
37
- ```
38
-
39
- ## Wizard Checklist
40
-
41
- 1. **Open final debate** — dispatch agents to argue completeness directly
42
- 2. **Observe the fight** — agents challenge each other on what's done vs. missing
43
- 3. **Wizard rules on completeness** — only proceed if ruling is "complete"
44
- 4. **Verify all tests pass** — full suite, fresh run
45
- 5. **Present options** — exactly 4 choices
46
- 6. **Execute choice** — merge, PR, keep, or discard
47
- 7. **Clean up** — remove all Dungeon files (`.claude/raid-dungeon.md`, `.claude/raid-dungeon-phase-*.md`), worktree if applicable, remove `.claude/raid-session`
48
-
49
- ## Step 1: The Completeness Debate
50
-
51
- **DISPATCH:**
52
-
53
- > **@Warrior**: Review the implementation against the plan. Is every task completed? Every acceptance criterion met? Every test passing? Is anything half-done? Fight @Archer and @Rogue directly on their assessments.
54
- >
55
- > **@Archer**: Review the implementation against the design doc. Is every requirement covered? Naming patterns consistent throughout? File structure clean? Did we introduce inconsistencies with the rest of the codebase? Fight @Warrior and @Rogue directly.
56
- >
57
- > **@Rogue**: Review from the adversarial angle. What did we miss? What edge case is untested? What requirement was subtly misinterpreted? What will break in the first week of production? Fight @Warrior and @Archer directly.
58
- >
59
- > **All**: Reference ALL archived Dungeons (Phase 1-4) for full context. Debate directly. If you believe the work is incomplete, present evidence. Others challenge your claim. Pin conclusions to conversation (no Dungeon for finishing — this is the final debate).
60
-
61
- **The agents must fight over this.** If any agent believes the work is incomplete, they present evidence. The other two challenge that claim directly.
62
-
63
- RULING: [Complete — proceed | Incomplete — return to Phase 3/4 with specific issues]
64
-
65
- ## Step 2: Final Verification
66
-
67
- ```
68
- BEFORE presenting options:
69
- 1. IDENTIFY: test command from .claude/raid.json
70
- 2. RUN: Execute the FULL test suite (fresh, complete)
71
- 3. READ: Full output, check exit code, count failures
72
- 4. VERIFY: Zero failures?
73
- If NO → STOP. Fix first. Do not present options.
74
- If YES → Proceed with evidence.
75
- ```
76
-
77
- ### Browser Verification (when `browser.enabled` in raid.json)
78
-
79
- Additional final checks:
80
- - Full Playwright test suite passes headlessly
81
- - Verify no leaked processes from prior browser sessions
82
- - Verify all ports in `browser.portRange` are free (`lsof -i :PORT`)
83
- - Agents debate: "Are browser tests sufficient for this feature's coverage?"
84
-
85
- ## Step 3: Present Options
86
-
87
- ```
88
- RULING: Implementation complete and verified.
89
-
90
- Tests: [N] passing, 0 failures (evidence: [command output])
91
-
92
- Options:
93
- 1. Merge back to [base-branch] locally
94
- 2. Push and create a Pull Request
95
- 3. Keep the branch as-is (handle later)
96
- 4. Discard this work
97
-
98
- Which option?
99
- ```
100
-
101
- ## Step 4: Execute
102
-
103
- | Option | Actions |
104
- |--------|---------|
105
- | **1. Merge** | Checkout base -> pull -> merge -> run tests on merged result -> delete branch -> clean up |
106
- | **2. PR** | Push with -u -> create PR via gh -> clean up |
107
- | **3. Keep** | Report branch location. Done. |
108
- | **4. Discard** | Require typed "discard" confirmation -> delete branch (force) -> clean up |
109
-
110
- ## Step 5: Clean Up
111
-
112
- Remove ALL Dungeon artifacts:
113
- - `.claude/raid-dungeon.md` (if exists)
114
- - `.claude/raid-dungeon-phase-1.md`
115
- - `.claude/raid-dungeon-phase-2.md`
116
- - `.claude/raid-dungeon-phase-3.md`
117
- - `.claude/raid-dungeon-phase-4.md`
118
- - `.claude/raid-session`
119
- - Worktree (if applicable)
120
-
121
- ## Red Flags
122
-
123
- | Thought | Reality |
124
- |---------|---------|
125
- | "Tests passed earlier, no need to re-run" | Verification Iron Law. Fresh run or no claim. |
126
- | "The completeness debate is a formality" | It's where missed requirements surface. Take it seriously. |
127
- | "Let me report to the Wizard whether it's complete" | Debate with the other agents directly. |
128
- | "Merge without testing the merged result" | Merges introduce conflicts. Always test after merge. |
129
- | "Leave the Dungeon files, they might be useful" | Clean up. Session artifacts don't belong in the repo. |
130
-
131
- **Terminal state:** Choice executed. All Dungeon files removed. `.claude/raid-session` removed. Session over.
@@ -1,96 +0,0 @@
1
- ---
2
- name: raid-git-worktrees
3
- description: "Use when starting Raid implementation that needs isolation. Creates isolated git worktree with safety verification and clean test baseline."
4
- ---
5
-
6
- # Raid Git Worktrees — Isolated Workspaces
7
-
8
- Systematic directory selection + safety verification = reliable isolation.
9
-
10
- ## Process Flow
11
-
12
- ```dot
13
- digraph worktree {
14
- "Check worktree path from raid.json" -> "Directory exists?";
15
- "Directory exists?" -> "Verify gitignored" [label="yes"];
16
- "Directory exists?" -> "Create directory" [label="no"];
17
- "Create directory" -> "Add to .gitignore + commit";
18
- "Add to .gitignore + commit" -> "Verify gitignored";
19
- "Verify gitignored" -> "Ignored?" [shape=diamond];
20
- "Ignored?" -> "Create worktree" [label="yes"];
21
- "Ignored?" -> "Add to .gitignore + commit" [label="no"];
22
- "Create worktree" -> "Install dependencies";
23
- "Install dependencies" -> "Run baseline tests";
24
- "Run baseline tests" -> "Tests pass?" [shape=diamond];
25
- "Tests pass?" -> "Report ready" [label="yes", shape=doublecircle];
26
- "Tests pass?" -> "Report failures, ask user" [label="no"];
27
- }
28
- ```
29
-
30
- ## Directory Selection Priority
31
-
32
- 1. Check worktrees path from `.claude/raid.json` (default: `.worktrees/`) -> use it (verify ignored)
33
- 2. Check CLAUDE.md for preference -> use it
34
- 3. Ask the user
35
-
36
- ## Safety Verification
37
-
38
- ```bash
39
- # MUST verify directory is gitignored before creating worktree
40
- git check-ignore -q [worktrees-path] 2>/dev/null
41
- ```
42
-
43
- If NOT ignored: add to `.gitignore`, commit immediately, then proceed. Fix broken things immediately — don't leave unignored worktree directories.
44
-
45
- ## Creation
46
-
47
- ```bash
48
- WORKTREE_PATH=$(jq -r '.paths.worktrees // ".worktrees"' .claude/raid.json)
49
- git worktree add "$WORKTREE_PATH/$BRANCH_NAME" -b "$BRANCH_NAME"
50
- cd "$WORKTREE_PATH/$BRANCH_NAME"
51
-
52
- # Auto-detect and install deps
53
- [ -f package.json ] && npm install
54
- [ -f Cargo.toml ] && cargo build
55
- [ -f requirements.txt ] && pip install -r requirements.txt
56
- [ -f pyproject.toml ] && poetry install
57
- [ -f go.mod ] && go mod download
58
-
59
- # Verify clean baseline
60
- TEST_CMD=$(jq -r '.project.testCommand // empty' .claude/raid.json)
61
- [ -n "$TEST_CMD" ] && eval "$TEST_CMD"
62
- ```
63
-
64
- ## Report
65
-
66
- ```
67
- Worktree ready at [path]
68
- Branch: [branch-name]
69
- Tests: [N] passing, 0 failures
70
- Ready for Raid implementation
71
-
72
- Note: Dungeon files (.claude/raid-dungeon*.md) are session artifacts
73
- and will be cleaned up by raid-finishing. No gitignore needed.
74
- ```
75
-
76
- ## Quick Reference
77
-
78
- | Situation | Action |
79
- |-----------|--------|
80
- | `.worktrees/` exists | Use it (verify ignored) |
81
- | `worktrees/` exists | Use it (verify ignored) |
82
- | Both exist | Use `.worktrees/` |
83
- | Neither exists | Check raid.json -> CLAUDE.md -> ask user |
84
- | Directory not ignored | Add to .gitignore + commit first |
85
- | Tests fail during baseline | Report failures + ask user before proceeding |
86
- | No test command configured | Warn, proceed without baseline |
87
-
88
- ## Red Flags
89
-
90
- | Thought | Reality |
91
- |---------|---------|
92
- | "I'll add it to .gitignore later" | Fix it now. Worktree dirs must never be committed. |
93
- | "Baseline tests don't matter" | Failing baseline = you'll waste time debugging pre-existing failures. |
94
- | "Skip dependency install, it'll be fine" | Missing deps = mysterious failures during implementation. |
95
-
96
- **Never** create a worktree without verifying it's gitignored. **Never** skip baseline test verification. **Never** proceed with failing baseline tests without asking.