@iamnishankhan/opencode-kit-grok 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/bin/cli.js +46 -0
  2. package/kit/.opencode/AGENTS.md +392 -0
  3. package/kit/.opencode/README.md +71 -0
  4. package/kit/.opencode/USAGE.md +405 -0
  5. package/kit/.opencode/agents/backend-specialist.md +278 -0
  6. package/kit/.opencode/agents/code-archaeologist.md +114 -0
  7. package/kit/.opencode/agents/database-architect.md +233 -0
  8. package/kit/.opencode/agents/debugger.md +234 -0
  9. package/kit/.opencode/agents/devops-engineer.md +252 -0
  10. package/kit/.opencode/agents/documentation-writer.md +111 -0
  11. package/kit/.opencode/agents/explorer-agent.md +83 -0
  12. package/kit/.opencode/agents/frontend-specialist.md +606 -0
  13. package/kit/.opencode/agents/game-developer.md +169 -0
  14. package/kit/.opencode/agents/mobile-developer.md +385 -0
  15. package/kit/.opencode/agents/orchestrator.md +213 -0
  16. package/kit/.opencode/agents/penetration-tester.md +197 -0
  17. package/kit/.opencode/agents/performance-optimizer.md +194 -0
  18. package/kit/.opencode/agents/product-manager.md +120 -0
  19. package/kit/.opencode/agents/product-owner.md +103 -0
  20. package/kit/.opencode/agents/project-planner.md +418 -0
  21. package/kit/.opencode/agents/qa-automation-engineer.md +113 -0
  22. package/kit/.opencode/agents/security-auditor.md +179 -0
  23. package/kit/.opencode/agents/seo-specialist.md +119 -0
  24. package/kit/.opencode/agents/test-engineer.md +169 -0
  25. package/kit/.opencode/commands/brainstorm.md +113 -0
  26. package/kit/.opencode/commands/coordinate.md +72 -0
  27. package/kit/.opencode/commands/create.md +63 -0
  28. package/kit/.opencode/commands/debug.md +102 -0
  29. package/kit/.opencode/commands/deploy.md +175 -0
  30. package/kit/.opencode/commands/enhance.md +62 -0
  31. package/kit/.opencode/commands/orchestrate.md +241 -0
  32. package/kit/.opencode/commands/plan.md +89 -0
  33. package/kit/.opencode/commands/preview.md +80 -0
  34. package/kit/.opencode/commands/remember.md +67 -0
  35. package/kit/.opencode/commands/status.md +86 -0
  36. package/kit/.opencode/commands/test.md +143 -0
  37. package/kit/.opencode/commands/verify.md +71 -0
  38. package/kit/.opencode/memory/MEMORY.md +6 -0
  39. package/kit/.opencode/memory/feedback-history.md +9 -0
  40. package/kit/.opencode/memory/project-conventions.md +16 -0
  41. package/kit/.opencode/memory/tech-decisions.md +10 -0
  42. package/kit/.opencode/memory/user-preferences.md +9 -0
  43. package/kit/.opencode/opencode.json +15 -0
  44. package/kit/.opencode/scripts/README.md +95 -0
  45. package/kit/.opencode/scripts/auto_preview.py +149 -0
  46. package/kit/.opencode/scripts/checklist.py +75 -0
  47. package/kit/.opencode/scripts/component_registry.py +238 -0
  48. package/kit/.opencode/scripts/dependency_graph.py +73 -0
  49. package/kit/.opencode/scripts/generate_manifest.py +44 -0
  50. package/kit/.opencode/scripts/session_manager.py +120 -0
  51. package/kit/.opencode/scripts/tests/test_toolkit.py +238 -0
  52. package/kit/.opencode/scripts/validate_kit.py +397 -0
  53. package/kit/.opencode/scripts/validation_runner.py +216 -0
  54. package/kit/.opencode/scripts/verify_all.py +85 -0
  55. package/kit/.opencode/skills/api-patterns/SKILL.md +83 -0
  56. package/kit/.opencode/skills/api-patterns/api-style.md +42 -0
  57. package/kit/.opencode/skills/api-patterns/auth.md +24 -0
  58. package/kit/.opencode/skills/api-patterns/documentation.md +26 -0
  59. package/kit/.opencode/skills/api-patterns/graphql.md +41 -0
  60. package/kit/.opencode/skills/api-patterns/rate-limiting.md +31 -0
  61. package/kit/.opencode/skills/api-patterns/response.md +37 -0
  62. package/kit/.opencode/skills/api-patterns/rest.md +40 -0
  63. package/kit/.opencode/skills/api-patterns/scripts/api_validator.py +211 -0
  64. package/kit/.opencode/skills/api-patterns/security-testing.md +122 -0
  65. package/kit/.opencode/skills/api-patterns/trpc.md +41 -0
  66. package/kit/.opencode/skills/api-patterns/versioning.md +22 -0
  67. package/kit/.opencode/skills/app-builder/SKILL.md +78 -0
  68. package/kit/.opencode/skills/app-builder/agent-coordination.md +71 -0
  69. package/kit/.opencode/skills/app-builder/feature-building.md +53 -0
  70. package/kit/.opencode/skills/app-builder/project-detection.md +45 -0
  71. package/kit/.opencode/skills/app-builder/scaffolding.md +110 -0
  72. package/kit/.opencode/skills/app-builder/tech-stack.md +41 -0
  73. package/kit/.opencode/skills/app-builder/templates/SKILL.md +39 -0
  74. package/kit/.opencode/skills/app-builder/templates/astro-static/TEMPLATE.md +78 -0
  75. package/kit/.opencode/skills/app-builder/templates/chrome-extension/TEMPLATE.md +96 -0
  76. package/kit/.opencode/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  77. package/kit/.opencode/skills/app-builder/templates/electron-desktop/TEMPLATE.md +97 -0
  78. package/kit/.opencode/skills/app-builder/templates/express-api/TEMPLATE.md +89 -0
  79. package/kit/.opencode/skills/app-builder/templates/flutter-app/TEMPLATE.md +93 -0
  80. package/kit/.opencode/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +97 -0
  81. package/kit/.opencode/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +126 -0
  82. package/kit/.opencode/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +125 -0
  83. package/kit/.opencode/skills/app-builder/templates/nextjs-static/TEMPLATE.md +174 -0
  84. package/kit/.opencode/skills/app-builder/templates/nuxt-app/TEMPLATE.md +127 -0
  85. package/kit/.opencode/skills/app-builder/templates/python-fastapi/TEMPLATE.md +94 -0
  86. package/kit/.opencode/skills/app-builder/templates/react-native-app/TEMPLATE.md +121 -0
  87. package/kit/.opencode/skills/architecture/SKILL.md +57 -0
  88. package/kit/.opencode/skills/architecture/context-discovery.md +43 -0
  89. package/kit/.opencode/skills/architecture/examples.md +94 -0
  90. package/kit/.opencode/skills/architecture/pattern-selection.md +68 -0
  91. package/kit/.opencode/skills/architecture/patterns-reference.md +50 -0
  92. package/kit/.opencode/skills/architecture/trade-off-analysis.md +77 -0
  93. package/kit/.opencode/skills/bash-linux/SKILL.md +201 -0
  94. package/kit/.opencode/skills/batch-operations/SKILL.md +105 -0
  95. package/kit/.opencode/skills/behavioral-modes/SKILL.md +253 -0
  96. package/kit/.opencode/skills/brainstorming/SKILL.md +178 -0
  97. package/kit/.opencode/skills/brainstorming/dynamic-questioning.md +350 -0
  98. package/kit/.opencode/skills/clean-code/SKILL.md +201 -0
  99. package/kit/.opencode/skills/code-review-checklist/SKILL.md +111 -0
  100. package/kit/.opencode/skills/code-review-graph/SKILL.md +305 -0
  101. package/kit/.opencode/skills/context-compression/SKILL.md +145 -0
  102. package/kit/.opencode/skills/coordinator-mode/SKILL.md +208 -0
  103. package/kit/.opencode/skills/database-design/SKILL.md +54 -0
  104. package/kit/.opencode/skills/database-design/database-selection.md +43 -0
  105. package/kit/.opencode/skills/database-design/indexing.md +39 -0
  106. package/kit/.opencode/skills/database-design/migrations.md +48 -0
  107. package/kit/.opencode/skills/database-design/optimization.md +36 -0
  108. package/kit/.opencode/skills/database-design/orm-selection.md +30 -0
  109. package/kit/.opencode/skills/database-design/schema-design.md +56 -0
  110. package/kit/.opencode/skills/database-design/scripts/schema_validator.py +172 -0
  111. package/kit/.opencode/skills/deployment-procedures/SKILL.md +243 -0
  112. package/kit/.opencode/skills/design-spec/SKILL.md +185 -0
  113. package/kit/.opencode/skills/design-spec/collection.md +106 -0
  114. package/kit/.opencode/skills/documentation-templates/SKILL.md +196 -0
  115. package/kit/.opencode/skills/frontend-architecture/SKILL.md +245 -0
  116. package/kit/.opencode/skills/frontend-design/SKILL.md +1222 -0
  117. package/kit/.opencode/skills/frontend-design/redesign.md +178 -0
  118. package/kit/.opencode/skills/frontend-design/scripts/accessibility_checker.py +145 -0
  119. package/kit/.opencode/skills/frontend-design/scripts/ux_audit.py +722 -0
  120. package/kit/.opencode/skills/frontend-design/style-brutalist.md +92 -0
  121. package/kit/.opencode/skills/frontend-design/style-minimalist.md +85 -0
  122. package/kit/.opencode/skills/game-development/2d-games/SKILL.md +118 -0
  123. package/kit/.opencode/skills/game-development/3d-games/SKILL.md +134 -0
  124. package/kit/.opencode/skills/game-development/SKILL.md +169 -0
  125. package/kit/.opencode/skills/game-development/game-art/SKILL.md +184 -0
  126. package/kit/.opencode/skills/game-development/game-audio/SKILL.md +189 -0
  127. package/kit/.opencode/skills/game-development/game-design/SKILL.md +128 -0
  128. package/kit/.opencode/skills/game-development/mobile-games/SKILL.md +107 -0
  129. package/kit/.opencode/skills/game-development/multiplayer/SKILL.md +131 -0
  130. package/kit/.opencode/skills/game-development/pc-games/SKILL.md +143 -0
  131. package/kit/.opencode/skills/game-development/vr-ar/SKILL.md +122 -0
  132. package/kit/.opencode/skills/game-development/web-games/SKILL.md +149 -0
  133. package/kit/.opencode/skills/geo-fundamentals/SKILL.md +158 -0
  134. package/kit/.opencode/skills/geo-fundamentals/scripts/geo_checker.py +273 -0
  135. package/kit/.opencode/skills/i18n-localization/SKILL.md +156 -0
  136. package/kit/.opencode/skills/i18n-localization/scripts/i18n_checker.py +223 -0
  137. package/kit/.opencode/skills/intelligent-routing/SKILL.md +337 -0
  138. package/kit/.opencode/skills/lint-and-validate/SKILL.md +47 -0
  139. package/kit/.opencode/skills/lint-and-validate/scripts/lint_runner.py +184 -0
  140. package/kit/.opencode/skills/lint-and-validate/scripts/type_coverage.py +245 -0
  141. package/kit/.opencode/skills/mcp-builder/SKILL.md +205 -0
  142. package/kit/.opencode/skills/memory-system/SKILL.md +181 -0
  143. package/kit/.opencode/skills/mobile-design/SKILL.md +396 -0
  144. package/kit/.opencode/skills/mobile-design/decision-trees.md +516 -0
  145. package/kit/.opencode/skills/mobile-design/mobile-backend.md +491 -0
  146. package/kit/.opencode/skills/mobile-design/mobile-color-system.md +420 -0
  147. package/kit/.opencode/skills/mobile-design/mobile-debugging.md +122 -0
  148. package/kit/.opencode/skills/mobile-design/mobile-design-thinking.md +357 -0
  149. package/kit/.opencode/skills/mobile-design/mobile-navigation.md +458 -0
  150. package/kit/.opencode/skills/mobile-design/mobile-performance.md +767 -0
  151. package/kit/.opencode/skills/mobile-design/mobile-testing.md +356 -0
  152. package/kit/.opencode/skills/mobile-design/mobile-typography.md +433 -0
  153. package/kit/.opencode/skills/mobile-design/platform-android.md +666 -0
  154. package/kit/.opencode/skills/mobile-design/platform-ios.md +561 -0
  155. package/kit/.opencode/skills/mobile-design/scripts/mobile_audit.py +670 -0
  156. package/kit/.opencode/skills/mobile-design/touch-psychology.md +537 -0
  157. package/kit/.opencode/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +351 -0
  158. package/kit/.opencode/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
  159. package/kit/.opencode/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
  160. package/kit/.opencode/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
  161. package/kit/.opencode/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
  162. package/kit/.opencode/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
  163. package/kit/.opencode/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
  164. package/kit/.opencode/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
  165. package/kit/.opencode/skills/nextjs-react-expert/9-cache-components.md +103 -0
  166. package/kit/.opencode/skills/nextjs-react-expert/SKILL.md +293 -0
  167. package/kit/.opencode/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
  168. package/kit/.opencode/skills/nextjs-react-expert/scripts/react_performance_checker.py +281 -0
  169. package/kit/.opencode/skills/nodejs-best-practices/SKILL.md +336 -0
  170. package/kit/.opencode/skills/parallel-agents/SKILL.md +192 -0
  171. package/kit/.opencode/skills/performance-profiling/SKILL.md +145 -0
  172. package/kit/.opencode/skills/performance-profiling/scripts/bundle_analyzer.py +120 -0
  173. package/kit/.opencode/skills/performance-profiling/scripts/lighthouse_audit.py +108 -0
  174. package/kit/.opencode/skills/plan-writing/SKILL.md +153 -0
  175. package/kit/.opencode/skills/powershell-windows/SKILL.md +169 -0
  176. package/kit/.opencode/skills/python-patterns/SKILL.md +443 -0
  177. package/kit/.opencode/skills/red-team-tactics/SKILL.md +201 -0
  178. package/kit/.opencode/skills/rust-pro/SKILL.md +177 -0
  179. package/kit/.opencode/skills/seo-fundamentals/SKILL.md +131 -0
  180. package/kit/.opencode/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
  181. package/kit/.opencode/skills/server-management/SKILL.md +163 -0
  182. package/kit/.opencode/skills/simplify-code/SKILL.md +131 -0
  183. package/kit/.opencode/skills/skillify/SKILL.md +115 -0
  184. package/kit/.opencode/skills/systematic-debugging/SKILL.md +111 -0
  185. package/kit/.opencode/skills/tailwind-patterns/SKILL.md +271 -0
  186. package/kit/.opencode/skills/tdd-workflow/SKILL.md +151 -0
  187. package/kit/.opencode/skills/testing-patterns/SKILL.md +180 -0
  188. package/kit/.opencode/skills/testing-patterns/scripts/test_runner.py +219 -0
  189. package/kit/.opencode/skills/verify-changes/SKILL.md +127 -0
  190. package/kit/.opencode/skills/vulnerability-scanner/SKILL.md +278 -0
  191. package/kit/.opencode/skills/vulnerability-scanner/checklists.md +124 -0
  192. package/kit/.opencode/skills/vulnerability-scanner/scripts/dependency_analyzer.py +144 -0
  193. package/kit/.opencode/skills/vulnerability-scanner/scripts/security_scan.py +410 -0
  194. package/kit/.opencode/skills/web-design-guidelines/SKILL.md +56 -0
  195. package/kit/.opencode/skills/webapp-testing/SKILL.md +189 -0
  196. package/kit/.opencode/skills/webapp-testing/scripts/playwright_runner.py +123 -0
  197. package/lib/init.js +61 -0
  198. package/package.json +21 -0
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: context-compression
3
+ description: Manage and compress conversation context in long sessions. Detect when context is growing large, summarize completed work phases, archive old findings while preserving key decisions. Prevents context degradation.
4
+ compatibility: opencode
5
+ metadata:
6
+ when_to_use: "\"When a session has 20+ turns, when context feels repetitive, when the agent is losing track of earlier work, or when the user says 'summarize what we've done'. NOT for short sessions.\""
7
+ version: "1.0.0"
8
+ ---
9
+ # Context Compression — Long Session Management
10
+
11
+ > Keep sessions productive by compressing completed work while preserving key decisions.
12
+
13
+ ## Overview
14
+
15
+ Long sessions (30+ turns) cause context degradation — the AI loses track of earlier work, repeats itself, or forgets decisions. Context compression proactively summarizes completed phases so the context window stays focused on active work.
16
+
17
+ **Token Impact:** Recovers 5,000-15,000 tokens in long sessions by replacing verbose tool outputs with semantic summaries.
18
+
19
+ ---
20
+
21
+ ## When to Compress
22
+
23
+ | Signal | Action |
24
+ |---|---|
25
+ | Session has 20+ turns | Consider proactive compression |
26
+ | Agent repeats earlier suggestions | Context is saturated — compress now |
27
+ | User says "we already discussed this" | Compress immediately |
28
+ | Switching to a new phase of work | Compress the completed phase |
29
+ | Large tool output (500+ lines) | Micro-compact the output |
30
+
31
+ ---
32
+
33
+ ## Compression Levels
34
+
35
+ ### Level 1: Micro-Compact (Tool Output)
36
+
37
+ Compress individual tool outputs while retaining semantic content:
38
+
39
+ ```
40
+ ❌ Before (raw grep output — 200 lines, ~4,000 tokens):
41
+ src/auth/jwt.ts:15: import { verify } from 'jsonwebtoken'
42
+ src/auth/jwt.ts:23: export function validateToken(token: string) {
43
+ src/auth/jwt.ts:24: try {
44
+ src/auth/jwt.ts:25: const decoded = verify(token, SECRET)
45
+ ... (195 more lines)
46
+
47
+ ✅ After (micro-compact — 5 lines, ~100 tokens):
48
+ Grep results for "jwt": Found 8 files, 42 matches.
49
+ Key files: src/auth/jwt.ts (main JWT logic), src/middleware/auth.ts (middleware),
50
+ src/api/login.ts (token creation). Token validation at jwt.ts:23-40.
51
+ Error handling at jwt.ts:42-55. Secret loaded from env at jwt.ts:8.
52
+ ```
53
+
54
+ ### Level 2: Phase Summary
55
+
56
+ Replace a completed work phase with a summary:
57
+
58
+ ```
59
+ ❌ Before (full research transcript — ~3,000 tokens):
60
+ [turn 1] Read package.json...
61
+ [turn 2] Read src/index.ts...
62
+ [turn 3] Grep for "auth"...
63
+ [turn 4] Found 8 files related to auth...
64
+ [turn 5] Read src/auth/jwt.ts...
65
+ ... (10 more turns of exploration)
66
+
67
+ ✅ After (phase summary — ~200 tokens):
68
+ ## Research Phase Complete
69
+ - Project: Next.js 15 app with JWT auth
70
+ - Auth files: 8 files in src/auth/, src/middleware/, src/api/
71
+ - Token flow: login → create JWT → store in httpOnly cookie → validate in middleware
72
+ - Bug location: src/auth/jwt.ts:45 — expiry check uses `<` instead of `<=`
73
+ - Decision: Fix the comparison operator, add edge case test
74
+ ```
75
+
76
+ ### Level 3: Session Checkpoint
77
+
78
+ Full session summary for long-running work:
79
+
80
+ ```markdown
81
+ ## Session Checkpoint (Turn 35)
82
+
83
+ ### Completed
84
+ - [x] Researched auth system (8 files, JWT flow mapped)
85
+ - [x] Fixed token expiry bug in jwt.ts:45
86
+ - [x] Added edge case test in jwt.test.ts
87
+ - [x] Verified: all 42 tests passing
88
+
89
+ ### In Progress
90
+ - [ ] Update API documentation
91
+ - [ ] Review related middleware
92
+
93
+ ### Key Decisions
94
+ 1. Keep httpOnly cookies (not localStorage) for token storage
95
+ 2. Use `<=` for expiry check to include exact-moment expiry
96
+ 3. Add 5-minute grace period for clock skew
97
+
98
+ ### Files Modified
99
+ - src/auth/jwt.ts (line 45: comparison fix)
100
+ - tests/auth/jwt.test.ts (added 3 edge case tests)
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Compression Protocol
106
+
107
+ ### Step 1: Identify Completed Phases
108
+ ```
109
+ What work is DONE and won't be revisited?
110
+ → Research findings already synthesized
111
+ → Implementation already verified
112
+ → Decisions already made and applied
113
+ ```
114
+
115
+ ### Step 2: Extract Key Information
116
+ ```
117
+ From the completed phase, preserve:
118
+ ✅ Decisions made and WHY
119
+ ✅ File paths and line numbers of changes
120
+ ✅ Key findings that inform ongoing work
121
+ ✅ Error messages or test results (summarized)
122
+
123
+ Discard:
124
+ ❌ Step-by-step tool invocation details
125
+ ❌ Full file contents that were read
126
+ ❌ Exploratory dead-ends that didn't lead anywhere
127
+ ❌ Verbose error stack traces (keep the message only)
128
+ ```
129
+
130
+ ### Step 3: Write Summary
131
+ ```
132
+ Use the Phase Summary format above.
133
+ Keep to 100-300 tokens per completed phase.
134
+ Include enough detail to resume work without re-reading.
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Best Practices
140
+
141
+ 1. **Compress phases, not facts** — Individual decisions should stay, full transcripts should go
142
+ 2. **Preserve "why" over "what"** — Why a decision was made matters more than the exact commands run
143
+ 3. **Never auto-compress** — Always tell the user "I'm summarizing the completed research phase to keep context focused"
144
+ 4. **Keep file references** — Always preserve file paths and line numbers in summaries
145
+ 5. **Checkpoint on phase transitions** — Natural compression point when switching from research to implementation
@@ -0,0 +1,208 @@
1
+ ---
2
+ name: coordinator-mode
3
+ description: Advanced multi-agent orchestration with parallel workers, synthesis protocols, and coordinator lifecycle. Use when complex tasks require multiple agents working in parallel with intelligent result synthesis.
4
+ compatibility: opencode
5
+ metadata:
6
+ when_to_use: "\"When the user needs multi-agent coordination, parallel task execution, complex multi-domain work, or when /coordinate or /orchestrate is invoked. NOT for single-domain tasks.\""
7
+ version: "1.0.0"
8
+ ---
9
+ # Coordinator Mode — Multi-Agent Orchestration
10
+
11
+ > Distilled from production-proven coordinator patterns. Transforms sequential agent chains into intelligent parallel orchestration.
12
+
13
+ ## Overview
14
+
15
+ The Coordinator is a specialized orchestration mode where **you become the conductor** — decomposing complex tasks into worker subtasks, dispatching them in parallel where safe, and synthesizing results into cohesive output.
16
+
17
+ **You are NOT a worker. You are the coordinator.** Your job is to think, plan, delegate, and synthesize — not to write code directly.
18
+
19
+ ---
20
+
21
+ ## Coordinator Lifecycle
22
+
23
+ ```
24
+ User Request
25
+
26
+ 1. DECOMPOSE — Break task into worker subtasks
27
+
28
+ 2. CLASSIFY — Mark each subtask: Research | Implementation | Verification
29
+
30
+ 3. DISPATCH — Launch workers (parallel for reads, sequential for writes)
31
+
32
+ 4. MONITOR — Track worker completion notifications
33
+
34
+ 5. SYNTHESIZE — Combine results into unified response
35
+
36
+ 6. VERIFY — Ensure completeness before reporting to user
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Phase-Based Workflow
42
+
43
+ | Phase | Purpose | Concurrency | Worker Type |
44
+ |-------|---------|-------------|-------------|
45
+ | **Research** | Gather information, explore codebase | ✅ Fully parallel | Read-only agents |
46
+ | **Synthesis** | Analyze findings, plan approach | ❌ Coordinator only | No workers |
47
+ | **Implementation** | Make changes to code/files | ⚠️ Sequential per file set | Write-capable agents |
48
+ | **Verification** | Test, lint, validate changes | ✅ Parallel (independent) | Test/security agents |
49
+
50
+ > 🔴 **Rule:** NEVER skip the Synthesis phase. Research → direct Implementation = poor results.
51
+
52
+ ---
53
+
54
+ ## Concurrency Rules
55
+
56
+ ### Safe to Parallelize
57
+ - ✅ Multiple agents reading different files
58
+ - ✅ Security audit + performance audit (read-only)
59
+ - ✅ Test runner + linter (independent)
60
+ - ✅ Exploring different directories
61
+
62
+ ### Must Be Sequential
63
+ - ❌ Two agents writing to the same file
64
+ - ❌ Implementation that depends on another agent's output
65
+ - ❌ Database migration + code that uses the new schema
66
+ - ❌ API change + frontend that consumes the API
67
+
68
+ ---
69
+
70
+ ## Worker Prompt Writing Guide
71
+
72
+ ### 🔴 The Golden Rule: Never Delegate Understanding
73
+
74
+ ```
75
+ ❌ WRONG: "Based on your findings, fix the bug"
76
+ ❌ WRONG: "Based on the research, implement it"
77
+ ❌ WRONG: "Look at the code and do what's needed"
78
+
79
+ ✅ RIGHT: "The bug is in src/auth/jwt.ts line 45 — the token expiry
80
+ check uses `<` instead of `<=`, causing off-by-one failures
81
+ at exactly the expiry time. Change line 45 from
82
+ `if (now < expiry)` to `if (now <= expiry)`"
83
+ ```
84
+
85
+ > **Why:** Phrases like "based on your findings" push synthesis onto the worker instead of doing it yourself. Write prompts that prove YOU understood — include file paths, line numbers, what specifically to change.
86
+
87
+ ### Writing Effective Worker Prompts
88
+
89
+ Brief the worker like a **smart colleague who just walked into the room**:
90
+
91
+ 1. **Explain what** you're trying to accomplish and why
92
+ 2. **Describe what** you've already learned or ruled out
93
+ 3. **Give enough context** about the surrounding problem for judgment calls
94
+ 4. **Be specific** about scope: what's in, what's out, what another agent handles
95
+ 5. **State the output format** you expect ("report in under 200 words")
96
+
97
+ ### Prompt Templates
98
+
99
+ #### Research Worker
100
+ ```
101
+ Investigate [specific question] in [file/directory scope].
102
+ Context: We're trying to [goal] because [reason].
103
+ I've already checked [what you checked] and found [what you found].
104
+ Report: List [specific deliverable]. Under 200 words.
105
+ ```
106
+
107
+ #### Implementation Worker
108
+ ```
109
+ Modify [specific file(s)] to [specific change].
110
+ Context: [Why this change is needed].
111
+ The current code at [file:line] does [X], change it to [Y].
112
+ Constraints: Don't touch [out-of-scope files]. Another agent handles [related area].
113
+ Verify: [How the worker should confirm success].
114
+ ```
115
+
116
+ #### Verification Worker
117
+ ```
118
+ Verify that [specific change] works correctly.
119
+ Run: [specific commands].
120
+ Check: [what success looks like].
121
+ Report: Pass/fail with details on any failures.
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Fork Semantics
127
+
128
+ ### When to Fork (vs. Spawn Fresh Agent)
129
+
130
+ | Scenario | Action | Why |
131
+ |----------|--------|-----|
132
+ | Open-ended research question | **Fork** (omit agent type) | Fork inherits context, shorter prompt |
133
+ | Independent parallel research | **Fork** multiple in one message | Each fork shares cache |
134
+ | Specialized domain work | **Spawn** (specify agent type) | Fresh specialist starts clean |
135
+ | Second opinion on your work | **Spawn** | Independent perspective |
136
+
137
+ ### Fork Rules
138
+
139
+ 1. **Don't peek.** Don't read the fork's output file mid-flight. You'll get a completion notification. Reading the transcript pulls tool noise into your context.
140
+
141
+ 2. **Don't race.** After launching, you know nothing about what the fork found. Never fabricate or predict fork results. If the user asks before notification lands, say "the fork is still running."
142
+
143
+ 3. **Keep prompts short.** Forks inherit your full context — write a *directive* (what to do), not a *briefing* (what the situation is).
144
+
145
+ ---
146
+
147
+ ## Anti-Patterns
148
+
149
+ | Anti-Pattern | Why It's Bad | Fix |
150
+ |---|---|---|
151
+ | "Look at the code and fix it" | Zero context = workers make wrong assumptions | Provide specific file paths, line numbers, and what to change |
152
+ | Skipping Research phase | Implementation without understanding = rework | Always research first, even briefly |
153
+ | Launching 10+ workers at once | Overwhelms synthesis, diminishing returns | 2-5 workers per round, synthesize, then more if needed |
154
+ | Fabricating worker results | User gets wrong information | Wait for actual notification, say "still running" if asked |
155
+ | Coordinator writes code directly | Loses orchestration benefits | Always delegate to appropriate specialist |
156
+
157
+ ---
158
+
159
+ ## Synthesis Protocol
160
+
161
+ After all workers complete:
162
+
163
+ ```markdown
164
+ ## Coordinator Synthesis
165
+
166
+ ### Task: [Original Request]
167
+
168
+ ### Workers Dispatched
169
+ | Worker | Type | Status | Key Finding |
170
+ |--------|------|--------|-------------|
171
+ | agent-1 | Research | ✅ | Found X in file Y |
172
+ | agent-2 | Research | ✅ | Identified Y pattern |
173
+
174
+ ### Consolidated Analysis
175
+ [Your synthesis — not a copy-paste of worker output]
176
+
177
+ ### Decision & Rationale
178
+ [What you decided based on ALL worker findings and why]
179
+
180
+ ### Implementation Plan
181
+ 1. [Specific change with file path]
182
+ 2. [Specific change with file path]
183
+
184
+ ### Remaining Risk
185
+ - [Anything workers flagged but couldn't resolve]
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Continue vs. Spawn Decision
191
+
192
+ | Situation | Action |
193
+ |-----------|--------|
194
+ | Worker completed, need follow-up on same topic | **Continue** (send message to worker ID) |
195
+ | Worker completed, need different domain work | **Spawn new** specialist |
196
+ | Worker failed, need retry with same context | **Continue** with corrected instructions |
197
+ | Worker failed, need fundamentally different approach | **Spawn new** |
198
+
199
+ ---
200
+
201
+ ## Best Practices
202
+
203
+ 1. **Start with 2-3 workers** — add more after synthesis if needed
204
+ 2. **Research before implementation** — always, even for "simple" tasks
205
+ 3. **Synthesize, don't copy** — your summary should add insight, not repeat
206
+ 4. **Verify independently** — verification workers shouldn't trust implementation workers
207
+ 5. **Track state** — note which workers are pending/completed/failed
208
+ 6. **Share scratchpad** — use a known directory for cross-worker artifacts
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: database-design
3
+ description: Database design principles and decision-making. Schema design, indexing strategy, ORM selection, serverless databases.
4
+ compatibility: opencode
5
+ metadata:
6
+ when_to_use: "\"When designing database schemas, choosing ORMs, planning migrations, or optimizing queries. When working with Prisma, Drizzle, or SQL files.\""
7
+ version: "1.0.0"
8
+ ---
9
+ # Database Design
10
+
11
+ > **Learn to THINK, not copy SQL patterns.**
12
+
13
+ ## 🎯 Selective Reading Rule
14
+
15
+ **Read ONLY files relevant to the request!** Check the content map, find what you need.
16
+
17
+ | File | Description | When to Read |
18
+ |------|-------------|--------------|
19
+ | `database-selection.md` | PostgreSQL vs Neon vs Turso vs SQLite | Choosing database |
20
+ | `orm-selection.md` | Drizzle vs Prisma vs Kysely | Choosing ORM |
21
+ | `schema-design.md` | Normalization, PKs, relationships | Designing schema |
22
+ | `indexing.md` | Index types, composite indexes | Performance tuning |
23
+ | `optimization.md` | N+1, EXPLAIN ANALYZE | Query optimization |
24
+ | `migrations.md` | Safe migrations, serverless DBs | Schema changes |
25
+
26
+ ---
27
+
28
+ ## ⚠️ Core Principle
29
+
30
+ - ASK user for database preferences when unclear
31
+ - Choose database/ORM based on CONTEXT
32
+ - Don't default to PostgreSQL for everything
33
+
34
+ ---
35
+
36
+ ## Decision Checklist
37
+
38
+ Before designing schema:
39
+
40
+ - [ ] Asked user about database preference?
41
+ - [ ] Chosen database for THIS context?
42
+ - [ ] Considered deployment environment?
43
+ - [ ] Planned index strategy?
44
+ - [ ] Defined relationship types?
45
+
46
+ ---
47
+
48
+ ## Anti-Patterns
49
+
50
+ ❌ Default to PostgreSQL for simple apps (SQLite may suffice)
51
+ ❌ Skip indexing
52
+ ❌ Use SELECT * in production
53
+ ❌ Store JSON when structured data is better
54
+ ❌ Ignore N+1 queries
@@ -0,0 +1,43 @@
1
+ # Database Selection
2
+
3
+ > Choose database based on context, not default.
4
+
5
+ ## Decision Tree
6
+
7
+ ```
8
+ What are your requirements?
9
+
10
+ ├── Full relational features needed
11
+ │ ├── Self-hosted → PostgreSQL
12
+ │ └── Serverless → Neon, Supabase
13
+
14
+ ├── Edge deployment / Ultra-low latency
15
+ │ └── Turso (edge SQLite)
16
+
17
+ ├── AI / Vector search
18
+ │ └── PostgreSQL + pgvector
19
+
20
+ ├── Simple / Embedded / Local
21
+ │ └── SQLite
22
+
23
+ └── Global distribution
24
+ └── PlanetScale, CockroachDB, Turso
25
+ ```
26
+
27
+ ## Comparison
28
+
29
+ | Database | Best For | Trade-offs |
30
+ |----------|----------|------------|
31
+ | **PostgreSQL** | Full features, complex queries | Needs hosting |
32
+ | **Neon** | Serverless PG, branching | PG complexity |
33
+ | **Turso** | Edge, low latency | SQLite limitations |
34
+ | **SQLite** | Simple, embedded, local | Single-writer |
35
+ | **PlanetScale** | MySQL, global scale | FK support enabled per-database |
36
+
37
+ ## Questions to Ask
38
+
39
+ 1. What's the deployment environment?
40
+ 2. How complex are the queries?
41
+ 3. Is edge/serverless important?
42
+ 4. Vector search needed?
43
+ 5. Global distribution required?
@@ -0,0 +1,39 @@
1
+ # Indexing Principles
2
+
3
+ > When and how to create indexes effectively.
4
+
5
+ ## When to Create Indexes
6
+
7
+ ```
8
+ Index these:
9
+ ├── Columns in WHERE clauses
10
+ ├── Columns in JOIN conditions
11
+ ├── Columns in ORDER BY
12
+ ├── Foreign key columns
13
+ └── Unique constraints
14
+
15
+ Don't over-index:
16
+ ├── Write-heavy tables (slower inserts)
17
+ ├── Low-cardinality columns
18
+ ├── Columns rarely queried
19
+ ```
20
+
21
+ ## Index Type Selection
22
+
23
+ | Type | Use For |
24
+ |------|---------|
25
+ | **B-tree** | General purpose, equality & range |
26
+ | **Hash** | Equality only, faster |
27
+ | **GIN** | JSONB, arrays, full-text |
28
+ | **GiST** | Geometric, range types |
29
+ | **HNSW/IVFFlat** | Vector similarity (pgvector) |
30
+
31
+ ## Composite Index Principles
32
+
33
+ ```
34
+ Order matters for composite indexes:
35
+ ├── Equality columns first
36
+ ├── Range columns last
37
+ ├── Most selective first
38
+ └── Match query pattern
39
+ ```
@@ -0,0 +1,48 @@
1
+ # Migration Principles
2
+
3
+ > Safe migration strategy for zero-downtime changes.
4
+
5
+ ## Safe Migration Strategy
6
+
7
+ ```
8
+ For zero-downtime changes:
9
+
10
+ ├── Adding column
11
+ │ └── Add as nullable → backfill → add NOT NULL
12
+
13
+ ├── Removing column
14
+ │ └── Stop using → deploy → remove column
15
+
16
+ ├── Adding index
17
+ │ └── CREATE INDEX CONCURRENTLY (non-blocking)
18
+
19
+ └── Renaming column
20
+ └── Add new → migrate data → deploy → drop old
21
+ ```
22
+
23
+ ## Migration Philosophy
24
+
25
+ - Never make breaking changes in one step
26
+ - Test migrations on data copy first
27
+ - Have rollback plan
28
+ - Run in transaction when possible
29
+
30
+ ## Serverless Databases
31
+
32
+ ### Neon (Serverless PostgreSQL)
33
+
34
+ | Feature | Benefit |
35
+ |---------|---------|
36
+ | Scale to zero | Cost savings |
37
+ | Instant branching | Dev/preview |
38
+ | Full PostgreSQL | Compatibility |
39
+ | Autoscaling | Traffic handling |
40
+
41
+ ### Turso (Edge SQLite)
42
+
43
+ | Feature | Benefit |
44
+ |---------|---------|
45
+ | Edge locations | Ultra-low latency |
46
+ | SQLite compatible | Simple |
47
+ | Generous free tier | Cost |
48
+ | Global distribution | Performance |
@@ -0,0 +1,36 @@
1
+ # Query Optimization
2
+
3
+ > N+1 problem, EXPLAIN ANALYZE, optimization priorities.
4
+
5
+ ## N+1 Problem
6
+
7
+ ```
8
+ What is N+1?
9
+ ├── 1 query to get parent records
10
+ ├── N queries to get related records
11
+ └── Very slow!
12
+
13
+ Solutions:
14
+ ├── JOIN → Single query with all data
15
+ ├── Eager loading → ORM handles JOIN
16
+ ├── DataLoader → Batch and cache (GraphQL)
17
+ └── Subquery → Fetch related in one query
18
+ ```
19
+
20
+ ## Query Analysis Mindset
21
+
22
+ ```
23
+ Before optimizing:
24
+ ├── EXPLAIN ANALYZE the query
25
+ ├── Look for Seq Scan (full table scan)
26
+ ├── Check actual vs estimated rows
27
+ └── Identify missing indexes
28
+ ```
29
+
30
+ ## Optimization Priorities
31
+
32
+ 1. **Add missing indexes** (most common issue)
33
+ 2. **Select only needed columns** (not SELECT *)
34
+ 3. **Use proper JOINs** (avoid subqueries when possible)
35
+ 4. **Limit early** (pagination at database level)
36
+ 5. **Cache** (when appropriate)
@@ -0,0 +1,30 @@
1
+ # ORM Selection
2
+
3
+ > Choose ORM based on deployment and DX needs.
4
+
5
+ ## Decision Tree
6
+
7
+ ```
8
+ What's the context?
9
+
10
+ ├── Edge deployment / Bundle size matters
11
+ │ └── Drizzle (smallest, SQL-like)
12
+
13
+ ├── Best DX / Schema-first
14
+ │ └── Prisma (migrations, studio)
15
+
16
+ ├── Maximum control
17
+ │ └── Raw SQL with query builder
18
+
19
+ └── Python ecosystem
20
+ └── SQLAlchemy 2.0 (async support)
21
+ ```
22
+
23
+ ## Comparison
24
+
25
+ | ORM | Best For | Trade-offs |
26
+ |-----|----------|------------|
27
+ | **Drizzle** | Edge, TypeScript | Newer, less examples |
28
+ | **Prisma** | DX, schema management | Heavier, not edge-ready |
29
+ | **Kysely** | Type-safe SQL builder | Manual migrations |
30
+ | **Raw SQL** | Complex queries, control | Manual type safety |
@@ -0,0 +1,56 @@
1
+ # Schema Design Principles
2
+
3
+ > Normalization, primary keys, timestamps, relationships.
4
+
5
+ ## Normalization Decision
6
+
7
+ ```
8
+ When to normalize (separate tables):
9
+ ├── Data is repeated across rows
10
+ ├── Updates would need multiple changes
11
+ ├── Relationships are clear
12
+ └── Query patterns benefit
13
+
14
+ When to denormalize (embed/duplicate):
15
+ ├── Read performance critical
16
+ ├── Data rarely changes
17
+ ├── Always fetched together
18
+ └── Simpler queries needed
19
+ ```
20
+
21
+ ## Primary Key Selection
22
+
23
+ | Type | Use When |
24
+ |------|----------|
25
+ | **UUID** | Distributed systems, security |
26
+ | **ULID** | UUID + sortable by time |
27
+ | **Auto-increment** | Simple apps, single database |
28
+ | **Natural key** | Rarely (business meaning) |
29
+
30
+ ## Timestamp Strategy
31
+
32
+ ```
33
+ For every table:
34
+ ├── created_at → When created
35
+ ├── updated_at → Last modified
36
+ └── deleted_at → Soft delete (if needed)
37
+
38
+ Use TIMESTAMPTZ (with timezone) not TIMESTAMP
39
+ ```
40
+
41
+ ## Relationship Types
42
+
43
+ | Type | When | Implementation |
44
+ |------|------|----------------|
45
+ | **One-to-One** | Extension data | Separate table with FK |
46
+ | **One-to-Many** | Parent-children | FK on child table |
47
+ | **Many-to-Many** | Both sides have many | Junction table |
48
+
49
+ ## Foreign Key ON DELETE
50
+
51
+ ```
52
+ ├── CASCADE → Delete children with parent
53
+ ├── SET NULL → Children become orphans
54
+ ├── RESTRICT → Prevent delete if children exist
55
+ └── SET DEFAULT → Children get default value
56
+ ```