@softspark/ai-toolkit 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 (327) hide show
  1. package/AGENTS.md +412 -0
  2. package/CHANGELOG.md +68 -0
  3. package/LICENSE +21 -0
  4. package/README.md +632 -0
  5. package/action.yml +53 -0
  6. package/app/.claude-plugin/plugin.json +44 -0
  7. package/app/ARCHITECTURE.md +306 -0
  8. package/app/CLAUDE.md.template +23 -0
  9. package/app/agents/ai-engineer.md +128 -0
  10. package/app/agents/backend-specialist.md +193 -0
  11. package/app/agents/business-intelligence.md +54 -0
  12. package/app/agents/chaos-monkey.md +67 -0
  13. package/app/agents/chief-of-staff.md +51 -0
  14. package/app/agents/code-archaeologist.md +127 -0
  15. package/app/agents/code-reviewer.md +184 -0
  16. package/app/agents/command-expert.md +131 -0
  17. package/app/agents/data-analyst.md +205 -0
  18. package/app/agents/data-scientist.md +151 -0
  19. package/app/agents/database-architect.md +317 -0
  20. package/app/agents/debugger.md +238 -0
  21. package/app/agents/devops-implementer.md +194 -0
  22. package/app/agents/documenter.md +364 -0
  23. package/app/agents/explorer-agent.md +145 -0
  24. package/app/agents/fact-checker.md +172 -0
  25. package/app/agents/frontend-specialist.md +209 -0
  26. package/app/agents/game-developer.md +216 -0
  27. package/app/agents/incident-responder.md +226 -0
  28. package/app/agents/infrastructure-architect.md +127 -0
  29. package/app/agents/infrastructure-validator.md +247 -0
  30. package/app/agents/llm-ops-engineer.md +237 -0
  31. package/app/agents/mcp-expert.md +228 -0
  32. package/app/agents/mcp-server-architect.md +195 -0
  33. package/app/agents/mcp-testing-engineer.md +292 -0
  34. package/app/agents/meta-architect.md +58 -0
  35. package/app/agents/ml-engineer.md +136 -0
  36. package/app/agents/mobile-developer.md +190 -0
  37. package/app/agents/night-watchman.md +55 -0
  38. package/app/agents/nlp-engineer.md +154 -0
  39. package/app/agents/orchestrator.md +437 -0
  40. package/app/agents/performance-optimizer.md +254 -0
  41. package/app/agents/predictive-analyst.md +57 -0
  42. package/app/agents/product-manager.md +194 -0
  43. package/app/agents/project-planner.md +287 -0
  44. package/app/agents/prompt-engineer.md +103 -0
  45. package/app/agents/qa-automation-engineer.md +182 -0
  46. package/app/agents/rag-engineer.md +201 -0
  47. package/app/agents/research-synthesizer.md +138 -0
  48. package/app/agents/search-specialist.md +101 -0
  49. package/app/agents/security-architect.md +62 -0
  50. package/app/agents/security-auditor.md +293 -0
  51. package/app/agents/seo-specialist.md +111 -0
  52. package/app/agents/system-governor.md +57 -0
  53. package/app/agents/tech-lead.md +62 -0
  54. package/app/agents/technical-researcher.md +103 -0
  55. package/app/agents/test-engineer.md +264 -0
  56. package/app/constitution.md +38 -0
  57. package/app/hooks/_profile-check.sh +11 -0
  58. package/app/hooks/guard-destructive.sh +74 -0
  59. package/app/hooks/guard-path.sh +73 -0
  60. package/app/hooks/post-tool-use.sh +35 -0
  61. package/app/hooks/pre-compact.sh +31 -0
  62. package/app/hooks/quality-check.sh +22 -0
  63. package/app/hooks/quality-gate.sh +49 -0
  64. package/app/hooks/save-session.sh +24 -0
  65. package/app/hooks/session-end.sh +37 -0
  66. package/app/hooks/session-start.sh +29 -0
  67. package/app/hooks/subagent-start.sh +16 -0
  68. package/app/hooks/subagent-stop.sh +16 -0
  69. package/app/hooks/track-usage.sh +50 -0
  70. package/app/hooks/user-prompt-submit.sh +25 -0
  71. package/app/hooks.json +178 -0
  72. package/app/mcp-defaults.json +23 -0
  73. package/app/output-styles/golden-rules.md +43 -0
  74. package/app/plugins/README.md +19 -0
  75. package/app/plugins/csharp-pack/README.md +11 -0
  76. package/app/plugins/csharp-pack/plugin.json +18 -0
  77. package/app/plugins/enterprise-pack/README.md +16 -0
  78. package/app/plugins/enterprise-pack/hooks/output-style.sh +6 -0
  79. package/app/plugins/enterprise-pack/hooks/status-line.sh +8 -0
  80. package/app/plugins/enterprise-pack/plugin.json +24 -0
  81. package/app/plugins/frontend-pack/README.md +14 -0
  82. package/app/plugins/frontend-pack/plugin.json +22 -0
  83. package/app/plugins/java-pack/README.md +11 -0
  84. package/app/plugins/java-pack/plugin.json +18 -0
  85. package/app/plugins/kotlin-pack/README.md +11 -0
  86. package/app/plugins/kotlin-pack/plugin.json +18 -0
  87. package/app/plugins/memory-pack/README.md +24 -0
  88. package/app/plugins/memory-pack/hooks/observation-capture.sh +67 -0
  89. package/app/plugins/memory-pack/hooks/session-summary.sh +71 -0
  90. package/app/plugins/memory-pack/plugin.json +22 -0
  91. package/app/plugins/memory-pack/scripts/init_db.py +81 -0
  92. package/app/plugins/memory-pack/scripts/strip_private.py +22 -0
  93. package/app/plugins/memory-pack/skills/mem-search/SKILL.md +70 -0
  94. package/app/plugins/research-pack/README.md +14 -0
  95. package/app/plugins/research-pack/plugin.json +22 -0
  96. package/app/plugins/ruby-pack/README.md +11 -0
  97. package/app/plugins/ruby-pack/plugin.json +18 -0
  98. package/app/plugins/rust-pack/README.md +11 -0
  99. package/app/plugins/rust-pack/plugin.json +18 -0
  100. package/app/plugins/security-pack/README.md +15 -0
  101. package/app/plugins/security-pack/plugin.json +23 -0
  102. package/app/plugins/swift-pack/README.md +11 -0
  103. package/app/plugins/swift-pack/plugin.json +18 -0
  104. package/app/rules/claude-toolkit-rules.md +21 -0
  105. package/app/rules/git-conventions.md +5 -0
  106. package/app/rules/quality-gates.md +10 -0
  107. package/app/skills/_lib/__init__.py +1 -0
  108. package/app/skills/_lib/detect_utils.py +150 -0
  109. package/app/skills/agent-creator/SKILL.md +82 -0
  110. package/app/skills/analyze/SKILL.md +92 -0
  111. package/app/skills/analyze/scripts/complexity.py +165 -0
  112. package/app/skills/api-patterns/SKILL.md +305 -0
  113. package/app/skills/app-builder/SKILL.md +187 -0
  114. package/app/skills/architecture-audit/SKILL.md +141 -0
  115. package/app/skills/architecture-decision/SKILL.md +55 -0
  116. package/app/skills/architecture-decision/templates/adr-template.md +36 -0
  117. package/app/skills/biz-scan/SKILL.md +30 -0
  118. package/app/skills/briefing/SKILL.md +27 -0
  119. package/app/skills/build/SKILL.md +97 -0
  120. package/app/skills/build/scripts/detect-build.py +151 -0
  121. package/app/skills/chaos/SKILL.md +32 -0
  122. package/app/skills/ci/SKILL.md +77 -0
  123. package/app/skills/ci/scripts/ci-detect.py +135 -0
  124. package/app/skills/ci/templates/github-actions-node.yml +38 -0
  125. package/app/skills/ci/templates/github-actions-python.yml +42 -0
  126. package/app/skills/ci-cd-patterns/SKILL.md +299 -0
  127. package/app/skills/clean-code/SKILL.md +110 -0
  128. package/app/skills/clean-code/reference/dart.md +18 -0
  129. package/app/skills/clean-code/reference/go.md +23 -0
  130. package/app/skills/clean-code/reference/php.md +32 -0
  131. package/app/skills/clean-code/reference/python.md +180 -0
  132. package/app/skills/clean-code/reference/typescript.md +26 -0
  133. package/app/skills/command-creator/SKILL.md +83 -0
  134. package/app/skills/commit/SKILL.md +98 -0
  135. package/app/skills/commit/scripts/pre-commit-check.py +87 -0
  136. package/app/skills/commit/templates/conventional-commit.md +52 -0
  137. package/app/skills/csharp-patterns/SKILL.md +450 -0
  138. package/app/skills/database-patterns/SKILL.md +297 -0
  139. package/app/skills/debug/SKILL.md +154 -0
  140. package/app/skills/debug/scripts/error-parser.py +187 -0
  141. package/app/skills/debugging-tactics/SKILL.md +136 -0
  142. package/app/skills/deploy/SKILL.md +130 -0
  143. package/app/skills/deploy/scripts/pre_deploy_check.py +171 -0
  144. package/app/skills/deploy/templates/deployment-checklist.md +31 -0
  145. package/app/skills/design-an-interface/SKILL.md +105 -0
  146. package/app/skills/design-engineering/SKILL.md +260 -0
  147. package/app/skills/docker-devops/SKILL.md +303 -0
  148. package/app/skills/docs/SKILL.md +145 -0
  149. package/app/skills/docs/scripts/doc-inventory.py +176 -0
  150. package/app/skills/docs/templates/adr-template.md +36 -0
  151. package/app/skills/docs/templates/readme-template.md +67 -0
  152. package/app/skills/documentation-standards/SKILL.md +191 -0
  153. package/app/skills/ecommerce-patterns/SKILL.md +209 -0
  154. package/app/skills/evaluate/SKILL.md +132 -0
  155. package/app/skills/evolve/SKILL.md +27 -0
  156. package/app/skills/explain/SKILL.md +54 -0
  157. package/app/skills/explain/scripts/dependency-graph.py +215 -0
  158. package/app/skills/explore/SKILL.md +112 -0
  159. package/app/skills/explore/scripts/visualize.py +117 -0
  160. package/app/skills/fix/SKILL.md +78 -0
  161. package/app/skills/fix/scripts/error-classifier.py +191 -0
  162. package/app/skills/flutter-patterns/SKILL.md +254 -0
  163. package/app/skills/git-mastery/SKILL.md +70 -0
  164. package/app/skills/grill-me/SKILL.md +38 -0
  165. package/app/skills/health/SKILL.md +91 -0
  166. package/app/skills/health/scripts/health_check.py +162 -0
  167. package/app/skills/hive-mind/SKILL.md +56 -0
  168. package/app/skills/hook-creator/SKILL.md +107 -0
  169. package/app/skills/index/SKILL.md +74 -0
  170. package/app/skills/instinct-review/SKILL.md +77 -0
  171. package/app/skills/java-patterns/SKILL.md +442 -0
  172. package/app/skills/kotlin-patterns/SKILL.md +446 -0
  173. package/app/skills/lint/SKILL.md +103 -0
  174. package/app/skills/lint/scripts/detect-linters.py +112 -0
  175. package/app/skills/mcp-patterns/SKILL.md +270 -0
  176. package/app/skills/mem-search/SKILL.md +70 -0
  177. package/app/skills/migrate/SKILL.md +90 -0
  178. package/app/skills/migrate/scripts/migration-status.py +195 -0
  179. package/app/skills/migration-patterns/SKILL.md +260 -0
  180. package/app/skills/night-watch/SKILL.md +28 -0
  181. package/app/skills/observability-patterns/SKILL.md +203 -0
  182. package/app/skills/onboard/SKILL.md +76 -0
  183. package/app/skills/orchestrate/SKILL.md +86 -0
  184. package/app/skills/panic/SKILL.md +30 -0
  185. package/app/skills/performance-profiling/SKILL.md +59 -0
  186. package/app/skills/plan/SKILL.md +110 -0
  187. package/app/skills/plan/templates/plan-template.md +40 -0
  188. package/app/skills/plan-writing/SKILL.md +201 -0
  189. package/app/skills/plugin-creator/SKILL.md +78 -0
  190. package/app/skills/pr/SKILL.md +129 -0
  191. package/app/skills/pr/scripts/pr-summary.py +175 -0
  192. package/app/skills/prd-to-issues/SKILL.md +108 -0
  193. package/app/skills/prd-to-plan/SKILL.md +120 -0
  194. package/app/skills/predict/SKILL.md +30 -0
  195. package/app/skills/qa-session/SKILL.md +110 -0
  196. package/app/skills/rag-patterns/SKILL.md +203 -0
  197. package/app/skills/refactor/SKILL.md +124 -0
  198. package/app/skills/refactor/scripts/refactor-scan.py +210 -0
  199. package/app/skills/refactor-plan/SKILL.md +112 -0
  200. package/app/skills/repeat/SKILL.md +149 -0
  201. package/app/skills/research-mastery/SKILL.md +56 -0
  202. package/app/skills/review/SKILL.md +141 -0
  203. package/app/skills/review/scripts/diff-analyzer.py +170 -0
  204. package/app/skills/rollback/SKILL.md +87 -0
  205. package/app/skills/rollback/scripts/rollback_info.py +149 -0
  206. package/app/skills/ruby-patterns/SKILL.md +454 -0
  207. package/app/skills/rust-patterns/SKILL.md +446 -0
  208. package/app/skills/search/SKILL.md +64 -0
  209. package/app/skills/security-patterns/SKILL.md +91 -0
  210. package/app/skills/security-patterns/reference/authentication.md +37 -0
  211. package/app/skills/security-patterns/reference/authorization.md +22 -0
  212. package/app/skills/security-patterns/reference/input-validation.md +30 -0
  213. package/app/skills/security-patterns/reference/oauth-csrf-audit.md +131 -0
  214. package/app/skills/skill-creator/SKILL.md +154 -0
  215. package/app/skills/skill-creator/templates/dashboard/index.html +130 -0
  216. package/app/skills/skill-creator/templates/reasoning-engine/assets/example.json +12 -0
  217. package/app/skills/skill-creator/templates/reasoning-engine/search.py +110 -0
  218. package/app/skills/subagent-development/SKILL.md +225 -0
  219. package/app/skills/subagent-development/reference/code-quality-reviewer-prompt.md +145 -0
  220. package/app/skills/subagent-development/reference/implementer-prompt.md +118 -0
  221. package/app/skills/subagent-development/reference/spec-reviewer-prompt.md +100 -0
  222. package/app/skills/swarm/SKILL.md +81 -0
  223. package/app/skills/swift-patterns/SKILL.md +500 -0
  224. package/app/skills/tdd/SKILL.md +174 -0
  225. package/app/skills/tdd/reference/deep-modules.md +32 -0
  226. package/app/skills/tdd/reference/interface-design.md +32 -0
  227. package/app/skills/tdd/reference/mocking.md +52 -0
  228. package/app/skills/tdd/reference/refactoring.md +10 -0
  229. package/app/skills/tdd/reference/tests.md +59 -0
  230. package/app/skills/teams/SKILL.md +101 -0
  231. package/app/skills/test/SKILL.md +107 -0
  232. package/app/skills/test/scripts/detect-runner.py +113 -0
  233. package/app/skills/testing-patterns/SKILL.md +73 -0
  234. package/app/skills/testing-patterns/reference/flutter-testing.md +33 -0
  235. package/app/skills/testing-patterns/reference/go-testing.md +52 -0
  236. package/app/skills/testing-patterns/reference/php-phpunit.md +39 -0
  237. package/app/skills/testing-patterns/reference/python-pytest.md +228 -0
  238. package/app/skills/testing-patterns/reference/typescript-vitest.md +50 -0
  239. package/app/skills/triage-issue/SKILL.md +120 -0
  240. package/app/skills/typescript-patterns/SKILL.md +256 -0
  241. package/app/skills/ubiquitous-language/SKILL.md +74 -0
  242. package/app/skills/verification-before-completion/SKILL.md +108 -0
  243. package/app/skills/workflow/SKILL.md +250 -0
  244. package/app/skills/write-a-prd/SKILL.md +129 -0
  245. package/app/skills/write-a-prd/reference/visual-companion.md +78 -0
  246. package/app/skills/write-a-prd/scripts/frame-template.html +111 -0
  247. package/app/skills/write-a-prd/scripts/visual-server.cjs +79 -0
  248. package/app/templates/skill/generator/SKILL.md.template +40 -0
  249. package/app/templates/skill/knowledge/SKILL.md.template +52 -0
  250. package/app/templates/skill/linter/SKILL.md.template +34 -0
  251. package/app/templates/skill/reviewer/SKILL.md.template +51 -0
  252. package/app/templates/skill/workflow/SKILL.md.template +49 -0
  253. package/benchmarks/README.md +111 -0
  254. package/benchmarks/ecosystem-dashboard.json +148 -0
  255. package/benchmarks/ecosystem-harvest.json +148 -0
  256. package/benchmarks/results.json +38 -0
  257. package/benchmarks/run.py +351 -0
  258. package/bin/ai-toolkit.js +345 -0
  259. package/kb/best-practices/README.md +11 -0
  260. package/kb/howto/README.md +11 -0
  261. package/kb/procedures/maintenance-sop.md +306 -0
  262. package/kb/reference/agents-catalog.md +124 -0
  263. package/kb/reference/anti-pattern-registry-format.md +221 -0
  264. package/kb/reference/architecture-overview.md +232 -0
  265. package/kb/reference/benchmark-config.md +62 -0
  266. package/kb/reference/ci-integration.md +66 -0
  267. package/kb/reference/claude-ecosystem-benchmark-snapshot.md +80 -0
  268. package/kb/reference/claude-ecosystem-expansion-foundations.md +102 -0
  269. package/kb/reference/commands-catalog.md +21 -0
  270. package/kb/reference/distribution-model.md +63 -0
  271. package/kb/reference/global-install-model.md +56 -0
  272. package/kb/reference/hierarchical-override-pattern.md +200 -0
  273. package/kb/reference/hooks-catalog.md +306 -0
  274. package/kb/reference/integrations.md +88 -0
  275. package/kb/reference/language-packs.md +52 -0
  276. package/kb/reference/merge-friendly-install-model.md +58 -0
  277. package/kb/reference/plugin-pack-conventions.md +151 -0
  278. package/kb/reference/quick-wins-implementation-summary.md +70 -0
  279. package/kb/reference/skill-templates.md +50 -0
  280. package/kb/reference/skills-catalog.md +215 -0
  281. package/kb/reference/skills-unification.md +57 -0
  282. package/kb/reference/stats.md +69 -0
  283. package/kb/reference/sync.md +76 -0
  284. package/kb/troubleshooting/README.md +11 -0
  285. package/llms-full.txt +3068 -0
  286. package/llms.txt +39 -0
  287. package/package.json +75 -0
  288. package/scripts/_common.py +160 -0
  289. package/scripts/add_rule.py +50 -0
  290. package/scripts/benchmark_config.py +127 -0
  291. package/scripts/benchmark_ecosystem.py +288 -0
  292. package/scripts/check_deps.py +260 -0
  293. package/scripts/create_skill.py +118 -0
  294. package/scripts/doctor.py +504 -0
  295. package/scripts/eject.py +113 -0
  296. package/scripts/emission.py +256 -0
  297. package/scripts/evaluate_skills.py +260 -0
  298. package/scripts/frontmatter.py +58 -0
  299. package/scripts/generate_agents_md.py +91 -0
  300. package/scripts/generate_aider_conf.py +51 -0
  301. package/scripts/generate_cline.py +35 -0
  302. package/scripts/generate_copilot.py +30 -0
  303. package/scripts/generate_cursor_rules.py +35 -0
  304. package/scripts/generate_gemini.py +28 -0
  305. package/scripts/generate_llms_txt.py +164 -0
  306. package/scripts/generate_roo_modes.py +80 -0
  307. package/scripts/generate_windsurf.py +35 -0
  308. package/scripts/generator_base.py +140 -0
  309. package/scripts/harvest_ecosystem.py +50 -0
  310. package/scripts/inject_rule_cli.py +101 -0
  311. package/scripts/inject_section_cli.py +47 -0
  312. package/scripts/injection.py +180 -0
  313. package/scripts/install.py +236 -0
  314. package/scripts/install_git_hooks.py +71 -0
  315. package/scripts/install_steps/__init__.py +5 -0
  316. package/scripts/install_steps/ai_tools.py +261 -0
  317. package/scripts/install_steps/hooks.py +90 -0
  318. package/scripts/install_steps/markers.py +79 -0
  319. package/scripts/install_steps/symlinks.py +87 -0
  320. package/scripts/merge-hooks.py +192 -0
  321. package/scripts/plugin.py +642 -0
  322. package/scripts/plugin_schema.py +138 -0
  323. package/scripts/remove_rule.py +58 -0
  324. package/scripts/stats.py +81 -0
  325. package/scripts/sync.py +215 -0
  326. package/scripts/uninstall.py +292 -0
  327. package/scripts/validate.py +700 -0
@@ -0,0 +1,260 @@
1
+ ---
2
+ name: migration-patterns
3
+ description: "Loaded when user asks about database migrations or zero-downtime deploys"
4
+ effort: medium
5
+ user-invocable: false
6
+ ---
7
+
8
+ # Migration Patterns
9
+
10
+ ## Database Migration Tools
11
+
12
+ ### Alembic (Python/SQLAlchemy)
13
+ ```bash
14
+ # Initialize
15
+ alembic init migrations
16
+
17
+ # Create migration
18
+ alembic revision --autogenerate -m "add users table"
19
+
20
+ # Apply
21
+ alembic upgrade head
22
+
23
+ # Rollback
24
+ alembic downgrade -1
25
+ ```
26
+
27
+ ```python
28
+ # migrations/versions/001_add_users.py
29
+ def upgrade():
30
+ op.create_table(
31
+ "users",
32
+ sa.Column("id", sa.Integer, primary_key=True),
33
+ sa.Column("email", sa.String(255), unique=True, nullable=False),
34
+ sa.Column("created_at", sa.DateTime, server_default=sa.func.now()),
35
+ )
36
+ op.create_index("idx_users_email", "users", ["email"])
37
+
38
+ def downgrade():
39
+ op.drop_index("idx_users_email")
40
+ op.drop_table("users")
41
+ ```
42
+
43
+ ### Prisma (TypeScript)
44
+ ```bash
45
+ # Create migration
46
+ npx prisma migrate dev --name add_users
47
+
48
+ # Apply in production
49
+ npx prisma migrate deploy
50
+
51
+ # Reset (dev only)
52
+ npx prisma migrate reset
53
+ ```
54
+
55
+ ### Laravel (PHP)
56
+ ```bash
57
+ # Create migration
58
+ php artisan make:migration create_users_table
59
+
60
+ # Apply
61
+ php artisan migrate
62
+
63
+ # Rollback
64
+ php artisan migrate:rollback --step=1
65
+
66
+ # Dry run
67
+ php artisan migrate --pretend
68
+ ```
69
+
70
+ ### Django (Python)
71
+ ```bash
72
+ # Create migration from models
73
+ python manage.py makemigrations
74
+
75
+ # Apply
76
+ python manage.py migrate
77
+
78
+ # Rollback
79
+ python manage.py migrate app_name 0001
80
+
81
+ # Show plan
82
+ python manage.py showmigrations
83
+ ```
84
+
85
+ ### Flyway (Java/SQL)
86
+ ```bash
87
+ flyway migrate
88
+ flyway info
89
+ flyway undo # Undo last migration (Teams edition)
90
+ flyway repair # Fix metadata table
91
+ ```
92
+
93
+ ## Zero-Downtime Migration Strategies
94
+
95
+ ### 1. Expand-Contract Pattern
96
+ ```
97
+ Phase 1 (Expand): Add new column, keep old
98
+ ALTER TABLE users ADD COLUMN full_name VARCHAR(200);
99
+
100
+ Phase 2 (Migrate): Copy data
101
+ UPDATE users SET full_name = first_name || ' ' || last_name;
102
+
103
+ Phase 3 (Switch): Update code to use new column
104
+ Deploy new code that reads/writes full_name
105
+
106
+ Phase 4 (Contract): Remove old columns
107
+ ALTER TABLE users DROP COLUMN first_name;
108
+ ALTER TABLE users DROP COLUMN last_name;
109
+ ```
110
+
111
+ ### 2. Safe Column Operations
112
+ ```sql
113
+ -- Safe: Add nullable column
114
+ ALTER TABLE users ADD COLUMN phone VARCHAR(20);
115
+
116
+ -- Safe: Add column with default (PostgreSQL 11+, instant)
117
+ ALTER TABLE users ADD COLUMN status VARCHAR(20) DEFAULT 'active';
118
+
119
+ -- Safe: Create index concurrently (no lock)
120
+ CREATE INDEX CONCURRENTLY idx_users_status ON users(status);
121
+
122
+ -- UNSAFE: Add NOT NULL without default (locks table)
123
+ -- Instead, do it in 3 steps:
124
+ ALTER TABLE users ADD COLUMN email VARCHAR(255);
125
+ UPDATE users SET email = 'unknown@example.com' WHERE email IS NULL;
126
+ ALTER TABLE users ALTER COLUMN email SET NOT NULL;
127
+ ```
128
+
129
+ ### 3. Rename Column Safely
130
+ ```
131
+ Step 1: Add new column
132
+ Step 2: Write to both old and new columns (dual-write)
133
+ Step 3: Backfill new column from old
134
+ Step 4: Read from new column
135
+ Step 5: Stop writing to old column
136
+ Step 6: Drop old column (next release)
137
+ ```
138
+
139
+ ## Data Backfill Patterns
140
+
141
+ ### Batch Processing
142
+ ```python
143
+ BATCH_SIZE = 1000
144
+
145
+ def backfill_users():
146
+ last_id = 0
147
+ while True:
148
+ batch = db.execute(
149
+ "SELECT id, first_name, last_name FROM users "
150
+ "WHERE id > :last_id ORDER BY id LIMIT :limit",
151
+ {"last_id": last_id, "limit": BATCH_SIZE}
152
+ ).fetchall()
153
+
154
+ if not batch:
155
+ break
156
+
157
+ for row in batch:
158
+ db.execute(
159
+ "UPDATE users SET full_name = :name WHERE id = :id",
160
+ {"name": f"{row.first_name} {row.last_name}", "id": row.id}
161
+ )
162
+
163
+ db.commit()
164
+ last_id = batch[-1].id
165
+ logger.info(f"Backfilled up to id={last_id}")
166
+ ```
167
+
168
+ ## API Versioning
169
+
170
+ ### URL-Based (Most Common)
171
+ ```
172
+ GET /api/v1/users
173
+ GET /api/v2/users
174
+ ```
175
+
176
+ ### Header-Based
177
+ ```
178
+ GET /api/users
179
+ Accept: application/vnd.myapp.v2+json
180
+ ```
181
+
182
+ ### Implementation Pattern
183
+ ```python
184
+ # FastAPI
185
+ from fastapi import APIRouter
186
+
187
+ v1_router = APIRouter(prefix="/api/v1")
188
+ v2_router = APIRouter(prefix="/api/v2")
189
+
190
+ @v1_router.get("/users")
191
+ def get_users_v1():
192
+ return [{"name": user.name} for user in users] # Old format
193
+
194
+ @v2_router.get("/users")
195
+ def get_users_v2():
196
+ return [{"full_name": user.name, "id": user.id} for user in users] # New format
197
+ ```
198
+
199
+ ## Feature Flags for Gradual Rollout
200
+
201
+ ```python
202
+ # Simple feature flag
203
+ import os
204
+
205
+ def is_feature_enabled(feature: str, user_id: str | None = None) -> bool:
206
+ flag = os.getenv(f"FF_{feature.upper()}", "false")
207
+ if flag == "true":
208
+ return True
209
+ if flag.endswith("%") and user_id:
210
+ percentage = int(flag[:-1])
211
+ return hash(user_id) % 100 < percentage
212
+ return False
213
+
214
+ # Usage
215
+ if is_feature_enabled("new_search", user_id=request.user.id):
216
+ return new_search(query)
217
+ else:
218
+ return old_search(query)
219
+ ```
220
+
221
+ ## Rollback Strategies
222
+
223
+ ### Database Rollback
224
+ ```bash
225
+ # Always test rollback before deploying
226
+ alembic downgrade -1 # Alembic
227
+ npx prisma migrate resolve --rolled-back 20240101_migration # Prisma
228
+ php artisan migrate:rollback --step=1 # Laravel
229
+ ```
230
+
231
+ ### Application Rollback
232
+ ```bash
233
+ # Git-based rollback
234
+ git revert HEAD --no-edit
235
+ git push
236
+
237
+ # Container rollback
238
+ kubectl rollout undo deployment/api
239
+ docker service rollback api
240
+ ```
241
+
242
+ ## Migration Checklist
243
+
244
+ - [ ] Forward migration tested on staging
245
+ - [ ] Rollback migration tested on staging
246
+ - [ ] No data loss in either direction
247
+ - [ ] Performance impact assessed (large tables?)
248
+ - [ ] Backward compatible with current code
249
+ - [ ] Backfill script tested (if needed)
250
+ - [ ] Feature flag in place (if needed)
251
+ - [ ] Monitoring/alerts configured
252
+ - [ ] Team notified of migration window
253
+
254
+ ## Anti-Patterns
255
+ - Running migrations without rollback plan
256
+ - Locking large tables during peak hours
257
+ - Mixing schema and data migrations
258
+ - Not testing rollback path
259
+ - Deploying code before migration completes
260
+ - Dropping columns before removing code references
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: night-watch
3
+ description: "Run autonomous maintenance and dependency updates"
4
+ effort: medium
5
+ disable-model-invocation: true
6
+ context: fork
7
+ agent: night-watchman
8
+ allowed-tools: Bash, Read, Edit, Grep
9
+ ---
10
+
11
+ # Night Watch Command
12
+
13
+ Triggers the autonomous maintenance agent.
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ /night-watch [scope]
19
+ # Example: /night-watch deps
20
+ # Example: /night-watch cleanup
21
+ # Default: runs full suite
22
+ ```
23
+
24
+ ## Protocol
25
+ 1. **Checkout**: Create `maintenance/` branch.
26
+ 2. **Execute**: Run `night-watchman` agent skills.
27
+ 3. **Verify**: Run full test suite.
28
+ 4. **Report**: Generate Shift Report.
@@ -0,0 +1,203 @@
1
+ ---
2
+ name: observability-patterns
3
+ description: "Loaded when user asks about logging, metrics, or tracing patterns"
4
+ effort: medium
5
+ user-invocable: false
6
+ ---
7
+
8
+ # Observability Patterns
9
+
10
+ ## Structured Logging
11
+
12
+ ### Python (structlog)
13
+ ```python
14
+ import structlog
15
+
16
+ logger = structlog.get_logger()
17
+
18
+ logger.info("user_created", user_id=user.id, email=user.email, source="api")
19
+ logger.error("payment_failed", order_id=order.id, error=str(e), amount=amount)
20
+ ```
21
+
22
+ ### Node.js (Pino)
23
+ ```typescript
24
+ import pino from "pino";
25
+
26
+ const logger = pino({ level: "info", transport: { target: "pino-pretty" } });
27
+
28
+ logger.info({ userId: user.id, action: "login" }, "User logged in");
29
+ logger.error({ err, orderId: order.id }, "Payment processing failed");
30
+ ```
31
+
32
+ ### Log Levels
33
+ | Level | Use For |
34
+ |-------|---------|
35
+ | `error` | Failures requiring attention |
36
+ | `warn` | Unexpected but handled situations |
37
+ | `info` | Business events, state transitions |
38
+ | `debug` | Development diagnostics |
39
+
40
+ ### Rules
41
+ - Always use structured key-value pairs, not string interpolation
42
+ - Include correlation IDs for request tracing
43
+ - Never log sensitive data (passwords, tokens, PII)
44
+ - Log at boundaries: API entry/exit, external calls, state changes
45
+
46
+ ## OpenTelemetry
47
+
48
+ ### Python Setup
49
+ ```python
50
+ from opentelemetry import trace, metrics
51
+ from opentelemetry.sdk.trace import TracerProvider
52
+ from opentelemetry.sdk.metrics import MeterProvider
53
+ from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
54
+
55
+ trace.set_tracer_provider(TracerProvider())
56
+ trace.get_tracer_provider().add_span_processor(
57
+ BatchSpanProcessor(OTLPSpanExporter(endpoint="http://otel-collector:4317"))
58
+ )
59
+
60
+ tracer = trace.get_tracer(__name__)
61
+ meter = metrics.get_meter(__name__)
62
+
63
+ request_counter = meter.create_counter("http_requests_total", description="Total HTTP requests")
64
+ request_duration = meter.create_histogram("http_request_duration_seconds")
65
+
66
+ @tracer.start_as_current_span("process_order")
67
+ def process_order(order_id: str):
68
+ request_counter.add(1, {"method": "POST", "endpoint": "/orders"})
69
+ with tracer.start_as_current_span("validate_order"):
70
+ validate(order_id)
71
+ with tracer.start_as_current_span("charge_payment"):
72
+ charge(order_id)
73
+ ```
74
+
75
+ ### Node.js Setup
76
+ ```typescript
77
+ import { NodeSDK } from "@opentelemetry/sdk-node";
78
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
79
+
80
+ const sdk = new NodeSDK({
81
+ traceExporter: new OTLPTraceExporter({ url: "http://otel-collector:4317" }),
82
+ instrumentations: [getNodeAutoInstrumentations()],
83
+ });
84
+ sdk.start();
85
+ ```
86
+
87
+ ## Prometheus Metrics
88
+
89
+ ### Metric Types
90
+ ```python
91
+ # Counter - monotonically increasing (requests, errors)
92
+ http_requests_total = Counter("http_requests_total", "Total requests", ["method", "status", "path"])
93
+
94
+ # Histogram - distribution (latency, sizes)
95
+ request_duration = Histogram("request_duration_seconds", "Request latency",
96
+ buckets=[0.01, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0])
97
+
98
+ # Gauge - current value (connections, queue size)
99
+ active_connections = Gauge("active_connections", "Current active connections")
100
+ ```
101
+
102
+ ### Key Metrics (RED Method)
103
+ | Metric | Type | Purpose |
104
+ |--------|------|---------|
105
+ | Request **R**ate | Counter | Traffic volume |
106
+ | Request **E**rrors | Counter | Error rate |
107
+ | Request **D**uration | Histogram | Latency distribution |
108
+
109
+ ### Key Metrics (USE Method - Infrastructure)
110
+ | Metric | Type | Purpose |
111
+ |--------|------|---------|
112
+ | **U**tilization | Gauge | % resource used |
113
+ | **S**aturation | Gauge | Queue depth |
114
+ | **E**rrors | Counter | Error count |
115
+
116
+ ## Health Check Endpoints
117
+
118
+ ```python
119
+ # FastAPI example
120
+ @app.get("/health")
121
+ async def health():
122
+ checks = {
123
+ "database": await check_db(),
124
+ "redis": await check_redis(),
125
+ "disk": check_disk_space(),
126
+ }
127
+ status = "healthy" if all(checks.values()) else "degraded"
128
+ code = 200 if status == "healthy" else 503
129
+ return JSONResponse({"status": status, "checks": checks}, status_code=code)
130
+
131
+ @app.get("/ready")
132
+ async def readiness():
133
+ """Kubernetes readiness probe - can this instance serve traffic?"""
134
+ return {"ready": True}
135
+
136
+ @app.get("/live")
137
+ async def liveness():
138
+ """Kubernetes liveness probe - is the process alive?"""
139
+ return {"alive": True}
140
+ ```
141
+
142
+ ## Error Tracking (Sentry)
143
+
144
+ ```python
145
+ import sentry_sdk
146
+
147
+ sentry_sdk.init(
148
+ dsn="https://key@sentry.io/project",
149
+ traces_sample_rate=0.1,
150
+ profiles_sample_rate=0.1,
151
+ environment="production",
152
+ )
153
+
154
+ # Automatic exception capture + manual context
155
+ with sentry_sdk.push_scope() as scope:
156
+ scope.set_tag("order_id", order.id)
157
+ scope.set_context("payment", {"amount": amount, "currency": "USD"})
158
+ sentry_sdk.capture_exception(e)
159
+ ```
160
+
161
+ ## SLI/SLO Definition
162
+
163
+ ### Example SLOs
164
+ | Service | SLI | SLO | Window |
165
+ |---------|-----|-----|--------|
166
+ | API | Availability (2xx / total) | 99.9% | 30 days |
167
+ | API | Latency p99 | < 500ms | 30 days |
168
+ | Search | Result relevance | > 80% | 7 days |
169
+ | Ingest | Processing success rate | 99.5% | 30 days |
170
+
171
+ ### Error Budget
172
+ ```
173
+ Error Budget = 1 - SLO = 1 - 0.999 = 0.1%
174
+ Monthly budget = 30 days * 24h * 60min * 0.001 = 43.2 minutes
175
+ ```
176
+
177
+ ## Alerting Rules
178
+
179
+ ### Prometheus Alert Examples
180
+ ```yaml
181
+ groups:
182
+ - name: api-alerts
183
+ rules:
184
+ - alert: HighErrorRate
185
+ expr: rate(http_requests_total{status=~"5.."}[5m]) / rate(http_requests_total[5m]) > 0.05
186
+ for: 5m
187
+ labels:
188
+ severity: critical
189
+ annotations:
190
+ summary: "Error rate above 5% for 5 minutes"
191
+
192
+ - alert: HighLatency
193
+ expr: histogram_quantile(0.99, rate(request_duration_seconds_bucket[5m])) > 1
194
+ for: 10m
195
+ labels:
196
+ severity: warning
197
+ ```
198
+
199
+ ### Alert Best Practices
200
+ - Alert on symptoms (high latency), not causes (high CPU)
201
+ - Include runbook links in annotations
202
+ - Set appropriate severity: page only for user-impacting issues
203
+ - Use `for` duration to avoid flapping
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: onboard
3
+ description: "Generate project onboarding materials"
4
+ effort: medium
5
+ disable-model-invocation: true
6
+ argument-hint: "[project-path]"
7
+ allowed-tools: Bash, Read, Write, Glob
8
+ ---
9
+
10
+ # /onboard - Project Setup Guide
11
+
12
+ $ARGUMENTS
13
+
14
+ ## What This Command Does
15
+
16
+ Guide the user through setting up the ai-toolkit in their project, including configuration and customization.
17
+
18
+ ## Setup Steps
19
+
20
+ ### Step 1: Prerequisites Check
21
+ - [ ] Claude Code CLI installed
22
+ - [ ] ai-toolkit repository cloned
23
+ - [ ] Current directory is the target project
24
+
25
+ ### Step 2: Install Toolkit
26
+ ```bash
27
+ # Run the installer from the toolkit directory
28
+ /path/to/ai-toolkit/install.sh
29
+ ```
30
+
31
+ This creates symlinks in `.claude/`:
32
+ - `agents/` -> toolkit agents
33
+ - `skills/` -> toolkit skills (slash commands + knowledge skills)
34
+ - `hooks.json` -> quality gates
35
+ - `constitution.md` -> safety rules
36
+
37
+ ### Step 3: Configure CLAUDE.md
38
+ Create a project-specific `CLAUDE.md` from the template:
39
+ ```bash
40
+ cp /path/to/ai-toolkit/CLAUDE.md.template ./CLAUDE.md
41
+ ```
42
+
43
+ Customize with:
44
+ - Project description and tech stack
45
+ - Coding standards specific to this project
46
+ - Common development commands
47
+ - Architecture notes
48
+
49
+ ### Step 4: Configure Settings
50
+ Edit `.claude/settings.local.json` for project-specific settings:
51
+ - MCP server connections
52
+ - Permission overrides
53
+ - Environment variables
54
+
55
+ ### Step 5: Verify Installation
56
+ ```bash
57
+ /path/to/ai-toolkit/validate.sh
58
+ ```
59
+
60
+ ### Step 6: Quick Start Guide
61
+
62
+ | Command | Purpose |
63
+ |---------|---------|
64
+ | `/explore` | Understand the codebase |
65
+ | `/plan` | Plan a new feature |
66
+ | `/test` | Run tests |
67
+ | `/review` | Code review |
68
+ | `/commit` | Create a structured commit |
69
+
70
+ ## Usage Examples
71
+
72
+ ```
73
+ /onboard # Full guided setup
74
+ /onboard verify # Just verify existing installation
75
+ /onboard update # Update toolkit symlinks
76
+ ```
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: orchestrate
3
+ description: "Coordinate multiple specialized agents in parallel"
4
+ user-invocable: true
5
+ effort: max
6
+ argument-hint: "[task]"
7
+ context: fork
8
+ agent: orchestrator
9
+ model: opus
10
+ allowed-tools: Bash, Read, Write, Edit, Glob, Grep, Agent, TeamCreate, TeamDelete, SendMessage, TaskCreate, TaskList, TaskUpdate
11
+ ---
12
+
13
+ # /orchestrate - Multi-Agent Coordination
14
+
15
+ $ARGUMENTS
16
+
17
+ ## MANDATORY: You MUST use the Agent tool
18
+
19
+ **DO NOT analyze or implement this task yourself.** Your only job is to decompose the task and invoke specialized agents via the `Agent` tool. If you attempt to do the work inline, you have failed.
20
+
21
+ ## Step 1 — Decompose
22
+
23
+ Analyze the task and identify 3–6 sub-domains (e.g. backend, frontend, security, testing, docs). Define clear file ownership per domain so agents don't conflict.
24
+
25
+ Present the decomposition to the user and wait for approval before Step 2.
26
+
27
+ ## Step 2 — Spawn agents in parallel (REQUIRED)
28
+
29
+ Call the `Agent` tool **multiple times in a single response** — one call per sub-domain. All independent agents MUST be launched in the same message to run in parallel.
30
+
31
+ Example for a feature implementation task:
32
+
33
+ ```
34
+ Agent(subagent_type="backend-specialist", prompt="...", ...)
35
+ Agent(subagent_type="frontend-specialist", prompt="...", ...)
36
+ Agent(subagent_type="test-engineer", prompt="...", ...)
37
+ Agent(subagent_type="security-auditor", prompt="...", ...)
38
+ ```
39
+
40
+ Each agent prompt MUST include:
41
+ 1. The original user task
42
+ 2. The specific sub-task this agent owns
43
+ 3. File paths this agent is allowed to modify
44
+ 4. Success criteria for this agent's work
45
+
46
+ ## Step 3 — Synthesize
47
+
48
+ After all agents complete, generate the Orchestration Report combining their findings.
49
+
50
+ ## Available Agents
51
+
52
+ | Agent | Domain |
53
+ |-------|--------|
54
+ | `backend-specialist` | API, server logic, databases |
55
+ | `frontend-specialist` | React, Vue, UI components |
56
+ | `test-engineer` | Unit, integration, E2E tests |
57
+ | `security-auditor` | OWASP, vulnerabilities, auth |
58
+ | `database-architect` | Schema, migrations, queries |
59
+ | `devops-implementer` | Docker, CI/CD, infra |
60
+ | `performance-optimizer` | Profiling, bottlenecks |
61
+ | `documenter` | KB, architecture notes, runbooks |
62
+ | `code-reviewer` | Code quality, patterns |
63
+ | `tech-lead` | Architecture, standards |
64
+
65
+ ## Output Format
66
+
67
+ ```markdown
68
+ ## Orchestration Report
69
+
70
+ ### Task
71
+ [Original task]
72
+
73
+ ### Agents Invoked
74
+ | # | Agent | Sub-task | Files | Status |
75
+ |---|-------|----------|-------|--------|
76
+ | 1 | backend-specialist | API layer | src/api/ | Done |
77
+ | 2 | frontend-specialist | UI components | src/components/ | Done |
78
+ | 3 | test-engineer | Test suite | tests/ | Done |
79
+
80
+ ### Key Findings
81
+ 1. **[Agent]**: Finding
82
+ 2. **[Agent]**: Finding
83
+
84
+ ### Summary
85
+ [Synthesis]
86
+ ```
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: panic
3
+ description: "Emergency stabilization via system-governor agent"
4
+ effort: low
5
+ disable-model-invocation: true
6
+ agent: system-governor
7
+ context: fork
8
+ allowed-tools: Bash
9
+ ---
10
+
11
+ # Panic Command (The Kill Switch)
12
+
13
+ Stops the system dead in its tracks.
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ /panic [reason]
19
+ # Example: /panic "Agents are looping infinitely"
20
+ ```
21
+
22
+ ## Protocol
23
+ 1. **Create Lockfile**: `touch .claude/HALT`
24
+ 2. **Notify User**: "System Halted. Delete .claude/HALT to resume."
25
+
26
+ ## Resume
27
+ To resume operations:
28
+ ```bash
29
+ rm .claude/HALT
30
+ ```