aiblueprint-cli 1.4.12 → 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 (54) 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/package.json +1 -1
  39. package/claude-code-config/commands/apex.md +0 -109
  40. package/claude-code-config/commands/tasks/run-task.md +0 -220
  41. package/claude-code-config/commands/utils/watch-ci.md +0 -47
  42. package/claude-code-config/scripts/command-validator/biome.json +0 -29
  43. package/claude-code-config/scripts/command-validator/bun.lockb +0 -0
  44. package/claude-code-config/scripts/command-validator/package.json +0 -27
  45. package/claude-code-config/scripts/command-validator/vitest.config.ts +0 -7
  46. package/claude-code-config/scripts/hook-post-file.ts +0 -162
  47. package/claude-code-config/scripts/statusline/biome.json +0 -34
  48. package/claude-code-config/scripts/statusline/bun.lockb +0 -0
  49. package/claude-code-config/scripts/statusline/fixtures/test-input.json +0 -25
  50. package/claude-code-config/scripts/statusline/package.json +0 -19
  51. package/claude-code-config/scripts/statusline/statusline.config.ts +0 -25
  52. package/claude-code-config/scripts/statusline/test.ts +0 -20
  53. package/claude-code-config/scripts/validate-command.js +0 -712
  54. package/claude-code-config/scripts/validate-command.readme.md +0 -283
@@ -0,0 +1,567 @@
1
+ # Context Management for Subagents
2
+
3
+ <core_problem>
4
+
5
+
6
+ "Most agent failures are not model failures, they are context failures."
7
+
8
+ <stateless_nature>
9
+ LLMs are stateless by default. Each invocation starts fresh with no memory of previous interactions.
10
+
11
+ **For subagents, this means**:
12
+ - Long-running tasks lose context between tool calls
13
+ - Repeated information wastes tokens
14
+ - Important decisions from earlier in workflow forgotten
15
+ - Context window fills with redundant information
16
+ </stateless_nature>
17
+
18
+ <context_window_limits>
19
+ Full conversation history leads to:
20
+ - Degraded performance (important info buried in noise)
21
+ - High costs (paying for redundant tokens)
22
+ - Context limits exceeded (workflow fails)
23
+
24
+ **Critical threshold**: When context approaches limit, quality degrades before hard failure.
25
+ </context_window_limits>
26
+ </core_problem>
27
+
28
+ <memory_architecture>
29
+
30
+
31
+ <short_term_memory>
32
+ **Short-term memory (STM)**: Last 5-9 interactions.
33
+
34
+ **Implementation**: Preserved in context window.
35
+
36
+ **Use for**:
37
+ - Current task state
38
+ - Recent tool call results
39
+ - Immediate decisions
40
+ - Active conversation flow
41
+
42
+ **Limitation**: Limited capacity, volatile (lost when context cleared).
43
+ </short_term_memory>
44
+
45
+ <long_term_memory>
46
+ **Long-term memory (LTM)**: Persistent storage across sessions.
47
+
48
+ **Implementation**: External storage (files, databases, vector stores).
49
+
50
+ **Use for**:
51
+ - Historical patterns
52
+ - Accumulated knowledge
53
+ - User preferences
54
+ - Past task outcomes
55
+
56
+ **Access pattern**: Retrieve relevant memories into working memory when needed.
57
+ </long_term_memory>
58
+
59
+ <working_memory>
60
+ **Working memory**: Current context + retrieved memories.
61
+
62
+ **Composition**:
63
+ - Core task information (always present)
64
+ - Recent interaction history (STM)
65
+ - Retrieved relevant memories (from LTM)
66
+ - Current tool outputs
67
+
68
+ **Management**: This is what fits in context window. Optimize aggressively.
69
+ </working_memory>
70
+
71
+ <core_memory>
72
+ **Core memory**: Actively used information in current interaction.
73
+
74
+ **Examples**:
75
+ - Current task goal and constraints
76
+ - Key facts about the codebase being worked on
77
+ - Critical requirements from user
78
+ - Active workflow state
79
+
80
+ **Principle**: Keep core memory minimal and highly relevant. Everything else is retrievable.
81
+ </core_memory>
82
+
83
+ <archival_memory>
84
+ **Archival memory**: Persistent storage for less critical data.
85
+
86
+ **Examples**:
87
+ - Complete conversation transcripts
88
+ - Full tool output logs
89
+ - Historical metrics
90
+ - Deprecated approaches that were tried
91
+
92
+ **Access**: Rarely needed, searchable when required, doesn't consume context window.
93
+ </archival_memory>
94
+ </memory_architecture>
95
+
96
+ <context_strategies>
97
+
98
+
99
+ <summarization>
100
+ **Pattern**: Move information from context to searchable database, keep summary in memory.
101
+
102
+ <when_to_summarize>
103
+ Trigger summarization when:
104
+ - Context reaches 75% of limit
105
+ - Task transitions to new phase
106
+ - Information is important but no longer actively needed
107
+ - Repeated information appears multiple times
108
+ </when_to_summarize>
109
+
110
+ <summary_quality>
111
+ **Quality guidelines**:
112
+
113
+ 1. **Highlight important events**
114
+ ```markdown
115
+ Bad: "Reviewed code, found issues, provided fixes"
116
+ Good: "Identified critical SQL injection in auth.ts:127, provided parameterized query fix. High-priority: requires immediate attention before deployment."
117
+ ```
118
+
119
+ 2. **Include timing for sequential reasoning**
120
+ ```markdown
121
+ "First attempt: Direct fix failed due to type mismatch.
122
+ Second attempt: Added type conversion, introduced runtime error.
123
+ Final approach: Refactored to use type-safe wrapper (successful)."
124
+ ```
125
+
126
+ 3. **Structure into categories vs long paragraphs**
127
+ ```markdown
128
+ Issues found:
129
+ - Security: SQL injection (Critical), XSS (High)
130
+ - Performance: N+1 query (Medium)
131
+ - Code quality: Duplicate logic (Low)
132
+
133
+ Actions taken:
134
+ - Fixed SQL injection with prepared statements
135
+ - Added input sanitization for XSS
136
+ - Deferred performance optimization (noted in TODOs)
137
+ ```
138
+
139
+ **Benefit**: Organized grouping improves relationship understanding.
140
+ </summary_quality>
141
+
142
+ <example_workflow>
143
+ ```markdown
144
+ <context_management>
145
+ When conversation history exceeds 15 turns:
146
+ 1. Identify information that is:
147
+ - Important (must preserve)
148
+ - Complete (no longer actively changing)
149
+ - Historical (not needed for next immediate step)
150
+ 2. Create structured summary with categories
151
+ 3. Store full details in file (archival memory)
152
+ 4. Replace verbose history with concise summary
153
+ 5. Continue with reduced context load
154
+ </context_management>
155
+ ```
156
+ </example_workflow>
157
+ </summarization>
158
+
159
+ <sliding_window>
160
+ **Pattern**: Recent interactions in context, older interactions as vectors for retrieval.
161
+
162
+ <implementation>
163
+ ```markdown
164
+ <sliding_window_strategy>
165
+ Maintain in context:
166
+ - Last 5 tool calls and results (short-term memory)
167
+ - Current task state and goals (core memory)
168
+ - Key facts from user requirements (core memory)
169
+
170
+ Move to vector storage:
171
+ - Tool calls older than 5 steps
172
+ - Completed subtask results
173
+ - Historical debugging attempts
174
+ - Exploration that didn't lead to solution
175
+
176
+ Retrieval trigger:
177
+ - When current issue similar to past issue
178
+ - When user references earlier discussion
179
+ - When pattern matching suggests relevant history
180
+ </sliding_window_strategy>
181
+ ```
182
+
183
+ **Benefit**: Bounded context growth, relevant history still accessible.
184
+ </implementation>
185
+ </sliding_window>
186
+
187
+ <semantic_context_switching>
188
+ **Pattern**: Detect context changes, respond appropriately.
189
+
190
+ <example>
191
+ ```markdown
192
+ <context_switch_detection>
193
+ Monitor for topic changes:
194
+ - User switches from "fix bug" to "add feature"
195
+ - Subagent transitions from "analysis" to "implementation"
196
+ - Task scope changes mid-execution
197
+
198
+ On context switch:
199
+ 1. Summarize current context state
200
+ 2. Save state to working memory/file
201
+ 3. Load relevant context for new topic
202
+ 4. Acknowledge switch: "Switching from bug analysis to feature implementation. Bug analysis results saved for later reference."
203
+ </context_switch_detection>
204
+ ```
205
+
206
+ **Prevents**: Mixing contexts, applying wrong constraints, forgetting important info when switching tasks.
207
+ </example>
208
+ </semantic_context_switching>
209
+
210
+ <scratchpads>
211
+ **Pattern**: Record intermediate results outside LLM context.
212
+
213
+ <use_cases>
214
+ **When to use scratchpads**:
215
+ - Complex calculations with many steps
216
+ - Exploration of multiple approaches
217
+ - Detailed analysis that may not all be relevant
218
+ - Debugging traces
219
+ - Intermediate data transformations
220
+
221
+ **Implementation**:
222
+ ```markdown
223
+ <scratchpad_workflow>
224
+ For complex debugging:
225
+ 1. Create scratchpad file: `.claude/scratch/debug-session-{timestamp}.md`
226
+ 2. Log each hypothesis and test result in scratchpad
227
+ 3. Keep only current hypothesis and key findings in context
228
+ 4. Reference scratchpad for full debugging history
229
+ 5. Summarize successful approach in final output
230
+ </scratchpad_workflow>
231
+ ```
232
+
233
+ **Benefit**: Context contains insights, scratchpad contains exploration. User gets clean summary, full details available if needed.
234
+ </use_cases>
235
+ </scratchpads>
236
+
237
+ <smart_memory_management>
238
+ **Pattern**: Auto-add key data, retrieve on demand.
239
+
240
+ <smart_write>
241
+ ```markdown
242
+ <auto_capture>
243
+ Automatically save to memory:
244
+ - User-stated preferences: "I prefer TypeScript over JavaScript"
245
+ - Project conventions: "This codebase uses Jest for testing"
246
+ - Critical decisions: "Decided to use OAuth2 for authentication"
247
+ - Frequent patterns: "API endpoints follow REST naming: /api/v1/{resource}"
248
+
249
+ Store in structured format for easy retrieval.
250
+ </auto_capture>
251
+ ```
252
+ </smart_write>
253
+
254
+ <smart_read>
255
+ ```markdown
256
+ <auto_retrieval>
257
+ Automatically retrieve from memory when:
258
+ - User asks about past decision: "Why did we choose OAuth2?"
259
+ - Similar task encountered: "Last time we added auth, we used..."
260
+ - Pattern matching: "This looks like the payment flow issue from last week"
261
+
262
+ Inject relevant memories into working context.
263
+ </auto_retrieval>
264
+ ```
265
+ </smart_read>
266
+ </smart_memory_management>
267
+
268
+ <compaction>
269
+ **Pattern**: Summarize near-limit conversations, reinitiate with summary.
270
+
271
+ <workflow>
272
+ ```markdown
273
+ <compaction_workflow>
274
+ When context reaches 90% capacity:
275
+ 1. Identify essential information:
276
+ - Current task and status
277
+ - Key decisions made
278
+ - Critical constraints
279
+ - Important discoveries
280
+ 2. Generate concise summary (max 20% of context size)
281
+ 3. Save full context to archival storage
282
+ 4. Create new conversation initialized with summary
283
+ 5. Continue task in fresh context
284
+
285
+ Summary format:
286
+ **Task**: [Current objective]
287
+ **Status**: [What's been completed, what remains]
288
+ **Key findings**: [Important discoveries]
289
+ **Decisions**: [Critical choices made]
290
+ **Next steps**: [Immediate actions]
291
+ </compaction_workflow>
292
+ ```
293
+
294
+ **When to use**: Long-running tasks, exploratory analysis, iterative debugging.
295
+ </workflow>
296
+ </compaction>
297
+ </context_strategies>
298
+
299
+ <framework_support>
300
+
301
+
302
+ <langchain>
303
+ **LangChain**: Provides automatic memory management.
304
+
305
+ **Features**:
306
+ - Conversation memory buffers
307
+ - Summary memory
308
+ - Vector store memory
309
+ - Entity extraction
310
+
311
+ **Use case**: Building subagents that need sophisticated memory without manual implementation.
312
+ </langchain>
313
+
314
+ <llamaindex>
315
+ **LlamaIndex**: Indexing for longer conversations.
316
+
317
+ **Features**:
318
+ - Semantic search over conversation history
319
+ - Automatic chunking and indexing
320
+ - Retrieval augmentation
321
+
322
+ **Use case**: Subagents working with large codebases, documentation, or extensive conversation history.
323
+ </llamaindex>
324
+
325
+ <file_based>
326
+ **File-based memory**: Simple, explicit, debuggable.
327
+
328
+ ```markdown
329
+ <memory_structure>
330
+ .claude/memory/
331
+ core-facts.md # Essential project information
332
+ decisions.md # Key decisions and rationale
333
+ patterns.md # Discovered patterns and conventions
334
+ {subagent}-state.json # Subagent-specific state
335
+ </memory_structure>
336
+
337
+ <usage>
338
+ Subagent reads relevant files at start, updates during execution, summarizes at end.
339
+ </usage>
340
+ ```
341
+
342
+ **Benefit**: Transparent, version-controllable, human-readable.
343
+ </file_based>
344
+ </framework_support>
345
+
346
+ <subagent_patterns>
347
+
348
+
349
+ <stateful_subagent>
350
+ **For long-running or frequently-invoked subagents**:
351
+
352
+ ```markdown
353
+ ---
354
+ name: code-architect
355
+ description: Maintains understanding of system architecture across multiple invocations
356
+ tools: Read, Write, Grep, Glob
357
+ model: sonnet
358
+ ---
359
+
360
+ <role>
361
+ You are a system architect maintaining coherent design across project evolution.
362
+ </role>
363
+
364
+ <memory_management>
365
+ On each invocation:
366
+ 1. Read `.claude/memory/architecture-state.md` for current system state
367
+ 2. Perform assigned task with full context
368
+ 3. Update architecture-state.md with new components, decisions, patterns
369
+ 4. Maintain concise state (max 500 lines), summarize older decisions
370
+
371
+ State file structure:
372
+ - Current architecture (always up-to-date)
373
+ - Recent changes (last 10 modifications)
374
+ - Key design decisions (why choices were made)
375
+ - Active concerns (issues to address)
376
+ </memory_management>
377
+ ```
378
+ </stateful_subagent>
379
+
380
+ <stateless_subagent>
381
+ **For simple, focused subagents**:
382
+
383
+ ```markdown
384
+ ---
385
+ name: syntax-checker
386
+ description: Validates code syntax without maintaining state
387
+ tools: Read, Bash
388
+ model: haiku
389
+ ---
390
+
391
+ <role>
392
+ You are a syntax validator. Check code for syntax errors.
393
+ </role>
394
+
395
+ <workflow>
396
+ 1. Read specified files
397
+ 2. Run syntax checker (language-specific linter)
398
+ 3. Report errors with line numbers
399
+ 4. No memory needed - each invocation is independent
400
+ </workflow>
401
+ ```
402
+
403
+ **When to use stateless**: Single-purpose validators, formatters, simple transformations.
404
+ </stateless_subagent>
405
+
406
+ <context_inheritance>
407
+ **Inheriting context from main chat**:
408
+
409
+ Subagents automatically have access to:
410
+ - User's original request
411
+ - Any context provided in invocation
412
+
413
+ ```markdown
414
+ Main chat: "Review the authentication changes for security issues.
415
+ Context: We recently switched from JWT to session-based auth."
416
+
417
+ Subagent receives:
418
+ - Task: Review authentication changes
419
+ - Context: Recent switch from JWT to session-based auth
420
+ - This context informs review focus without explicit memory management
421
+ ```
422
+ </context_inheritance>
423
+ </subagent_patterns>
424
+
425
+ <anti_patterns>
426
+
427
+
428
+ <anti_pattern name="context_dumping">
429
+ ❌ Including everything in context "just in case"
430
+
431
+ **Problem**: Buries important information in noise, wastes tokens, degrades performance.
432
+
433
+ **Fix**: Include only what's relevant for current task. Everything else is retrievable.
434
+ </anti_pattern>
435
+
436
+ <anti_pattern name="no_summarization">
437
+ ❌ Letting context grow unbounded until limit hit
438
+
439
+ **Problem**: Sudden context overflow mid-task, quality degradation before failure.
440
+
441
+ **Fix**: Proactive summarization at 75% capacity, continuous compaction.
442
+ </anti_pattern>
443
+
444
+ <anti_pattern name="lossy_summarization">
445
+ ❌ Summaries that discard critical information
446
+
447
+ **Example**:
448
+ ```markdown
449
+ Bad summary: "Tried several approaches, eventually fixed bug"
450
+ Lost information: What approaches failed, why, what the successful fix was
451
+ ```
452
+
453
+ **Fix**: Summaries preserve essential facts, decisions, and rationale. Details go to archival storage.
454
+ </anti_pattern>
455
+
456
+ <anti_pattern name="no_memory_structure">
457
+ ❌ Unstructured memory (long paragraphs, no organization)
458
+
459
+ **Problem**: Hard to retrieve relevant information, poor for LLM reasoning.
460
+
461
+ **Fix**: Structured memory with categories, bullet points, clear sections.
462
+ </anti_pattern>
463
+
464
+ <anti_pattern name="context_failure_ignorance">
465
+ ❌ Assuming all failures are model limitations
466
+
467
+ **Reality**: "Most agent failures are context failures, not model failures."
468
+
469
+ Check context quality before blaming model:
470
+ - Is relevant information present?
471
+ - Is it organized clearly?
472
+ - Is important info buried in noise?
473
+ - Has context been properly maintained?
474
+ </anti_pattern>
475
+ </anti_patterns>
476
+
477
+ <best_practices>
478
+
479
+
480
+ <principle name="core_memory_minimal">
481
+ Keep core memory minimal and highly relevant.
482
+
483
+ **Rule of thumb**: If information isn't needed for next 3 steps, it doesn't belong in core memory.
484
+ </principle>
485
+
486
+ <principle name="summaries_structured">
487
+ Summaries should be structured, categorized, and scannable.
488
+
489
+ **Template**:
490
+ ```markdown
491
+
492
+ **Status**: [Progress]
493
+ **Completed**:
494
+ - [Key accomplishment 1]
495
+ - [Key accomplishment 2]
496
+
497
+ **Active**:
498
+ - [Current work]
499
+
500
+ **Decisions**:
501
+ - [Important choice 1]: [Rationale]
502
+ - [Important choice 2]: [Rationale]
503
+
504
+ **Next**: [Immediate next steps]
505
+ ```
506
+ </principle>
507
+
508
+ <principle name="timing_matters">
509
+ Include timing for sequential reasoning.
510
+
511
+ "First tried X (failed), then tried Y (worked)" is more useful than "Used approach Y".
512
+ </principle>
513
+
514
+ <principle name="retrieval_over_retention">
515
+ Better to retrieve information on-demand than keep it in context always.
516
+
517
+ **Exception**: Frequently-used core facts (task goal, critical constraints).
518
+ </principle>
519
+
520
+ <principle name="external_storage">
521
+ Use filesystem for:
522
+ - Full logs and traces
523
+ - Detailed exploration results
524
+ - Historical data
525
+ - Intermediate work products
526
+
527
+ Use context for:
528
+ - Current task state
529
+ - Key decisions
530
+ - Active workflow
531
+ - Immediate next steps
532
+ </principle>
533
+ </best_practices>
534
+
535
+ <prompt_caching_interaction>
536
+
537
+
538
+ Prompt caching (see [subagents.md](subagents.md#prompt_caching)) works best with stable context.
539
+
540
+ <cache_friendly_context>
541
+ **Structure context for caching**:
542
+
543
+ ```markdown
544
+ [CACHEABLE: Stable subagent instructions]
545
+ <role>...</role>
546
+ <focus_areas>...</focus_areas>
547
+ <workflow>...</workflow>
548
+ ---
549
+ [CACHE BREAKPOINT]
550
+ ---
551
+ [VARIABLE: Task-specific context]
552
+ Current task: ...
553
+ Recent context: ...
554
+ ```
555
+
556
+ **Benefit**: Stable instructions cached, task-specific context fresh. 90% cost reduction on cached portion.
557
+ </cache_friendly_context>
558
+
559
+ <cache_invalidation>
560
+ **When context changes invalidate cache**:
561
+ - Subagent prompt updated
562
+ - Core memory structure changed
563
+ - Context reorganization
564
+
565
+ **Mitigation**: Keep stable content (role, workflow, constraints) separate from variable content (current task, recent history).
566
+ </cache_invalidation>
567
+ </prompt_caching_interaction>