claude-code-orchestrator-kit 1.2.4 → 1.2.5

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.
@@ -0,0 +1,327 @@
1
+ ---
2
+ description: Code reuse detection and consolidation workflow with full cycle management
3
+ ---
4
+
5
+ # Code Reuse Health Check
6
+
7
+ > **PATTERN**: Agent-based orchestration (see `docs/Agents Ecosystem/AGENT-ORCHESTRATION.md` for details)
8
+
9
+ Complete code duplication detection and consolidation workflow with orchestrator-worker coordination.
10
+
11
+ **What it does:**
12
+ - Full duplication detection (types, schemas, constants, utilities)
13
+ - Staged consolidation (HIGH → MEDIUM → LOW priority)
14
+ - Quality gates after each stage
15
+ - Verification scan
16
+ - Up to 3 iterations if issues remain
17
+ - Comprehensive final report
18
+
19
+ **No configuration needed** - runs comprehensive checks always.
20
+
21
+ ---
22
+
23
+ ## Your Task
24
+
25
+ ### Step 1: Phase 0 - Invoke Orchestrator (Pre-flight)
26
+
27
+ Use Task tool to invoke reuse-orchestrator for pre-flight validation:
28
+
29
+ ```
30
+ subagent_type: "reuse-orchestrator"
31
+ description: "Reuse orchestrator pre-flight"
32
+ prompt: "Execute Phase 0: Pre-flight Validation
33
+
34
+ Tasks:
35
+ 1. Validate environment (package.json, scripts, git status)
36
+ 2. Initialize progress tracking via TodoWrite
37
+ 3. Initialize iteration tracking (iteration=1, max=3)
38
+ 4. Create .tmp/current/plans/reuse-detection.json for rollback tracking
39
+ 5. Report pre-flight status
40
+
41
+ IMPORTANT: After completing pre-flight, create .tmp/current/plans/reuse-detection.json and return control to main session.
42
+
43
+ Return the following information:
44
+ - Pre-flight status (✅/⛔)
45
+ - Environment validation results
46
+ - Plan file path created
47
+ - Ready for next phase: true/false
48
+ "
49
+ ```
50
+
51
+ **Then**: Wait for orchestrator to return.
52
+
53
+ ---
54
+
55
+ ### Step 2: Phase 1 - Invoke reuse-hunter (Detection)
56
+
57
+ After orchestrator returns:
58
+
59
+ 1. **Read plan file** to confirm it was created:
60
+ ```
61
+ Use Read tool: .tmp/current/plans/reuse-detection.json
62
+ Verify nextAgent === "reuse-hunter"
63
+ ```
64
+
65
+ 2. **Invoke reuse-hunter** using Task tool:
66
+ ```
67
+ subagent_type: "reuse-hunter"
68
+ description: "Code duplication detection phase"
69
+ prompt: "Execute code duplication detection based on plan file: .tmp/current/plans/reuse-detection.json
70
+
71
+ Read the plan file and execute comprehensive duplication detection:
72
+ - Scan entire codebase for duplicated types, interfaces, Zod schemas
73
+ - Find duplicated constants and configuration objects
74
+ - Identify utility functions that are copied instead of imported
75
+ - Categorize by priority (HIGH → MEDIUM → LOW)
76
+ - Generate reuse-hunting-report.md
77
+
78
+ Return to main session when complete."
79
+ ```
80
+
81
+ **Then**: Wait for reuse-hunter to return with report.
82
+
83
+ ---
84
+
85
+ ### Step 3: Quality Gate 1 - Resume Orchestrator (Validate Detection)
86
+
87
+ After reuse-hunter returns:
88
+
89
+ 1. **Resume orchestrator** for validation using Task tool:
90
+ ```
91
+ subagent_type: "reuse-orchestrator"
92
+ description: "Validate duplication detection"
93
+ prompt: "Execute Quality Gate 1: Detection Validation
94
+
95
+ Phase: Validate reuse-hunter output
96
+
97
+ Tasks:
98
+ 1. Verify reuse-hunting-report.md exists
99
+ 2. Validate report structure (required sections)
100
+ 3. Parse duplication counts by priority
101
+ 4. Run type-check validation (non-blocking warning)
102
+ 5. Report gate results
103
+
104
+ IMPORTANT: After validation, if duplications found:
105
+ - Create .tmp/current/plans/reuse-consolidation-{priority}.json for highest priority
106
+ - Return control to main session
107
+
108
+ If no duplications found or all gates fail:
109
+ - Skip to final summary
110
+ - Return control
111
+
112
+ Return the following:
113
+ - Gate status (✅ PASSED / ⛔ FAILED / ⚠️ WARNINGS)
114
+ - Duplication counts by priority
115
+ - Next phase: consolidation-high / consolidation-medium / final-summary
116
+ - Plan file created (if applicable)
117
+ "
118
+ ```
119
+
120
+ **Then**: Wait for orchestrator validation results.
121
+
122
+ ---
123
+
124
+ ### Step 4: Phase 2-4 - Consolidation Stages (Iterative)
125
+
126
+ After orchestrator returns with consolidation plan:
127
+
128
+ **For each priority level** (HIGH → MEDIUM → LOW):
129
+
130
+ 1. **Check if this priority has duplications**:
131
+ - Read orchestrator response
132
+ - If orchestrator says "skip to next priority" → continue loop
133
+ - If orchestrator says "final summary" → go to Step 5
134
+
135
+ 2. **Read consolidation plan**:
136
+ ```
137
+ Use Read tool: .tmp/current/plans/reuse-consolidation-{priority}.json
138
+ Verify nextAgent === "reuse-fixer"
139
+ Verify config.priority === "{current-priority}"
140
+ ```
141
+
142
+ 3. **Invoke reuse-fixer** using Task tool:
143
+ ```
144
+ subagent_type: "reuse-fixer"
145
+ description: "Consolidate {priority} duplications"
146
+ prompt: "Execute code consolidation based on plan file: .tmp/current/plans/reuse-consolidation-{priority}.json
147
+
148
+ Read the plan file and consolidate duplications for priority: {priority}
149
+ - Read reuse-hunting-report.md for duplication list
150
+ - For each duplication:
151
+ - Determine canonical location (usually shared-types)
152
+ - Create/update canonical file
153
+ - Replace duplicates with re-exports
154
+ - Log changes to .reuse-changes.json
155
+ - Update reuse-consolidation-implemented.md (consolidated report)
156
+
157
+ Return to main session when complete."
158
+ ```
159
+
160
+ 4. **Resume orchestrator** for validation:
161
+ ```
162
+ subagent_type: "reuse-orchestrator"
163
+ description: "Validate {priority} consolidation"
164
+ prompt: "Execute Quality Gate 2: Consolidation Validation for priority={priority}
165
+
166
+ Tasks:
167
+ 1. Verify reuse-consolidation-implemented.md exists
168
+ 2. Run type-check (BLOCKING)
169
+ 3. Run build (BLOCKING)
170
+ 4. Parse consolidation success rate
171
+ 5. Check if retry needed (if < 80% success)
172
+
173
+ If validation PASSES and more priorities remain:
174
+ - Create next .tmp/current/plans/reuse-consolidation-{priority}.json
175
+ - Return control
176
+
177
+ If validation FAILS:
178
+ - Provide rollback instructions
179
+ - Return control with error
180
+
181
+ If all priorities complete:
182
+ - Proceed to verification phase
183
+ - Return control
184
+
185
+ Return:
186
+ - Gate status
187
+ - Consolidation success rate
188
+ - Next phase: consolidation-{next-priority} / verification / final-summary
189
+ "
190
+ ```
191
+
192
+ 5. **Repeat** for next priority level.
193
+
194
+ ---
195
+
196
+ ### Step 5: Phase 5 - Verification
197
+
198
+ After all consolidation stages complete:
199
+
200
+ 1. **Resume orchestrator** for verification:
201
+ ```
202
+ subagent_type: "reuse-orchestrator"
203
+ description: "Create verification plan"
204
+ prompt: "Execute Phase 5: Verification Preparation
205
+
206
+ Create .tmp/current/plans/reuse-verification.json for re-scanning codebase.
207
+
208
+ Return control with plan file path."
209
+ ```
210
+
211
+ 2. **Invoke reuse-hunter** for verification:
212
+ ```
213
+ subagent_type: "reuse-hunter"
214
+ description: "Verification scan"
215
+ prompt: "Execute verification scan based on: .tmp/current/plans/reuse-verification.json
216
+
217
+ Re-scan codebase to verify consolidations. Overwrites reuse-hunting-report.md.
218
+
219
+ Return when complete."
220
+ ```
221
+
222
+ 3. **Resume orchestrator** for verification validation:
223
+ ```
224
+ subagent_type: "reuse-orchestrator"
225
+ description: "Validate verification"
226
+ prompt: "Execute Quality Gate 3: Verification Validation
227
+
228
+ Compare original reuse-hunting-report.md (baseline) with new scan:
229
+ - Count duplications resolved
230
+ - Check if new duplications introduced
231
+ - Determine if iteration needed
232
+
233
+ Return:
234
+ - Verification status
235
+ - Duplications remaining
236
+ - Iteration decision: iterate / complete
237
+ "
238
+ ```
239
+
240
+ ---
241
+
242
+ ### Step 6: Final Summary
243
+
244
+ After all phases complete:
245
+
246
+ 1. **Resume orchestrator** for final summary:
247
+ ```
248
+ subagent_type: "reuse-orchestrator"
249
+ description: "Generate final summary"
250
+ prompt: "Execute Phase 7: Final Summary
251
+
252
+ Generate comprehensive reuse-orchestration-summary.md:
253
+ - All duplications detected
254
+ - All consolidations performed
255
+ - Success rates by priority
256
+ - Validation results
257
+ - Iteration summary
258
+ - Cleanup instructions
259
+
260
+ Return final summary."
261
+ ```
262
+
263
+ 2. **Display results** to user:
264
+ ```
265
+ Read reuse-orchestration-summary.md
266
+ Display key metrics
267
+ Show validation status
268
+ List next steps
269
+ ```
270
+
271
+ ---
272
+
273
+ ## Example Usage
274
+
275
+ ```bash
276
+ # Run complete code reuse workflow
277
+ /health-reuse
278
+ ```
279
+
280
+ ---
281
+
282
+ ## Architecture Notes
283
+
284
+ **Orchestrator Role**:
285
+ - Creates plan files
286
+ - Validates worker outputs
287
+ - Returns control to main session
288
+ - NO direct worker invocation
289
+
290
+ **Main Session Role** (this command):
291
+ - Reads plan files
292
+ - Invokes workers via Task tool
293
+ - Resumes orchestrator for validation
294
+ - Manages full cycle
295
+
296
+ **Worker Role**:
297
+ - Reads plan file
298
+ - Executes work
299
+ - Generates report
300
+ - Returns to main session
301
+
302
+ This pattern follows Claude Code's actual capabilities (no auto-invoke).
303
+
304
+ ---
305
+
306
+ ## Duplication Categories
307
+
308
+ **Types/Interfaces** (shared-types):
309
+ - Database types
310
+ - API types
311
+ - Zod schemas
312
+ - Common enums
313
+
314
+ **Constants** (shared-types):
315
+ - Configuration objects
316
+ - MIME types, file limits
317
+ - Feature flags
318
+
319
+ **Utilities** (shared package or re-export):
320
+ - Helper functions
321
+ - Validation utilities
322
+ - Formatters
323
+
324
+ **Single Source of Truth Pattern**:
325
+ 1. Canonical location: `packages/shared-types/src/`
326
+ 2. Other packages: `export * from '@megacampus/shared-types/{module}'`
327
+ 3. NEVER copy code between packages
@@ -14,6 +14,13 @@ You **MUST** consider the user input before proceeding (if not empty).
14
14
 
15
15
  ## Outline
16
16
 
17
+ 0. **Session Check** (DeksdenFlow):
18
+ - Invoke `resume-session` skill to check for existing session
19
+ - If valid session found: ask user "Resume previous session or start fresh?"
20
+ - If resume: load context.md and session-log.md, jump to saved phase
21
+ - If fresh or no session: proceed to step 1
22
+ - **Also**: Invoke `load-project-context` skill to load project structure map
23
+
17
24
  1. Run `.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
18
25
 
19
26
  2. **Check checklists status** (if FEATURE_DIR/checklists/ exists):
@@ -145,6 +152,10 @@ You **MUST** consider the user input before proceeding (if not empty).
145
152
  - [EXECUTOR: MAIN]? → Execute directly if trivial, else delegate
146
153
  - [EXECUTOR: subagent-name]? → Delegate to specified subagent
147
154
  3. GATHER CONTEXT: Read existing code, search patterns, review docs, check commits
155
+ 3.5. LIBRARY SEARCH: Before writing >20 lines of new code, search for existing npm/pypi packages
156
+ - Use WebSearch + Context7 to find and evaluate libraries
157
+ - If suitable library found: install and configure instead of implementing from scratch
158
+ - Check: weekly downloads >1000, recent commits, TypeScript support, no critical vulnerabilities
148
159
  4. EXECUTE:
149
160
  - Direct: Use Edit/Write tools for trivial tasks only
150
161
  - Delegated: Launch Task tool with complete context (code snippets, file paths, patterns, validation criteria)
@@ -172,6 +183,10 @@ You **MUST** consider the user input before proceeding (if not empty).
172
183
  - Provide clear error messages with context for debugging
173
184
  - Suggest next steps if implementation cannot proceed
174
185
  - **IMPORTANT** For completed tasks, make sure to mark the task off as [X] in the tasks file
186
+ - **Session Context** (DeksdenFlow):
187
+ * After completing each PHASE (not task): invoke `save-session-context` skill
188
+ * On error or pause: save context before stopping
189
+ * Log significant decisions to session-log.md (architecture choices, issue resolutions)
175
190
  - **Critical Rules**:
176
191
  * NEVER skip verification
177
192
  * NEVER proceed if task failed
@@ -56,7 +56,12 @@ You **MUST** consider the user input before proceeding (if not empty).
56
56
  - Rationale: [why chosen]
57
57
  - Alternatives considered: [what else evaluated]
58
58
 
59
- **Output**: research.md with all NEEDS CLARIFICATION resolved
59
+ 4. **Library discovery** for each planned component:
60
+ - Search npm/pypi for existing solutions (WebSearch + Context7)
61
+ - Evaluate: maintenance status (commits last 6 months), weekly downloads >1000, TypeScript support
62
+ - Document in research.md: chosen libraries with rationale, or justification for custom implementation
63
+
64
+ **Output**: research.md with all NEEDS CLARIFICATION resolved and library decisions documented
60
65
 
61
66
  ### Phase 1: Design & Contracts
62
67
 
@@ -71,6 +71,13 @@ The tasks.md should be immediately executable - each task must be specific enoug
71
71
 
72
72
  **Tests are OPTIONAL**: Only generate test tasks if explicitly requested in the feature specification or if user requests TDD approach.
73
73
 
74
+ **Library Evaluation (BEFORE creating implementation tasks)**:
75
+ - For each major component (>20 lines), check if suitable library exists
76
+ - Use research.md library decisions from planning phase
77
+ - If suitable library found: task becomes "Install and configure {library} for {functionality}"
78
+ - If no suitable library: task becomes "Implement {component} in {file_path}"
79
+ - Document library choice rationale in task description when relevant
80
+
74
81
  ### Checklist Format (REQUIRED)
75
82
 
76
83
  Every task MUST strictly follow this format:
@@ -0,0 +1,75 @@
1
+ # Project Index: Claude Code Orchestrator Kit
2
+
3
+ > Quick navigation for AI agents. Updated: 2025-11-27
4
+ >
5
+ > **Purpose:** Helps agents understand project structure without reading entire codebase.
6
+
7
+ ## Architecture
8
+
9
+ - **[CLAUDE.md](../../CLAUDE.md)** — Behavioral rules, orchestration patterns, main entry point
10
+ - **[docs/ARCHITECTURE.md](../../docs/ARCHITECTURE.md)** — System design, C4 diagrams, workflow patterns
11
+ - **[docs/FAQ.md](../../docs/FAQ.md)** — Common questions and answers
12
+
13
+ ## Core Domains
14
+
15
+ ### Agents (.claude/agents/)
16
+ - **[agents/](agents/)** — 33+ specialized AI agents
17
+ - **[health/orchestrators/](agents/health/orchestrators/)** — Bug, security, deps, cleanup workflows
18
+ - **[health/workers/](agents/health/workers/)** — Bug-hunter, bug-fixer, security-scanner, etc.
19
+ - **[development/workers/](agents/development/workers/)** — LLM, TypeScript, cost specialists
20
+ - **[meta/workers/](agents/meta/workers/)** — meta-agent-v3, skill-builder-v2
21
+ - Pattern: Orchestrator delegates to Workers via Task tool
22
+
23
+ ### Commands (.claude/commands/)
24
+ - **[commands/](commands/)** — 19+ slash commands
25
+ - Key: `health-*.md` — Health monitoring workflows
26
+ - Key: `speckit.*.md` — Specification toolkit
27
+ - Key: `push.md` — Release automation
28
+ - Pattern: Commands trigger orchestrators or direct actions
29
+
30
+ ### Skills (.claude/skills/)
31
+ - **[skills/](skills/)** — 15+ reusable utilities
32
+ - Key: `run-quality-gate/` — Type-check, build, tests validation
33
+ - Key: `validate-plan-file/` — JSON schema validation
34
+ - Key: `rollback-changes/` — File restoration
35
+ - Pattern: Stateless utilities, <100 lines, invoked via Skill tool
36
+
37
+ ### MCP Configurations (mcp/)
38
+ - **[mcp/](../../mcp/)** — 7 MCP server configurations
39
+ - Key: `.mcp.base.json` — Minimal (~600 tokens)
40
+ - Key: `.mcp.serena.json` — LSP semantic search (~2500 tokens)
41
+ - Key: `.mcp.full.json` — All servers (~6500 tokens)
42
+ - Pattern: switch-mcp.sh for dynamic switching
43
+
44
+ ## Temporary Files
45
+
46
+ - **[.tmp/current/](../../.tmp/current/)** — Active workflow artifacts (git-ignored)
47
+ - `plans/` — Orchestrator plan files
48
+ - `reports/` — Worker-generated reports
49
+ - `session/` — Session context and logs
50
+
51
+ ## Configuration
52
+
53
+ - **[.env.example](../../.env.example)** — Environment variables template
54
+ - **[switch-mcp.sh](../../switch-mcp.sh)** — MCP configuration switcher
55
+
56
+ ## Patterns & Conventions
57
+
58
+ - **Orchestration:** Main Claude Code delegates to sub-agents via Task tool
59
+ - **Verification:** Always read modified files + run type-check after delegation
60
+ - **Quality Gates:** type-check, build, tests must pass before commit
61
+ - **Commits:** `/push patch` after each completed task
62
+
63
+ ## Key Entry Points
64
+
65
+ | Purpose | File | Description |
66
+ |---------|------|-------------|
67
+ | Behavioral rules | `CLAUDE.md` | Read by Claude Code at session start |
68
+ | Agent selection | `settings.local.json` | Task tool subagent_type mapping |
69
+ | Health workflows | `commands/health-*.md` | Entry points for health checks |
70
+
71
+ ## Recent Changes
72
+
73
+ - 2025-11-27: Added Serena MCP, DeksdenFlow integration started
74
+ - 2025-11-27: Added reuse-hunting workflow agents
75
+ - 2025-11-26: Updated agent configurations
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: load-project-context
3
+ description: Load project structure and navigation for complex tasks. Use when exploring unfamiliar parts of codebase or starting complex multi-file tasks.
4
+ trigger: When exploring unfamiliar code areas, planning complex features, or needing project structure overview
5
+ ---
6
+
7
+ # Load Project Context
8
+
9
+ Loads the project index file to understand project structure without reading the entire codebase.
10
+
11
+ ## When to Use
12
+
13
+ - Before exploring unfamiliar parts of the codebase
14
+ - When planning complex multi-file changes
15
+ - When you need to understand where specific functionality lives
16
+ - At the start of complex orchestrator workflows
17
+
18
+ ## When NOT to Use
19
+
20
+ - For simple, single-file tasks
21
+ - When you already know the file locations
22
+ - For trivial bug fixes
23
+
24
+ ## Algorithm
25
+
26
+ 1. Check if `.claude/project-index.md` exists
27
+ 2. If exists:
28
+ - Read the file
29
+ - Return the content for agent consumption
30
+ 3. If not exists:
31
+ - Inform that project index is not configured
32
+ - Suggest creating one from template
33
+
34
+ ## Implementation
35
+
36
+ ```markdown
37
+ ### Step 1: Check for project index
38
+
39
+ Read the file `.claude/project-index.md`
40
+
41
+ ### Step 2: If file exists
42
+
43
+ Return the full content. The agent should use this to:
44
+ - Understand project structure
45
+ - Identify key directories for the task
46
+ - Find relevant patterns and conventions
47
+
48
+ ### Step 3: If file does not exist
49
+
50
+ Return this message:
51
+ "Project index not found. To create one:
52
+ 1. Copy `.claude/templates/project-index.template.md` to `.claude/project-index.md`
53
+ 2. Customize for your project structure
54
+ 3. Keep under 150 lines for token efficiency"
55
+ ```
56
+
57
+ ## Output Format
58
+
59
+ The skill returns the project index content directly, which includes:
60
+ - Architecture overview with links
61
+ - Core domains with key directories
62
+ - Patterns and conventions
63
+ - Recent changes
64
+
65
+ ## Token Cost
66
+
67
+ - File read: ~100-200 tokens (if index is well-maintained at <150 lines)
68
+ - No additional processing overhead
69
+
70
+ ## Example Usage
71
+
72
+ ```
73
+ Agent: I need to understand where authentication is handled in this project.
74
+
75
+ [Invokes load-project-context skill]
76
+
77
+ Skill returns project-index.md content showing:
78
+ - Auth pattern: "Supabase Auth + RLS policies"
79
+ - Key directory: "packages/api/src/middleware/" for auth middleware
80
+
81
+ Agent now knows exactly where to look without scanning entire codebase.
82
+ ```
83
+
84
+ ## Maintenance
85
+
86
+ The project index should be updated:
87
+ - When major architectural changes occur
88
+ - Weekly for "Recent Changes" section
89
+ - When new domains/packages are added