sinapse-ai 7.1.0 → 7.3.0

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 (70) hide show
  1. package/.sinapse-ai/data/entity-registry.yaml +777 -881
  2. package/.sinapse-ai/data/registry-update-log.jsonl +2 -0
  3. package/.sinapse-ai/development/agents/sinapse-orqx.md +599 -443
  4. package/.sinapse-ai/install-manifest.yaml +6 -6
  5. package/bin/cli.js +116 -75
  6. package/package.json +2 -1
  7. package/packages/installer/src/wizard/i18n.js +2 -2
  8. package/packages/installer/src/wizard/index.js +14 -0
  9. package/packages/installer/src/wizard/questions.js +3 -3
  10. package/sinapse/agents/sinapse-orqx.md +32 -14
  11. package/squads/claude-code-mastery/CHANGELOG.md +22 -0
  12. package/squads/claude-code-mastery/README.md +146 -0
  13. package/squads/claude-code-mastery/agents/claude-mastery-chief.md +554 -0
  14. package/squads/claude-code-mastery/agents/config-engineer.md +865 -0
  15. package/squads/claude-code-mastery/agents/hooks-architect.md +1013 -0
  16. package/squads/claude-code-mastery/agents/mcp-integrator.md +791 -0
  17. package/squads/claude-code-mastery/agents/project-integrator.md +1196 -0
  18. package/squads/claude-code-mastery/agents/roadmap-sentinel.md +931 -0
  19. package/squads/claude-code-mastery/agents/skill-craftsman.md +1250 -0
  20. package/squads/claude-code-mastery/agents/swarm-orqx.md +1008 -0
  21. package/squads/claude-code-mastery/checklists/agent-team-readiness-checklist.md +88 -0
  22. package/squads/claude-code-mastery/checklists/brownfield-readiness-checklist.md +91 -0
  23. package/squads/claude-code-mastery/checklists/change-checklist.md +75 -0
  24. package/squads/claude-code-mastery/checklists/context-rot-checklist.md +114 -0
  25. package/squads/claude-code-mastery/checklists/integration-audit-checklist.md +104 -0
  26. package/squads/claude-code-mastery/checklists/multi-agent-review-checklist.md +77 -0
  27. package/squads/claude-code-mastery/checklists/pre-push-checklist.md +79 -0
  28. package/squads/claude-code-mastery/data/ci-cd-patterns.yaml +412 -0
  29. package/squads/claude-code-mastery/data/claude-code-quick-ref.yaml +314 -0
  30. package/squads/claude-code-mastery/data/hook-patterns.yaml +512 -0
  31. package/squads/claude-code-mastery/data/mcp-integration-catalog.yaml +323 -0
  32. package/squads/claude-code-mastery/data/project-type-signatures.yaml +335 -0
  33. package/squads/claude-code-mastery/scripts/validate-setup.js +163 -0
  34. package/squads/claude-code-mastery/squad.yaml +205 -0
  35. package/squads/claude-code-mastery/tasks/audit-integration.md +219 -0
  36. package/squads/claude-code-mastery/tasks/audit-settings.md +206 -0
  37. package/squads/claude-code-mastery/tasks/audit-setup.md +225 -0
  38. package/squads/claude-code-mastery/tasks/brownfield-setup.md +322 -0
  39. package/squads/claude-code-mastery/tasks/ci-cd-setup.md +335 -0
  40. package/squads/claude-code-mastery/tasks/claude-md-engineer.md +334 -0
  41. package/squads/claude-code-mastery/tasks/configure-claude-code.md +215 -0
  42. package/squads/claude-code-mastery/tasks/context-rot-audit.md +329 -0
  43. package/squads/claude-code-mastery/tasks/create-agent-definition.md +278 -0
  44. package/squads/claude-code-mastery/tasks/create-rules.md +206 -0
  45. package/squads/claude-code-mastery/tasks/create-team-topology.md +258 -0
  46. package/squads/claude-code-mastery/tasks/diagnose.md +166 -0
  47. package/squads/claude-code-mastery/tasks/enterprise-config.md +346 -0
  48. package/squads/claude-code-mastery/tasks/hook-designer.md +272 -0
  49. package/squads/claude-code-mastery/tasks/integrate-project.md +304 -0
  50. package/squads/claude-code-mastery/tasks/mcp-integration-plan.md +229 -0
  51. package/squads/claude-code-mastery/tasks/mcp-workflow.md +285 -0
  52. package/squads/claude-code-mastery/tasks/multi-project-setup.md +228 -0
  53. package/squads/claude-code-mastery/tasks/optimize-context.md +217 -0
  54. package/squads/claude-code-mastery/tasks/optimize-workflow.md +226 -0
  55. package/squads/claude-code-mastery/tasks/parallel-decomposition.md +293 -0
  56. package/squads/claude-code-mastery/tasks/permission-strategy.md +266 -0
  57. package/squads/claude-code-mastery/tasks/sandbox-setup.md +279 -0
  58. package/squads/claude-code-mastery/tasks/setup-repository.md +230 -0
  59. package/squads/claude-code-mastery/tasks/setup-wizard.md +236 -0
  60. package/squads/claude-code-mastery/tasks/worktree-strategy.md +320 -0
  61. package/squads/claude-code-mastery/templates/claude-md-fullstack.md +147 -0
  62. package/squads/claude-code-mastery/templates/claude-md-library.md +175 -0
  63. package/squads/claude-code-mastery/templates/claude-md-microservices.md +186 -0
  64. package/squads/claude-code-mastery/templates/claude-md-mobile.md +198 -0
  65. package/squads/claude-code-mastery/templates/claude-md-monorepo.md +139 -0
  66. package/squads/claude-code-mastery/templates/github-actions-claude-ci.yml +348 -0
  67. package/squads/claude-code-mastery/templates/github-actions-claude-review.yml +179 -0
  68. package/squads/claude-code-mastery/workflows/wf-audit-complete.yaml +140 -0
  69. package/squads/claude-code-mastery/workflows/wf-knowledge-update.yaml +165 -0
  70. package/squads/claude-code-mastery/workflows/wf-project-setup.yaml +192 -0
@@ -0,0 +1,236 @@
1
+ # Task: Setup Wizard
2
+
3
+ **Task ID:** CCM-CHIEF-003
4
+ **Version:** 1.0.0
5
+ **Command:** `*setup-wizard`
6
+ **Orchestrator:** Orion (claude-mastery-chief)
7
+ **Purpose:** Interactive wizard to set up Claude Code for a new or existing project, generating all required configuration files tailored to the detected project type.
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ ```
14
+ +------------------+ +------------------+ +------------------+
15
+ | 1. Detect | --> | 2. Generate | --> | 3. Configure |
16
+ | Project Type | | CLAUDE.md | | settings.json |
17
+ +------------------+ +------------------+ +------------------+
18
+ | |
19
+ v v
20
+ +------------------+ +------------------+ +------------------+
21
+ | 4. Create | --> | 5. Configure | --> | 6. Set Up |
22
+ | .claude/rules | | Hooks | | MCP Servers |
23
+ +------------------+ +------------------+ +------------------+
24
+ | |
25
+ v v
26
+ +------------------+ +------------------+
27
+ | 7. Create | --> | COMPLETE |
28
+ | Agents (opt.) | | Summary |
29
+ +------------------+ +------------------+
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Inputs
35
+
36
+ | Field | Type | Source | Required | Validation |
37
+ |-------|------|--------|----------|------------|
38
+ | project_root | string | Working directory | Yes | Must be a valid directory |
39
+ | mode | string | User parameter | No | `guided` (default, interactive) or `express` (smart defaults) |
40
+ | preset | string | User parameter | No | Project type override (monorepo, fullstack, library, api, cli) |
41
+
42
+ ---
43
+
44
+ ## Preconditions
45
+
46
+ - Working directory is a project root
47
+ - Write access to the project directory
48
+ - No existing .claude/ directory (or user confirms overwrite)
49
+
50
+ ---
51
+
52
+ ## Execution Phases
53
+
54
+ ### Phase 1: Detect Project Type
55
+
56
+ Analyze the project to determine its type:
57
+
58
+ 1. Check for project markers:
59
+ - `package.json` -> Node.js project; check for `workspaces` field (monorepo)
60
+ - `next.config.*` -> Next.js fullstack
61
+ - `vite.config.*` -> Vite frontend
62
+ - `tsconfig.json` -> TypeScript project
63
+ - `pyproject.toml` / `setup.py` -> Python project
64
+ - `Cargo.toml` -> Rust project
65
+ - `go.mod` -> Go project
66
+ - `.sinapse-ai/` -> SINAPSE-managed project
67
+ 2. Detect project structure:
68
+ - `src/app/` or `app/` -> App Router (Next.js)
69
+ - `src/pages/` -> Pages Router
70
+ - `packages/` or `apps/` -> Monorepo
71
+ - `src/lib/` or `lib/` -> Library
72
+ - `src/api/` or `server/` -> API backend
73
+ 3. Present detection result and ask user to confirm or override
74
+
75
+ **Project Type Matrix:**
76
+
77
+ | Type | Markers | Default Permission Mode |
78
+ |------|---------|------------------------|
79
+ | monorepo | workspaces, packages/ | acceptEdits |
80
+ | fullstack | next.config, app/ + api/ | acceptEdits |
81
+ | frontend | vite.config, src/components | acceptEdits |
82
+ | api | server/, express/fastify dep | acceptEdits |
83
+ | library | main/module in package.json | askAlways |
84
+ | cli | bin/ field in package.json | askAlways |
85
+ | python | pyproject.toml, src/ | acceptEdits |
86
+ | sinapse | .sinapse-ai/ directory | acceptEdits |
87
+
88
+ ### Phase 2: Generate CLAUDE.md
89
+
90
+ 1. Create `.claude/CLAUDE.md` (or `./CLAUDE.md` based on user preference)
91
+ 2. Include sections based on project type:
92
+ - **Project overview**: Name, description, tech stack
93
+ - **Development commands**: Build, test, lint, dev server
94
+ - **Code standards**: Naming conventions, patterns, file organization
95
+ - **Testing**: Test framework, coverage requirements, how to run
96
+ - **Architecture notes**: Key directories and their purpose
97
+ 3. Use @imports for large reference documents
98
+ 4. Target: under 200 lines
99
+ 5. If SINAPSE project: include SINAPSE-specific sections (agent system, workflows)
100
+
101
+ ### Phase 3: Configure settings.json
102
+
103
+ 1. Create `.claude/settings.json` with:
104
+ - **permissions.deny**: Sensitive files (.env, secrets/, credentials)
105
+ - **permissions.allow**: Safe development operations based on project type
106
+ - **permissions.defaultMode**: Based on project type matrix
107
+ 2. Add project-specific rules:
108
+ - Monorepo: allow Read/Edit across all packages
109
+ - Frontend: allow Bash(npm run dev), Bash(npm run build)
110
+ - API: deny external network calls by default
111
+ - Library: stricter permissions (askAlways)
112
+ 3. If SINAPSE project: add L1-L4 boundary protection deny rules
113
+
114
+ ### Phase 4: Set Up .claude/rules/
115
+
116
+ 1. Create `.claude/rules/` directory
117
+ 2. Generate conditional rules based on project structure:
118
+ - **api-rules.md**: API conventions (if src/api/ or server/ exists)
119
+ - `paths: ["src/api/**", "server/**"]`
120
+ - **test-rules.md**: Testing conventions (if tests/ or __tests__/ exists)
121
+ - `paths: ["tests/**", "**/*.test.*", "**/*.spec.*"]`
122
+ - **component-rules.md**: Component patterns (if src/components/ exists)
123
+ - `paths: ["src/components/**", "**/*.tsx"]`
124
+ - **database-rules.md**: Migration patterns (if migrations/ or supabase/ exists)
125
+ - `paths: ["migrations/**", "supabase/**"]`
126
+ 3. Create one unconditional rule for project-wide conventions
127
+
128
+ ### Phase 5: Configure Hooks
129
+
130
+ 1. Ask the user about their automation needs:
131
+ - Pre-commit validation? (lint, format, type check)
132
+ - Command safety? (block dangerous bash commands)
133
+ - Session logging? (track tool usage)
134
+ - Compaction preservation? (save context before auto-compaction)
135
+ 2. Generate hook configuration based on answers:
136
+ ```json
137
+ {
138
+ "hooks": {
139
+ "PreToolUse": [{
140
+ "matcher": "Bash",
141
+ "hooks": [{ "type": "command", "command": "...", "timeout": 10 }]
142
+ }],
143
+ "PreCompact": [{
144
+ "hooks": [{ "type": "command", "command": "...", "timeout": 5 }]
145
+ }]
146
+ }
147
+ }
148
+ ```
149
+ 3. For express mode: apply sensible defaults (PreToolUse bash guard + PreCompact)
150
+
151
+ ### Phase 6: Set Up MCP Servers
152
+
153
+ 1. Ask the user which capabilities they need:
154
+ - Web search (Exa)
155
+ - Library documentation (Context7)
156
+ - Browser automation (Playwright)
157
+ - Database access (Supabase, Postgres)
158
+ - File system extended access
159
+ 2. Generate `.claude/mcp.json` with selected servers
160
+ 3. Provide setup instructions for each server (install commands, API keys needed)
161
+ 4. For express mode: configure Context7 (most universally useful)
162
+
163
+ ### Phase 7: Create Agents (Optional)
164
+
165
+ 1. Ask if the user needs custom subagents
166
+ 2. If yes, create `.claude/agents/` directory with starter agents:
167
+ - **reviewer.md**: Code review agent with Read-only tools
168
+ - **planner.md**: Planning agent with limited scope
169
+ 3. Each agent gets proper YAML frontmatter:
170
+ ```yaml
171
+ ---
172
+ name: Reviewer
173
+ description: Code review specialist
174
+ tools: [Read, Grep, Glob]
175
+ ---
176
+ ```
177
+ 4. For express mode: skip unless user explicitly requests
178
+
179
+ ---
180
+
181
+ ## Output Format
182
+
183
+ ```markdown
184
+ ## Setup Complete
185
+
186
+ **Project:** {project-name}
187
+ **Type:** {detected-type}
188
+ **Mode:** {guided | express}
189
+
190
+ ### Files Created
191
+
192
+ | File | Purpose | Lines |
193
+ |------|---------|-------|
194
+ | .claude/CLAUDE.md | Project instructions | {N} |
195
+ | .claude/settings.json | Permissions and config | {N} |
196
+ | .claude/rules/{name}.md | Conditional rule | {N} |
197
+ | ... | ... | ... |
198
+
199
+ ### Configuration Summary
200
+
201
+ - **Permission mode:** {defaultMode}
202
+ - **Deny rules:** {count} rules protecting sensitive files
203
+ - **Allow rules:** {count} rules for development operations
204
+ - **Hooks:** {count} hooks configured ({event names})
205
+ - **MCP servers:** {count} servers ({names})
206
+ - **Custom agents:** {count} agents ({names})
207
+
208
+ ### Next Steps
209
+
210
+ 1. Review .claude/settings.json and adjust permissions
211
+ 2. Customize CLAUDE.md with project-specific instructions
212
+ 3. Run `*audit` to verify the setup scores well
213
+ 4. {Additional steps based on project type}
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Veto Conditions
219
+
220
+ - **NEVER** overwrite existing .claude/ configuration without explicit user confirmation. Always ask first.
221
+ - **NEVER** include real API keys, tokens, or secrets in generated configuration files. Use placeholder values with comments.
222
+ - **NEVER** set `bypassPermissions` as the default mode. Start with `acceptEdits` or `askAlways`.
223
+ - **NEVER** create a CLAUDE.md over 200 lines. Split into @imports and .claude/rules/ if content exceeds the limit.
224
+ - **NEVER** skip the project type detection confirmation step, even in express mode.
225
+
226
+ ---
227
+
228
+ ## Completion Criteria
229
+
230
+ - [ ] Project type detected and confirmed
231
+ - [ ] CLAUDE.md generated under 200 lines
232
+ - [ ] settings.json created with deny-first permission rules
233
+ - [ ] At least one .claude/rules/ file created with paths: frontmatter
234
+ - [ ] Hooks configured (at minimum in guided mode)
235
+ - [ ] MCP servers section addressed (configured or explicitly skipped)
236
+ - [ ] Setup summary displayed with file list and next steps
@@ -0,0 +1,320 @@
1
+ # Task: Git Worktree Isolation Strategy
2
+
3
+ **Task ID:** worktree-strategy
4
+ **Version:** 1.0
5
+ **Purpose:** Plan and configure git worktree isolation for multi-agent development scenarios
6
+ **Orchestrator:** @swarm-orqx (Nexus)
7
+ **Mode:** Interactive (elicit: true)
8
+ **Quality Standard:** Worktree lifecycle tested end-to-end, cleanup verified
9
+
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ This task plans git worktree isolation for agent teams where multiple agents modify code simultaneously. Worktrees give each agent its own working directory and branch, eliminating merge conflicts during execution and deferring integration to a controlled merge phase.
15
+
16
+ ```
17
+ INPUT (agents_count + shared_files_risk + merge_strategy)
18
+ |
19
+ [PHASE 1: ISOLATION ASSESSMENT]
20
+ -> Evaluate merge conflict risk
21
+ -> Determine if worktree isolation is needed
22
+ -> Identify alternative strategies
23
+ |
24
+ [PHASE 2: BRANCH STRATEGY]
25
+ -> Define branch naming convention
26
+ -> Plan base branch selection
27
+ -> Set up branch protection
28
+ |
29
+ [PHASE 3: WORKTREE CONFIGURATION]
30
+ -> Create worktrees for each agent
31
+ -> Configure agent working directories
32
+ -> Verify each worktree is functional
33
+ |
34
+ [PHASE 4: LIFECYCLE MANAGEMENT]
35
+ -> Define create -> work -> merge -> cleanup flow
36
+ -> Set up automated cleanup triggers
37
+ -> Plan stale worktree detection
38
+ |
39
+ [PHASE 5: MERGE AND CLEANUP]
40
+ -> Define merge order (dependency-aware)
41
+ -> Handle merge conflicts
42
+ -> Remove worktrees after successful merge
43
+ |
44
+ OUTPUT: Worktree config + branch strategy + lifecycle plan
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Inputs
50
+
51
+ | Field | Type | Source | Required | Validation |
52
+ |-------|------|--------|----------|------------|
53
+ | agent_count | number | From team topology | yes | Number of agents needing isolation |
54
+ | base_branch | string | Auto-detect or user | no | Branch to create worktrees from (default: current) |
55
+ | task_id | string | User | yes | Identifier for this parallel work session |
56
+ | shared_files | array | Analysis | no | Files that multiple agents might modify |
57
+ | auto_cleanup | boolean | User | no | Remove worktrees after merge (default: true) |
58
+
59
+ ---
60
+
61
+ ## Preconditions
62
+
63
+ 1. Git repository is initialized and has at least one commit
64
+ 2. Current working tree is clean (no uncommitted changes)
65
+ 3. `git worktree` command is available (Git 2.5+)
66
+ 4. Sufficient disk space for N copies of the working directory
67
+
68
+ ---
69
+
70
+ ## Phase 1: Isolation Assessment
71
+
72
+ **Goal:** Determine if worktree isolation is actually needed.
73
+
74
+ ### When to Use Worktrees vs Shared Repo
75
+
76
+ | Scenario | Strategy | Reason |
77
+ |----------|----------|--------|
78
+ | Agents modify different files | **Shared repo** | No conflict risk, simpler setup |
79
+ | Agents modify same files | **Worktree** | Prevents runtime merge conflicts |
80
+ | Sequential pipeline (A then B) | **Shared repo** | No simultaneous writes |
81
+ | Parallel agents with file overlap | **Worktree** | Each agent needs clean state |
82
+ | Single agent with long-running task | **Shared repo** | No need for isolation |
83
+ | CI/CD parallel test execution | **Worktree** | Tests need independent environments |
84
+
85
+ ### Steps
86
+
87
+ 1.1. Analyze agent assignments from the team topology.
88
+ 1.2. Build a file-ownership matrix:
89
+
90
+ ```
91
+ | Agent-A | Agent-B | Agent-C |
92
+ ---------|---------|---------|---------|
93
+ file1.ts | W | R | |
94
+ file2.ts | | W | W | <-- CONFLICT
95
+ file3.ts | W | | |
96
+ ```
97
+
98
+ 1.3. If any file has multiple W (write) entries, worktree isolation is recommended.
99
+ 1.4. If no conflicts, document decision to use shared repo and SKIP remaining phases.
100
+
101
+ ---
102
+
103
+ ## Phase 2: Branch Strategy
104
+
105
+ **Goal:** Define how branches map to agents and worktrees.
106
+
107
+ ### Branch Naming Convention
108
+
109
+ ```
110
+ {task-id}/{agent-name}
111
+
112
+ Examples:
113
+ feature-auth/code-reviewer
114
+ feature-auth/test-writer
115
+ feature-auth/docs-updater
116
+ ```
117
+
118
+ ### Steps
119
+
120
+ 2.1. Define the base branch (where worktrees branch from):
121
+ - Use current branch for story work
122
+ - Use `main` for independent feature work
123
+
124
+ 2.2. Create a branch plan:
125
+
126
+ ```yaml
127
+ branches:
128
+ base: "feature/auth-system"
129
+ worktree_branches:
130
+ - name: "feature/auth-system/api-agent"
131
+ agent: "api-agent"
132
+ files_owned: ["src/api/**"]
133
+ - name: "feature/auth-system/test-agent"
134
+ agent: "test-agent"
135
+ files_owned: ["tests/**"]
136
+ - name: "feature/auth-system/docs-agent"
137
+ agent: "docs-agent"
138
+ files_owned: ["docs/**"]
139
+ ```
140
+
141
+ 2.3. Verify no branch names conflict with existing branches.
142
+
143
+ ---
144
+
145
+ ## Phase 3: Worktree Configuration
146
+
147
+ **Goal:** Create and configure worktrees for each agent.
148
+
149
+ ### Worktree Location
150
+
151
+ Worktrees are created as sibling directories to the main repo:
152
+
153
+ ```
154
+ project/ <-- main working tree
155
+ project-wt-api-agent/ <-- worktree for api-agent
156
+ project-wt-test-agent/ <-- worktree for test-agent
157
+ project-wt-docs-agent/ <-- worktree for docs-agent
158
+ ```
159
+
160
+ ### Steps
161
+
162
+ 3.1. For each agent, create a worktree:
163
+
164
+ ```bash
165
+ # Create branch and worktree together
166
+ git worktree add ../project-wt-{agent-name} -b {branch-name} {base-branch}
167
+ ```
168
+
169
+ 3.2. Verify each worktree is functional:
170
+
171
+ ```bash
172
+ git worktree list
173
+ # Should show main + N worktrees
174
+ ```
175
+
176
+ 3.3. Configure each agent to use its worktree directory as working directory.
177
+ 3.4. Install dependencies in each worktree if needed (e.g., `npm install`).
178
+
179
+ ---
180
+
181
+ ## Phase 4: Lifecycle Management
182
+
183
+ **Goal:** Define the full create-work-merge-cleanup lifecycle.
184
+
185
+ ### Lifecycle Flow
186
+
187
+ ```
188
+ CREATE WORK MERGE CLEANUP
189
+ | | | |
190
+ Create worktree -> Agent works -> Merge branch -> Remove worktree
191
+ Create branch in isolation to base Delete branch
192
+ Install deps Commits to branch Resolve conflicts Verify clean
193
+ | | | |
194
+ [Automated] [Agent-driven] [Orchestrated] [Automated]
195
+ ```
196
+
197
+ ### Steps
198
+
199
+ 4.1. Document the lifecycle for this specific task:
200
+
201
+ ```yaml
202
+ lifecycle:
203
+ create:
204
+ trigger: "Task start"
205
+ steps: ["create worktree", "create branch", "install deps"]
206
+ estimated_time: "1-3 min"
207
+ work:
208
+ trigger: "Agent activation"
209
+ duration: "Variable"
210
+ monitoring: "Progress file in shared location"
211
+ merge:
212
+ trigger: "All agents complete"
213
+ order: ["api-agent", "test-agent", "docs-agent"]
214
+ conflict_resolution: "manual"
215
+ cleanup:
216
+ trigger: "Merge complete + verified"
217
+ steps: ["remove worktree", "delete branch"]
218
+ auto: true
219
+ ```
220
+
221
+ 4.2. Define stale worktree detection:
222
+ - Worktree with no commits in 24 hours = potentially stale
223
+ - Worktree from deleted/merged branch = definitely stale
224
+ 4.3. Set up cleanup command:
225
+
226
+ ```bash
227
+ # Remove a specific worktree
228
+ git worktree remove ../project-wt-{agent-name}
229
+
230
+ # Prune stale worktree references
231
+ git worktree prune
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Phase 5: Merge and Cleanup
237
+
238
+ **Goal:** Safely merge all agent work back to the base branch.
239
+
240
+ ### Merge Order
241
+
242
+ 5.1. Merge in dependency order (agents whose work is depended on merge first):
243
+
244
+ ```
245
+ 1. api-agent (no dependencies on other agents)
246
+ 2. test-agent (may import from api-agent's code)
247
+ 3. docs-agent (documents what api-agent + test-agent built)
248
+ ```
249
+
250
+ 5.2. For each merge:
251
+
252
+ ```bash
253
+ # Switch to base branch
254
+ git checkout {base-branch}
255
+
256
+ # Merge agent branch
257
+ git merge {agent-branch} --no-ff -m "merge: {agent-name} work for {task-id}"
258
+
259
+ # If conflict:
260
+ # 1. Identify conflicting files
261
+ # 2. Resolve manually or with orchestrator guidance
262
+ # 3. Commit resolution
263
+ ```
264
+
265
+ 5.3. After all merges complete:
266
+ - Run full test suite on merged result
267
+ - If tests fail, identify which merge introduced the failure
268
+ - Fix or revert as needed
269
+
270
+ 5.4. Cleanup:
271
+
272
+ ```bash
273
+ # Remove all worktrees for this task
274
+ git worktree remove ../project-wt-api-agent
275
+ git worktree remove ../project-wt-test-agent
276
+ git worktree remove ../project-wt-docs-agent
277
+
278
+ # Delete merged branches
279
+ git branch -d feature/auth-system/api-agent
280
+ git branch -d feature/auth-system/test-agent
281
+ git branch -d feature/auth-system/docs-agent
282
+
283
+ # Prune any lingering references
284
+ git worktree prune
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Output Format
290
+
291
+ ```yaml
292
+ worktree_strategy_result:
293
+ isolation_needed: true
294
+ reason: "2 agents modify overlapping files in src/"
295
+ worktrees:
296
+ - agent: "api-agent"
297
+ path: "../project-wt-api-agent"
298
+ branch: "feature/auth-system/api-agent"
299
+ status: "created"
300
+ - agent: "test-agent"
301
+ path: "../project-wt-test-agent"
302
+ branch: "feature/auth-system/test-agent"
303
+ status: "created"
304
+ merge_order: ["api-agent", "test-agent"]
305
+ auto_cleanup: true
306
+ lifecycle_documented: true
307
+ ```
308
+
309
+ ---
310
+
311
+ ## Veto Conditions
312
+
313
+ | Condition | Action |
314
+ |-----------|--------|
315
+ | Git repository has no commits | HALT -- initialize repo first |
316
+ | Uncommitted changes in working tree | HALT -- commit or stash before creating worktrees |
317
+ | Disk space insufficient for N worktrees | HALT -- estimate ~size of repo per worktree |
318
+ | Git version < 2.5 | HALT -- upgrade git for worktree support |
319
+ | No file conflicts detected between agents | SKIP -- use shared repo instead (simpler) |
320
+ | Worktree creation fails | HALT -- check git lock files and existing worktrees |
@@ -0,0 +1,147 @@
1
+ # CLAUDE.md — Fullstack Project (Next.js + React)
2
+
3
+ ## Project Overview
4
+
5
+ - **Name:** [PROJECT_NAME]
6
+ - **Description:** [Brief description of the application]
7
+ - **Type:** Fullstack web application
8
+ - **Framework:** Next.js (App Router)
9
+ - **Status:** [Development / Staging / Production]
10
+
11
+ ## Tech Stack
12
+
13
+ | Layer | Technology | Version |
14
+ |-------|-----------|---------|
15
+ | Framework | Next.js | 15.x |
16
+ | UI Library | React | 19.x |
17
+ | Language | TypeScript | 5.x |
18
+ | Styling | Tailwind CSS | 4.x |
19
+ | UI Components | shadcn/ui | latest |
20
+ | State (client) | Zustand | 5.x |
21
+ | Data Fetching | TanStack Query | 5.x |
22
+ | Database | PostgreSQL | via Supabase |
23
+ | Auth | Supabase Auth | — |
24
+ | Validation | Zod | 3.x |
25
+ | Testing | Jest + React Testing Library | — |
26
+ | Linting | ESLint + Prettier | — |
27
+
28
+ ## Directory Structure
29
+
30
+ ```
31
+ src/
32
+ app/ # Next.js App Router pages
33
+ (auth)/ # Auth route group (login, register)
34
+ (dashboard)/ # Dashboard route group
35
+ api/ # API route handlers
36
+ layout.tsx # Root layout
37
+ page.tsx # Landing page
38
+ components/
39
+ ui/ # shadcn/ui base components
40
+ shared/ # Shared composite components
41
+ features/ # Feature-specific components
42
+ lib/
43
+ supabase/ # Supabase client configuration
44
+ utils.ts # Utility functions
45
+ constants.ts # Application constants
46
+ hooks/ # Custom React hooks
47
+ stores/ # Zustand stores
48
+ types/ # TypeScript type definitions
49
+ styles/ # Global styles, Tailwind config
50
+ ```
51
+
52
+ ## Code Standards
53
+
54
+ ### Components
55
+ - Use function components with TypeScript interfaces for props
56
+ - Prefer named exports: `export function Button() {}` not `export default`
57
+ - Co-locate component tests: `Button.tsx` + `Button.test.tsx`
58
+ - Separate server components (default) from client components (`'use client'`)
59
+ - Keep components under 200 lines; extract logic into hooks
60
+
61
+ ### Naming Conventions
62
+ - Components: PascalCase (`UserProfile.tsx`)
63
+ - Hooks: camelCase with `use` prefix (`useAuth.ts`)
64
+ - Utilities: camelCase (`formatDate.ts`)
65
+ - Types: PascalCase with descriptive suffixes (`UserProfileProps`, `AuthState`)
66
+ - API routes: lowercase with hyphens (`/api/user-profile/route.ts`)
67
+ - Constants: SCREAMING_SNAKE_CASE (`MAX_RETRY_COUNT`)
68
+
69
+ ### Server vs Client Components
70
+ - **Server Components** (default): Data fetching, database access, sensitive logic
71
+ - **Client Components** (`'use client'`): Interactivity, browser APIs, state, effects
72
+ - Never import server-only modules in client components
73
+ - Pass serializable props from server to client components
74
+
75
+ ### API Patterns
76
+ - API routes in `src/app/api/` using Route Handlers
77
+ - Validate all inputs with Zod schemas
78
+ - Return consistent response shapes: `{ data, error, meta }`
79
+ - Use proper HTTP status codes (200, 201, 400, 401, 404, 500)
80
+ - Handle errors with try/catch, never expose internal errors
81
+
82
+ ### State Management
83
+ - **Server state:** TanStack Query for all API data (caching, revalidation)
84
+ - **Client state:** Zustand for UI state (modals, sidebars, preferences)
85
+ - **Form state:** React Hook Form + Zod validation
86
+ - Never duplicate server state in client stores
87
+
88
+ ## Testing Requirements
89
+
90
+ - Run all tests: `npm test`
91
+ - Run with coverage: `npm test -- --coverage`
92
+ - Minimum coverage: 80% for business logic, 60% for components
93
+ - Test files: `*.test.ts` or `*.test.tsx` co-located with source
94
+ - Use `@testing-library/react` for component tests
95
+ - Mock Supabase client in tests, never hit real database
96
+
97
+ ## Git Conventions
98
+
99
+ - **Commits:** Conventional commits (`feat:`, `fix:`, `docs:`, `chore:`, `test:`, `refactor:`)
100
+ - **Branches:** `feat/description`, `fix/description`, `chore/description`
101
+ - **PR titles:** Same as conventional commits
102
+ - Reference issue/story: `feat: add user profile page [STORY-1.2]`
103
+
104
+ ## Common Commands
105
+
106
+ ```bash
107
+ npm run dev # Start development server (localhost:3000)
108
+ npm run build # Production build
109
+ npm run start # Start production server
110
+ npm test # Run Jest tests
111
+ npm run lint # ESLint check
112
+ npm run lint:fix # ESLint auto-fix
113
+ npm run typecheck # TypeScript type checking
114
+ npm run format # Prettier formatting
115
+ ```
116
+
117
+ ## Environment Variables
118
+
119
+ - `.env.local` for local development (gitignored)
120
+ - `.env.example` as template (committed)
121
+ - Required: `NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`
122
+ - Server-only: `SUPABASE_SERVICE_ROLE_KEY` (never prefix with `NEXT_PUBLIC_`)
123
+
124
+ ## Error Handling
125
+
126
+ ```typescript
127
+ // API route pattern
128
+ export async function GET(request: Request) {
129
+ try {
130
+ const data = await fetchData();
131
+ return NextResponse.json({ data });
132
+ } catch (error) {
133
+ console.error('GET /api/resource failed:', error);
134
+ return NextResponse.json(
135
+ { error: 'Failed to fetch resource' },
136
+ { status: 500 }
137
+ );
138
+ }
139
+ }
140
+ ```
141
+
142
+ ## Important Notes
143
+
144
+ - Always check `npm run typecheck` before committing
145
+ - Never store secrets in client-side code or `NEXT_PUBLIC_` variables
146
+ - Use `loading.tsx` and `error.tsx` for route-level loading/error states
147
+ - Prefer Server Actions for mutations over API routes when possible