@champpaba/claude-agent-kit 1.0.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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +561 -0
  3. package/bin/cli.js +61 -0
  4. package/lib/init.js +52 -0
  5. package/lib/update.js +73 -0
  6. package/package.json +47 -0
  7. package/template/.claude/CHANGELOG-v1.1.1.md +259 -0
  8. package/template/.claude/CLAUDE.md +329 -0
  9. package/template/.claude/agents/01-integration.md +797 -0
  10. package/template/.claude/agents/02-uxui-frontend.md +899 -0
  11. package/template/.claude/agents/03-test-debug.md +759 -0
  12. package/template/.claude/agents/04-frontend.md +1099 -0
  13. package/template/.claude/agents/05-backend.md +1217 -0
  14. package/template/.claude/agents/06-database.md +969 -0
  15. package/template/.claude/commands/agentsetup.md +1464 -0
  16. package/template/.claude/commands/cdev.md +327 -0
  17. package/template/.claude/commands/csetup.md +447 -0
  18. package/template/.claude/commands/cstatus.md +60 -0
  19. package/template/.claude/commands/cview.md +364 -0
  20. package/template/.claude/commands/psetup.md +101 -0
  21. package/template/.claude/contexts/design/accessibility.md +611 -0
  22. package/template/.claude/contexts/design/box-thinking.md +553 -0
  23. package/template/.claude/contexts/design/color-theory.md +498 -0
  24. package/template/.claude/contexts/design/index.md +247 -0
  25. package/template/.claude/contexts/design/layout.md +400 -0
  26. package/template/.claude/contexts/design/responsive.md +551 -0
  27. package/template/.claude/contexts/design/shadows.md +522 -0
  28. package/template/.claude/contexts/design/spacing.md +428 -0
  29. package/template/.claude/contexts/design/typography.md +465 -0
  30. package/template/.claude/contexts/domain/README.md +164 -0
  31. package/template/.claude/contexts/patterns/agent-coordination.md +388 -0
  32. package/template/.claude/contexts/patterns/agent-discovery.md +182 -0
  33. package/template/.claude/contexts/patterns/change-workflow.md +538 -0
  34. package/template/.claude/contexts/patterns/code-standards.md +515 -0
  35. package/template/.claude/contexts/patterns/development-principles.md +513 -0
  36. package/template/.claude/contexts/patterns/error-handling.md +478 -0
  37. package/template/.claude/contexts/patterns/error-recovery.md +365 -0
  38. package/template/.claude/contexts/patterns/frontend-component-strategy.md +365 -0
  39. package/template/.claude/contexts/patterns/git-workflow.md +207 -0
  40. package/template/.claude/contexts/patterns/logging.md +424 -0
  41. package/template/.claude/contexts/patterns/task-breakdown.md +452 -0
  42. package/template/.claude/contexts/patterns/task-classification.md +523 -0
  43. package/template/.claude/contexts/patterns/tdd-classification.md +516 -0
  44. package/template/.claude/contexts/patterns/testing.md +413 -0
  45. package/template/.claude/contexts/patterns/ui-component-consistency.md +304 -0
  46. package/template/.claude/contexts/patterns/validation-framework.md +776 -0
  47. package/template/.claude/lib/README.md +39 -0
  48. package/template/.claude/lib/agent-executor.md +258 -0
  49. package/template/.claude/lib/agent-router.md +572 -0
  50. package/template/.claude/lib/flags-updater.md +469 -0
  51. package/template/.claude/lib/tdd-classifier.md +345 -0
  52. package/template/.claude/lib/validation-gates.md +484 -0
  53. package/template/.claude/settings.local.json +42 -0
  54. package/template/.claude/templates/context-template.md +45 -0
  55. package/template/.claude/templates/flags-template.json +42 -0
  56. package/template/.claude/templates/phase-templates.json +124 -0
  57. package/template/.claude/templates/phases-sections/accessibility-test.md +17 -0
  58. package/template/.claude/templates/phases-sections/api-design.md +37 -0
  59. package/template/.claude/templates/phases-sections/backend-tests.md +16 -0
  60. package/template/.claude/templates/phases-sections/backend.md +37 -0
  61. package/template/.claude/templates/phases-sections/business-logic-validation.md +16 -0
  62. package/template/.claude/templates/phases-sections/component-tests.md +17 -0
  63. package/template/.claude/templates/phases-sections/contract-backend.md +16 -0
  64. package/template/.claude/templates/phases-sections/contract-frontend.md +16 -0
  65. package/template/.claude/templates/phases-sections/database.md +35 -0
  66. package/template/.claude/templates/phases-sections/documentation.md +17 -0
  67. package/template/.claude/templates/phases-sections/e2e-tests.md +16 -0
  68. package/template/.claude/templates/phases-sections/fix-implementation.md +17 -0
  69. package/template/.claude/templates/phases-sections/frontend-integration.md +18 -0
  70. package/template/.claude/templates/phases-sections/frontend-mockup.md +123 -0
  71. package/template/.claude/templates/phases-sections/manual-flow-test.md +15 -0
  72. package/template/.claude/templates/phases-sections/manual-ux-test.md +16 -0
  73. package/template/.claude/templates/phases-sections/refactor-implementation.md +17 -0
  74. package/template/.claude/templates/phases-sections/refactor.md +16 -0
  75. package/template/.claude/templates/phases-sections/regression-tests.md +15 -0
  76. package/template/.claude/templates/phases-sections/report.md +16 -0
  77. package/template/.claude/templates/phases-sections/responsive-test.md +16 -0
  78. package/template/.claude/templates/phases-sections/script-implementation.md +43 -0
  79. package/template/.claude/templates/phases-sections/test-coverage.md +16 -0
  80. package/template/.claude/templates/phases-sections/user-approval.md +14 -0
package/lib/update.js ADDED
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Update Command - Update Claude Agent Kit template to latest version
3
+ *
4
+ * This function updates the .claude/ folder with the latest template files.
5
+ */
6
+
7
+ const fs = require('fs-extra');
8
+ const path = require('path');
9
+ const chalk = require('chalk');
10
+
11
+ module.exports = async function update(options = {}) {
12
+ const { backup } = options;
13
+
14
+ // Paths
15
+ const templatePath = path.join(__dirname, '../template/.claude');
16
+ const targetPath = path.join(process.cwd(), '.claude');
17
+ const backupPath = path.join(process.cwd(), '.claude.backup');
18
+
19
+ console.log(chalk.cyan('\n🤖 Claude Agent Kit - Updating...\n'));
20
+
21
+ // Check if .claude/ exists
22
+ if (!fs.existsSync(targetPath)) {
23
+ console.log(chalk.yellow('⚠️ .claude/ not found in this project.'));
24
+ console.log(chalk.gray(' Run init first:\n'));
25
+ console.log(chalk.cyan(' cak init\n'));
26
+ return;
27
+ }
28
+
29
+ // Check if template exists
30
+ if (!fs.existsSync(templatePath)) {
31
+ throw new Error('Template folder not found. Please reinstall the package.');
32
+ }
33
+
34
+ // Create backup if requested
35
+ if (backup) {
36
+ console.log(chalk.gray('📦 Creating backup...\n'));
37
+
38
+ // Remove old backup if exists
39
+ if (fs.existsSync(backupPath)) {
40
+ await fs.remove(backupPath);
41
+ }
42
+
43
+ // Copy current .claude/ to backup
44
+ await fs.copy(targetPath, backupPath);
45
+ console.log(chalk.green('✅ Backup created: ') + chalk.cyan('.claude.backup\n'));
46
+ }
47
+
48
+ // Update template
49
+ try {
50
+ // Strategy: Overwrite all files from template
51
+ // User customizations in domain/ should be preserved if they don't conflict
52
+ await fs.copy(templatePath, targetPath, {
53
+ overwrite: true,
54
+ errorOnExist: false
55
+ });
56
+
57
+ console.log(chalk.green('✅ Successfully updated Claude Agent Kit!\n'));
58
+ console.log(chalk.white('📁 Updated files in: ') + chalk.cyan(targetPath));
59
+
60
+ if (backup) {
61
+ console.log(chalk.white('\n💾 Backup available at: ') + chalk.cyan(backupPath));
62
+ console.log(chalk.gray(' You can restore it if needed:\n'));
63
+ console.log(chalk.cyan(' rm -rf .claude && mv .claude.backup .claude\n'));
64
+ }
65
+
66
+ console.log(chalk.white('\n📚 What\'s new:\n'));
67
+ console.log(chalk.gray(' Check CHANGELOG.md for latest changes'));
68
+ console.log(chalk.gray(' Or visit: ') + chalk.cyan('https://github.com/your-username/claude-agent-kit\n'));
69
+
70
+ } catch (error) {
71
+ throw new Error(`Failed to update template: ${error.message}`);
72
+ }
73
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@champpaba/claude-agent-kit",
3
+ "version": "1.0.0",
4
+ "description": "Universal multi-agent template for Claude Code - AI-assisted development with specialized agents",
5
+ "main": "bin/cli.js",
6
+ "bin": {
7
+ "claude-agent-kit": "./bin/cli.js",
8
+ "cak": "./bin/cli.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "lib/",
13
+ "template/"
14
+ ],
15
+ "scripts": {
16
+ "test": "echo \"No tests yet\" && exit 0"
17
+ },
18
+ "keywords": [
19
+ "claude",
20
+ "claude-code",
21
+ "ai",
22
+ "agents",
23
+ "multi-agent",
24
+ "template",
25
+ "cli",
26
+ "development",
27
+ "automation"
28
+ ],
29
+ "author": "ChampPABA <aimilic@gmail.com>",
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/ChampPABA/claude-multi-agent-template"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/ChampPABA/claude-multi-agent-template/issues"
37
+ },
38
+ "homepage": "https://github.com/ChampPABA/claude-multi-agent-template#readme",
39
+ "dependencies": {
40
+ "commander": "^12.0.0",
41
+ "fs-extra": "^11.2.0",
42
+ "chalk": "^4.1.2"
43
+ },
44
+ "engines": {
45
+ "node": ">=14.0.0"
46
+ }
47
+ }
@@ -0,0 +1,259 @@
1
+ # Changelog v1.1.1 - Critical Fixes
2
+
3
+ > **Release Date:** 2025-10-31
4
+ > **Type:** Bug fixes and enforcement improvements
5
+ > **Status:** Production-ready
6
+
7
+ ---
8
+
9
+ ## 🎯 Problem Statement
10
+
11
+ Two critical issues identified in real-world usage:
12
+
13
+ 1. **Main Agent Not Updating flags.json**
14
+ - Users couldn't track progress
15
+ - flags.json rarely updated after phase completion
16
+ - ~30% update rate (should be 100%)
17
+
18
+ 2. **Main Agent Doing Work Directly**
19
+ - Implementation work not delegated to specialized agents
20
+ - Only ~60% proper delegation rate (should be 95%+)
21
+ - Lost benefits of specialized agents
22
+
23
+ ---
24
+
25
+ ## 🔧 Solutions Implemented
26
+
27
+ ### ✅ Solution 1: Mandatory Progress Tracking
28
+
29
+ **New File:** `.claude/lib/flags-updater.md`
30
+
31
+ **What it does:**
32
+ - Defines WHO updates flags.json: Main Claude (NOT sub-agents)
33
+ - Defines WHEN: Immediately after sub-agent completes
34
+ - Defines HOW: Exact implementation with helper functions
35
+ - Provides parsing utilities for extracting files, tasks, duration
36
+
37
+ **Key Features:**
38
+ ```typescript
39
+ updateFlagsAfterPhase(changeId, phaseName, agentResponse)
40
+ → Extracts files created/modified
41
+ → Calculates actual duration
42
+ → Updates meta statistics (progress %, time remaining)
43
+ → Moves to next phase
44
+ → Reports to user
45
+ ```
46
+
47
+ **Enforcement:**
48
+ - Updated `/cdev` Step 5 to REQUIRE flags update
49
+ - Added to CLAUDE.md as mandatory protocol
50
+ - No exceptions allowed
51
+
52
+ ---
53
+
54
+ ### ✅ Solution 2: Mandatory Agent Routing
55
+
56
+ **New File:** `.claude/lib/agent-router.md`
57
+
58
+ **What it does:**
59
+ - Defines strict agent boundaries
60
+ - Provides work type detection patterns
61
+ - Enforces delegation for implementation work
62
+ - Includes self-check protocol for Main Claude
63
+
64
+ **Key Features:**
65
+ ```typescript
66
+ WORK_PATTERNS = {
67
+ 'ui-component': { agent: 'uxui-frontend', canMainDo: false },
68
+ 'api-endpoint': { agent: 'backend', canMainDo: false },
69
+ 'database-work': { agent: 'database', canMainDo: false },
70
+ 'api-integration': { agent: 'frontend', canMainDo: false },
71
+ 'testing-debugging': { agent: 'test-debug', canMainDo: false },
72
+ 'planning': { agent: 'main-claude', canMainDo: true }
73
+ }
74
+ ```
75
+
76
+ **Enforcement:**
77
+ - Added self-check checklist to CLAUDE.md
78
+ - Main Claude MUST complete before any work
79
+ - Override protection (even if user says "do it yourself")
80
+
81
+ ---
82
+
83
+ ### ✅ Solution 3: Validation Gates
84
+
85
+ **New File:** `.claude/lib/validation-gates.md`
86
+
87
+ **What it does:**
88
+ - Four checkpoints Main Claude MUST pass:
89
+ 1. **Before work** - Ensure correct routing
90
+ 2. **After agent responds** - Validate agent output
91
+ 3. **Before reporting** - Ensure flags.json updated
92
+ 4. **Before phase start** - Check phase readiness
93
+
94
+ **Key Benefits:**
95
+ - Catch errors early
96
+ - Ensure quality at each step
97
+ - Provide clear error messages
98
+ - Enable automatic recovery
99
+
100
+ ---
101
+
102
+ ## 📝 Files Changed
103
+
104
+ ### New Files (3)
105
+ ```
106
+ .claude/lib/
107
+ ├── flags-updater.md (NEW - 450 lines)
108
+ ├── agent-router.md (NEW - 500 lines)
109
+ └── validation-gates.md (NEW - 400 lines)
110
+ ```
111
+
112
+ ### Modified Files (3)
113
+ ```
114
+ .claude/
115
+ ├── CLAUDE.md (MODIFIED - Added self-check protocol)
116
+ ├── lib/README.md (MODIFIED - Added new file descriptions)
117
+ └── commands/cdev.md (MODIFIED - Step 5 now mandatory flags update)
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 📊 Expected Impact
123
+
124
+ ### Metric 1: flags.json Update Rate
125
+ - **Before:** ~30%
126
+ - **After:** 100%
127
+ - **How:** Mandatory update in /cdev Step 5
128
+
129
+ ### Metric 2: Agent Delegation Rate
130
+ - **Before:** ~60%
131
+ - **After:** 95%+
132
+ - **How:** Self-check protocol + work type detection
133
+
134
+ ### Metric 3: User Visibility
135
+ - **Before:** Must run `/cstatus` manually
136
+ - **After:** Auto-reported after every phase
137
+ - **How:** Progress report in flags-updater protocol
138
+
139
+ ---
140
+
141
+ ## 🎯 Breaking Changes
142
+
143
+ **None** - All changes are additive:
144
+ - New files add protocols
145
+ - Existing files enhanced (not breaking)
146
+ - Backward compatible with v1.1.0
147
+
148
+ ---
149
+
150
+ ## ✅ Migration Guide
151
+
152
+ **No migration needed** - Changes are effective immediately:
153
+
154
+ 1. **For existing projects:**
155
+ - Templates automatically use new protocols
156
+ - Next `/cdev` run will use updated Step 5
157
+ - Main Claude will read new CLAUDE.md instructions
158
+
159
+ 2. **For in-progress changes:**
160
+ - Continue current phase normally
161
+ - New protocols apply from next `/cdev` invocation
162
+ - flags.json will start updating correctly
163
+
164
+ ---
165
+
166
+ ## 🔍 Testing Checklist
167
+
168
+ Before considering this release complete, verify:
169
+
170
+ - [ ] `/cdev` updates flags.json after phase completion
171
+ - [ ] Main Claude delegates implementation work (not doing it directly)
172
+ - [ ] Progress reported to user automatically
173
+ - [ ] Self-check protocol appears in Main Claude output
174
+ - [ ] Validation gates catch common errors
175
+ - [ ] `/cview` and `/cstatus` show accurate data
176
+
177
+ ---
178
+
179
+ ## 📚 Documentation Updates
180
+
181
+ ### CLAUDE.md
182
+ - Added "Main Claude Self-Check Protocol" section
183
+ - Links to agent-router.md for complete routing rules
184
+ - Lists new lib/ files in Quick Navigation
185
+
186
+ ### cdev.md
187
+ - Step 5 completely rewritten
188
+ - Now REQUIRES flags.json update
189
+ - Shows exact execution order
190
+ - Includes common mistake examples
191
+
192
+ ### lib/README.md
193
+ - Added descriptions for 3 new files
194
+ - Explains purpose of each
195
+
196
+ ---
197
+
198
+ ## 🚀 Future Enhancements (Not in v1.1.1)
199
+
200
+ **Phase 2 Candidates:**
201
+ - Automated testing of validation gates
202
+ - Progress visualization in terminal
203
+ - Metrics dashboard for delegation rate
204
+ - Agent performance profiling
205
+
206
+ **Phase 3 Candidates:**
207
+ - LLM-based validation (use Claude to validate Claude)
208
+ - Predictive time estimation
209
+ - Automatic recovery from common errors
210
+ - Multi-change parallel execution
211
+
212
+ ---
213
+
214
+ ## 🙏 Acknowledgments
215
+
216
+ Issues identified through:
217
+ - Real-world usage testing
218
+ - User feedback on progress tracking
219
+ - Analysis of Main Agent behavior patterns
220
+
221
+ ---
222
+
223
+ ## 📞 Support
224
+
225
+ **Issues with v1.1.1?**
226
+ 1. Check validation gate error messages
227
+ 2. Verify flags.json exists and is valid JSON
228
+ 3. Review Main Claude output for self-check protocol
229
+ 4. Open issue with details
230
+
231
+ **Questions?**
232
+ - Read: `.claude/lib/flags-updater.md`
233
+ - Read: `.claude/lib/agent-router.md`
234
+ - Read: `.claude/lib/validation-gates.md`
235
+
236
+ ---
237
+
238
+ **Version:** 1.1.1
239
+ **Previous:** 1.1.0
240
+ **Next:** TBD (based on feedback)
241
+
242
+ ---
243
+
244
+ ## 🎯 Quick Reference
245
+
246
+ **Problem 1: flags.json not updated**
247
+ → Solution: `.claude/lib/flags-updater.md`
248
+ → Enforced by: `/cdev` Step 5
249
+
250
+ **Problem 2: Main Agent doing work**
251
+ → Solution: `.claude/lib/agent-router.md`
252
+ → Enforced by: CLAUDE.md self-check protocol
253
+
254
+ **Both problems validated by:**
255
+ → `.claude/lib/validation-gates.md` (4 checkpoints)
256
+
257
+ ---
258
+
259
+ **🎉 Ready for production use!**
@@ -0,0 +1,329 @@
1
+ # CLAUDE.md
2
+
3
+ > **Navigation Hub for AI Agents**
4
+ > **Template Version:** 1.1.0 - Universal Multi-Agent Template
5
+ > **Latest:** Production-ready with validation enforcement, TDD classification, and retry logic
6
+
7
+ ---
8
+
9
+ ## 🎯 What is This Template?
10
+
11
+ Universal, framework-agnostic template for AI-assisted development.
12
+
13
+ **What's Included:**
14
+ - ✅ 6 Specialized Agents (integration + 5 domain specialists)
15
+ - ✅ Universal Patterns (logging, testing, error-handling, agent selection)
16
+ - ✅ Design Foundation (color theory, spacing, typography)
17
+ - ✅ **Auto-Generated Best Practices** (from Context7 MCP per project)
18
+ - ✅ **3-Level Indexing** (agents auto-discover project context)
19
+ - ✅ Domain-Specific Support (add your business logic)
20
+
21
+ **What's NOT Included:**
22
+ - ❌ Framework patterns → Generated dynamically via `/agentsetup`
23
+ - ❌ Package managers → Detected by `/agentsetup`
24
+ - ❌ Spec frameworks → Optional (OpenSpec, BMAD, SpecKit)
25
+
26
+ ---
27
+
28
+ ## 📖 Quick Navigation
29
+
30
+ **Design/UI:**
31
+ - `@/.claude/contexts/design/index.md` (Start here)
32
+ - `@/.claude/contexts/design/box-thinking.md` (Layout analysis)
33
+ - `@/.claude/contexts/patterns/ui-component-consistency.md` (Visual consistency)
34
+
35
+ **Development:**
36
+ - `@/.claude/contexts/patterns/task-classification.md` (Agent selection guide)
37
+ - `@/.claude/contexts/patterns/agent-coordination.md` (When to run agents parallel/sequential)
38
+ - `@/.claude/contexts/patterns/error-recovery.md` (How agents handle errors & escalate)
39
+ - `@/.claude/contexts/patterns/logging.md`
40
+ - `@/.claude/contexts/patterns/testing.md`
41
+ - `@/.claude/contexts/patterns/task-breakdown.md`
42
+ - `@/.claude/contexts/patterns/frontend-component-strategy.md`
43
+
44
+ **Project Setup:**
45
+ - `/psetup` - One-time project setup (detect tech stack, generate best practices)
46
+ - `/agentsetup` - Auto-detect tech stack and generate best practices
47
+
48
+ **OpenSpec Multi-Agent Workflow:**
49
+ - `/csetup {change-id}` - Setup change context (analyze tasks, generate workflow)
50
+ - `/cdev {change-id}` - Start/continue multi-agent development
51
+ - `/cview {change-id}` - View detailed progress for a change
52
+ - `/cstatus {change-id}` - Quick progress status for a change
53
+
54
+ **Best Practices (Dynamic):**
55
+ - `.claude/contexts/domain/{project}/best-practices/` (generated by `/agentsetup`)
56
+ - Framework-specific guidelines from Context7 MCP
57
+
58
+ **Indexing (3 Levels):**
59
+ - Level 1: `.claude/contexts/domain/index.md` (Project Registry)
60
+ - Level 2: `.claude/contexts/domain/{project}/README.md` (Project Overview)
61
+ - Level 3: `.claude/contexts/domain/{project}/best-practices/index.md` (Best Practices Registry)
62
+
63
+ **🆕 Implementation Logic (v1.1.0):**
64
+ - `@/.claude/lib/README.md` - Implementation logic overview
65
+ - `@/.claude/lib/agent-executor.md` - Agent retry & escalation logic (used by /cdev)
66
+ - `@/.claude/lib/tdd-classifier.md` - TDD classification logic (used by /csetup)
67
+ - `@/.claude/lib/flags-updater.md` - 🆕 Progress tracking protocol (Main Claude updates flags.json)
68
+ - `@/.claude/lib/agent-router.md` - 🆕 Mandatory agent routing rules (enforce delegation)
69
+ - `@/.claude/contexts/patterns/agent-discovery.md` - Shared agent discovery flow
70
+
71
+ ---
72
+
73
+ ## 📚 Best Practices System
74
+
75
+ ### How It Works:
76
+
77
+ 1. **Run `/agentsetup`** to detect tech stack and generate best practices
78
+ 2. **Context7 queries** latest framework docs (React, Next.js, Prisma, etc.)
79
+ 3. **Best practices files** created in `domain/{project}/best-practices/`
80
+ 4. **Agents auto-discover** project via 3-level indexing
81
+ 5. **Code quality** enforced by framework-specific patterns
82
+
83
+ ### Generated Files:
84
+
85
+ ```
86
+ .claude/contexts/domain/
87
+ ├── index.md # Level 1 - Project Registry
88
+ └── {project}/
89
+ ├── README.md # Level 2 - Project Overview
90
+ ├── tech-stack.md # Tech details
91
+ └── best-practices/
92
+ ├── index.md # Level 3 - Best Practices Registry
93
+ ├── react-18.md # ✅ DO's, ❌ DON'Ts, 🎯 Checklist
94
+ ├── nextjs-15.md
95
+ ├── prisma-6.md
96
+ └── vitest-2.md
97
+ ```
98
+
99
+ ### Agent Discovery Flow:
100
+
101
+ **Every agent follows this sequence (STEP 0):**
102
+
103
+ ```
104
+ 1. Read: domain/index.md → Get current project name
105
+ 2. Read: domain/{project}/README.md → Get tech stack
106
+ 3. Read: domain/{project}/best-practices/index.md → Get relevant files
107
+ 4. Read: domain/{project}/best-practices/{files} → Load best practices
108
+ 5. Report: "✅ Project Context Loaded"
109
+ ```
110
+
111
+ **Example: uxui-frontend agent**
112
+ ```
113
+ ✅ Project Context Loaded
114
+
115
+ 📁 Project: my-app
116
+ 🛠️ Stack: Next.js 15, React 18, Prisma 6
117
+ 📚 Best Practices Loaded:
118
+ - React 18 ✓
119
+ - Next.js 15 ✓
120
+
121
+ 🎯 Ready to create UI components!
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 🤖 Agent System
127
+
128
+ ### How It Works:
129
+
130
+ **Main Claude analyzes tasks → Invokes specialist agents directly**
131
+
132
+ ```
133
+ 1. User provides task (e.g., "Build login system")
134
+
135
+ 2. Main Claude reads @task-classification.md
136
+
137
+ 3. Main Claude selects appropriate agent(s)
138
+
139
+ 4. Execute in proper sequence:
140
+ - Phase 1: uxui-frontend (UI with mock data)
141
+ - Phase 2: backend + database (parallel)
142
+ - Phase 2.5: integration (validate contracts)
143
+ - Phase 3: frontend (connect UI to API)
144
+ - Phase 4: test-debug (tests & bug fixes)
145
+ ```
146
+
147
+ ### Available Agents (6 specialists):
148
+
149
+ | Agent | Color | When to Use | Phase |
150
+ |-------|-------|-------------|-------|
151
+ | **integration** | Orange | Validate API contracts before connecting | 2.5 |
152
+ | **uxui-frontend** | Blue | Design UI components with mock data | 1 |
153
+ | **test-debug** | Red | Run tests and fix bugs (max 3-4 iterations) | 1,3,4 |
154
+ | **frontend** | Green | Connect UI to backend APIs | 3 |
155
+ | **backend** | Purple | Create API endpoints with validation | 2 |
156
+ | **database** | Pink | Design schemas, migrations, complex queries | 2 |
157
+
158
+ ### Usage:
159
+
160
+ **For any task, Main Claude will:**
161
+ 1. Read `@/.claude/contexts/patterns/task-classification.md`
162
+ 2. Determine which agent(s) to use
163
+ 3. Invoke agents in proper sequence
164
+ 4. Coordinate between agents
165
+
166
+ **You can also invoke agents directly:**
167
+ ```
168
+ User: "/agents uxui-frontend"
169
+ Main Claude: *Executes uxui-frontend agent directly*
170
+ ```
171
+
172
+ ---
173
+
174
+ ### 🔒 Main Claude Self-Check Protocol (MANDATORY)
175
+
176
+ **⚠️ CRITICAL: Main Claude MUST complete this checklist BEFORE doing ANY work**
177
+
178
+ See: `@/.claude/lib/agent-router.md` for complete routing protocol
179
+
180
+ **Pre-Work Checklist (Run for EVERY user request):**
181
+
182
+ ```markdown
183
+ ## ✅ Pre-Work Self-Check
184
+
185
+ [ ] 1. Read user request carefully
186
+ - What are they asking for?
187
+ - What is the end goal?
188
+
189
+ [ ] 2. Detect work type
190
+ - Is this implementation work? (writing code, creating files)
191
+ - Is this planning/analysis? (reading, explaining, breaking down)
192
+
193
+ [ ] 3. If IMPLEMENTATION work:
194
+ - Read: @/.claude/contexts/patterns/task-classification.md
195
+ - Which agent should handle this?
196
+ • UI components → uxui-frontend
197
+ • API endpoints → backend
198
+ • Database schemas → database
199
+ • API integration → frontend
200
+ • Tests/bugs → test-debug
201
+ • Contracts → integration
202
+
203
+ [ ] 4. Can Main Claude do this?
204
+ ✅ YES for: Planning, reading files, explaining, orchestrating workflows
205
+ ❌ NO for: Writing components, creating endpoints, designing schemas
206
+
207
+ [ ] 5. If MUST delegate:
208
+ - Use Task tool with selected agent
209
+ - Include all necessary context
210
+ - Wait for agent response
211
+ - Update flags.json after completion (if using /cdev)
212
+
213
+ [ ] 6. Report decision to user
214
+ ```
215
+ 🔍 Task Analysis:
216
+ - Work type: [type]
217
+ - Requires: [agent] agent
218
+ - Reason: [explanation]
219
+
220
+ 🚀 Invoking [agent] agent...
221
+ ```
222
+ ```
223
+
224
+ **Main Claude's Role:**
225
+ - ✅ Orchestrator (plan, coordinate, report)
226
+ - ✅ Progress tracker (update flags.json)
227
+ - ✅ Analyst (read files, explain code)
228
+ - ❌ NOT implementer (no writing code directly)
229
+
230
+ **If Main Claude skips this self-check for implementation work, it violates system protocol.**
231
+
232
+ ---
233
+
234
+ ### ⚠️ Agent Pre-Work Requirements
235
+
236
+ **STEP 0 (ALL agents):** Every agent must discover project context first
237
+
238
+ **STEP 1-5 (uxui-frontend only):** Design fundamentals checklist
239
+
240
+ ---
241
+
242
+ #### STEP 0: Project Discovery (ALL Agents)
243
+
244
+ **Every agent MUST complete this before ANY work:**
245
+
246
+ ```
247
+ 1. Read: domain/index.md → Get current project name
248
+ 2. Read: domain/{project}/README.md → Get tech stack summary
249
+ 3. Read: domain/{project}/best-practices/index.md → Find relevant files
250
+ 4. Read: domain/{project}/best-practices/{files} → Load best practices
251
+ 5. Report: "✅ Project Context Loaded"
252
+ ```
253
+
254
+ **Fallback:** If discovery fails, warn user to run `/agentsetup`
255
+
256
+ ---
257
+
258
+ #### STEP 1-5: Design Fundamentals (uxui-frontend only)
259
+
260
+ **When invoking uxui-frontend agent, Main Claude MUST include these requirements in the Task prompt:**
261
+
262
+ ```
263
+ MANDATORY PRE-WORK CHECKLIST (after STEP 0):
264
+
265
+ Before writing ANY code, you MUST:
266
+
267
+ 1. **Read ALL design contexts:**
268
+ - @/.claude/contexts/design/index.md
269
+ - @/.claude/contexts/design/box-thinking.md
270
+ - @/.claude/contexts/design/color-theory.md
271
+ - @/.claude/contexts/design/spacing.md
272
+ - @/.claude/contexts/patterns/ui-component-consistency.md
273
+ - @/.claude/contexts/patterns/frontend-component-strategy.md
274
+
275
+ 2. **Do Box Thinking Analysis:**
276
+ - Identify all boxes (parent, children, siblings)
277
+ - Document relationships (container, adjacent, nested)
278
+ - Plan space flow using spacing scale (8, 16, 24, 32, 40, 48px)
279
+ - Plan responsive behavior (stack/merge/compress)
280
+
281
+ 3. **Search for Existing Components:**
282
+ - Glob: "**/*{Keyword}*.{tsx,jsx,vue}"
283
+ - Grep: "[similar-pattern]"
284
+ - Decision: Reuse > Compose > Extend > Create New
285
+ - If creating new: Extract design tokens from most similar component
286
+
287
+ 4. **Extract Design Tokens from Reference Component:**
288
+ ```typescript
289
+ const DESIGN_TOKENS = {
290
+ spacing: { padding: '[from reference]', gap: '[from reference]' },
291
+ colors: { bg: '[theme token]', text: '[theme token]', border: '[theme token]' },
292
+ shadows: '[from reference - e.g., shadow-sm]',
293
+ borderRadius: '[from reference - e.g., rounded-md]'
294
+ }
295
+ ```
296
+
297
+ 5. **Report Pre-Implementation Analysis:**
298
+ You MUST provide a detailed report covering steps 1-4 BEFORE writing any code.
299
+
300
+ CRITICAL RULES:
301
+ - ❌ NO hardcoded colors (text-gray-500) → ✅ Use theme tokens (text-foreground/70)
302
+ - ❌ NO arbitrary spacing (p-5) → ✅ Use spacing scale (p-4, p-6)
303
+ - ❌ NO inconsistent icons (h-5 w-5, opacity-50) → ✅ Match reference (h-4 w-4, text-foreground/70)
304
+ - ❌ NO creating duplicate components → ✅ Search and reuse first
305
+
306
+ If you skip these steps, your work will be rejected.
307
+ ```
308
+
309
+ **Why this enforcement matters:**
310
+ - Prevents visual inconsistency (mismatched colors, spacing, shadows)
311
+ - Ensures component reuse (avoids duplicates)
312
+ - Maintains design system integrity
313
+ - Saves implementation time
314
+
315
+ **Example: Build Login System**
316
+ ```
317
+ User: "Build a login system"
318
+ Main Claude analyzes → Breaks into phases:
319
+ Phase 1: /agents uxui-frontend (create login form UI)
320
+ Phase 2: /agents backend (create POST /api/login)
321
+ /agents database (create User model) [parallel]
322
+ Phase 2.5: /agents integration (verify contracts)
323
+ Phase 3: /agents frontend (connect form to API)
324
+ Phase 4: /agents test-debug (test everything)
325
+ ```
326
+
327
+ ---
328
+
329
+ **💡 Remember:** This template is universal. Use Context7 for framework-specific docs!