azclaude-copilot 0.4.33 → 0.4.36

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.
@@ -8,8 +8,8 @@
8
8
  "plugins": [
9
9
  {
10
10
  "name": "azclaude",
11
- "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 34 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
- "version": "0.4.33",
11
+ "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 37 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
+ "version": "0.4.36",
13
13
  "source": {
14
14
  "source": "github",
15
15
  "repo": "haytamAroui/AZ-CLAUDE-COPILOT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "azclaude",
3
- "version": "0.4.33",
4
- "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 34 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
3
+ "version": "0.4.36",
4
+ "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 37 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
5
5
  "author": {
6
6
  "name": "haytamAroui",
7
7
  "url": "https://github.com/haytamAroui"
package/README.md CHANGED
@@ -15,7 +15,9 @@
15
15
  <a href="#spec-driven-workflow">Spec-Driven</a> ·
16
16
  <a href="#memory-system">Memory</a> ·
17
17
  <a href="#self-improving-loop">Self-Improving Loop</a> ·
18
- <a href="#all-33-commands">Commands</a> ·
18
+ <a href="#all-36-commands">Commands</a> ·
19
+ <a href="#parallel-execution">Parallel</a> ·
20
+ <a href="#mcp-integration">MCP</a> ·
19
21
  <a href="#autonomous-mode">Autonomous Mode</a> ·
20
22
  <a href="DOCS.md">Full Docs</a>
21
23
  </p>
@@ -61,7 +63,7 @@ AZCLAUDE inverts this. **You start with almost nothing. The environment builds i
61
63
  npx azclaude-copilot@latest # one command. that's it.
62
64
  ```
63
65
 
64
- No agent files to write. No skills to configure. No prompt engineering. `npx azclaude-copilot` installs 34 commands, 4 hooks, memory structure, and a manifest. The rest is generated from your actual codebase as you work. Run the same command again later — it auto-detects whether to skip, install, or upgrade.
66
+ No agent files to write. No skills to configure. No prompt engineering. `npx azclaude-copilot` installs 37 commands, 4 hooks, memory structure, and a manifest. The rest is generated from your actual codebase as you work. Run the same command again later — it auto-detects whether to skip, install, or upgrade.
65
67
 
66
68
  **What the environment looks like across sessions:**
67
69
 
@@ -117,7 +119,7 @@ npx azclaude-copilot@latest
117
119
  ```
118
120
 
119
121
  That's it. One command, no flags. Auto-detects whether this is a fresh install or an upgrade:
120
- - **First time** → full install (34 commands, 4 hooks, 15 agents, 10 skills, memory, reflexes)
122
+ - **First time** → full install (37 commands, 4 hooks, 15 agents, 10 skills, memory, reflexes)
121
123
  - **Already installed, older version** → auto-upgrades everything to latest templates
122
124
  - **Already up to date** → verifies, no overwrites
123
125
 
@@ -129,12 +131,12 @@ npx azclaude-copilot@latest doctor # 32 checks — verify everything is wired
129
131
 
130
132
  ## What You Get
131
133
 
132
- **34 commands** · **9 auto-invoked skills** · **15 agents** · **4 hooks** · **memory across sessions** · **learned reflexes** · **self-evolving environment**
134
+ **37 commands** · **9 auto-invoked skills** · **15 agents** · **4 hooks** · **memory across sessions** · **learned reflexes** · **self-evolving environment**
133
135
 
134
136
  ```
135
137
  .claude/
136
138
  ├── CLAUDE.md ← dispatch table: conventions, stack, routing
137
- ├── commands/ ← 33 slash commands (/add, /fix, /copilot, /spec, /sentinel...)
139
+ ├── commands/ ← 36 slash commands (/add, /fix, /copilot, /parallel, /mcp, /sentinel...)
138
140
  ├── skills/ ← 10 skills (test-first, security, architecture-advisor, frontend-design...)
139
141
  ├── agents/ ← 15 agents (orchestrator, spec-reviewer, constitution-guard...)
140
142
  ├── capabilities/ ← 37 files, lazy-loaded via manifest.md (~380 tokens/task)
@@ -265,6 +267,8 @@ Node.js runner restarts Claude Code sessions in a loop until `COPILOT_COMPLETE`.
265
267
  /snapshot # save WHY you made decisions — auto-injected next session
266
268
  /reflect # find and fix stale/missing rules in CLAUDE.md
267
269
  /reflexes # view learned behavioral patterns with confidence scores
270
+ /parallel M2 M3 # run multiple milestones simultaneously (worktree isolation + auto-merge)
271
+ /mcp # recommend and install MCP servers based on your stack
268
272
  ```
269
273
 
270
274
  ---
@@ -623,7 +627,57 @@ Session 4: /evolve → /analyze → /audit → /ship → COPILOT_COMPLETE
623
627
 
624
628
  ---
625
629
 
626
- ## All 33 Commands
630
+ ## Parallel Execution
631
+
632
+ AZCLAUDE runs multiple Claude Code agents simultaneously on the same codebase — without file corruption or test interference. Each agent works in an isolated git worktree on its own branch. Changes merge sequentially after all agents complete.
633
+
634
+ ```
635
+ M1 (schema) → done
636
+
637
+ ┌────────────┬────────────┬────────────┐
638
+ M2 (auth) M3 (profile) M4 (email) M5 (dashboard) ← all run simultaneously
639
+ ↓ ↓ ↓ ↓
640
+ └────────────┴────────────┴────────────┘
641
+
642
+ M6 (E2E tests)
643
+ ```
644
+
645
+ **Automatic — via `/copilot`:** The orchestrator reads `Wave:` fields in plan.md (written by `/blueprint`), dispatches same-wave milestones with `isolation: "worktree"` in a single message, then merges sequentially.
646
+
647
+ **Manual — via `/parallel`:**
648
+ ```bash
649
+ /parallel M2 M3 M4 M5 # dispatch these milestones simultaneously
650
+ ```
651
+
652
+ **Three-layer safety:** `/blueprint` checks directory isolation + shared-utility imports before writing plan.md (Layer 1 — no agents spawned). `problem-architect` returns exact `Files Written:` and `Parallel Safe:` per milestone after plan.md (Layer 2). The orchestrator checks file overlap again at dispatch time (Layer 3 — final gate, cannot be bypassed).
653
+
654
+ See `docs/parallel-feature.md` for the complete reference.
655
+
656
+ ---
657
+
658
+ ## MCP Integration
659
+
660
+ AZCLAUDE recommends MCP servers based on your stack and wires them into daily-use commands.
661
+
662
+ ```bash
663
+ /mcp # detect stack → recommend universal MCPs → show install commands
664
+ ```
665
+
666
+ **Universal (free, no API key — recommended for every project):**
667
+ - `Context7` — `/add` fetches live library docs before writing any library calls. Prevents stale API usage.
668
+ - `Sequential Thinking` — `/blueprint` and `/copilot` use iterative reasoning for milestone planning.
669
+
670
+ **Stack-specific:**
671
+ - `GitHub MCP` — any GitHub repo: richer `/ship` and PR creation
672
+ - `Playwright MCP` — any web project: E2E testing with qa-engineer
673
+ - `Supabase MCP` — Supabase in deps: schema introspection, migrations
674
+ - `Brave Search` — `/fix` looks up external library errors before guessing root cause
675
+
676
+ `/setup` checks MCP status at the end and nudges if none are configured.
677
+
678
+ ---
679
+
680
+ ## All 37 Commands
627
681
 
628
682
  ### Build and Ship
629
683
 
@@ -653,6 +707,10 @@ Session 4: /evolve → /analyze → /audit → /ship → COPILOT_COMPLETE
653
707
  | `/analyze` | Cross-artifact consistency check. Finds ghost milestones (marked done, files missing), spec vs. code drift, plan vs. reality gaps. Read-only. |
654
708
  | `/tasks` | Build dependency graph from plan.md. Shows parallelizable wave groups and critical path. Tells orchestrator which milestones can run simultaneously. |
655
709
  | `/issues` | Convert plan.md milestones to GitHub Issues. Deduplicates, creates labels, writes issue numbers back to plan.md for traceability. |
710
+ | `/parallel` | Run multiple milestones simultaneously. Worktree isolation per agent. Auto-merges after all complete. Three-layer file collision safety. |
711
+ | `/mcp` | Recommend and install MCP servers based on detected stack. Wires Context7, Sequential Thinking, GitHub, Playwright, Brave Search, Supabase. |
712
+ | `/driven` | Generate `.claude/code-rules.md` — 6-question interview → DO/DO NOT coding contract. Read by every /add and /fix before writing code. |
713
+ | `/verify` | Audit existing code against `code-rules.md`. Reports violations at `file:line`. Auto-fix mode. Falls back to per-stack rule libraries when no contract exists. |
656
714
 
657
715
  ### Think and Improve
658
716
 
@@ -807,11 +865,11 @@ Run `/level-up` at any time to see your current level and build the next one.
807
865
 
808
866
  ## Verified
809
867
 
810
- 1473 tests. Every template, command, capability, agent, hook, and CLI feature verified.
868
+ 1558 tests. Every template, command, capability, agent, hook, and CLI feature verified.
811
869
 
812
870
  ```bash
813
871
  bash tests/test-features.sh
814
- # Results: 1473 passed, 0 failed, 1473 total
872
+ # Results: 1558 passed, 0 failed, 1558 total
815
873
  ```
816
874
 
817
875
  ---
package/bin/cli.js CHANGED
@@ -8,8 +8,8 @@ const { execSync } = require('child_process');
8
8
 
9
9
  const TEMPLATE_DIR = path.join(__dirname, '..', 'templates');
10
10
  const CORE_COMMANDS = ['setup', 'fix', 'add', 'audit', 'test', 'blueprint', 'ship', 'pulse', 'explain', 'snapshot', 'persist'];
11
- const EXTENDED_COMMANDS = ['dream', 'refactor', 'doc', 'loop', 'migrate', 'deps', 'find', 'create', 'reflect', 'hookify', 'sentinel', 'clarify', 'spec', 'analyze', 'constitute', 'tasks', 'issues', 'driven'];
12
- const ADVANCED_COMMANDS = ['evolve', 'debate', 'level-up', 'copilot', 'reflexes'];
11
+ const EXTENDED_COMMANDS = ['dream', 'refactor', 'doc', 'loop', 'migrate', 'deps', 'find', 'create', 'reflect', 'hookify', 'sentinel', 'clarify', 'spec', 'analyze', 'constitute', 'tasks', 'issues', 'driven', 'mcp', 'verify'];
12
+ const ADVANCED_COMMANDS = ['evolve', 'debate', 'level-up', 'copilot', 'reflexes', 'parallel'];
13
13
  const COMMANDS = [...CORE_COMMANDS, ...EXTENDED_COMMANDS, ...ADVANCED_COMMANDS];
14
14
 
15
15
  function ok(msg) { console.log(` ✓ ${msg}`); }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "azclaude-copilot",
3
- "version": "0.4.33",
4
- "description": "AI coding environment — 34 commands, 10 skills, 15 agents, memory, reflexes, evolution. Install: npx azclaude-copilot@latest, then open Claude Code.",
3
+ "version": "0.4.36",
4
+ "description": "AI coding environment — 37 commands, 10 skills, 15 agents, memory, reflexes, evolution. Install: npx azclaude-copilot@latest, then open Claude Code.",
5
5
  "bin": {
6
6
  "azclaude": "bin/cli.js",
7
7
  "azclaude-copilot": "bin/copilot.js"
@@ -40,9 +40,21 @@ Extended (load command file on use):
40
40
  - /tasks: dependency graph + parallel wave groups from plan.md
41
41
  - /issues: convert plan.md milestones to GitHub Issues
42
42
  - Standards: /driven → generates .claude/code-rules.md (coding contract for /add and /fix)
43
+ - /verify → audits existing code against code-rules.md (file:line violations + auto-fix)
44
+ - MCP: /mcp → recommends and installs MCP servers based on your stack
43
45
 
44
46
  Advanced (Level 5+):
45
47
  - /evolve · /debate · /level-up
48
+ - Parallel execution: /parallel → dispatch multiple milestones simultaneously (worktree isolation + auto-merge)
49
+ - /tasks → shows which milestones can run in parallel (wave groups)
50
+
51
+ ## Parallel Agent Rules
52
+ When running parallel agents (/copilot with parallel waves, or /parallel):
53
+ 1. **Own your scope** — only write files in your declared directories. Touch nothing outside.
54
+ 2. **Errors in files you didn't modify** → do not fix them. Report "scope violation: {file}" to orchestrator.
55
+ 3. **Never push from a worktree** — commit locally only. Orchestrator merges after all agents complete.
56
+ 4. **Test in isolation** — run `{test framework} tests/{your-area}/` not the full suite. Cross-cutting failures are expected during parallel execution.
57
+ 5. **Report your branch** — always end completion report with "Branch: parallel/{slug}".
46
58
 
47
59
  Unknown capability → grep manifest.md by description, load match
48
60
 
@@ -53,4 +65,4 @@ When priorities conflict:
53
65
  3. {{PRIORITY_3}}
54
66
 
55
67
  ## Available Commands
56
- /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify · /spec · /clarify · /analyze · /constitute · /tasks · /issues · /driven
68
+ /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify · /spec · /clarify · /analyze · /constitute · /tasks · /issues · /driven · /mcp · /parallel · /verify
@@ -111,8 +111,21 @@ Tests must PASS before reporting done. Show actual output — never summarize.
111
111
 
112
112
  ### Step 5: Commit and Report Back
113
113
 
114
- On success:
114
+ **Detect execution mode:**
115
+ ```bash
116
+ # Am I in a worktree (parallel mode)?
117
+ git worktree list 2>/dev/null | grep -c "$(pwd)" | grep -q "^1$" \
118
+ && echo "WORKTREE_MODE" || echo "MAIN_MODE"
119
+ ```
115
120
 
121
+ **If WORKTREE_MODE** (parallel dispatch with worktree isolation):
122
+ ```bash
123
+ git add {files changed}
124
+ git commit -m "{type}: {what} — {why}"
125
+ # DO NOT push — orchestrator merges all parallel branches after wave completes
126
+ ```
127
+
128
+ **If MAIN_MODE** (sequential dispatch):
116
129
  ```bash
117
130
  git add {files changed}
118
131
  git commit -m "{type}: {what} — {why}"
@@ -124,6 +137,10 @@ Report to orchestrator:
124
137
  ```
125
138
  ## Milestone {N} — {title}: COMPLETE
126
139
 
140
+ ### Execution Mode
141
+ WORKTREE | MAIN
142
+ Branch: {current branch name} ← required for orchestrator merge tracking
143
+
127
144
  ### Files Changed
128
145
  - {file}: {create|modify} — {one-line description}
129
146
 
@@ -138,6 +155,11 @@ PASS — {N} tests passing
138
155
  {anti-pattern description} — or "none"
139
156
  ```
140
157
 
158
+ **Worktree coordination errors** (errors in files outside your declared scope):
159
+ - DO NOT attempt to fix them
160
+ - Report: "Scope violation detected: {file} outside my directories — possible parallel agent interference"
161
+ - Orchestrator handles resolution
162
+
141
163
  ---
142
164
 
143
165
  ## Rules
@@ -35,13 +35,21 @@ If CLAUDE.md unfilled → run `/setup` with intent from copilot-intent.md first.
35
35
 
36
36
  ### Step 2: Select Next Milestone Wave
37
37
 
38
+ **If plan.md has `Wave:` fields** (blueprint wrote them — read directly):
39
+ ```bash
40
+ grep "Wave:" .claude/plan.md
41
+ ```
42
+ Find the lowest wave number where all milestones have `status = pending` and all `Depends:` are `done`.
43
+ This is the next wave to dispatch.
44
+
45
+ **If plan.md has NO `Wave:` fields** (older plan format — compute from scratch):
38
46
  Find milestones where `status = pending` AND all dependencies have `status = done`.
39
47
 
40
- **Parallel candidates:** milestones with independent dependencies.
48
+ **Parallel candidates:** milestones in the same wave with `Parallel: yes` (or computed as independent).
41
49
 
42
- **REQUIRED parallel safety check:** Before dispatching in parallel, get `Files Written`
43
- from problem-architect for each candidate. If any two candidates share a written file
44
- → dispatch sequentially. Silent file corruption otherwise.
50
+ **REQUIRED parallel safety check:** Even if `Parallel: yes`, verify `Files Written` from problem-architect
51
+ for each candidate don't overlap. `Files Written` is more precise than `Files:` — use it.
52
+ If any two candidates share a written file → dispatch sequentially. Silent file corruption otherwise.
45
53
 
46
54
  - All done → SHIP
47
55
  - All remaining blocked → BLOCKER RECOVERY
@@ -93,6 +101,18 @@ If verdict is `APPROVED` or `APPROVED (no constitution found)`: proceed to Step
93
101
 
94
102
  ### Step 4: Dispatch Milestone Builder(s)
95
103
 
104
+ **Parallel dispatch (2+ milestones in wave with disjoint Files Written):**
105
+
106
+ Load `capabilities/shared/parallel-coordination.md` first.
107
+
108
+ 1. Write `.claude/ownership.md` table (branch, directories, status) for every agent in this wave
109
+ 2. Spawn each builder via Task with `isolation: "worktree"` in the same message (true parallel)
110
+ 3. Include worktree rules in every parallel prompt (see parallel-coordination.md Step 3)
111
+ 4. Wait for ALL agents in the wave before merging
112
+ 5. Merge branches sequentially (simplest milestone first) following the Merge Protocol
113
+
114
+ **Sequential dispatch (single milestone OR overlapping files):**
115
+
96
116
  Spawn milestone-builder via Task with fully packaged context:
97
117
 
98
118
  ```
@@ -123,8 +143,8 @@ Fix attempts: {2 for SIMPLE/MEDIUM, 3 for COMPLEX}
123
143
  When done, report: files changed + test status + new patterns/anti-patterns.
124
144
  ```
125
145
 
126
- Independent milestones with disjoint `Files Written` → spawn in parallel.
127
- Dependent milestones OR overlapping `Files Written` → spawn sequentially.
146
+ Independent milestones with disjoint `Files Written` AND `Parallel Safe: YES` → spawn in parallel with worktree isolation.
147
+ Dependent milestones, overlapping `Files Written`, or `Parallel Safe: NO` → spawn sequentially.
128
148
 
129
149
  ---
130
150
 
@@ -128,6 +128,12 @@ If YES: topic = {what orchestrator must /debate before dispatching}
128
128
  ### Estimated Complexity
129
129
  SIMPLE (< 3 files) | MEDIUM (3-8 files) | COMPLEX (8+ files)
130
130
  COMPLEX → orchestrator gives builder 3 fix attempts instead of 2
131
+
132
+ ### Parallel Safe
133
+ YES | NO
134
+ If NO: reason = {specific conflict — shared file, schema dependency, runtime ordering}
135
+ The orchestrator uses this to decide whether to use worktree isolation or sequential dispatch.
136
+ Parallel Safe = YES requires: isolated directories, no shared config/schema, no runtime dependency on a sibling milestone.
131
137
  ```
132
138
 
133
139
  ---
@@ -58,6 +58,16 @@ Load only the files that match the current task. Never load the full list.
58
58
  | intelligence/pipeline.md | 3+ agents must chain output — context bleed is a risk | ~350 |
59
59
  | intelligence/experiment.md | Trying a risky approach that must not touch main branch — "try this safely" | ~80 |
60
60
 
61
+ ## Code Rules — per-stack rule libraries (load matching stack only)
62
+ | File | When to load | Tokens |
63
+ |------|-------------|--------|
64
+ | shared/rules/typescript.md | Writing or verifying TypeScript code — load for /add, /fix, /verify when TS detected | ~250 |
65
+ | shared/rules/react.md | Writing or verifying React/Next.js components — load when JSX/TSX detected | ~250 |
66
+ | shared/rules/python.md | Writing or verifying Python/FastAPI/Django code — load when .py detected | ~250 |
67
+ | shared/rules/node.md | Writing or verifying Node.js/Express backend code — load when Node stack detected | ~250 |
68
+
69
+ **When to load:** `/verify` (rule source), `/driven` (default rule generation), `/add` and `/fix` (when no code-rules.md exists and stack is detected). Load only the matching stack file, never all four.
70
+
61
71
  ## Spec-Driven Workflow — load in sequence
62
72
  | Command | Purpose | Loads |
63
73
  |---------|---------|-------|
@@ -0,0 +1,176 @@
1
+ # Parallel Agent Coordination
2
+
3
+ This file is loaded by the orchestrator when dispatching milestone-builder agents in parallel.
4
+ It defines the worktree isolation protocol, ownership map format, and merge sequence.
5
+
6
+ ---
7
+
8
+ ## Why Worktrees Are Required for Parallel Dispatch
9
+
10
+ Without worktree isolation, two agents writing to the same repo simultaneously cause:
11
+ - **File corruption**: agent A's partial write is read by agent B mid-implementation
12
+ - **Test interference**: A's failing tests pollute B's test run, causing false failures
13
+ - **Commit races**: both agents commit, one overwrites the other's changes on push
14
+
15
+ Worktree isolation gives each parallel agent a private copy of the repo on its own branch.
16
+ The orchestrator merges completed branches sequentially once all agents report done.
17
+
18
+ ---
19
+
20
+ ## Ownership Map
21
+
22
+ The orchestrator maintains `.claude/ownership.md` during parallel sessions.
23
+ Format — one entry per active parallel agent:
24
+
25
+ ```
26
+ ## Active Parallel Session — {ISO timestamp}
27
+
28
+ | Agent Slot | Milestone | Branch | Directories Owned | Status |
29
+ |------------|-----------|--------|-------------------|--------|
30
+ | P1 | M3 — Auth endpoints | parallel/m3-auth | src/auth/, tests/auth/ | running |
31
+ | P2 | M4 — User profile | parallel/m4-profile | src/users/, tests/users/ | running |
32
+ | P3 | M5 — Email service | parallel/m5-email | src/email/, tests/email/ | done |
33
+ ```
34
+
35
+ Rules:
36
+ - Two agents cannot share a directory in "Directories Owned"
37
+ - Orchestrator writes this table before dispatching; builders do NOT modify it
38
+ - `parallel/{milestone-slug}` is the branch naming convention
39
+ - Delete the table when the wave is merged (replace with "Wave N merged — {timestamp}")
40
+
41
+ ---
42
+
43
+ ## Dispatch Protocol (Orchestrator)
44
+
45
+ ### Step 1: Confirm Parallel Safety
46
+
47
+ Before spawning any parallel agents for a wave, verify from problem-architect Team Specs:
48
+
49
+ ```
50
+ For each pair (A, B) in the wave:
51
+ - Files Written(A) ∩ Files Written(B) = empty set? → safe
52
+ - Parent directories of A and B do not overlap? → safe
53
+ - No shared schema/config files (prisma.schema, package.json, tsconfig)? → safe
54
+ - No runtime dependency (A's output is B's input)? → safe
55
+
56
+ If any check fails → remove the conflicting milestone from the wave, dispatch sequentially
57
+ ```
58
+
59
+ ### Step 2: Write Ownership Map
60
+
61
+ Write `.claude/ownership.md` before spawning any agents.
62
+
63
+ ### Step 3: Dispatch with Worktree Isolation
64
+
65
+ Spawn each agent via Task with `isolation: "worktree"`:
66
+
67
+ ```
68
+ Task: Implement Milestone {N} — {title}
69
+
70
+ [worktree mode]
71
+ Branch: parallel/{milestone-slug}
72
+ Do NOT push to origin. Commit locally only.
73
+ Report branch name in completion message.
74
+
75
+ {standard milestone context from orchestrator Step 4}
76
+ ```
77
+
78
+ Include in every parallel dispatch:
79
+ ```
80
+ Worktree rules:
81
+ - You are in an isolated git worktree on branch: parallel/{slug}
82
+ - Run all tests — they test YOUR changes in isolation only
83
+ - If you see errors in files outside your owned directories: STOP, report to orchestrator
84
+ - Do NOT run git push — commit locally only
85
+ - Your completion message MUST include: "Branch: parallel/{slug}" for merge tracking
86
+ ```
87
+
88
+ ### Step 4: Wait for All Agents in the Wave
89
+
90
+ Do NOT start the merge until ALL parallel agents in this wave have reported:
91
+ - `COMPLETE` → proceed with merge
92
+ - `FAILED` → merge all completed branches first, then handle the failure as a blocked milestone
93
+
94
+ ---
95
+
96
+ ## Merge Protocol (Orchestrator)
97
+
98
+ After all parallel agents report done, merge sequentially:
99
+
100
+ ```bash
101
+ # Step 1: Return to main branch
102
+ git checkout main # or master / development
103
+
104
+ # Step 2: Merge each branch in completion order
105
+ git merge parallel/m3-auth --no-ff -m "merge: M3 auth endpoints [parallel wave N]"
106
+ git merge parallel/m4-profile --no-ff -m "merge: M4 user profile [parallel wave N]"
107
+
108
+ # Step 3: If merge conflict on step N:
109
+ # - Identify which files conflict
110
+ # - Read both versions
111
+ # - Apply the correct merge (usually: keep both feature additions, not one-or-other)
112
+ # - Mark conflict resolved, continue with remaining branches
113
+
114
+ # Step 4: Run full test suite on merged main
115
+ npm test 2>&1 | tail -20
116
+
117
+ # Step 5: If tests pass → push
118
+ git push origin main
119
+
120
+ # Step 6: Clean up worktree branches
121
+ git branch -d parallel/m3-auth parallel/m4-profile parallel/m5-email
122
+ ```
123
+
124
+ **Merge order matters**: merge the branch with the fewest cross-dependencies first.
125
+ When uncertain: sort by `Estimated Complexity` ascending (simpler merges first).
126
+
127
+ ---
128
+
129
+ ## Agent Coordination Rules (for Milestone Builder in Parallel Mode)
130
+
131
+ These rules are injected by orchestrator into every parallel milestone-builder prompt:
132
+
133
+ 1. **Own your scope** — only write files in your declared "Directories Owned". If the task requires touching a file outside your scope, STOP and report to orchestrator.
134
+
135
+ 2. **Never push** — commit locally on your worktree branch. Do not run `git push`.
136
+
137
+ 3. **Test in isolation** — your test run should only test what you changed. If the test suite has cross-cutting failures, filter to your files: `pytest tests/auth/ -v` not `pytest .`
138
+
139
+ 4. **Errors outside your files = not your problem** — if you see compilation errors or test failures in files you didn't modify, that's a parallel agent's in-progress state. Report to orchestrator: "Test failures in {file} — outside my scope, may be parallel agent interference."
140
+
141
+ 5. **Report branch on completion** — always end your report with: `Branch: parallel/{slug}`
142
+
143
+ ---
144
+
145
+ ## Conflict Resolution Ladder
146
+
147
+ | Conflict type | Resolution |
148
+ |---------------|-----------|
149
+ | Two agents wrote to the same file (despite safety check) | Orchestrator reads both versions, applies correct merge manually |
150
+ | Merge conflict on shared config (package.json, tsconfig) | Merge both dependency lists; the second merge wins on formatting |
151
+ | Merge conflict on shared schema | STOP — run /debate before merging; schema changes are architectural |
152
+ | Test suite broken after merge | Identify which merge introduced the break; revert that branch, add to blocked |
153
+ | Agent reports "errors in files outside my scope" | Orchestrator pauses that agent, lets the other agent stabilize first |
154
+
155
+ ---
156
+
157
+ ## When NOT to Use Parallel Dispatch
158
+
159
+ | Condition | Reason |
160
+ |-----------|--------|
161
+ | Milestone touches `package.json` / `requirements.txt` | Dependency changes affect the full build — sequential only |
162
+ | Milestone touches database schema | Schema migrations must run in order |
163
+ | Milestone has `Structural Decision Required: YES` | Architecture must be resolved before implementation |
164
+ | Project has < 3 milestones total | Sequential is simpler; parallel overhead exceeds gain |
165
+ | No worktree support (bare repo, certain CI environments) | Falls back to sequential automatically |
166
+
167
+ ---
168
+
169
+ ## Ownership Map Cleanup
170
+
171
+ After wave merge is complete:
172
+ ```bash
173
+ # Remove ownership.md entries for the completed wave
174
+ # (or replace the table with a merge record)
175
+ echo "## Wave {N} merged — {timestamp}" >> .claude/ownership.md
176
+ ```
@@ -18,14 +18,20 @@ Every plan.md must follow this structure exactly. The copilot runner parses it.
18
18
 
19
19
  ### M1: {title}
20
20
  - Status: {pending|in-progress|done|blocked|skipped}
21
- - Files: {expected files to create/modify}
21
+ - Wave: {1|2|3|...} execution wave (same wave = runs in parallel)
22
+ - Files: {expected files to create/modify — be specific, e.g. src/auth/login.ts}
23
+ - Dirs: {top-level directories this milestone owns — e.g. src/auth/, tests/auth/}
22
24
  - Depends: {M-numbers this depends on, or "none"}
25
+ - Parallel: {yes|no} — yes = safe to run alongside other same-wave milestones
23
26
  - Commit: {expected commit message}
24
27
 
25
28
  ### M2: {title}
26
29
  - Status: pending
30
+ - Wave: 2
27
31
  - Files: ...
32
+ - Dirs: src/users/, tests/users/
28
33
  - Depends: M1
34
+ - Parallel: yes
29
35
  - Commit: ...
30
36
 
31
37
  ## Summary
@@ -33,8 +39,19 @@ Total: {N} milestones
33
39
  Done: {N}/{total}
34
40
  In progress: {N}/{total}
35
41
  Blocked: {N}/{total}
42
+ Waves: {N} (max parallel in one wave: {N})
36
43
  ```
37
44
 
45
+ ### Field Definitions
46
+
47
+ | Field | Purpose |
48
+ |-------|---------|
49
+ | `Wave:` | Which execution wave. Same number = can run simultaneously. Wave 1 always first. |
50
+ | `Dirs:` | Directories this milestone exclusively owns. Two milestones in the same wave MUST have non-overlapping `Dirs:`. |
51
+ | `Files:` | Expected file paths to create/modify. Blueprint's estimate — problem-architect refines to `Files Written:`. |
52
+ | `Parallel: yes` | Orchestrator may dispatch with worktree isolation alongside other Wave N milestones. |
53
+ | `Parallel: no` | Reasons: touches shared config, schema change, or has runtime dep on sibling milestone. |
54
+
38
55
  ## Status Values
39
56
 
40
57
  | Status | Meaning |
@@ -0,0 +1,70 @@
1
+ # Node.js / Express Code Rules — Curated DO/DO NOT Reference
2
+
3
+ **Load when**: stack contains Node.js, Express, Fastify, or similar backend JS/TS; generating code-rules.md for Node projects; or verifying Node/Express files.
4
+
5
+ ---
6
+
7
+ ## Async Patterns
8
+
9
+ - DO: use `async/await` throughout — no callback-style code in new files
10
+ - DO: always `await` Promises or chain `.catch()` — unhandled rejections crash Node
11
+ - DO: wrap `await` calls in `try/catch` at the service boundary
12
+ - DO NOT: mix `async/await` and `.then()/.catch()` in the same function
13
+ - DO NOT: use `Promise.all` without handling individual rejections — use `Promise.allSettled` when partial failure is acceptable
14
+
15
+ ## Route Structure
16
+
17
+ - DO: split routes into separate files by resource — `routes/users.ts`, `routes/orders.ts`
18
+ - DO: use a router factory pattern — `export function usersRouter(deps: Deps): Router`
19
+ - DO: validate all request input at the route entry — use zod, joi, or class-validator
20
+ - DO: return semantically correct HTTP status codes:
21
+ - `201` for successful resource creation
22
+ - `204` for successful delete with no body
23
+ - `400` for validation failures
24
+ - `404` for not found
25
+ - `409` for conflicts
26
+ - `422` for unprocessable entity
27
+ - DO NOT: put business logic in route handlers — delegate to a service layer
28
+ - DO NOT: return stack traces in error responses — log server-side, return a generic message
29
+
30
+ ## Middleware
31
+
32
+ - DO: register middleware in order: security → logging → parsing → auth → routes → errors
33
+ - DO: error-handling middleware uses 4 parameters exactly: `(err, req, res, next)`
34
+ - DO: always call `next(err)` on errors in async middleware — never swallow silently
35
+ - DO NOT: call both `next()` and `res.send()` in the same middleware path
36
+ - DO NOT: use synchronous file I/O in middleware (`fs.readFileSync`) — blocks the event loop
37
+
38
+ ## Database and Queries
39
+
40
+ - DO: use parameterized queries or an ORM — never concatenate user input into SQL
41
+ - DO: define a data access layer (repository) — routes and services never call the DB directly
42
+ - DO: use database transactions for multi-step writes
43
+ - DO NOT: select `*` — list columns explicitly in queries
44
+ - DO NOT: put connection logic inside route handlers — use a shared pool or ORM connection
45
+
46
+ ## Security
47
+
48
+ - DO: load secrets from `process.env` — never hardcode keys, tokens, or passwords in source
49
+ - DO: validate and sanitize all user input before use
50
+ - DO: set security headers — use `helmet` for Express
51
+ - DO: apply rate limiting to all public endpoints
52
+ - DO NOT: log request bodies containing passwords or tokens
53
+ - DO NOT: expose internal error messages to clients — wrap in a safe error response
54
+
55
+ ## Configuration
56
+
57
+ - DO: validate all required env vars at startup — fail fast with a clear message if missing
58
+ ```ts
59
+ const PORT = Number(process.env.PORT) || 3000;
60
+ if (!process.env.DATABASE_URL) throw new Error("DATABASE_URL required");
61
+ ```
62
+ - DO: use a config module — centralize all `process.env` access in one file
63
+ - DO NOT: use `process.env.X` scattered throughout the codebase
64
+
65
+ ## Testing
66
+
67
+ - DO: test routes with supertest against the real Express app — not mocked handlers
68
+ - DO: use a test database — never run tests against production or development databases
69
+ - DO: reset database state between tests using transactions or table truncation
70
+ - DO NOT: mock the database layer in route integration tests — it hides real issues