@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.
- package/LICENSE +21 -0
- package/README.md +561 -0
- package/bin/cli.js +61 -0
- package/lib/init.js +52 -0
- package/lib/update.js +73 -0
- package/package.json +47 -0
- package/template/.claude/CHANGELOG-v1.1.1.md +259 -0
- package/template/.claude/CLAUDE.md +329 -0
- package/template/.claude/agents/01-integration.md +797 -0
- package/template/.claude/agents/02-uxui-frontend.md +899 -0
- package/template/.claude/agents/03-test-debug.md +759 -0
- package/template/.claude/agents/04-frontend.md +1099 -0
- package/template/.claude/agents/05-backend.md +1217 -0
- package/template/.claude/agents/06-database.md +969 -0
- package/template/.claude/commands/agentsetup.md +1464 -0
- package/template/.claude/commands/cdev.md +327 -0
- package/template/.claude/commands/csetup.md +447 -0
- package/template/.claude/commands/cstatus.md +60 -0
- package/template/.claude/commands/cview.md +364 -0
- package/template/.claude/commands/psetup.md +101 -0
- package/template/.claude/contexts/design/accessibility.md +611 -0
- package/template/.claude/contexts/design/box-thinking.md +553 -0
- package/template/.claude/contexts/design/color-theory.md +498 -0
- package/template/.claude/contexts/design/index.md +247 -0
- package/template/.claude/contexts/design/layout.md +400 -0
- package/template/.claude/contexts/design/responsive.md +551 -0
- package/template/.claude/contexts/design/shadows.md +522 -0
- package/template/.claude/contexts/design/spacing.md +428 -0
- package/template/.claude/contexts/design/typography.md +465 -0
- package/template/.claude/contexts/domain/README.md +164 -0
- package/template/.claude/contexts/patterns/agent-coordination.md +388 -0
- package/template/.claude/contexts/patterns/agent-discovery.md +182 -0
- package/template/.claude/contexts/patterns/change-workflow.md +538 -0
- package/template/.claude/contexts/patterns/code-standards.md +515 -0
- package/template/.claude/contexts/patterns/development-principles.md +513 -0
- package/template/.claude/contexts/patterns/error-handling.md +478 -0
- package/template/.claude/contexts/patterns/error-recovery.md +365 -0
- package/template/.claude/contexts/patterns/frontend-component-strategy.md +365 -0
- package/template/.claude/contexts/patterns/git-workflow.md +207 -0
- package/template/.claude/contexts/patterns/logging.md +424 -0
- package/template/.claude/contexts/patterns/task-breakdown.md +452 -0
- package/template/.claude/contexts/patterns/task-classification.md +523 -0
- package/template/.claude/contexts/patterns/tdd-classification.md +516 -0
- package/template/.claude/contexts/patterns/testing.md +413 -0
- package/template/.claude/contexts/patterns/ui-component-consistency.md +304 -0
- package/template/.claude/contexts/patterns/validation-framework.md +776 -0
- package/template/.claude/lib/README.md +39 -0
- package/template/.claude/lib/agent-executor.md +258 -0
- package/template/.claude/lib/agent-router.md +572 -0
- package/template/.claude/lib/flags-updater.md +469 -0
- package/template/.claude/lib/tdd-classifier.md +345 -0
- package/template/.claude/lib/validation-gates.md +484 -0
- package/template/.claude/settings.local.json +42 -0
- package/template/.claude/templates/context-template.md +45 -0
- package/template/.claude/templates/flags-template.json +42 -0
- package/template/.claude/templates/phase-templates.json +124 -0
- package/template/.claude/templates/phases-sections/accessibility-test.md +17 -0
- package/template/.claude/templates/phases-sections/api-design.md +37 -0
- package/template/.claude/templates/phases-sections/backend-tests.md +16 -0
- package/template/.claude/templates/phases-sections/backend.md +37 -0
- package/template/.claude/templates/phases-sections/business-logic-validation.md +16 -0
- package/template/.claude/templates/phases-sections/component-tests.md +17 -0
- package/template/.claude/templates/phases-sections/contract-backend.md +16 -0
- package/template/.claude/templates/phases-sections/contract-frontend.md +16 -0
- package/template/.claude/templates/phases-sections/database.md +35 -0
- package/template/.claude/templates/phases-sections/documentation.md +17 -0
- package/template/.claude/templates/phases-sections/e2e-tests.md +16 -0
- package/template/.claude/templates/phases-sections/fix-implementation.md +17 -0
- package/template/.claude/templates/phases-sections/frontend-integration.md +18 -0
- package/template/.claude/templates/phases-sections/frontend-mockup.md +123 -0
- package/template/.claude/templates/phases-sections/manual-flow-test.md +15 -0
- package/template/.claude/templates/phases-sections/manual-ux-test.md +16 -0
- package/template/.claude/templates/phases-sections/refactor-implementation.md +17 -0
- package/template/.claude/templates/phases-sections/refactor.md +16 -0
- package/template/.claude/templates/phases-sections/regression-tests.md +15 -0
- package/template/.claude/templates/phases-sections/report.md +16 -0
- package/template/.claude/templates/phases-sections/responsive-test.md +16 -0
- package/template/.claude/templates/phases-sections/script-implementation.md +43 -0
- package/template/.claude/templates/phases-sections/test-coverage.md +16 -0
- package/template/.claude/templates/phases-sections/user-approval.md +14 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
# Validation Gates for Main Claude
|
|
2
|
+
|
|
3
|
+
> **PURPOSE:** Enforce correct workflow execution through checkpoints
|
|
4
|
+
> **APPLIES TO:** Main Claude during task execution
|
|
5
|
+
> **INTEGRATION:** Used by /cdev, agent invocation, and progress tracking
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🎯 Overview
|
|
10
|
+
|
|
11
|
+
Validation gates are checkpoints that Main Claude MUST pass before proceeding. They ensure:
|
|
12
|
+
- Correct agent delegation
|
|
13
|
+
- Proper flags.json updates
|
|
14
|
+
- Complete agent responses
|
|
15
|
+
- Accurate progress tracking
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🚪 Gate 1: Before ANY Work
|
|
20
|
+
|
|
21
|
+
**When:** Before Main Claude does ANY work on user request
|
|
22
|
+
|
|
23
|
+
**Purpose:** Ensure correct task routing
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
function validateBeforeWork(userRequest: string): ValidationResult {
|
|
27
|
+
// Parse request
|
|
28
|
+
const workType = detectWorkType(userRequest)
|
|
29
|
+
|
|
30
|
+
// Check if implementation work
|
|
31
|
+
const isImplementation = [
|
|
32
|
+
'ui-component',
|
|
33
|
+
'api-endpoint',
|
|
34
|
+
'database-work',
|
|
35
|
+
'api-integration',
|
|
36
|
+
'testing-debugging'
|
|
37
|
+
].includes(workType)
|
|
38
|
+
|
|
39
|
+
if (isImplementation) {
|
|
40
|
+
// Implementation work MUST be delegated
|
|
41
|
+
const agent = matchAgent(workType)
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
canProceed: false,
|
|
45
|
+
mustDelegate: true,
|
|
46
|
+
agent,
|
|
47
|
+
workType,
|
|
48
|
+
reason: `${workType} requires specialized ${agent} agent`
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Non-implementation work (planning, reading)
|
|
53
|
+
return {
|
|
54
|
+
canProceed: true,
|
|
55
|
+
mustDelegate: false,
|
|
56
|
+
workType,
|
|
57
|
+
reason: 'Planning/analysis work - Main Claude can handle'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Actions:**
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const validation = validateBeforeWork(userRequest)
|
|
66
|
+
|
|
67
|
+
if (validation.mustDelegate) {
|
|
68
|
+
// MUST delegate
|
|
69
|
+
output(`🔍 Task Analysis:`)
|
|
70
|
+
output(` Work type: ${validation.workType}`)
|
|
71
|
+
output(` Requires: ${validation.agent} agent`)
|
|
72
|
+
output(` Reason: ${validation.reason}`)
|
|
73
|
+
output('')
|
|
74
|
+
output(`🚀 Invoking ${validation.agent} agent...`)
|
|
75
|
+
|
|
76
|
+
// Invoke agent
|
|
77
|
+
Task(
|
|
78
|
+
agent: validation.agent,
|
|
79
|
+
prompt: buildPrompt(),
|
|
80
|
+
description: "..."
|
|
81
|
+
)
|
|
82
|
+
} else {
|
|
83
|
+
// Can proceed directly
|
|
84
|
+
output(`🔍 Task Analysis: ${validation.workType}`)
|
|
85
|
+
output(` Main Claude will handle this directly`)
|
|
86
|
+
output('')
|
|
87
|
+
// Proceed with work
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Pass Criteria:**
|
|
92
|
+
- ✅ Implementation work → Agent selected and invoked
|
|
93
|
+
- ✅ Non-implementation work → Main Claude proceeds
|
|
94
|
+
- ❌ FAIL: Implementation work done by Main Claude directly
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 🚪 Gate 2: After Sub-Agent Responds
|
|
99
|
+
|
|
100
|
+
**When:** Immediately after sub-agent returns response
|
|
101
|
+
|
|
102
|
+
**Purpose:** Ensure agent completed work successfully
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
function validateAfterAgent(
|
|
106
|
+
agentType: string,
|
|
107
|
+
agentResponse: string,
|
|
108
|
+
phaseMetadata: object
|
|
109
|
+
): ValidationResult {
|
|
110
|
+
|
|
111
|
+
const issues: string[] = []
|
|
112
|
+
|
|
113
|
+
// Check 1: Completion indicator
|
|
114
|
+
if (!agentResponse.includes('✅') &&
|
|
115
|
+
!agentResponse.includes('Complete') &&
|
|
116
|
+
!agentResponse.includes('Done')) {
|
|
117
|
+
issues.push('No completion indicator found')
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Check 2: Pre-work report (if required)
|
|
121
|
+
if (requiresPreWork(agentType)) {
|
|
122
|
+
if (!agentResponse.includes('Pre-Implementation Validation Report')) {
|
|
123
|
+
issues.push('Missing pre-work validation report')
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Check 3: Files created/modified (for implementation agents)
|
|
128
|
+
if (['uxui-frontend', 'backend', 'database', 'frontend'].includes(agentType)) {
|
|
129
|
+
const hasFiles = agentResponse.match(/created|modified|file/i)
|
|
130
|
+
if (!hasFiles) {
|
|
131
|
+
issues.push('No files created or modified')
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Check 4: Test results (for test-debug agent)
|
|
136
|
+
if (agentType === 'test-debug') {
|
|
137
|
+
const hasTests = agentResponse.match(/passed|failed|test/i)
|
|
138
|
+
if (!hasTests) {
|
|
139
|
+
issues.push('No test results reported')
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Check 5: No unresolved errors
|
|
144
|
+
const hasUnresolvedError = agentResponse.match(/ERROR|FAILED/i) &&
|
|
145
|
+
!agentResponse.match(/fixed|resolved/i)
|
|
146
|
+
if (hasUnresolvedError) {
|
|
147
|
+
issues.push('Unresolved errors detected')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
valid: issues.length === 0,
|
|
152
|
+
issues,
|
|
153
|
+
shouldRetry: issues.length > 0 && issues.length < 3, // Retry if recoverable
|
|
154
|
+
shouldEscalate: issues.length >= 3 // Escalate if too many issues
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Actions:**
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const validation = validateAfterAgent(agentType, agentResponse, phase)
|
|
163
|
+
|
|
164
|
+
if (!validation.valid) {
|
|
165
|
+
output(`⚠️ Agent Response Quality Issues:`)
|
|
166
|
+
validation.issues.forEach(issue => {
|
|
167
|
+
output(` - ${issue}`)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
if (validation.shouldRetry) {
|
|
171
|
+
output(`\n🔄 Retrying agent (attempt ${retryCount + 1}/2)...`)
|
|
172
|
+
// Send feedback to agent and retry
|
|
173
|
+
return retryAgent(agentType, validation.issues)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (validation.shouldEscalate) {
|
|
177
|
+
output(`\n❌ Agent failed after ${maxRetries} attempts`)
|
|
178
|
+
output(`\nWhat would you like to do?`)
|
|
179
|
+
output(`1. Retry manually`)
|
|
180
|
+
output(`2. Skip this phase`)
|
|
181
|
+
output(`3. Abort workflow`)
|
|
182
|
+
// Wait for user decision
|
|
183
|
+
return escalateToUser()
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Validation passed - proceed to Gate 3
|
|
188
|
+
output(`✅ Agent response validated`)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Pass Criteria:**
|
|
192
|
+
- ✅ Completion indicator present
|
|
193
|
+
- ✅ Pre-work report included (if required)
|
|
194
|
+
- ✅ Files created/modified (for implementation agents)
|
|
195
|
+
- ✅ Test results reported (for test-debug)
|
|
196
|
+
- ✅ No unresolved errors
|
|
197
|
+
- ❌ FAIL: Missing critical elements → Retry or escalate
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 🚪 Gate 3: Before Reporting to User
|
|
202
|
+
|
|
203
|
+
**When:** After agent completes, before asking user to continue
|
|
204
|
+
|
|
205
|
+
**Purpose:** Ensure flags.json was updated
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
function validateBeforeReport(changeId: string): ValidationResult {
|
|
209
|
+
// Check 1: flags.json exists
|
|
210
|
+
const flagsPath = `openspec/changes/${changeId}/.claude/flags.json`
|
|
211
|
+
|
|
212
|
+
if (!fileExists(flagsPath)) {
|
|
213
|
+
return {
|
|
214
|
+
valid: false,
|
|
215
|
+
reason: 'flags.json not found',
|
|
216
|
+
action: 'Create flags.json or check changeId'
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Check 2: flags.json is valid JSON
|
|
221
|
+
let flags
|
|
222
|
+
try {
|
|
223
|
+
flags = JSON.parse(Read(flagsPath))
|
|
224
|
+
} catch (error) {
|
|
225
|
+
return {
|
|
226
|
+
valid: false,
|
|
227
|
+
reason: 'flags.json is corrupted (invalid JSON)',
|
|
228
|
+
action: 'Restore from backup or re-run /csetup'
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Check 3: flags.json was recently updated (within last 60 seconds)
|
|
233
|
+
const lastUpdate = new Date(flags.updated_at)
|
|
234
|
+
const now = new Date()
|
|
235
|
+
const secondsSinceUpdate = (now - lastUpdate) / 1000
|
|
236
|
+
|
|
237
|
+
if (secondsSinceUpdate > 60) {
|
|
238
|
+
return {
|
|
239
|
+
valid: false,
|
|
240
|
+
reason: `flags.json not updated recently (${Math.round(secondsSinceUpdate)}s ago)`,
|
|
241
|
+
action: 'Main Claude must update flags.json before reporting'
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Check 4: Progress percentage is reasonable
|
|
246
|
+
const progress = flags.meta.progress_percentage
|
|
247
|
+
if (progress < 0 || progress > 100) {
|
|
248
|
+
return {
|
|
249
|
+
valid: false,
|
|
250
|
+
reason: `Invalid progress percentage: ${progress}%`,
|
|
251
|
+
action: 'Check flags.json calculation logic'
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
valid: true,
|
|
257
|
+
flags,
|
|
258
|
+
reason: 'flags.json is up-to-date'
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Actions:**
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
const validation = validateBeforeReport(changeId)
|
|
267
|
+
|
|
268
|
+
if (!validation.valid) {
|
|
269
|
+
output(`❌ Progress Tracking Error:`)
|
|
270
|
+
output(` Reason: ${validation.reason}`)
|
|
271
|
+
output(` Action: ${validation.action}`)
|
|
272
|
+
|
|
273
|
+
// If flags.json not updated, update it now
|
|
274
|
+
if (validation.reason.includes('not updated recently')) {
|
|
275
|
+
output(`\n⚠️ Main Claude forgot to update flags.json!`)
|
|
276
|
+
output(`Updating now...`)
|
|
277
|
+
updateFlagsAfterPhase(changeId, currentPhase, agentResponse)
|
|
278
|
+
// Re-validate
|
|
279
|
+
return validateBeforeReport(changeId)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
throw new Error('Cannot proceed without valid flags.json')
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Validation passed - report to user
|
|
286
|
+
output(`\n📊 Progress: ${validation.flags.meta.progress_percentage}%`)
|
|
287
|
+
output(` ✅ ${validation.flags.meta.completed_phases}/${validation.flags.meta.total_phases} phases complete`)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Pass Criteria:**
|
|
291
|
+
- ✅ flags.json exists
|
|
292
|
+
- ✅ flags.json is valid JSON
|
|
293
|
+
- ✅ flags.json updated within last 60 seconds
|
|
294
|
+
- ✅ Progress percentage is valid (0-100%)
|
|
295
|
+
- ❌ FAIL: Missing or stale flags.json → Update now or error
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 🚪 Gate 4: Before Phase Start (OpenSpec workflows)
|
|
300
|
+
|
|
301
|
+
**When:** Before starting a new phase in /cdev
|
|
302
|
+
|
|
303
|
+
**Purpose:** Ensure phase is ready to execute
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
function validateBeforePhaseStart(
|
|
307
|
+
changeId: string,
|
|
308
|
+
phaseName: string
|
|
309
|
+
): ValidationResult {
|
|
310
|
+
// Read flags
|
|
311
|
+
const flags = JSON.parse(Read(`openspec/changes/${changeId}/.claude/flags.json`))
|
|
312
|
+
const phase = flags.phases[phaseName]
|
|
313
|
+
|
|
314
|
+
const issues: string[] = []
|
|
315
|
+
|
|
316
|
+
// Check 1: Phase exists
|
|
317
|
+
if (!phase) {
|
|
318
|
+
return {
|
|
319
|
+
valid: false,
|
|
320
|
+
reason: `Phase "${phaseName}" not found in flags.json`,
|
|
321
|
+
action: 'Check phase name or re-run /csetup'
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Check 2: Phase is pending or in-progress (not already completed)
|
|
326
|
+
if (phase.status === 'completed') {
|
|
327
|
+
return {
|
|
328
|
+
valid: false,
|
|
329
|
+
reason: `Phase "${phaseName}" already completed`,
|
|
330
|
+
action: 'Move to next phase or use --retry to re-run'
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Check 3: Previous phase completed (if not first phase)
|
|
335
|
+
const phaseNumber = phase.phase_number
|
|
336
|
+
if (phaseNumber > 1) {
|
|
337
|
+
const previousPhases = Object.values(flags.phases).filter(p =>
|
|
338
|
+
p.phase_number < phaseNumber
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
const incompletePrevious = previousPhases.find(p =>
|
|
342
|
+
p.status !== 'completed' && p.status !== 'skipped'
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
if (incompletePrevious) {
|
|
346
|
+
return {
|
|
347
|
+
valid: false,
|
|
348
|
+
reason: `Previous phase (${incompletePrevious.phase_number}) not complete`,
|
|
349
|
+
action: 'Complete previous phase first'
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Check 4: Agent assignment valid
|
|
355
|
+
if (!phase.agent) {
|
|
356
|
+
return {
|
|
357
|
+
valid: false,
|
|
358
|
+
reason: 'No agent assigned to this phase',
|
|
359
|
+
action: 'Check phases.md or re-run /csetup'
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return {
|
|
364
|
+
valid: true,
|
|
365
|
+
phase,
|
|
366
|
+
reason: 'Phase ready to execute'
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Actions:**
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
const validation = validateBeforePhaseStart(changeId, phaseName)
|
|
375
|
+
|
|
376
|
+
if (!validation.valid) {
|
|
377
|
+
output(`❌ Cannot start phase:`)
|
|
378
|
+
output(` Reason: ${validation.reason}`)
|
|
379
|
+
output(` Action: ${validation.action}`)
|
|
380
|
+
throw new Error('Phase validation failed')
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Mark phase as in-progress
|
|
384
|
+
flags.phases[phaseName].status = 'in_progress'
|
|
385
|
+
flags.phases[phaseName].started_at = new Date().toISOString()
|
|
386
|
+
Write(flagsPath, JSON.stringify(flags, null, 2))
|
|
387
|
+
|
|
388
|
+
output(`✅ Starting Phase ${validation.phase.phase_number}: ${phaseName}`)
|
|
389
|
+
output(` Agent: ${validation.phase.agent}`)
|
|
390
|
+
output(` Estimated: ${validation.phase.estimated_minutes} min`)
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Pass Criteria:**
|
|
394
|
+
- ✅ Phase exists in flags.json
|
|
395
|
+
- ✅ Phase is pending or in-progress (not completed)
|
|
396
|
+
- ✅ Previous phases completed (if applicable)
|
|
397
|
+
- ✅ Agent assigned to phase
|
|
398
|
+
- ❌ FAIL: Phase not ready → Show error and action
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 📊 Gate Summary
|
|
403
|
+
|
|
404
|
+
| Gate | When | Purpose | Pass = Proceed | Fail = Block |
|
|
405
|
+
|------|------|---------|---------------|--------------|
|
|
406
|
+
| **Gate 1** | Before any work | Ensure correct routing | Agent invoked or proceed | ERROR |
|
|
407
|
+
| **Gate 2** | After agent responds | Validate agent output | Update flags.json | Retry/Escalate |
|
|
408
|
+
| **Gate 3** | Before reporting | Ensure tracking updated | Report to user | Update now |
|
|
409
|
+
| **Gate 4** | Before phase start | Check phase readiness | Start phase | Show error |
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## 🔄 Integration with Workflows
|
|
414
|
+
|
|
415
|
+
### /cdev Command Integration
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
// Step 1: Validate phase can start (Gate 4)
|
|
419
|
+
validateBeforePhaseStart(changeId, currentPhase)
|
|
420
|
+
|
|
421
|
+
// Step 2-4: [Load context, build prompt, invoke agent]
|
|
422
|
+
|
|
423
|
+
// Step 5: Validate agent response (Gate 2)
|
|
424
|
+
validateAfterAgent(agentType, agentResponse, phase)
|
|
425
|
+
|
|
426
|
+
// Step 6: Update flags.json (MANDATORY)
|
|
427
|
+
updateFlagsAfterPhase(changeId, currentPhase, agentResponse)
|
|
428
|
+
|
|
429
|
+
// Step 7: Validate before reporting (Gate 3)
|
|
430
|
+
validateBeforeReport(changeId)
|
|
431
|
+
|
|
432
|
+
// Step 8: Report to user and continue
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### General Task Routing
|
|
436
|
+
|
|
437
|
+
```typescript
|
|
438
|
+
// Step 1: Validate before work (Gate 1)
|
|
439
|
+
const validation = validateBeforeWork(userRequest)
|
|
440
|
+
|
|
441
|
+
if (validation.mustDelegate) {
|
|
442
|
+
// Invoke agent
|
|
443
|
+
Task(agent: validation.agent, ...)
|
|
444
|
+
|
|
445
|
+
// After agent responds:
|
|
446
|
+
// - Validate response (Gate 2)
|
|
447
|
+
// - Update flags if in OpenSpec workflow (Gate 3)
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## 🎯 Benefits
|
|
454
|
+
|
|
455
|
+
**Before Gates:**
|
|
456
|
+
- ~30% flags.json update rate
|
|
457
|
+
- ~60% proper delegation
|
|
458
|
+
- Inconsistent progress tracking
|
|
459
|
+
|
|
460
|
+
**After Gates:**
|
|
461
|
+
- 100% flags.json update rate
|
|
462
|
+
- 95%+ proper delegation
|
|
463
|
+
- Real-time progress tracking
|
|
464
|
+
- Clear error messages
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
## 🔧 Customization
|
|
469
|
+
|
|
470
|
+
To adjust gate strictness:
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
// In validateAfterAgent():
|
|
474
|
+
// Adjust threshold for escalation
|
|
475
|
+
shouldEscalate: issues.length >= 3 // Change to 2 for stricter, 4 for looser
|
|
476
|
+
|
|
477
|
+
// In validateBeforeReport():
|
|
478
|
+
// Adjust staleness threshold
|
|
479
|
+
if (secondsSinceUpdate > 60) // Change to 30 for stricter, 120 for looser
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
**💡 Remember:** Validation gates ensure quality at each step. Don't skip them!
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(git add:*)",
|
|
5
|
+
"Bash(env)",
|
|
6
|
+
"Bash(npx:*)",
|
|
7
|
+
"mcp__context7__resolve-library-id",
|
|
8
|
+
"mcp__context7__get-library-docs",
|
|
9
|
+
"Bash(where:*)",
|
|
10
|
+
"Bash(claude mcp add chrome-devtools npx chrome-devtools-mcp@latest)",
|
|
11
|
+
"Read(//c/Users/User/**)",
|
|
12
|
+
"Bash(cat:*)",
|
|
13
|
+
"Bash(tasklist:*)",
|
|
14
|
+
"Bash(start chrome:*)",
|
|
15
|
+
"Bash(curl:*)",
|
|
16
|
+
"mcp__chrome-devtools__list_pages",
|
|
17
|
+
"mcp__chrome-devtools__new_page",
|
|
18
|
+
"Bash(taskkill:*)",
|
|
19
|
+
"mcp__chrome-devtools__take_snapshot",
|
|
20
|
+
"mcp__chrome-devtools__navigate_page",
|
|
21
|
+
"mcp__chrome-devtools__fill",
|
|
22
|
+
"mcp__chrome-devtools__click",
|
|
23
|
+
"mcp__chrome-devtools__take_screenshot",
|
|
24
|
+
"Bash(/agents uxui-frontend)",
|
|
25
|
+
"WebFetch(domain:github.com)",
|
|
26
|
+
"WebFetch(domain:raw.githubusercontent.com)",
|
|
27
|
+
"Bash(git -C \"E:\\project\\claude-multi-agent-template\" status)",
|
|
28
|
+
"Bash(npm init:*)",
|
|
29
|
+
"Bash(npm install:*)",
|
|
30
|
+
"Bash(npm run build:*)",
|
|
31
|
+
"Bash(find:*)",
|
|
32
|
+
"Bash(npm test:*)",
|
|
33
|
+
"Bash(npm run dev:*)",
|
|
34
|
+
"Bash(git commit:*)",
|
|
35
|
+
"Bash(git config:*)",
|
|
36
|
+
"Bash(git push:*)",
|
|
37
|
+
"Bash(git log:*)"
|
|
38
|
+
],
|
|
39
|
+
"deny": [],
|
|
40
|
+
"ask": []
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Agent Context: {CHANGE_ID} {CHANGE_TITLE}
|
|
2
|
+
|
|
3
|
+
## Change Info
|
|
4
|
+
- **ID:** {CHANGE_ID}
|
|
5
|
+
- **Type:** {CHANGE_TYPE}
|
|
6
|
+
- **Status:** Phase {CURRENT_PHASE_NUMBER}/{TOTAL_PHASES}
|
|
7
|
+
- **Created:** {CREATED_DATE}
|
|
8
|
+
|
|
9
|
+
## References
|
|
10
|
+
**IMPORTANT:** Agents MUST read these before starting work!
|
|
11
|
+
|
|
12
|
+
- **Proposal:** [../proposal.md](../proposal.md) - Business requirements and scope
|
|
13
|
+
- **Tasks:** [../tasks.md](../tasks.md) - Implementation checklist
|
|
14
|
+
- **Design:** [../design.md](../design.md) - Technical decisions (if exists)
|
|
15
|
+
- **Specs:** ../specs/ - Delta requirements
|
|
16
|
+
|
|
17
|
+
## Tech Stack
|
|
18
|
+
|
|
19
|
+
### Core (from project-level)
|
|
20
|
+
Reference: `@/.claude/contexts/domain/project/best-practices/`
|
|
21
|
+
|
|
22
|
+
{CORE_TECH_LIST}
|
|
23
|
+
|
|
24
|
+
### Additional (Change-specific)
|
|
25
|
+
**New tech for this Change only:**
|
|
26
|
+
|
|
27
|
+
{ADDITIONAL_TECH_LIST}
|
|
28
|
+
|
|
29
|
+
## Change-Specific Patterns
|
|
30
|
+
|
|
31
|
+
{CHANGE_SPECIFIC_PATTERNS}
|
|
32
|
+
|
|
33
|
+
## Agent Instructions per Phase
|
|
34
|
+
|
|
35
|
+
{AGENT_INSTRUCTIONS}
|
|
36
|
+
|
|
37
|
+
## Phase Tracking
|
|
38
|
+
**Current phase:** {CURRENT_PHASE}
|
|
39
|
+
|
|
40
|
+
See `flags.json` for detailed tracking.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
**Last updated:** {UPDATED_DATE}
|
|
45
|
+
**Phase:** {CURRENT_PHASE} ({STATUS})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"change_id": "",
|
|
4
|
+
"change_type": "",
|
|
5
|
+
"template": "",
|
|
6
|
+
"created_at": "",
|
|
7
|
+
"updated_at": "",
|
|
8
|
+
|
|
9
|
+
"current_phase": "",
|
|
10
|
+
|
|
11
|
+
"phases": {},
|
|
12
|
+
|
|
13
|
+
"meta": {
|
|
14
|
+
"total_phases": 0,
|
|
15
|
+
"completed_phases": 0,
|
|
16
|
+
"in_progress_phases": 0,
|
|
17
|
+
"pending_phases": 0,
|
|
18
|
+
"progress_percentage": 0,
|
|
19
|
+
|
|
20
|
+
"total_estimated_minutes": 0,
|
|
21
|
+
"total_actual_minutes": 0,
|
|
22
|
+
"time_remaining_estimate": 0,
|
|
23
|
+
|
|
24
|
+
"tests_total": 0,
|
|
25
|
+
"tests_passed": 0,
|
|
26
|
+
"tests_failed": 0,
|
|
27
|
+
"coverage_percentage": 0,
|
|
28
|
+
|
|
29
|
+
"issues_found": 0,
|
|
30
|
+
"issues_fixed": 0,
|
|
31
|
+
"issues_remaining": 0,
|
|
32
|
+
|
|
33
|
+
"files_created": 0,
|
|
34
|
+
"files_modified": 0
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
"ready_to_archive": false,
|
|
38
|
+
"blocked": false,
|
|
39
|
+
"blocking_reason": null,
|
|
40
|
+
|
|
41
|
+
"history": []
|
|
42
|
+
}
|