@codeharbor/agent-playbook 0.1.0 → 0.1.2

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 (114) hide show
  1. package/README.md +4 -2
  2. package/package.json +5 -2
  3. package/skills/api-designer/README.md +36 -0
  4. package/skills/api-designer/SKILL.md +232 -0
  5. package/skills/api-designer/references/graphql-patterns.md +12 -0
  6. package/skills/api-designer/references/rest-patterns.md +17 -0
  7. package/skills/api-designer/scripts/generate_api.py +87 -0
  8. package/skills/api-designer/scripts/validate_api.py +48 -0
  9. package/skills/api-documenter/README.md +41 -0
  10. package/skills/api-documenter/SKILL.md +209 -0
  11. package/skills/api-documenter/references/examples/README.md +3 -0
  12. package/skills/api-documenter/references/examples/openapi-example.yaml +10 -0
  13. package/skills/api-documenter/references/openapi-template.yaml +5 -0
  14. package/skills/api-documenter/scripts/generate_openapi.py +84 -0
  15. package/skills/api-documenter/scripts/validate_openapi.py +45 -0
  16. package/skills/architecting-solutions/README.md +22 -0
  17. package/skills/architecting-solutions/SKILL.md +459 -0
  18. package/skills/auto-trigger/README.md +23 -0
  19. package/skills/auto-trigger/SKILL.md +183 -0
  20. package/skills/code-reviewer/README.md +59 -0
  21. package/skills/code-reviewer/SKILL.md +220 -0
  22. package/skills/code-reviewer/references/checklist.md +80 -0
  23. package/skills/code-reviewer/references/patterns.md +226 -0
  24. package/skills/code-reviewer/references/security.md +88 -0
  25. package/skills/code-reviewer/scripts/review_checklist.py +191 -0
  26. package/skills/commit-helper/README.md +58 -0
  27. package/skills/commit-helper/SKILL.md +159 -0
  28. package/skills/commit-helper/references/conventional-commits.md +68 -0
  29. package/skills/commit-helper/references/examples.md +125 -0
  30. package/skills/commit-helper/references/scopes.md +49 -0
  31. package/skills/commit-helper/scripts/validate_commit.py +70 -0
  32. package/skills/create-pr/README.md +182 -0
  33. package/skills/create-pr/SKILL.md +340 -0
  34. package/skills/debugger/README.md +53 -0
  35. package/skills/debugger/SKILL.md +239 -0
  36. package/skills/debugger/references/checklist.md +7 -0
  37. package/skills/debugger/references/errors.md +6 -0
  38. package/skills/debugger/references/patterns.md +5 -0
  39. package/skills/debugger/scripts/debug_report.py +77 -0
  40. package/skills/deployment-engineer/README.md +40 -0
  41. package/skills/deployment-engineer/SKILL.md +242 -0
  42. package/skills/deployment-engineer/references/kubernetes.md +23 -0
  43. package/skills/deployment-engineer/references/monitoring.md +14 -0
  44. package/skills/deployment-engineer/references/pipelines.md +12 -0
  45. package/skills/deployment-engineer/scripts/generate_deploy.py +72 -0
  46. package/skills/deployment-engineer/scripts/validate_deploy.py +46 -0
  47. package/skills/documentation-engineer/README.md +41 -0
  48. package/skills/documentation-engineer/SKILL.md +164 -0
  49. package/skills/documentation-engineer/references/api-template.md +22 -0
  50. package/skills/documentation-engineer/references/readme-template.md +25 -0
  51. package/skills/documentation-engineer/references/style-guide.md +13 -0
  52. package/skills/documentation-engineer/scripts/generate_docs.py +68 -0
  53. package/skills/documentation-engineer/scripts/validate_docs.py +46 -0
  54. package/skills/figma-designer/README.md +222 -0
  55. package/skills/figma-designer/SKILL.md +407 -0
  56. package/skills/figma-designer/references/example-output.md +86 -0
  57. package/skills/performance-engineer/README.md +42 -0
  58. package/skills/performance-engineer/SKILL.md +236 -0
  59. package/skills/performance-engineer/references/checklist.md +6 -0
  60. package/skills/performance-engineer/references/monitoring.md +5 -0
  61. package/skills/performance-engineer/references/optimization.md +7 -0
  62. package/skills/performance-engineer/scripts/perf_report.py +64 -0
  63. package/skills/performance-engineer/scripts/profile.py +63 -0
  64. package/skills/planning-with-files/README.md +27 -0
  65. package/skills/planning-with-files/SKILL.md +103 -0
  66. package/skills/prd-implementation-precheck/README.md +97 -0
  67. package/skills/prd-implementation-precheck/SKILL.md +112 -0
  68. package/skills/prd-planner/README.md +102 -0
  69. package/skills/prd-planner/SKILL.md +449 -0
  70. package/skills/prd-planner/references/edge-case-analysis.md +111 -0
  71. package/skills/qa-expert/README.md +37 -0
  72. package/skills/qa-expert/SKILL.md +225 -0
  73. package/skills/qa-expert/references/gates.md +11 -0
  74. package/skills/qa-expert/references/metrics.md +6 -0
  75. package/skills/qa-expert/references/strategy.md +11 -0
  76. package/skills/qa-expert/scripts/coverage_analysis.py +61 -0
  77. package/skills/qa-expert/scripts/generate_test_plan.py +68 -0
  78. package/skills/refactoring-specialist/README.md +37 -0
  79. package/skills/refactoring-specialist/SKILL.md +283 -0
  80. package/skills/refactoring-specialist/references/checklist.md +6 -0
  81. package/skills/refactoring-specialist/references/smells.md +6 -0
  82. package/skills/refactoring-specialist/references/techniques.md +6 -0
  83. package/skills/security-auditor/README.md +48 -0
  84. package/skills/security-auditor/SKILL.md +256 -0
  85. package/skills/security-auditor/references/checklist.md +7 -0
  86. package/skills/security-auditor/references/owasp.md +12 -0
  87. package/skills/security-auditor/references/remediation.md +7 -0
  88. package/skills/security-auditor/scripts/find_secrets.py +58 -0
  89. package/skills/security-auditor/scripts/security_audit.py +64 -0
  90. package/skills/self-improving-agent/README.md +136 -0
  91. package/skills/self-improving-agent/SKILL.md +407 -0
  92. package/skills/self-improving-agent/hooks/post-bash.sh +10 -0
  93. package/skills/self-improving-agent/hooks/pre-tool.sh +10 -0
  94. package/skills/self-improving-agent/hooks/session-end.sh +4 -0
  95. package/skills/self-improving-agent/memory/semantic-patterns.json +288 -0
  96. package/skills/self-improving-agent/references/appendix.md +131 -0
  97. package/skills/self-improving-agent/templates/correction-template.md +11 -0
  98. package/skills/self-improving-agent/templates/pattern-template.md +15 -0
  99. package/skills/self-improving-agent/templates/validation-template.md +14 -0
  100. package/skills/session-logger/README.md +50 -0
  101. package/skills/session-logger/SKILL.md +156 -0
  102. package/skills/skill-router/README.md +155 -0
  103. package/skills/skill-router/SKILL.md +215 -0
  104. package/skills/test-automator/README.md +41 -0
  105. package/skills/test-automator/SKILL.md +202 -0
  106. package/skills/test-automator/references/best-practices.md +6 -0
  107. package/skills/test-automator/references/examples/README.md +3 -0
  108. package/skills/test-automator/references/examples/unit-test-example.md +8 -0
  109. package/skills/test-automator/references/mocking.md +5 -0
  110. package/skills/test-automator/scripts/coverage_report.py +59 -0
  111. package/skills/test-automator/scripts/generate_test.py +66 -0
  112. package/skills/workflow-orchestrator/README.md +20 -0
  113. package/skills/workflow-orchestrator/SKILL.md +342 -0
  114. package/src/cli.js +107 -20
@@ -0,0 +1,459 @@
1
+ ---
2
+ name: architecting-solutions
3
+ description: Designs technical solutions and architecture. Use when user says "design solution", "architecture design", "technical design", or "方案设计" WITHOUT mentioning PRD. For PRD-specific work, use prd-planner skill instead.
4
+ allowed-tools: Read, Write, Edit, Bash, AskUserQuestion, WebSearch, Grep, Glob
5
+ ---
6
+
7
+ # Architecting Solutions
8
+
9
+ Analyzes requirements and creates detailed PRD documents for software implementation.
10
+
11
+ ## Description
12
+
13
+ Use this skill when you need to:
14
+ - Create PRD documents
15
+ - Design software solutions
16
+ - Analyze requirements
17
+ - Specify features
18
+ - Document technical plans
19
+ - Plan refactoring or migration
20
+
21
+ ## Installation
22
+
23
+ This skill is typically installed globally at `~/.claude/skills/architecting-solutions/`.
24
+
25
+ ## How It Works
26
+
27
+ The skill guides Claude through a structured workflow:
28
+
29
+ 1. **Clarify requirements** - Ask targeted questions to understand the problem
30
+ 2. **Analyze context** - Review existing codebase for patterns and constraints
31
+ 3. **Design solution** - Propose architecture with trade-offs considered
32
+ 4. **Generate PRD** - Output markdown PRD to `{PROJECT_ROOT}/docs/` directory
33
+
34
+ **IMPORTANT**: Always write PRD to the project's `docs/` folder, never to plan files or hidden locations.
35
+
36
+ ## Workflow
37
+
38
+ Copy this checklist and track progress:
39
+
40
+ ```
41
+ Requirements Analysis:
42
+ - [ ] Step 1: Clarify user intent and success criteria
43
+ - [ ] Step 2: Identify constraints (tech stack, timeline, resources)
44
+ - [ ] Step 3: Analyze existing codebase patterns
45
+ - [ ] Step 4: Research best practices (if needed)
46
+ - [ ] Step 5: Design solution architecture
47
+ - [ ] Step 6: Generate PRD document (must be in {PROJECT_ROOT}/docs/)
48
+ - [ ] Step 7: Validate with user
49
+ ```
50
+
51
+ ## Step 1: Clarify Requirements
52
+
53
+ Ask these questions to understand the problem:
54
+
55
+ ### Core Understanding
56
+ - **Problem Statement**: What problem are we solving? What is the current pain point?
57
+ - **Success Criteria**: How do we know this is successful? Be specific.
58
+ - **Target Users**: Who will use this feature? What are their goals?
59
+
60
+ ### For Refactoring/Migration:
61
+ - **Why Refactor?**: What's wrong with current implementation? Be specific.
62
+ - **Breaking Changes**: What will break? What needs migration?
63
+ - **Rollback Plan**: How do we revert if something goes wrong?
64
+
65
+ ## Step 2: Identify Constraints
66
+
67
+ - **Technical Constraints**: Existing tech stack, architecture patterns, dependencies
68
+ - **Time Constraints**: Any deadlines or phases?
69
+ - **Resource Constraints**: Team size, expertise availability
70
+ - **Business Constraints**: Budget, external dependencies, third-party APIs
71
+
72
+ ## Step 3: Analyze Existing Codebase
73
+
74
+ ```bash
75
+ # Find similar patterns in the codebase
76
+ grep -r "related_keyword" packages/ --include="*.ts" --include="*.tsx"
77
+
78
+ # Find relevant directory structures
79
+ find packages/ -type d -name "*keyword*"
80
+
81
+ # Check existing patterns
82
+ ls -la packages/kit/src/views/similar-feature/
83
+ ```
84
+
85
+ **Critical for Refactoring:**
86
+ - Find ALL consumers of the code being changed
87
+ - Identify ALL state/data flows
88
+ - Trace ALL entry points and exit points
89
+ - **Look for existing mechanisms that might solve the problem already**
90
+
91
+ ```bash
92
+ # Find all imports/usages of a module
93
+ grep -r "useBorrowContext" packages/ --include="*.ts" --include="*.tsx"
94
+ grep -r "borrowRefreshReservesRef" packages/ --include="*.ts" --include="*.tsx"
95
+ ```
96
+
97
+ **CRITICAL: Before proposing a refactoring, ask:**
98
+ 1. Is there an **existing mechanism** that can be extended?
99
+ 2. What's the **simplest possible solution**?
100
+ 3. Can we solve this with **minimal changes**?
101
+ 4. **Does my solution actually connect the dots?** (e.g., empty callbacks won't work)
102
+
103
+ Look for:
104
+ - **Architectural patterns**: How are similar features implemented?
105
+ - **State management**: What state solution is used? (Jotai, Redux, Context, Refs)
106
+ - **Component patterns**: How are components organized?
107
+ - **API patterns**: How are API calls structured?
108
+ - **Type definitions**: Where are types defined?
109
+
110
+ ## Step 4: Research Best Practices
111
+
112
+ For unfamiliar domains, search for best practices.
113
+
114
+ ## Step 5: Design Solution Architecture
115
+
116
+ ### CRITICAL: Consider Multiple Solutions
117
+
118
+ **Before settling on a solution, ALWAYS present multiple options:**
119
+
120
+ 1. **Minimal Change Solution** - What's the absolute smallest change that could work?
121
+ 2. **Medium Effort Solution** - Balanced approach with some refactoring
122
+ 3. **Comprehensive Solution** - Full architectural overhaul
123
+
124
+ **Example:**
125
+ ```
126
+ Problem: Data doesn't refresh after operation
127
+
128
+ Option 1 (Minimal): Hook into existing pendingTx count decrease
129
+ - Changes: 1-2 files
130
+ - Risk: Low
131
+ - Selected: ✓
132
+
133
+ Option 2 (Medium): Add refresh callback through existing context
134
+ - Changes: 3-5 files
135
+ - Risk: Medium
136
+
137
+ Option 3 (Comprehensive): Migrate to Jotai Context pattern
138
+ - Changes: 10+ files, new atoms/actions
139
+ - Risk: High
140
+ - Time: 2-3 days
141
+ ```
142
+
143
+ **Ask user BEFORE writing PRD:**
144
+ - Which option do you prefer?
145
+ - Are you open to larger refactoring?
146
+ - What's your tolerance for change?
147
+
148
+ ### Architecture Design Principles
149
+
150
+ 1. **Simplicity First**: Choose the simplest solution that meets requirements
151
+ 2. **Progressive Enhancement**: Start with MVP, extend iteratively
152
+ 3. **Separation of Concerns**: UI, logic, and data should be separated
153
+ 4. **Reusability**: Design components that can be reused
154
+ 5. **Testability**: Design for easy testing
155
+
156
+ ### Document Trade-offs
157
+
158
+ For each major decision, document:
159
+
160
+ | Option | Pros | Cons | Selected |
161
+ |--------|------|------|----------|
162
+ | Approach A | Pro1, Pro2 | Con1 | ✓ |
163
+ | Approach B | Pro1 | Con1, Con2 | |
164
+
165
+ ## Step 6: Generate PRD Document
166
+
167
+ **IMPORTANT**: Always write PRD to the project's `docs/` directory, never to plan files or hidden locations.
168
+
169
+ Output location: `{PROJECT_ROOT}/docs/{feature-name}-prd.md`
170
+
171
+ Example:
172
+ - If project root is `/Users/user/my-project/`, write to `/Users/user/my-project/docs/feature-name-prd.md`
173
+ - Use kebab-case for filename: `borrow-refresh-logic-refactoring-prd.md`
174
+
175
+ ## Step 7: Validate with User
176
+
177
+ Before finalizing:
178
+ 1. **Review success criteria** - Do they align with user goals?
179
+ 2. **Check constraints** - Are all constraints addressed?
180
+ 3. **Verify completeness** - Can another agent implement from this PRD?
181
+ 4. **Confirm with user** - Get explicit approval before finalizing
182
+
183
+ ---
184
+
185
+ # PRD Quality Checklist
186
+
187
+ ## Content Quality
188
+
189
+ - [ ] Problem statement is clear and specific
190
+ - [ ] Success criteria are measurable
191
+ - [ ] Functional requirements are unambiguous
192
+ - [ ] Non-functional requirements are specified
193
+ - [ ] Constraints are documented
194
+ - [ ] Trade-offs are explained
195
+
196
+ ## Implementation Readiness
197
+
198
+ - [ ] Architecture is clearly defined
199
+ - [ ] File structure is specified
200
+ - [ ] API contracts are defined (if applicable)
201
+ - [ ] Data models are specified
202
+ - [ ] Edge cases are considered
203
+ - [ ] Testing approach is outlined
204
+
205
+ ## Agent-Friendliness
206
+
207
+ - [ ] Another agent can implement without clarification
208
+ - [ ] Code examples are provided where helpful
209
+ - [ ] File paths use forward slashes
210
+ - [ ] Existing code references are accurate
211
+
212
+ ---
213
+
214
+ ## Root Cause Analysis Checklist (CRITICAL)
215
+
216
+ For bugs and refresh issues, ALWAYS verify:
217
+
218
+ - [ ] **Existing mechanism already exists** - Does a working solution exist elsewhere?
219
+ - [ ] **Why existing solution doesn't work** - Timing? Scope? Not connected?
220
+ - [ ] **Each hook/component instance is independent** - They don't share state unless explicitly connected
221
+ - [ ] **Callback chain is complete** - Trace from trigger to effect, every link must work
222
+ - [ ] **Empty callbacks are called** - If `onRefresh` is provided, is it actually implemented?
223
+ - [ ] **Polling/refresh timing** - What are the intervals? When do they fire?
224
+
225
+ **Common Root Cause Mistakes**:
226
+ - Assuming hooks share state (they don't - each instance is independent)
227
+ - Empty callback implementations that do nothing
228
+ - Not tracing the full call chain from trigger to effect
229
+ - Not understanding when events fire (e.g., `revalidateOnFocus` requires actual focus change)
230
+
231
+ ---
232
+
233
+ # Migration Scope Completeness
234
+
235
+ - [ ] **ALL existing state is accounted for**: List every piece of state being migrated
236
+ - What states are being migrated? (e.g., reserves, market, reservesLoading, swapConfig, pendingTxs)
237
+ - What's the migration strategy for each? (direct move / transform / deprecate)
238
+
239
+ - [ ] **ALL consumers are identified**: Find every file that uses the code being changed
240
+ ```bash
241
+ # Must run: grep -r "import.*ModuleName" packages/
242
+ # Must run: grep -r "useHookName" packages/
243
+ ```
244
+
245
+ - [ ] **Provider usage points are covered**: Every file using the Provider is updated
246
+ - Root Provider → Mirror Provider migration
247
+ - All pages/components using the provider
248
+
249
+ ## State/Data Flow Validation
250
+
251
+ - [ ] **No orphaned state**: Every piece of state has a clear source and consumer
252
+ - [ ] **No dead state**: Every new state/state variable has a defined purpose and consumer
253
+ - [ ] **No undefined references**: All imports/references resolve to existing code
254
+ - [ ] **Complete call chain documented**: From trigger → callback → effect, show every step
255
+ - [ ] **All related operations covered**: If module has Supply/Withdraw/Borrow/Repay/Claim, test all of them
256
+
257
+ ## React/Hook Rules Compliance
258
+
259
+ - [ ] **No conditional hooks**: Never call hooks conditionally (e.g., `isBorrowType ? useHook() : null`)
260
+ - Hooks MUST be called at the top level, unconditionally
261
+ - If conditional logic is needed, use early return or conditional rendering
262
+
263
+ - [ ] **Ref usage is correct**: If using ref pattern, access via `.current`
264
+ - Check: `useBorrowActions().current` not `useBorrowActions()`
265
+
266
+ ## Provider Pattern Completeness
267
+
268
+ - [ ] **Root Provider is defined**: Main Provider component exists
269
+ - [ ] **Mirror Provider is defined**: Mirror Provider for modal/overlay contexts exists
270
+ - [ ] **All usage points wrapped**: Every page/component using the provider is wrapped
271
+ ```bash
272
+ # Must verify: Each page that uses the context has the Provider wrapper
273
+ ```
274
+
275
+ ## Auto-mount/System Integration
276
+
277
+ - [ ] **Enum registration**: Added to appropriate enum (e.g., `EJotaiContextStoreNames`)
278
+ - [ ] **Switch case registration**: Added to auto-mount switch statement
279
+ - [ ] **Store initialization**: Store initialization logic is complete
280
+ - [ ] **No duplicate registrations**: Verify no conflicts with existing entries
281
+
282
+ ## Backward Compatibility
283
+
284
+ - [ ] **Existing consumers work**: Code using the old pattern still works during migration
285
+ - [ ] **Migration path is clear**: How do consumers migrate to the new pattern?
286
+ - [ ] **Deprecation timeline**: When is the old pattern removed?
287
+
288
+ ## Code Examples
289
+
290
+ - [ ] **Before/After comparisons**: Show code changes clearly
291
+ - [ ] **Type definitions are accurate**: TypeScript types match the implementation
292
+ - [ ] **Import paths are correct**: All imports use correct workspace paths
293
+
294
+ ---
295
+
296
+ # Common Anti-Patterns to Avoid
297
+
298
+ | Anti-Pattern | Better Approach |
299
+ |--------------|-----------------|
300
+ | "Optimize the code" | "Reduce render time from 100ms to 16ms by memoizing expensive calculations" |
301
+ | "Make it faster" | "Implement caching to reduce API calls from 5 to 1 per session" |
302
+ | "Clean up the code" | "Extract duplicate logic into shared utility functions" |
303
+ | "Fix the bug" | "Handle null case in getUserById when user doesn't exist" |
304
+ | "Refactor to use Jotai" | "Migrate from Context+Ref to Jotai: <detailed state list and migration strategy>" |
305
+ | **Over-engineering** | **Start with simplest solution, extend only if needed** |
306
+
307
+ ---
308
+
309
+ # Over-Engineering Warning (Critical Lesson)
310
+
311
+ ## The Problem with Jumping to Complex Solutions
312
+
313
+ **Real Case Study:**
314
+ - **PRD Proposed**: Full Jotai Context migration (10+ files, 2-3 days)
315
+ - **Actual Solution**: Hook into existing pendingTx count decrease (1-2 files, 1 hour)
316
+ - **Lesson**: Always look for the simplest solution first
317
+
318
+ ## Signs You Might Be Over-Engineering
319
+
320
+ - ❌ Proposing new patterns when existing ones could work
321
+ - ❌ Creating new state management before exhausting current options
322
+ - ❌ Multiple new files when one file change could suffice
323
+ - ❌ "Best practice" justification without considering practicality
324
+
325
+ ## Questions to Ask Before Writing PRD
326
+
327
+ 1. **Is there an existing mechanism that does 80% of what we need?**
328
+ 2. **Can we extend/modify existing code instead of creating new patterns?**
329
+ 3. **What's the absolute minimum change to solve THIS problem?**
330
+ 4. **Does the user actually want a major refactor?**
331
+ 5. **Does my solution's callback actually do something?** (Empty callbacks are bugs!)
332
+ 6. **Have I traced the complete call chain?** (Trigger → ... → Effect)
333
+
334
+ ## When Comprehensive Solutions ARE Appropriate
335
+
336
+ - Current architecture is fundamentally broken
337
+ - Technical debt is blocking all new features
338
+ - Team has explicitly decided to modernize
339
+ - Problem will recur if not properly addressed
340
+
341
+ **Key**: Comprehensive solutions should be a CHOICE, not the DEFAULT.
342
+
343
+ ---
344
+
345
+ # Patterns for Common Scenarios
346
+
347
+ ## New Feature Implementation
348
+
349
+ ```
350
+ 1. Read similar feature implementations
351
+ 2. Identify reusable patterns
352
+ 3. Design component hierarchy
353
+ 4. Define state management approach
354
+ 5. Specify API integration points
355
+ 6. List all new files to create
356
+ 7. List all existing files to modify
357
+ ```
358
+
359
+ ## Refactoring Existing Code
360
+
361
+ ```
362
+ 1. Analyze current implementation
363
+ 2. Find ALL consumers (grep -r imports)
364
+ 3. Identify pain points and technical debt
365
+ 4. PROPOSE MULTIPLE SOLUTIONS (minimal → comprehensive)
366
+ 5. GET USER APPROVAL on approach
367
+ 6. Plan migration strategy (phased vs big-bang)
368
+ 7. Define rollback approach
369
+ 8. List migration checklist
370
+
371
+ # CRITICAL: Start with the simplest solution!
372
+ # Only propose comprehensive refactoring if user explicitly wants it.
373
+ ```
374
+
375
+ ## Bug Fix Investigation
376
+
377
+ ```
378
+ 1. Understand expected vs actual behavior
379
+ 2. Locate root cause in code
380
+ 3. Identify affected areas
381
+ 4. Design fix approach
382
+ 5. Specify testing for regression prevention
383
+ ```
384
+
385
+ ---
386
+
387
+ # Reference Materials
388
+
389
+ - **PRD Template**: Look at existing PRDs in the project's `docs/` folder
390
+ - **Similar Implementations**: Reference similar features/modules in the codebase
391
+
392
+ ---
393
+
394
+ # Tips for Effective PRDs
395
+
396
+ 1. **Be Specific**: "Improve performance" → "Reduce API response time from 2s to 500ms"
397
+ 2. **Show Context**: Explain why a decision was made, not just what was decided
398
+ 3. **Include Examples**: Show code snippets for complex patterns
399
+ 4. **Think About Edge Cases**: What happens when API fails? User has no data?
400
+ 5. **Consider Migration**: For refactoring, how do we move from A to B safely?
401
+ 6. **List ALL Changes**: For refactoring, list every file that changes
402
+ 7. **Validate Imports**: Verify all import paths exist and are correct
403
+ 8. **Check Hook Rules**: Ensure no conditional hooks, proper hook dependencies
404
+
405
+ ---
406
+
407
+ ## Accuracy & Completeness (Critical Lessons from Real PRD Reviews)
408
+
409
+ ### Technical Terms - Be Precise
410
+
411
+ | Wrong | Correct | Why |
412
+ |-------|---------|-----|
413
+ | "Shared state" | "Each instance polls independently" | Hooks don't share state unless explicitly connected |
414
+ | "Pending changes" | "Pending count decreases" | Code checks `!isPending && prevIsPending` (true→false) |
415
+ | "Triggers refresh" | "Calls navigation.goBack() which triggers..." | Show the complete chain |
416
+
417
+ ### Call Chain Documentation - Don't Skip Steps
418
+
419
+ **Bad**: "onRefresh triggers data refresh"
420
+ **Good**:
421
+ ```
422
+ onRefresh() → navigation.goBack() → BorrowHome focused
423
+ → usePromiseResult (revalidateOnFocus: true) fires
424
+ → refreshReserves() → handleRefresh()
425
+ → fetchReserves() + refreshBorrowRewards() + refreshHealthFactor()
426
+ ```
427
+
428
+ Include file paths and line numbers for each step!
429
+
430
+ ### Test Coverage - Cover ALL Operations
431
+
432
+ If module has 5 operations (Supply/Withdraw/Borrow/Repay/Claim), test all 5.
433
+ Don't just test the 2 you're focused on.
434
+
435
+ ### Timeline Analysis for Refresh/Timing Issues
436
+
437
+ Draw out the timeline:
438
+ ```
439
+ 0s ---- Modal opens, user starts Supply
440
+ 10s ---- Transaction submitted, pending: 0→1
441
+ 15s ---- Modal closes
442
+ └─ BorrowHome's hook last polled at 5s
443
+ └─ Next poll at 35s (25s away!) ❌
444
+ ```
445
+
446
+ This shows WHY it doesn't work.
447
+
448
+ ### Common PRD Mistakes
449
+
450
+ | Mistake | Example | Fix |
451
+ |---------|---------|-----|
452
+ | Empty callback | `onRefresh: () => {}` | Implement actual logic or remove |
453
+ | Incomplete root cause | "It doesn't refresh" | Explain WHY: timing/scope/disconnected |
454
+ | Missing call chain | "Somehow triggers refresh" | Document every step with file:line |
455
+ | Incomplete testing | Only test Supply/Withdraw | Also test Borrow/Repay/Claim |
456
+ | Assumptions as facts | "revalidateOnFocus fires on modal close" | Verify: only fires on actual focus change |
457
+ | Wrong trigger condition | "Pending changes" | Code shows: `!isPending && prevIsPending` (decreases) |
458
+
459
+ ---
@@ -0,0 +1,23 @@
1
+ # Auto-Trigger
2
+
3
+ > Configuration skill that defines automatic trigger relationships between skills.
4
+
5
+ ## Installation
6
+
7
+ This skill is part of the [agent-playbook](https://github.com/Charon-Fan/agent-playbook) collection.
8
+
9
+ ## Usage
10
+
11
+ This is a configuration skill and is **not** intended for direct invocation.
12
+
13
+ Typical usage is through `workflow-orchestrator`, which reads the hook definitions from this skill and executes follow-up actions.
14
+
15
+ ## Example
16
+
17
+ ```
18
+ # In another skill's front matter
19
+ hooks:
20
+ after_complete:
21
+ - trigger: session-logger
22
+ mode: auto
23
+ ```
@@ -0,0 +1,183 @@
1
+ ---
2
+ name: auto-trigger
3
+ description: Workflow automation hooks for agent-playbook skills. This skill defines automatic triggers between skills - DO NOT use directly, it's a configuration skill that other skills reference.
4
+ allowed-tools: Read, Write, Edit
5
+ ---
6
+
7
+ # Auto-Trigger Hooks
8
+
9
+ This skill defines automatic trigger relationships between skills. When a skill completes its workflow, it should automatically trigger the next skill in the chain.
10
+
11
+ ## Hook Definitions
12
+
13
+ ### PRD Creation Chain
14
+
15
+ ```yaml
16
+ prd_complete:
17
+ triggers:
18
+ - skill: self-improving-agent
19
+ mode: background
20
+ condition: PRD file exists and is complete
21
+ - skill: session-logger
22
+ mode: auto
23
+ context: "PRD created for {feature_name}"
24
+
25
+ prd_implemented:
26
+ triggers:
27
+ - skill: session-logger
28
+ mode: auto
29
+ context: "Implemented PRD: {feature_name}"
30
+ ```
31
+
32
+ ### Implementation Chain
33
+
34
+ ```yaml
35
+ implementation_complete:
36
+ triggers:
37
+ - skill: code-reviewer
38
+ mode: ask_first
39
+ message: "Implementation complete. Run code review?"
40
+ - skill: create-pr
41
+ mode: auto
42
+ condition: changes_staged
43
+ ```
44
+
45
+ ### Session Management
46
+
47
+ ```yaml
48
+ session_start:
49
+ auto_triggers:
50
+ - skill: session-logger
51
+ action: create_session_file
52
+
53
+ session_end:
54
+ auto_triggers:
55
+ - skill: session-logger
56
+ action: update_session_file
57
+ ```
58
+
59
+ ## Hook Format in Skills
60
+
61
+ To add auto-trigger capability to a skill, add to its front matter:
62
+
63
+ ```yaml
64
+ ---
65
+ name: my-skill
66
+ description: Skill description
67
+ allowed-tools: Read, Write, Edit
68
+ hooks:
69
+ before_start:
70
+ - trigger: session-logger
71
+ mode: auto
72
+ context: "Start {skill_name}"
73
+ after_complete:
74
+ - trigger: self-improving-agent
75
+ mode: background
76
+ - trigger: session-logger
77
+ mode: auto
78
+ on_error:
79
+ - trigger: self-improving-agent
80
+ mode: background
81
+ ---
82
+ ```
83
+
84
+ ## Implementation Guide
85
+
86
+ When a skill completes its workflow:
87
+
88
+ 1. **Check `hooks`** in its own front matter (`before_start`, `after_complete`, `on_error`, `on_progress`)
89
+ 2. **For each hook:**
90
+ - If `mode: auto`, trigger immediately
91
+ - If `mode: background`, trigger without waiting
92
+ - If `mode: ask_first`, ask user before triggering
93
+ - If `condition:` exists, check it first
94
+ 3. **Pass context** to the triggered skill
95
+
96
+ ## Example Integration
97
+
98
+ ### prd-planner should add:
99
+
100
+ ```yaml
101
+ ---
102
+ name: prd-planner
103
+ description: Creates PRDs using persistent file-based planning...
104
+ allowed-tools: Read, Write, Edit, Bash, Grep, Glob, AskUserQuestion, WebSearch
105
+ hooks:
106
+ after_complete:
107
+ - trigger: self-improving-agent
108
+ mode: background
109
+ context: "PRD created at {prd_file}"
110
+ - trigger: session-logger
111
+ mode: auto
112
+ context: "PRD creation complete"
113
+ ---
114
+ ```
115
+
116
+ ### self-improving-agent already has:
117
+
118
+ ```yaml
119
+ ---
120
+ name: self-improving-agent
121
+ description: Universal self-improvement that learns from all skill experiences...
122
+ allowed-tools: Read, Write,Edit, Bash, Grep, Glob, WebSearch
123
+ hooks:
124
+ after_complete:
125
+ - trigger: create-pr
126
+ mode: ask_first
127
+ condition: skills_modified
128
+ - trigger: session-logger
129
+ mode: auto
130
+ context: "Self-improvement cycle complete"
131
+ on_error:
132
+ - trigger: self-improving-agent
133
+ mode: background
134
+ ---
135
+ ```
136
+
137
+ ### create-pr should add:
138
+
139
+ ```yaml
140
+ ---
141
+ name: create-pr
142
+ description: Creates pull requests with bilingual documentation updates...
143
+ allowed-tools: Read, Write, Edit, Bash, Grep, AskUserQuestion
144
+ hooks:
145
+ after_complete:
146
+ - trigger: session-logger
147
+ mode: auto
148
+ context: "PR created: {pr_title}"
149
+ ---
150
+ ```
151
+
152
+ ## Chain Visualization
153
+
154
+ ```
155
+ ┌──────────────┐
156
+ │ prd-planner │
157
+ └──────┬───────┘
158
+ │ after_complete
159
+ ├──→ self-improving-agent (background)
160
+ │ └──→ create-pr (ask_first)
161
+ │ └──→ session-logger (auto)
162
+ └──→ session-logger (auto)
163
+ ```
164
+
165
+ ## Error Correction Chain
166
+
167
+ ```yaml
168
+ on_error:
169
+ triggers:
170
+ - skill: self-improving-agent
171
+ mode: background
172
+ context: "Error occurred in {skill_name}"
173
+ - skill: session-logger
174
+ mode: auto
175
+ context: "Error captured for {skill_name}"
176
+ ```
177
+
178
+ ## Important Rules
179
+
180
+ 1. **Don't create infinite loops** - Ensure chains terminate
181
+ 2. **Ask before major actions** - Use `mode: ask_first` for PRs, deployments
182
+ 3. **Background tasks** - Use `mode: background` for non-blocking tasks
183
+ 4. **Pass context** - Always include relevant context to triggered skills