aiblueprint-cli 1.4.11 → 1.4.13

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 (55) hide show
  1. package/claude-code-config/scripts/.claude/commands/fix-on-my-computer.md +87 -0
  2. package/claude-code-config/scripts/command-validator/CLAUDE.md +112 -0
  3. package/claude-code-config/scripts/command-validator/src/__tests__/validator.test.ts +62 -111
  4. package/claude-code-config/scripts/command-validator/src/cli.ts +5 -3
  5. package/claude-code-config/scripts/command-validator/src/lib/security-rules.ts +3 -4
  6. package/claude-code-config/scripts/command-validator/src/lib/types.ts +1 -0
  7. package/claude-code-config/scripts/command-validator/src/lib/validator.ts +47 -317
  8. package/claude-code-config/scripts/statusline/CLAUDE.md +29 -7
  9. package/claude-code-config/scripts/statusline/README.md +89 -1
  10. package/claude-code-config/scripts/statusline/defaults.json +75 -0
  11. package/claude-code-config/scripts/statusline/src/index.ts +101 -24
  12. package/claude-code-config/scripts/statusline/src/lib/config-types.ts +100 -0
  13. package/claude-code-config/scripts/statusline/src/lib/config.ts +21 -0
  14. package/claude-code-config/scripts/statusline/src/lib/context.ts +32 -11
  15. package/claude-code-config/scripts/statusline/src/lib/formatters.ts +360 -22
  16. package/claude-code-config/scripts/statusline/src/lib/git.ts +100 -0
  17. package/claude-code-config/scripts/statusline/src/lib/render-pure.ts +177 -0
  18. package/claude-code-config/scripts/statusline/src/lib/types.ts +11 -0
  19. package/claude-code-config/scripts/statusline/statusline.config.json +93 -0
  20. package/claude-code-config/skills/claude-memory/SKILL.md +689 -0
  21. package/claude-code-config/skills/claude-memory/references/comprehensive-example.md +175 -0
  22. package/claude-code-config/skills/claude-memory/references/project-patterns.md +334 -0
  23. package/claude-code-config/skills/claude-memory/references/prompting-techniques.md +411 -0
  24. package/claude-code-config/skills/claude-memory/references/section-templates.md +347 -0
  25. package/claude-code-config/skills/create-slash-commands/SKILL.md +1110 -0
  26. package/claude-code-config/skills/create-slash-commands/references/arguments.md +273 -0
  27. package/claude-code-config/skills/create-slash-commands/references/patterns.md +947 -0
  28. package/claude-code-config/skills/create-slash-commands/references/prompt-examples.md +656 -0
  29. package/claude-code-config/skills/create-slash-commands/references/tool-restrictions.md +389 -0
  30. package/claude-code-config/skills/create-subagents/SKILL.md +425 -0
  31. package/claude-code-config/skills/create-subagents/references/context-management.md +567 -0
  32. package/claude-code-config/skills/create-subagents/references/debugging-agents.md +714 -0
  33. package/claude-code-config/skills/create-subagents/references/error-handling-and-recovery.md +502 -0
  34. package/claude-code-config/skills/create-subagents/references/evaluation-and-testing.md +374 -0
  35. package/claude-code-config/skills/create-subagents/references/orchestration-patterns.md +591 -0
  36. package/claude-code-config/skills/create-subagents/references/subagents.md +599 -0
  37. package/claude-code-config/skills/create-subagents/references/writing-subagent-prompts.md +513 -0
  38. package/dist/cli.js +20 -3
  39. package/package.json +1 -1
  40. package/claude-code-config/commands/apex.md +0 -109
  41. package/claude-code-config/commands/tasks/run-task.md +0 -220
  42. package/claude-code-config/commands/utils/watch-ci.md +0 -47
  43. package/claude-code-config/scripts/command-validator/biome.json +0 -29
  44. package/claude-code-config/scripts/command-validator/bun.lockb +0 -0
  45. package/claude-code-config/scripts/command-validator/package.json +0 -27
  46. package/claude-code-config/scripts/command-validator/vitest.config.ts +0 -7
  47. package/claude-code-config/scripts/hook-post-file.ts +0 -162
  48. package/claude-code-config/scripts/statusline/biome.json +0 -34
  49. package/claude-code-config/scripts/statusline/bun.lockb +0 -0
  50. package/claude-code-config/scripts/statusline/fixtures/test-input.json +0 -25
  51. package/claude-code-config/scripts/statusline/package.json +0 -19
  52. package/claude-code-config/scripts/statusline/statusline.config.ts +0 -25
  53. package/claude-code-config/scripts/statusline/test.ts +0 -20
  54. package/claude-code-config/scripts/validate-command.js +0 -712
  55. package/claude-code-config/scripts/validate-command.readme.md +0 -283
@@ -0,0 +1,502 @@
1
+ # Error Handling and Recovery for Subagents
2
+
3
+ <common_failure_modes>
4
+
5
+
6
+ Industry research identifies these failure patterns:
7
+
8
+ <specification_problems>
9
+ **32% of failures**: Subagents don't know what to do.
10
+
11
+ **Causes**:
12
+ - Vague or incomplete role definition
13
+ - Missing workflow steps
14
+ - Unclear success criteria
15
+ - Ambiguous constraints
16
+
17
+ **Symptoms**: Subagent asks clarifying questions (can't if it's a subagent), makes incorrect assumptions, produces partial outputs, or fails to complete task.
18
+
19
+ **Prevention**: Explicit `<role>`, `<workflow>`, `<focus_areas>`, and `<output_format>` sections in prompt.
20
+ </specification_problems>
21
+
22
+ <inter_agent_misalignment>
23
+ **28% of failures**: Coordination breakdowns in multi-agent workflows.
24
+
25
+ **Causes**:
26
+ - Subagents have conflicting objectives
27
+ - Handoff points unclear
28
+ - No shared context or state
29
+ - Assumptions about other agents' outputs
30
+
31
+ **Symptoms**: Duplicate work, contradictory outputs, infinite loops, tasks falling through cracks.
32
+
33
+ **Prevention**: Clear orchestration patterns (see [orchestration-patterns.md](orchestration-patterns.md)), explicit handoff protocols.
34
+ </inter_agent_misalignment>
35
+
36
+ <verification_gaps>
37
+ **24% of failures**: Nobody checks quality.
38
+
39
+ **Causes**:
40
+ - No validation step in workflow
41
+ - Missing output format specification
42
+ - No error detection logic
43
+ - Blind trust in subagent outputs
44
+
45
+ **Symptoms**: Incorrect results silently propagated, hallucinations undetected, format errors break downstream processes.
46
+
47
+ **Prevention**: Include verification steps in subagent workflows, validate outputs before use, implement evaluator agents.
48
+ </verification_gaps>
49
+
50
+ <error_cascading>
51
+ **Critical pattern**: Failures in one subagent propagate to others.
52
+
53
+ **Causes**:
54
+ - No error handling in downstream agents
55
+ - Assumptions that upstream outputs are valid
56
+ - No circuit breakers or fallbacks
57
+
58
+ **Symptoms**: Single failure causes entire workflow to fail.
59
+
60
+ **Prevention**: Defensive programming in subagent prompts, graceful degradation strategies, validation at boundaries.
61
+ </error_cascading>
62
+
63
+ <non_determinism>
64
+ **Inherent challenge**: Same prompt can produce different outputs.
65
+
66
+ **Causes**:
67
+ - LLM sampling and temperature settings
68
+ - API latency variations
69
+ - Context window ordering effects
70
+
71
+ **Symptoms**: Inconsistent behavior across invocations, tests pass sometimes and fail other times.
72
+
73
+ **Mitigation**: Lower temperature for consistency-critical tasks, comprehensive testing to identify variation patterns, robust validation.
74
+ </non_determinism>
75
+ </common_failure_modes>
76
+
77
+ <recovery_strategies>
78
+
79
+
80
+ <graceful_degradation>
81
+ **Pattern**: Workflow produces useful result even when ideal path fails.
82
+
83
+ <example>
84
+ ```markdown
85
+ <workflow>
86
+ 1. Attempt to fetch latest API documentation from web
87
+ 2. If fetch fails, use cached documentation (flag as potentially outdated)
88
+ 3. If no cache available, use local stub documentation (flag as incomplete)
89
+ 4. Generate code with best available information
90
+ 5. Add TODO comments indicating what should be verified
91
+ </workflow>
92
+
93
+ <fallback_hierarchy>
94
+ - Primary: Live API docs (most accurate)
95
+ - Secondary: Cached docs (may be stale, flag date)
96
+ - Tertiary: Stub docs (minimal, flag as incomplete)
97
+ - Always: Add verification TODOs to generated code
98
+ </fallback_hierarchy>
99
+ ```
100
+
101
+ **Key principle**: Partial success better than total failure. Always produce something useful.
102
+ </example>
103
+ </graceful_degradation>
104
+
105
+ <autonomous_retry>
106
+ **Pattern**: Subagent retries failed operations with exponential backoff.
107
+
108
+ <example>
109
+ ```markdown
110
+ <error_handling>
111
+ When a tool call fails:
112
+ 1. Attempt operation
113
+ 2. If fails, wait 1 second and retry
114
+ 3. If fails again, wait 2 seconds and retry
115
+ 4. If fails third time, proceed with fallback approach
116
+ 5. Document the failure in output
117
+
118
+ Maximum 3 retry attempts before falling back.
119
+ </error_handling>
120
+ ```
121
+
122
+ **Use case**: Transient failures (network issues, temporary file locks, rate limits).
123
+
124
+ **Anti-pattern**: Infinite retry loops without backoff or max attempts.
125
+ </example>
126
+ </autonomous_retry>
127
+
128
+ <circuit_breakers>
129
+ **Pattern**: Prevent cascading failures by stopping calls to failing components.
130
+
131
+ <conceptual_example>
132
+ ```markdown
133
+ <circuit_breaker_logic>
134
+ If API endpoint has failed 5 consecutive times:
135
+ - Stop calling the endpoint (circuit "open")
136
+ - Use fallback data source
137
+ - After 5 minutes, attempt one call (circuit "half-open")
138
+ - If succeeds, resume normal calls (circuit "closed")
139
+ - If fails, keep circuit open for another 5 minutes
140
+ </circuit_breaker_logic>
141
+ ```
142
+
143
+ **Application to subagents**: Include in prompt when subagent calls external APIs or services.
144
+
145
+ **Benefit**: Prevents wasting time/tokens on operations known to be failing.
146
+ </conceptual_example>
147
+ </circuit_breakers>
148
+
149
+ <timeouts>
150
+ **Pattern**: Agents going silent shouldn't block workflow indefinitely.
151
+
152
+ <implementation>
153
+ ```markdown
154
+ <timeout_handling>
155
+ For long-running operations:
156
+ 1. Set reasonable timeout (e.g., 2 minutes for analysis)
157
+ 2. If operation exceeds timeout:
158
+ - Abort operation
159
+ - Provide partial results if available
160
+ - Clearly flag as incomplete
161
+ - Suggest manual intervention
162
+ </timeout_handling>
163
+ ```
164
+
165
+ **Note**: Claude Code has built-in timeouts for tool calls. Subagent prompts should include guidance on what to do when operations approach reasonable time limits.
166
+ </implementation>
167
+ </timeouts>
168
+
169
+ <multiple_verification_paths>
170
+ **Pattern**: Different validators catch different error types.
171
+
172
+ <example>
173
+ ```markdown
174
+ <verification_strategy>
175
+ After generating code:
176
+ 1. Syntax check: Parse code to verify valid syntax
177
+ 2. Type check: Run static type checker (if applicable)
178
+ 3. Linting: Check for common issues and anti-patterns
179
+ 4. Security scan: Check for obvious vulnerabilities
180
+ 5. Test run: Execute tests if available
181
+
182
+ If any check fails, fix issue and re-run all checks.
183
+ Each check catches different error types.
184
+ </verification_strategy>
185
+ ```
186
+
187
+ **Benefit**: Layered validation catches more issues than single validation pass.
188
+ </example>
189
+ </multiple_verification_paths>
190
+
191
+ <reassigning_tasks>
192
+ **Pattern**: Invoke alternative agents or escalate to human when primary approach fails.
193
+
194
+ <example>
195
+ ```markdown
196
+ <escalation_workflow>
197
+ If automated fix fails after 2 attempts:
198
+ 1. Document what was tried and why it failed
199
+ 2. Provide diagnosis of the problem
200
+ 3. Recommend human review with specific questions to investigate
201
+ 4. DO NOT continue attempting automated fixes that aren't working
202
+
203
+ Know when to escalate rather than thrashing.
204
+ </escalation_workflow>
205
+ ```
206
+
207
+ **Key insight**: Subagents should recognize their limitations and provide useful handoff information.
208
+ </example>
209
+ </reassigning_tasks>
210
+ </recovery_strategies>
211
+
212
+ <structured_communication>
213
+
214
+
215
+ Multi-agent systems fail when communication is ambiguous. Structured messaging prevents misunderstandings.
216
+
217
+ <message_types>
218
+ Every message between agents (or from agent to user) should have explicit type:
219
+
220
+ **Request**: Asking for something
221
+ ```markdown
222
+ Type: Request
223
+ From: code-reviewer
224
+ To: test-writer
225
+ Task: Create tests for authentication module
226
+ Context: Recent security review found gaps in auth testing
227
+ Expected output: Comprehensive test suite covering auth edge cases
228
+ ```
229
+
230
+ **Inform**: Providing information
231
+ ```markdown
232
+ Type: Inform
233
+ From: debugger
234
+ To: Main chat
235
+ Status: Investigation complete
236
+ Findings: Root cause identified in line 127, race condition in async handler
237
+ ```
238
+
239
+ **Commit**: Promising to do something
240
+ ```markdown
241
+ Type: Commit
242
+ From: security-reviewer
243
+ Task: Review all changes in PR #342 for security issues
244
+ Deadline: Before responding to main chat
245
+ ```
246
+
247
+ **Reject**: Declining request with reason
248
+ ```markdown
249
+ Type: Reject
250
+ From: test-writer
251
+ Reason: Cannot write tests - no testing framework configured in project
252
+ Recommendation: Install Jest or similar framework first
253
+ ```
254
+ </message_types>
255
+
256
+ <schema_validation>
257
+ **Pattern**: Validate every payload against expected schema.
258
+
259
+ <example>
260
+ ```markdown
261
+ <output_validation>
262
+ Expected output format:
263
+ {
264
+ "vulnerabilities": [
265
+ {
266
+ "severity": "Critical|High|Medium|Low",
267
+ "location": "file:line",
268
+ "type": "string",
269
+ "description": "string",
270
+ "fix": "string"
271
+ }
272
+ ],
273
+ "summary": "string"
274
+ }
275
+
276
+ Before returning output:
277
+ 1. Verify JSON is valid
278
+ 2. Check all required fields present
279
+ 3. Validate severity values are from allowed list
280
+ 4. Ensure location follows "file:line" format
281
+ </output_validation>
282
+ ```
283
+
284
+ **Benefit**: Prevents malformed outputs from breaking downstream processes.
285
+ </example>
286
+ </schema_validation>
287
+ </structured_communication>
288
+
289
+ <observability>
290
+
291
+
292
+ "Most agent failures are not model failures, they are context failures."
293
+
294
+ <structured_logging>
295
+ **What to log**:
296
+ - Input prompts and parameters
297
+ - Tool calls and their results
298
+ - Intermediate reasoning (if visible)
299
+ - Final outputs
300
+ - Metadata (timestamps, model version, token usage, latency)
301
+ - Errors and warnings
302
+
303
+ **Log structure**:
304
+ ```markdown
305
+ Invocation ID: abc-123-def
306
+ Timestamp: 2025-11-15T14:23:01Z
307
+ Subagent: security-reviewer
308
+ Model: sonnet-4.5
309
+ Input: "Review changes in commit a3f2b1c"
310
+ Tool calls:
311
+ 1. git diff a3f2b1c (success, 234 lines)
312
+ 2. Read src/auth.ts (success, 156 lines)
313
+ 3. Read src/db.ts (success, 203 lines)
314
+ Output: 3 vulnerabilities found (2 High, 1 Medium)
315
+ Tokens: 2,341 input, 876 output
316
+ Latency: 4.2s
317
+ Status: Success
318
+ ```
319
+
320
+ **Use case**: Debugging failures, identifying patterns, performance optimization.
321
+ </structured_logging>
322
+
323
+ <correlation_ids>
324
+ **Pattern**: Track every message, plan, and tool call for end-to-end reconstruction.
325
+
326
+ ```markdown
327
+ Correlation ID: workflow-20251115-abc123
328
+
329
+ Main chat [abc123]:
330
+ → Launched code-reviewer [abc123-1]
331
+ → Tool: git diff [abc123-1-t1]
332
+ → Tool: Read auth.ts [abc123-1-t2]
333
+ → Returned: 3 issues found
334
+ → Launched test-writer [abc123-2]
335
+ → Tool: Read auth.ts [abc123-2-t1]
336
+ → Tool: Write auth.test.ts [abc123-2-t2]
337
+ → Returned: Test suite created
338
+ → Presented results to user
339
+ ```
340
+
341
+ **Benefit**: Can trace entire workflow execution, identify where failures occurred, understand cascading effects.
342
+ </correlation_ids>
343
+
344
+ <metrics_monitoring>
345
+ **Key metrics to track**:
346
+ - Success rate (completed tasks / total invocations)
347
+ - Error rate by error type
348
+ - Average token usage (spikes indicate prompt issues)
349
+ - Latency trends (increases suggest inefficiency)
350
+ - Tool call patterns (unusual patterns indicate problems)
351
+ - Retry rates (how often users re-invoke after failure)
352
+
353
+ **Alert thresholds**:
354
+ - Success rate drops below 80%
355
+ - Error rate exceeds 15%
356
+ - Token usage increases >50% without prompt changes
357
+ - Latency exceeds 2x baseline
358
+ - Same error type occurs >5 times in 24 hours
359
+ </metrics_monitoring>
360
+
361
+ <evaluator_agents>
362
+ **Pattern**: Dedicated quality guardrail agents validate outputs.
363
+
364
+ <example>
365
+ ```markdown
366
+ ---
367
+ name: output-validator
368
+ description: Validates subagent outputs against expected schemas and quality criteria. Use after any subagent produces structured output.
369
+ tools: Read
370
+ model: haiku
371
+ ---
372
+
373
+ <role>
374
+ You are an output validation specialist. Check subagent outputs for:
375
+ - Schema compliance
376
+ - Completeness
377
+ - Internal consistency
378
+ - Format correctness
379
+ </role>
380
+
381
+ <workflow>
382
+ 1. Receive subagent output and expected schema
383
+ 2. Validate structure matches schema
384
+ 3. Check for required fields
385
+ 4. Verify value constraints (enums, formats, ranges)
386
+ 5. Test internal consistency (references valid, no contradictions)
387
+ 6. Return validation report: Pass/Fail with specific issues
388
+ </workflow>
389
+
390
+ <validation_criteria>
391
+ Pass: All checks succeed
392
+ Fail: Any check fails - provide detailed error report
393
+ Partial: Minor issues that don't prevent use - flag warnings
394
+ </validation_criteria>
395
+ ```
396
+
397
+ **Use case**: Critical workflows where output quality is essential, high-risk operations, compliance requirements.
398
+ </example>
399
+ </evaluator_agents>
400
+ </observability>
401
+
402
+ <anti_patterns>
403
+
404
+
405
+ <anti_pattern name="silent_failures">
406
+ ❌ Subagent fails but doesn't indicate failure in output
407
+
408
+ **Example**:
409
+ ```markdown
410
+ Task: Review 10 files for security issues
411
+ Reality: Only reviewed 3 files due to errors, returned results anyway
412
+ Output: "No issues found" (incomplete review, but looks successful)
413
+ ```
414
+
415
+ **Fix**: Explicitly state what was reviewed, flag partial completion, include error summary.
416
+ </anti_pattern>
417
+
418
+ <anti_pattern name="no_fallback">
419
+ ❌ When ideal path fails, subagent gives up entirely
420
+
421
+ **Example**:
422
+ ```markdown
423
+ Task: Generate code from API documentation
424
+ Error: API docs unavailable
425
+ Output: "Cannot complete task, API docs not accessible"
426
+ ```
427
+
428
+ **Better**:
429
+ ```markdown
430
+ Error: API docs unavailable
431
+ Fallback: Using cached documentation (last updated: 2025-11-01)
432
+ Output: Code generated with note: "Verify against current API docs, using cached version"
433
+ ```
434
+
435
+ **Principle**: Provide best possible output given constraints, clearly flag limitations.
436
+ </anti_pattern>
437
+
438
+ <anti_pattern name="infinite_retry">
439
+ ❌ Retrying failed operations without backoff or limit
440
+
441
+ **Risk**: Wastes tokens, time, and may hit rate limits.
442
+
443
+ **Fix**: Maximum retry count (typically 2-3), exponential backoff, fallback after exhausting retries.
444
+ </anti_pattern>
445
+
446
+ <anti_pattern name="error_cascading">
447
+ ❌ Downstream agents assume upstream outputs are valid
448
+
449
+ **Example**:
450
+ ```markdown
451
+ Agent 1: Generates code (contains syntax error)
452
+
453
+ Agent 2: Writes tests (assumes code is syntactically valid, tests fail)
454
+
455
+ Agent 3: Runs tests (all tests fail due to syntax error in code)
456
+
457
+ Total workflow failure from single upstream error
458
+ ```
459
+
460
+ **Fix**: Each agent validates inputs before processing, includes error handling for invalid inputs.
461
+ </anti_pattern>
462
+
463
+ <anti_pattern name="no_error_context">
464
+ ❌ Error messages without diagnostic context
465
+
466
+ **Bad**: "Failed to complete task"
467
+
468
+ **Good**: "Failed to complete task: Unable to access file src/auth.ts (file not found). Attempted to review authentication code but file missing from expected location. Recommendation: Verify file path or check if file was moved/deleted."
469
+
470
+ **Principle**: Error messages should help diagnose root cause and suggest remediation.
471
+ </anti_pattern>
472
+ </anti_patterns>
473
+
474
+ <recovery_checklist>
475
+
476
+
477
+ Include these patterns in subagent prompts:
478
+
479
+ **Error detection**:
480
+ - [ ] Validate inputs before processing
481
+ - [ ] Check tool call results for errors
482
+ - [ ] Verify outputs match expected format
483
+ - [ ] Test assumptions (file exists, data valid, etc.)
484
+
485
+ **Recovery mechanisms**:
486
+ - [ ] Define fallback approach for primary path failure
487
+ - [ ] Include retry logic for transient failures
488
+ - [ ] Graceful degradation (partial results better than none)
489
+ - [ ] Clear error messages with diagnostic context
490
+
491
+ **Failure communication**:
492
+ - [ ] Explicitly state when task cannot be completed
493
+ - [ ] Explain what was attempted and why it failed
494
+ - [ ] Provide partial results if available
495
+ - [ ] Suggest remediation or next steps
496
+
497
+ **Quality gates**:
498
+ - [ ] Validation steps before returning output
499
+ - [ ] Self-checking (does output make sense?)
500
+ - [ ] Format compliance verification
501
+ - [ ] Completeness check (all required components present?)
502
+ </recovery_checklist>