oh-my-customcodex 0.1.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 (351) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +327 -0
  3. package/dist/cli/index.js +32054 -0
  4. package/dist/index.js +5469 -0
  5. package/package.json +89 -0
  6. package/templates/.claude/agents/arch-documenter.md +38 -0
  7. package/templates/.claude/agents/arch-speckit-agent.md +66 -0
  8. package/templates/.claude/agents/be-django-expert.md +47 -0
  9. package/templates/.claude/agents/be-express-expert.md +31 -0
  10. package/templates/.claude/agents/be-fastapi-expert.md +45 -0
  11. package/templates/.claude/agents/be-go-backend-expert.md +45 -0
  12. package/templates/.claude/agents/be-nestjs-expert.md +29 -0
  13. package/templates/.claude/agents/be-springboot-expert.md +42 -0
  14. package/templates/.claude/agents/db-alembic-expert.md +73 -0
  15. package/templates/.claude/agents/db-postgres-expert.md +38 -0
  16. package/templates/.claude/agents/db-redis-expert.md +38 -0
  17. package/templates/.claude/agents/db-supabase-expert.md +37 -0
  18. package/templates/.claude/agents/de-airflow-expert.md +48 -0
  19. package/templates/.claude/agents/de-dbt-expert.md +36 -0
  20. package/templates/.claude/agents/de-kafka-expert.md +83 -0
  21. package/templates/.claude/agents/de-pipeline-expert.md +34 -0
  22. package/templates/.claude/agents/de-snowflake-expert.md +38 -0
  23. package/templates/.claude/agents/de-spark-expert.md +38 -0
  24. package/templates/.claude/agents/fe-design-expert.md +120 -0
  25. package/templates/.claude/agents/fe-flutter-agent.md +48 -0
  26. package/templates/.claude/agents/fe-svelte-agent.md +33 -0
  27. package/templates/.claude/agents/fe-vercel-agent.md +40 -0
  28. package/templates/.claude/agents/fe-vuejs-agent.md +34 -0
  29. package/templates/.claude/agents/infra-aws-expert.md +49 -0
  30. package/templates/.claude/agents/infra-docker-expert.md +49 -0
  31. package/templates/.claude/agents/lang-golang-expert.md +46 -0
  32. package/templates/.claude/agents/lang-java21-expert.md +42 -0
  33. package/templates/.claude/agents/lang-kotlin-expert.md +45 -0
  34. package/templates/.claude/agents/lang-python-expert.md +45 -0
  35. package/templates/.claude/agents/lang-rust-expert.md +45 -0
  36. package/templates/.claude/agents/lang-typescript-expert.md +45 -0
  37. package/templates/.claude/agents/mgr-claude-code-bible.md +62 -0
  38. package/templates/.claude/agents/mgr-creator.md +57 -0
  39. package/templates/.claude/agents/mgr-gitnerd.md +50 -0
  40. package/templates/.claude/agents/mgr-sauron.md +163 -0
  41. package/templates/.claude/agents/mgr-supplier.md +39 -0
  42. package/templates/.claude/agents/mgr-updater.md +40 -0
  43. package/templates/.claude/agents/qa-engineer.md +36 -0
  44. package/templates/.claude/agents/qa-planner.md +78 -0
  45. package/templates/.claude/agents/qa-writer.md +32 -0
  46. package/templates/.claude/agents/sec-codeql-expert.md +56 -0
  47. package/templates/.claude/agents/slack-cli-expert.md +98 -0
  48. package/templates/.claude/agents/souls/lang-golang-expert.soul.md +21 -0
  49. package/templates/.claude/agents/sys-memory-keeper.md +123 -0
  50. package/templates/.claude/agents/sys-naggy.md +76 -0
  51. package/templates/.claude/agents/tool-bun-expert.md +26 -0
  52. package/templates/.claude/agents/tool-npm-expert.md +31 -0
  53. package/templates/.claude/agents/tool-optimizer.md +37 -0
  54. package/templates/.claude/agents/wiki-curator.md +72 -0
  55. package/templates/.claude/config/required-plugins.json +30 -0
  56. package/templates/.claude/contexts/dev.md +20 -0
  57. package/templates/.claude/contexts/ecomode.md +110 -0
  58. package/templates/.claude/contexts/index.yaml +41 -0
  59. package/templates/.claude/contexts/research.md +28 -0
  60. package/templates/.claude/contexts/review.md +23 -0
  61. package/templates/.claude/hooks/hooks.json +533 -0
  62. package/templates/.claude/hooks/scripts/adaptive-harness-scan.sh +45 -0
  63. package/templates/.claude/hooks/scripts/agent-start-recorder.sh +40 -0
  64. package/templates/.claude/hooks/scripts/agent-teams-advisor.sh +76 -0
  65. package/templates/.claude/hooks/scripts/audit-log.sh +64 -0
  66. package/templates/.claude/hooks/scripts/auto-continue-guard.sh +33 -0
  67. package/templates/.claude/hooks/scripts/content-hash-validator.sh +75 -0
  68. package/templates/.claude/hooks/scripts/context-budget-advisor.sh +107 -0
  69. package/templates/.claude/hooks/scripts/cost-cap-advisor.sh +71 -0
  70. package/templates/.claude/hooks/scripts/cwd-change-detector.sh +36 -0
  71. package/templates/.claude/hooks/scripts/eval-core-batch-save.sh +46 -0
  72. package/templates/.claude/hooks/scripts/feedback-collector.sh +92 -0
  73. package/templates/.claude/hooks/scripts/file-change-validator.sh +26 -0
  74. package/templates/.claude/hooks/scripts/git-delegation-guard.sh +57 -0
  75. package/templates/.claude/hooks/scripts/model-escalation-advisor.sh +106 -0
  76. package/templates/.claude/hooks/scripts/omcodex-auto-update.sh +4 -0
  77. package/templates/.claude/hooks/scripts/omcustom-auto-update.sh +177 -0
  78. package/templates/.claude/hooks/scripts/rtk-intercept.sh +77 -0
  79. package/templates/.claude/hooks/scripts/rule-deletion-guard.sh +60 -0
  80. package/templates/.claude/hooks/scripts/schema-validator.sh +106 -0
  81. package/templates/.claude/hooks/scripts/secret-filter.sh +100 -0
  82. package/templates/.claude/hooks/scripts/session-autofix-prompt.sh +34 -0
  83. package/templates/.claude/hooks/scripts/session-autofix.sh +146 -0
  84. package/templates/.claude/hooks/scripts/session-env-check.sh +254 -0
  85. package/templates/.claude/hooks/scripts/skill-extractor-analyzer.sh +49 -0
  86. package/templates/.claude/hooks/scripts/stage-blocker.sh +16 -0
  87. package/templates/.claude/hooks/scripts/stale-todo-scanner.sh +91 -0
  88. package/templates/.claude/hooks/scripts/stall-detection-advisor.sh +112 -0
  89. package/templates/.claude/hooks/scripts/stop-console-audit.sh +46 -0
  90. package/templates/.claude/hooks/scripts/stuck-detector.sh +199 -0
  91. package/templates/.claude/hooks/scripts/task-outcome-recorder.sh +119 -0
  92. package/templates/.claude/hooks/scripts/task-state-precompact.sh +58 -0
  93. package/templates/.claude/hooks/scripts/user-prompt-preprocessor.sh +32 -0
  94. package/templates/.claude/hooks/skill-count-reminder.sh +34 -0
  95. package/templates/.claude/install-hooks.sh +100 -0
  96. package/templates/.claude/ontology/agents.yaml +546 -0
  97. package/templates/.claude/ontology/graphs/agent-skill.json +102 -0
  98. package/templates/.claude/ontology/graphs/full-graph.json +629 -0
  99. package/templates/.claude/ontology/graphs/routing.json +112 -0
  100. package/templates/.claude/ontology/graphs/skill-rule.json +78 -0
  101. package/templates/.claude/ontology/rules.yaml +251 -0
  102. package/templates/.claude/ontology/schema.yaml +144 -0
  103. package/templates/.claude/ontology/skills.yaml +575 -0
  104. package/templates/.claude/rules/MAY-optimization.md +42 -0
  105. package/templates/.claude/rules/MUST-agent-design.md +340 -0
  106. package/templates/.claude/rules/MUST-agent-identification.md +77 -0
  107. package/templates/.claude/rules/MUST-agent-teams.md +293 -0
  108. package/templates/.claude/rules/MUST-completion-verification.md +112 -0
  109. package/templates/.claude/rules/MUST-continuous-improvement.md +69 -0
  110. package/templates/.claude/rules/MUST-enforcement-policy.md +50 -0
  111. package/templates/.claude/rules/MUST-intent-transparency.md +74 -0
  112. package/templates/.claude/rules/MUST-language-policy.md +28 -0
  113. package/templates/.claude/rules/MUST-orchestrator-coordination.md +399 -0
  114. package/templates/.claude/rules/MUST-parallel-execution.md +184 -0
  115. package/templates/.claude/rules/MUST-permissions.md +32 -0
  116. package/templates/.claude/rules/MUST-safety.md +23 -0
  117. package/templates/.claude/rules/MUST-sync-verification.md +145 -0
  118. package/templates/.claude/rules/MUST-tool-identification.md +97 -0
  119. package/templates/.claude/rules/SHOULD-ecomode.md +123 -0
  120. package/templates/.claude/rules/SHOULD-error-handling.md +33 -0
  121. package/templates/.claude/rules/SHOULD-hud-statusline.md +51 -0
  122. package/templates/.claude/rules/SHOULD-interaction.md +77 -0
  123. package/templates/.claude/rules/SHOULD-memory-integration.md +371 -0
  124. package/templates/.claude/rules/SHOULD-ontology-rag-routing.md +49 -0
  125. package/templates/.claude/rules/SHOULD-wiki-sync.md +73 -0
  126. package/templates/.claude/rules/index.yaml +141 -0
  127. package/templates/.claude/schemas/tool-inputs.json +62 -0
  128. package/templates/.claude/skills/action-validator/SKILL.md +89 -0
  129. package/templates/.claude/skills/adaptive-harness/SKILL.md +335 -0
  130. package/templates/.claude/skills/adversarial-review/SKILL.md +80 -0
  131. package/templates/.claude/skills/agora/SKILL.md +194 -0
  132. package/templates/.claude/skills/airflow-best-practices/SKILL.md +94 -0
  133. package/templates/.claude/skills/alembic-best-practices/SKILL.md +295 -0
  134. package/templates/.claude/skills/ambiguity-gate/SKILL.md +94 -0
  135. package/templates/.claude/skills/analysis/SKILL.md +223 -0
  136. package/templates/.claude/skills/audit-agents/SKILL.md +118 -0
  137. package/templates/.claude/skills/aws-best-practices/SKILL.md +281 -0
  138. package/templates/.claude/skills/claude-code-bible/SKILL.md +93 -0
  139. package/templates/.claude/skills/claude-code-bible/scripts/fetch-docs.js +244 -0
  140. package/templates/.claude/skills/claude-native/SKILL.md +215 -0
  141. package/templates/.claude/skills/codex-exec/SKILL.md +206 -0
  142. package/templates/.claude/skills/codex-exec/scripts/codex-wrapper.cjs +430 -0
  143. package/templates/.claude/skills/create-agent/SKILL.md +94 -0
  144. package/templates/.claude/skills/cve-triage/SKILL.md +91 -0
  145. package/templates/.claude/skills/dag-orchestration/SKILL.md +201 -0
  146. package/templates/.claude/skills/dbt-best-practices/SKILL.md +55 -0
  147. package/templates/.claude/skills/de-lead-routing/SKILL.md +230 -0
  148. package/templates/.claude/skills/deep-plan/SKILL.md +344 -0
  149. package/templates/.claude/skills/deep-verify/SKILL.md +111 -0
  150. package/templates/.claude/skills/dev-lead-routing/SKILL.md +161 -0
  151. package/templates/.claude/skills/dev-refactor/SKILL.md +234 -0
  152. package/templates/.claude/skills/dev-review/SKILL.md +172 -0
  153. package/templates/.claude/skills/django-best-practices/SKILL.md +334 -0
  154. package/templates/.claude/skills/docker-best-practices/SKILL.md +276 -0
  155. package/templates/.claude/skills/evaluator-optimizer/SKILL.md +421 -0
  156. package/templates/.claude/skills/fastapi-best-practices/SKILL.md +271 -0
  157. package/templates/.claude/skills/fix-refs/SKILL.md +109 -0
  158. package/templates/.claude/skills/flutter-best-practices/SKILL.md +325 -0
  159. package/templates/.claude/skills/gemini-exec/SKILL.md +215 -0
  160. package/templates/.claude/skills/gemini-exec/scripts/gemini-wrapper.cjs +485 -0
  161. package/templates/.claude/skills/go-backend-best-practices/SKILL.md +135 -0
  162. package/templates/.claude/skills/go-best-practices/SKILL.md +204 -0
  163. package/templates/.claude/skills/hada-scout/SKILL.md +92 -0
  164. package/templates/.claude/skills/harness-eval/SKILL.md +95 -0
  165. package/templates/.claude/skills/harness-synthesizer/SKILL.md +145 -0
  166. package/templates/.claude/skills/help/SKILL.md +127 -0
  167. package/templates/.claude/skills/idea/SKILL.md +88 -0
  168. package/templates/.claude/skills/impeccable-design/SKILL.md +173 -0
  169. package/templates/.claude/skills/intent-detection/SKILL.md +293 -0
  170. package/templates/.claude/skills/intent-detection/patterns/agent-triggers.yaml +438 -0
  171. package/templates/.claude/skills/java21-best-practices/SKILL.md +190 -0
  172. package/templates/.claude/skills/jinja2-prompts/SKILL.md +86 -0
  173. package/templates/.claude/skills/kafka-best-practices/SKILL.md +53 -0
  174. package/templates/.claude/skills/kotlin-best-practices/SKILL.md +257 -0
  175. package/templates/.claude/skills/lists/SKILL.md +80 -0
  176. package/templates/.claude/skills/memory-management/SKILL.md +196 -0
  177. package/templates/.claude/skills/memory-recall/SKILL.md +172 -0
  178. package/templates/.claude/skills/memory-save/SKILL.md +128 -0
  179. package/templates/.claude/skills/model-escalation/SKILL.md +62 -0
  180. package/templates/.claude/skills/monitoring-setup/SKILL.md +215 -0
  181. package/templates/.claude/skills/multi-model-verification/SKILL.md +130 -0
  182. package/templates/.claude/skills/npm-audit/SKILL.md +74 -0
  183. package/templates/.claude/skills/npm-publish/SKILL.md +65 -0
  184. package/templates/.claude/skills/npm-version/SKILL.md +104 -0
  185. package/templates/.claude/skills/omcodex-auto-improve/SKILL.md +136 -0
  186. package/templates/.claude/skills/omcodex-feedback/SKILL.md +205 -0
  187. package/templates/.claude/skills/omcodex-improve-report/SKILL.md +65 -0
  188. package/templates/.claude/skills/omcodex-loop/SKILL.md +45 -0
  189. package/templates/.claude/skills/omcodex-release-notes/SKILL.md +117 -0
  190. package/templates/.claude/skills/omcodex-takeover/SKILL.md +115 -0
  191. package/templates/.claude/skills/omcodex-web/SKILL.md +95 -0
  192. package/templates/.claude/skills/optimize-analyze/SKILL.md +57 -0
  193. package/templates/.claude/skills/optimize-bundle/SKILL.md +69 -0
  194. package/templates/.claude/skills/optimize-report/SKILL.md +76 -0
  195. package/templates/.claude/skills/peer-messaging/SKILL.md +59 -0
  196. package/templates/.claude/skills/pipeline/SKILL.md +103 -0
  197. package/templates/.claude/skills/pipeline-architecture-patterns/SKILL.md +84 -0
  198. package/templates/.claude/skills/pipeline-guards/SKILL.md +173 -0
  199. package/templates/.claude/skills/post-release-followup/SKILL.md +134 -0
  200. package/templates/.claude/skills/postgres-best-practices/SKILL.md +67 -0
  201. package/templates/.claude/skills/pr-auto-improve/SKILL.md +129 -0
  202. package/templates/.claude/skills/professor-triage/SKILL.md +321 -0
  203. package/templates/.claude/skills/python-best-practices/SKILL.md +223 -0
  204. package/templates/.claude/skills/qa-lead-routing/SKILL.md +104 -0
  205. package/templates/.claude/skills/react-best-practices/SKILL.md +102 -0
  206. package/templates/.claude/skills/reasoning-sandwich/SKILL.md +64 -0
  207. package/templates/.claude/skills/redis-best-practices/SKILL.md +84 -0
  208. package/templates/.claude/skills/release-plan/SKILL.md +207 -0
  209. package/templates/.claude/skills/research/SKILL.md +493 -0
  210. package/templates/.claude/skills/result-aggregation/SKILL.md +165 -0
  211. package/templates/.claude/skills/rtk-exec/SKILL.md +199 -0
  212. package/templates/.claude/skills/rtk-exec/scripts/rtk-wrapper.cjs +377 -0
  213. package/templates/.claude/skills/rust-best-practices/SKILL.md +268 -0
  214. package/templates/.claude/skills/sauron-watch/SKILL.md +239 -0
  215. package/templates/.claude/skills/scout/SKILL.md +250 -0
  216. package/templates/.claude/skills/sdd/SKILL.md +24 -0
  217. package/templates/.claude/skills/sdd-dev/SKILL.md +257 -0
  218. package/templates/.claude/skills/sdd-development/SKILL.md +24 -0
  219. package/templates/.claude/skills/secretary-routing/SKILL.md +132 -0
  220. package/templates/.claude/skills/skill-extractor/SKILL.md +155 -0
  221. package/templates/.claude/skills/skills-sh-search/SKILL.md +210 -0
  222. package/templates/.claude/skills/snowflake-best-practices/SKILL.md +66 -0
  223. package/templates/.claude/skills/spark-best-practices/SKILL.md +53 -0
  224. package/templates/.claude/skills/springboot-best-practices/SKILL.md +74 -0
  225. package/templates/.claude/skills/springboot-best-practices/examples/config-properties-example.java +22 -0
  226. package/templates/.claude/skills/springboot-best-practices/examples/controller-example.java +28 -0
  227. package/templates/.claude/skills/springboot-best-practices/examples/controller-test-example.java +33 -0
  228. package/templates/.claude/skills/springboot-best-practices/examples/entity-example.java +22 -0
  229. package/templates/.claude/skills/springboot-best-practices/examples/exception-handler-example.java +30 -0
  230. package/templates/.claude/skills/springboot-best-practices/examples/repository-example.java +17 -0
  231. package/templates/.claude/skills/springboot-best-practices/examples/repository-test-example.java +23 -0
  232. package/templates/.claude/skills/springboot-best-practices/examples/security-config-example.java +27 -0
  233. package/templates/.claude/skills/springboot-best-practices/examples/service-example.java +33 -0
  234. package/templates/.claude/skills/status/SKILL.md +155 -0
  235. package/templates/.claude/skills/structured-dev-cycle/SKILL.md +200 -0
  236. package/templates/.claude/skills/stuck-recovery/SKILL.md +80 -0
  237. package/templates/.claude/skills/supabase-postgres-best-practices/SKILL.md +100 -0
  238. package/templates/.claude/skills/systematic-debugging/SKILL.md +288 -0
  239. package/templates/.claude/skills/systematic-debugging/condition-based-waiting-example.ts +278 -0
  240. package/templates/.claude/skills/systematic-debugging/condition-based-waiting.md +240 -0
  241. package/templates/.claude/skills/systematic-debugging/defense-in-depth.md +252 -0
  242. package/templates/.claude/skills/systematic-debugging/find-polluter.sh +147 -0
  243. package/templates/.claude/skills/systematic-debugging/root-cause-tracing.md +87 -0
  244. package/templates/.claude/skills/task-decomposition/SKILL.md +197 -0
  245. package/templates/.claude/skills/typescript-best-practices/SKILL.md +322 -0
  246. package/templates/.claude/skills/update-docs/SKILL.md +142 -0
  247. package/templates/.claude/skills/update-external/SKILL.md +169 -0
  248. package/templates/.claude/skills/vercel-deploy/SKILL.md +75 -0
  249. package/templates/.claude/skills/web-design-guidelines/SKILL.md +119 -0
  250. package/templates/.claude/skills/wiki/SKILL.md +426 -0
  251. package/templates/.claude/skills/wiki-rag/SKILL.md +154 -0
  252. package/templates/.claude/skills/worker-reviewer-pipeline/SKILL.md +165 -0
  253. package/templates/.claude/skills/writing-clearly-and-concisely/SKILL.md +66 -0
  254. package/templates/.claude/statusline.sh +380 -0
  255. package/templates/.claude/uninstall-hooks.sh +52 -0
  256. package/templates/.github/workflows/wiki-sync.yml +132 -0
  257. package/templates/AGENTS.md.en +255 -0
  258. package/templates/AGENTS.md.ko +255 -0
  259. package/templates/CLAUDE.md +263 -0
  260. package/templates/CLAUDE.md.en +256 -0
  261. package/templates/CLAUDE.md.ko +256 -0
  262. package/templates/deprecated-files.json +10 -0
  263. package/templates/guides/agents-md-quality/README.md +110 -0
  264. package/templates/guides/airflow/README.md +47 -0
  265. package/templates/guides/alembic/README.md +438 -0
  266. package/templates/guides/aws/common-patterns.md +169 -0
  267. package/templates/guides/aws/index.yaml +26 -0
  268. package/templates/guides/aws/well-architected.md +143 -0
  269. package/templates/guides/cc-token-saver/README.md +97 -0
  270. package/templates/guides/claude-code/01-overview.md +42 -0
  271. package/templates/guides/claude-code/03-tools.md +107 -0
  272. package/templates/guides/claude-code/04-agent-skills.md +90 -0
  273. package/templates/guides/claude-code/05-agent-sdk.md +129 -0
  274. package/templates/guides/claude-code/06-mcp.md +165 -0
  275. package/templates/guides/claude-code/07-prompt-engineering.md +100 -0
  276. package/templates/guides/claude-code/08-testing.md +56 -0
  277. package/templates/guides/claude-code/09-guardrails.md +78 -0
  278. package/templates/guides/claude-code/10-monitoring.md +87 -0
  279. package/templates/guides/claude-code/11-sub-agents.md +159 -0
  280. package/templates/guides/claude-code/12-workflow-patterns.md +182 -0
  281. package/templates/guides/claude-code/13-cli-flags.md +151 -0
  282. package/templates/guides/claude-code/index.yaml +61 -0
  283. package/templates/guides/dbt/README.md +32 -0
  284. package/templates/guides/django-best-practices/README.md +476 -0
  285. package/templates/guides/docker/compose-best-practices.md +284 -0
  286. package/templates/guides/docker/dockerfile-best-practices.md +262 -0
  287. package/templates/guides/docker/index.yaml +26 -0
  288. package/templates/guides/drizzle-orm/README.md +69 -0
  289. package/templates/guides/elements-of-style/elements-of-style.html +2609 -0
  290. package/templates/guides/fastapi/best-practices.md +232 -0
  291. package/templates/guides/fastapi/index.yaml +21 -0
  292. package/templates/guides/flutter/architecture.md +141 -0
  293. package/templates/guides/flutter/fundamentals.md +119 -0
  294. package/templates/guides/flutter/index.yaml +44 -0
  295. package/templates/guides/flutter/performance.md +119 -0
  296. package/templates/guides/flutter/security.md +120 -0
  297. package/templates/guides/flutter/state-management.md +144 -0
  298. package/templates/guides/flutter/testing.md +155 -0
  299. package/templates/guides/git-worktree-workflow/README.md +138 -0
  300. package/templates/guides/go-backend/index.yaml +26 -0
  301. package/templates/guides/go-backend/project-layout.md +243 -0
  302. package/templates/guides/go-backend/uber-style.md +212 -0
  303. package/templates/guides/golang/concurrency.md +282 -0
  304. package/templates/guides/golang/effective-go.md +309 -0
  305. package/templates/guides/golang/error-handling.md +250 -0
  306. package/templates/guides/golang/index.yaml +27 -0
  307. package/templates/guides/hook-data-flow/README.md +135 -0
  308. package/templates/guides/iceberg/README.md +49 -0
  309. package/templates/guides/impeccable-design/color-and-contrast.md +278 -0
  310. package/templates/guides/impeccable-design/index.yaml +12 -0
  311. package/templates/guides/impeccable-design/motion-design.md +390 -0
  312. package/templates/guides/impeccable-design/typography.md +386 -0
  313. package/templates/guides/impeccable-design/ux-writing.md +400 -0
  314. package/templates/guides/index.yaml +265 -0
  315. package/templates/guides/java21/index.yaml +29 -0
  316. package/templates/guides/java21/java-style-guide.md +248 -0
  317. package/templates/guides/java21/modern-java21.md +303 -0
  318. package/templates/guides/kafka/README.md +32 -0
  319. package/templates/guides/kotlin/coding-conventions.md +247 -0
  320. package/templates/guides/kotlin/idioms.md +234 -0
  321. package/templates/guides/kotlin/index.yaml +26 -0
  322. package/templates/guides/multi-model-routing/README.md +101 -0
  323. package/templates/guides/multi-provider-exec/README.md +83 -0
  324. package/templates/guides/postgres/README.md +58 -0
  325. package/templates/guides/python/index.yaml +26 -0
  326. package/templates/guides/python/pep8-style-guide.md +202 -0
  327. package/templates/guides/python/zen-of-python.md +79 -0
  328. package/templates/guides/redis/README.md +50 -0
  329. package/templates/guides/rust/error-handling.md +262 -0
  330. package/templates/guides/rust/index.yaml +26 -0
  331. package/templates/guides/rust/ownership.md +180 -0
  332. package/templates/guides/skill-bundle-design/README.md +106 -0
  333. package/templates/guides/slack-cli/README.md +145 -0
  334. package/templates/guides/snowflake/README.md +32 -0
  335. package/templates/guides/spark/README.md +32 -0
  336. package/templates/guides/springboot/best-practices.md +361 -0
  337. package/templates/guides/springboot/index.yaml +22 -0
  338. package/templates/guides/supabase-postgres/README.md +32 -0
  339. package/templates/guides/supabase-postgres/index.yaml +19 -0
  340. package/templates/guides/typescript/advanced-types.md +225 -0
  341. package/templates/guides/typescript/index.yaml +26 -0
  342. package/templates/guides/typescript/type-system.md +219 -0
  343. package/templates/guides/web-design/accessibility.md +66 -0
  344. package/templates/guides/web-design/index.yaml +20 -0
  345. package/templates/guides/web-design/performance.md +102 -0
  346. package/templates/guides/web-scraping/README.md +926 -0
  347. package/templates/guides/web-scraping/index.yaml +19 -0
  348. package/templates/guides/worktree-lifecycle/README.md +104 -0
  349. package/templates/index.yaml +18 -0
  350. package/templates/manifest.json +49 -0
  351. package/templates/workflows/auto-dev.yaml +46 -0
@@ -0,0 +1,421 @@
1
+ ---
2
+ name: evaluator-optimizer
3
+ description: Parameterized evaluator-optimizer loop for quality-critical output with configurable rubrics
4
+ scope: core
5
+ user-invocable: false
6
+ ---
7
+
8
+ # Evaluator-Optimizer Skill
9
+
10
+ ## Purpose
11
+
12
+ General-purpose iterative refinement loop. A generator agent produces output, an evaluator agent scores it against a configurable rubric, and the loop continues until the quality gate is met or max iterations are reached.
13
+
14
+ This skill generalizes the worker-reviewer-pipeline pattern beyond code review to any domain requiring quality-critical output: documentation, architecture decisions, test plans, configurations, and more.
15
+
16
+ ## Configuration Schema
17
+
18
+ ```yaml
19
+ evaluator-optimizer:
20
+ generator:
21
+ agent: {subagent_type} # Agent that produces output
22
+ model: sonnet # Default model
23
+ evaluator:
24
+ agent: {subagent_type} # Agent that reviews output
25
+ model: opus # Evaluator benefits from stronger reasoning
26
+ rubric:
27
+ - criterion: {name}
28
+ weight: {0.0-1.0}
29
+ description: {what to evaluate}
30
+ quality_gate:
31
+ type: all_pass | majority_pass | score_threshold
32
+ threshold: 0.8 # For score_threshold type
33
+ max_iterations: 3 # Default, hard cap: 5
34
+ ```
35
+
36
+ ### Pre-Negotiation (Sprint Contract Pattern)
37
+
38
+ Optional phase where generator and evaluator agree on rubric interpretation before the first iteration. Inspired by Anthropic's harness design for long-running applications.
39
+
40
+ ```yaml
41
+ evaluator-optimizer:
42
+ pre_negotiation:
43
+ enabled: true # Default: false
44
+ rounds: 1 # Negotiation rounds (1-2)
45
+ generator:
46
+ agent: fe-design-expert
47
+ ...
48
+ ```
49
+
50
+ When enabled:
51
+ 1. Generator receives the rubric and proposes its interpretation + planned approach
52
+ 2. Evaluator reviews and may adjust rubric weights or add clarifications
53
+ 3. Both proceed with aligned expectations, reducing wasted iterations
54
+
55
+ Use when: tasks requiring 3+ iterations consistently, or when generator-evaluator score disagreements exceed 0.3.
56
+
57
+ ### Evaluator Calibration
58
+
59
+ Anthropic's harness design research identifies evaluator leniency as a key failure mode: LLMs default to generous scoring, especially when evaluating output from the same model family. Counter-measures:
60
+
61
+ **Skepticism Prompting**: Include explicit instructions in the evaluator prompt:
62
+ - "Default to skepticism. A 'pass' should require clear evidence, not absence of issues."
63
+ - "Score as if you are reviewing code that will run in production with real users."
64
+ - "When uncertain between pass and fail, choose fail and explain what evidence would change your mind."
65
+
66
+ **Anti-Self-Praise Bias**: When generator and evaluator share the same model family (e.g., both Claude), add:
67
+ - "You are reviewing another agent's work, not your own. Do not give credit for intent — only for execution."
68
+ - "Identify at least one concrete improvement, even for high-quality output."
69
+
70
+ **Calibration via Rubric Examples**: Each rubric criterion SHOULD include a `fail_example` alongside the description:
71
+
72
+ ```yaml
73
+ rubric:
74
+ - criterion: error_handling
75
+ weight: 0.25
76
+ description: "All error paths handled with meaningful messages"
77
+ fail_example: "Generic try/catch with console.log(error) — no recovery, no user-facing message"
78
+ ```
79
+
80
+ Adding `fail_example` anchors the evaluator's scale, reducing score inflation by ~20% (based on Anthropic's internal testing).
81
+
82
+ ### Conditional Evaluator (Cost Optimization)
83
+
84
+ Not every task justifies evaluator overhead. Skip the evaluator loop for tasks within the model's reliable capability range. From Anthropic's research: "Worth cost when tasks sit beyond baseline model capability; unnecessary overhead for problems within model's reliable range."
85
+
86
+ ```yaml
87
+ evaluator-optimizer:
88
+ conditional:
89
+ enabled: true
90
+ skip_when:
91
+ - task_complexity: low # Simple, well-defined tasks
92
+ - generator_confidence: high # Generator self-reports high confidence
93
+ - historical_pass_rate: 0.9 # Same task type historically passes first try
94
+ ```
95
+
96
+ When `conditional.enabled: true` and ANY `skip_when` condition is met, the evaluator is skipped and the generator's first output is returned directly. This reduces token cost by ~40% for straightforward tasks.
97
+
98
+ **Decision matrix**:
99
+
100
+ | Task Type | Complexity | Evaluator? |
101
+ |-----------|-----------|------------|
102
+ | Simple file rename, config change | Low | Skip |
103
+ | Standard CRUD implementation | Medium | Run |
104
+ | Complex architecture, security-critical | High | Run with pre-negotiation |
105
+ | Previously failed task retry | Any | Always run |
106
+
107
+ ### Parameter Details
108
+
109
+ | Parameter | Required | Default | Description |
110
+ |-----------|----------|---------|-------------|
111
+ | `generator.agent` | Yes | — | Subagent type that produces output |
112
+ | `generator.model` | No | `sonnet` | Model for generation |
113
+ | `evaluator.agent` | Yes | — | Subagent type that evaluates output |
114
+ | `evaluator.model` | No | `opus` | Model for evaluation (stronger reasoning preferred) |
115
+ | `rubric` | Yes | — | List of evaluation criteria with weights |
116
+ | `quality_gate.type` | No | `score_threshold` | Gate strategy |
117
+ | `quality_gate.threshold` | No | `0.8` | Score threshold (for `score_threshold` type) |
118
+ | `max_iterations` | No | `3` | Max refinement loops (hard cap: 5) |
119
+
120
+ ### Model Selection Guidance
121
+
122
+ For model selection within the evaluator-optimizer loop, follow the [reasoning-sandwich](/skills/reasoning-sandwich) pattern:
123
+
124
+ - **Generator**: Use `sonnet` (default) — optimized for content generation
125
+ - **Evaluator**: Use `opus` (default) — benefits from stronger reasoning for quality assessment
126
+ - **Override**: For simpler domains, `sonnet`/`sonnet` is acceptable; for critical domains, consider `opus`/`opus`
127
+
128
+ ## Quality Gate Types
129
+
130
+ | Type | Behavior |
131
+ |------|----------|
132
+ | `all_pass` | Every rubric criterion must pass |
133
+ | `majority_pass` | >50% of weighted criteria pass |
134
+ | `score_threshold` | Weighted average score >= threshold |
135
+
136
+ ### Gate Evaluation Logic
137
+
138
+ - **all_pass**: Each criterion scored individually. All must receive `pass: true`.
139
+ - **majority_pass**: Sum weights of passing criteria. If > 0.5 of total weight, gate passes.
140
+ - **score_threshold**: Compute weighted average: `sum(score_i * weight_i) / sum(weight_i)`. Compare against threshold.
141
+
142
+ ## Workflow
143
+
144
+ ```
145
+ 1. Generator produces output
146
+ → Orchestrator spawns generator agent with task prompt
147
+ → Generator returns output artifact
148
+
149
+ 2. Evaluator scores against rubric
150
+ → Orchestrator spawns evaluator agent with:
151
+ - The output artifact
152
+ - The rubric criteria
153
+ - Instructions to produce verdict JSON
154
+ → Evaluator returns structured verdict
155
+
156
+ 3. Quality gate check:
157
+ - PASS → return output + final verdict
158
+ - FAIL → extract feedback, append to generator prompt → iteration N+1
159
+
160
+ 4. Max iterations reached → return best output + warning
161
+ → "Best" = output from iteration with highest weighted score
162
+ ```
163
+
164
+ ### Iteration Flow Diagram
165
+
166
+ ```
167
+ ┌─────────────────────────────────────────────────┐
168
+ │ Orchestrator │
169
+ │ │
170
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
171
+ │ │ Generate │───→│ Evaluate │───→│ Gate │ │
172
+ │ │ (iter N) │ │ │ │ Check │ │
173
+ │ └──────────┘ └──────────┘ └────┬─────┘ │
174
+ │ ↑ │ │
175
+ │ │ ┌──────────┐ FAIL │ PASS │
176
+ │ └─────────│ Feedback │←────────┘ │ │
177
+ │ └──────────┘ ↓ │
178
+ │ Return │
179
+ └─────────────────────────────────────────────────┘
180
+ ```
181
+
182
+ ## Stopping Criteria Display
183
+
184
+ ```
185
+ [Evaluator-Optimizer]
186
+ ├── Generator: {agent}:{model}
187
+ ├── Evaluator: {agent}:{model}
188
+ ├── Max iterations: {max_iterations} (hard cap: 5)
189
+ ├── Quality gate: {type} (threshold: {threshold})
190
+ └── Rubric: {N} criteria
191
+ ```
192
+
193
+ Display this at the start of the loop to provide transparency into the refinement configuration.
194
+
195
+ ## Verdict Format
196
+
197
+ The evaluator MUST return a structured verdict in this format:
198
+
199
+ ```json
200
+ {
201
+ "status": "pass | fail",
202
+ "iteration": 2,
203
+ "score": 0.85,
204
+ "rubric_results": [
205
+ {"criterion": "clarity", "pass": true, "score": 0.9, "feedback": "Clear structure and logical flow"},
206
+ {"criterion": "accuracy", "pass": true, "score": 0.8, "feedback": "All facts verified, one minor imprecision in section 3"}
207
+ ],
208
+ "improvement_summary": "Section 3 terminology tightened. Examples added to section 2."
209
+ }
210
+ ```
211
+
212
+ ### Verdict Fields
213
+
214
+ | Field | Type | Description |
215
+ |-------|------|-------------|
216
+ | `status` | `pass` or `fail` | Overall quality gate result |
217
+ | `iteration` | number | Current iteration number (1-indexed) |
218
+ | `score` | number (0.0-1.0) | Weighted average score across all criteria |
219
+ | `rubric_results` | array | Per-criterion evaluation details |
220
+ | `improvement_summary` | string | Summary of changes from previous iteration (empty on iteration 1) |
221
+
222
+ ## Domain Examples
223
+
224
+ | Domain | Generator | Evaluator | Rubric Focus |
225
+ |--------|-----------|-----------|--------------|
226
+ | Code review | `lang-*-expert` | opus reviewer | Correctness, style, security |
227
+ | Documentation | `arch-documenter` | opus reviewer | Completeness, clarity, accuracy |
228
+ | Architecture | Plan agent | opus reviewer | No SPOFs, no circular deps |
229
+ | Test plans | `qa-planner` | `qa-engineer` | Coverage, edge cases, feasibility |
230
+ | Test coverage | `qa-writer` | `qa-engineer` + coverage tool | `coverage >= target%` |
231
+ | Agent creation | `mgr-creator` | opus reviewer | Frontmatter validity, R006 compliance |
232
+ | Security audit | `sec-codeql-expert` | opus reviewer | Vulnerability coverage, false positive rate |
233
+
234
+ ### Example: Documentation Review
235
+
236
+ ```yaml
237
+ evaluator-optimizer:
238
+ generator:
239
+ agent: arch-documenter
240
+ model: sonnet
241
+ evaluator:
242
+ agent: general-purpose
243
+ model: opus
244
+ rubric:
245
+ - criterion: completeness
246
+ weight: 0.3
247
+ description: All sections present, no gaps in coverage
248
+ - criterion: clarity
249
+ weight: 0.3
250
+ description: Clear language, no ambiguity, proper examples
251
+ - criterion: accuracy
252
+ weight: 0.25
253
+ description: All technical details correct and verifiable
254
+ - criterion: consistency
255
+ weight: 0.15
256
+ description: Consistent terminology, formatting, and style
257
+ quality_gate:
258
+ type: score_threshold
259
+ threshold: 0.8
260
+ max_iterations: 3
261
+ ```
262
+
263
+ ### Example: Code Implementation
264
+
265
+ ```yaml
266
+ evaluator-optimizer:
267
+ generator:
268
+ agent: lang-typescript-expert
269
+ model: sonnet
270
+ evaluator:
271
+ agent: general-purpose
272
+ model: opus
273
+ rubric:
274
+ - criterion: correctness
275
+ weight: 0.35
276
+ description: Code compiles, logic is correct, edge cases handled
277
+ fail_example: "Missing null check on user input causes runtime crash"
278
+ - criterion: style
279
+ weight: 0.2
280
+ description: Follows project conventions, clean and readable
281
+ - criterion: security
282
+ weight: 0.25
283
+ description: No injection risks, proper input validation
284
+ - criterion: performance
285
+ weight: 0.2
286
+ description: No unnecessary allocations, efficient algorithms
287
+ quality_gate:
288
+ type: all_pass
289
+ max_iterations: 3
290
+ ```
291
+
292
+ ### Domain: Test Coverage Optimization
293
+
294
+ ```yaml
295
+ evaluator-optimizer:
296
+ generator:
297
+ agent: qa-writer
298
+ model: sonnet
299
+ evaluator:
300
+ agent: qa-engineer
301
+ model: sonnet
302
+ rubric:
303
+ - criterion: line_coverage
304
+ weight: 0.4
305
+ description: "Percentage of code lines exercised by tests"
306
+ - criterion: branch_coverage
307
+ weight: 0.3
308
+ description: "Percentage of conditional branches tested"
309
+ - criterion: edge_cases
310
+ weight: 0.2
311
+ description: "Critical edge cases explicitly tested"
312
+ - criterion: test_quality
313
+ weight: 0.1
314
+ description: "Tests are meaningful, not just hitting lines"
315
+ quality_gate:
316
+ type: score_threshold
317
+ threshold: 0.8
318
+ max_iterations: 5
319
+ parameters:
320
+ target_coverage: 80 # Minimum coverage percentage
321
+ max_iterations: 5 # Hard cap (matches skill-level cap)
322
+ ```
323
+
324
+ **Workflow**:
325
+ 1. qa-writer generates test cases targeting uncovered code
326
+ 2. qa-engineer runs tests and measures coverage
327
+ 3. If coverage < target: qa-writer generates additional tests for uncovered paths
328
+ 4. Repeat until target reached or max_iterations exhausted
329
+
330
+ **Parameters**:
331
+ | Parameter | Default | Description |
332
+ |-----------|---------|-------------|
333
+ | `target_coverage` | 80% | Minimum acceptable coverage |
334
+ | `max_iterations` | 5 | Hard cap on refinement loops |
335
+
336
+ ## Integration
337
+
338
+ | Rule | Integration |
339
+ |------|-------------|
340
+ | R009 | Generator and evaluator run sequentially (dependent — evaluator needs generator output) |
341
+ | R010 | Orchestrator configures and invokes the loop; generator and evaluator agents execute via Agent tool |
342
+ | R007 | Each iteration displays agent identification for both generator and evaluator |
343
+ | R008 | Tool calls within generator/evaluator follow tool identification rules |
344
+ | R013 | Ecomode: return verdict summary only, skip per-criterion details |
345
+ | R015 | Display configuration block at loop start for intent transparency |
346
+
347
+ ## Ecomode Behavior
348
+
349
+ When ecomode is active (R013), compress output:
350
+
351
+ **Normal mode:**
352
+ ```
353
+ [Evaluator-Optimizer] Iteration 2/3
354
+ ├── Generator: lang-typescript-expert:sonnet → produced 45-line module
355
+ ├── Evaluator: general-purpose:opus → scored 0.85
356
+ ├── Rubric: correctness ✓(0.9), style ✓(0.8), security ✓(0.85), performance ✓(0.8)
357
+ └── Gate: score_threshold(0.8) → PASS
358
+ ```
359
+
360
+ **Ecomode:**
361
+ ```
362
+ [EO] iter 2/3 → 0.85 → PASS
363
+ ```
364
+
365
+ ## Error Handling
366
+
367
+ | Scenario | Action |
368
+ |----------|--------|
369
+ | Generator fails to produce output | Retry once with simplified prompt; if still fails, abort with error |
370
+ | Evaluator returns malformed verdict | Retry once; if still malformed, treat as fail with score 0.0 |
371
+ | Max iterations reached without passing | Return best-scored output with warning: "Quality gate not met after {N} iterations" |
372
+ | Rubric has zero total weight | Reject configuration, report error before starting loop |
373
+ | Hard cap exceeded in config | Clamp `max_iterations` to 5, emit warning |
374
+
375
+ ## Constraints
376
+
377
+ - This skill does NOT use `context: fork` — it operates within the caller's context
378
+ - Generator and evaluator MUST be different agent invocations (no self-review)
379
+ - The evaluator prompt MUST include the full rubric to ensure consistent scoring
380
+ - Iteration state (best score, best output) is tracked by the orchestrator
381
+ - The hard cap of 5 iterations prevents runaway refinement loops
382
+ - For multi-sprint runs (5+ iterations), consider context reset: spawn a fresh evaluator agent rather than continuing with degraded context. The pipeline skill supports this via `context: fork` on individual steps. Anthropic's research confirms "context resets provide clean slates superior to compaction" for long-running evaluation.
383
+
384
+ ## Domain Examples
385
+
386
+ ### UI Generation (Anti-AI-Slop)
387
+
388
+ For UI/design generation tasks, use weighted rubrics that penalize generic AI patterns:
389
+
390
+ ```yaml
391
+ evaluator-optimizer:
392
+ generator:
393
+ agent: fe-design-expert
394
+ model: sonnet
395
+ evaluator:
396
+ agent: fe-design-expert
397
+ model: opus
398
+ rubric:
399
+ - criterion: originality
400
+ weight: 0.40
401
+ description: "No stock patterns (centered hero + 3-card grid). Unique layout, typography choices, color relationships."
402
+ - criterion: craft
403
+ weight: 0.35
404
+ description: "Intentional spacing, consistent type scale, purposeful color usage. Details that show care."
405
+ - criterion: functionality
406
+ weight: 0.25
407
+ description: "Accessibility (WCAG 2.1 AA), responsive behavior, interaction states."
408
+ quality_gate:
409
+ type: score_threshold
410
+ threshold: 0.85
411
+ pre_negotiation:
412
+ enabled: true
413
+ ```
414
+
415
+ Weight ordering (originality > craft > functionality) follows Anthropic's anti-slop principle: functionality is table stakes, but originality and craft distinguish quality output from generic AI generation.
416
+
417
+ Integration: Works with [impeccable-design](/skills/impeccable-design) skill for design language enforcement.
418
+
419
+ ### Harness Eval Preset
420
+
421
+ The `harness-eval` skill provides a structured 15-task SE benchmark rubric that can be used as a preset for the evaluator-optimizer pipeline. When invoked via `/omcodex:harness-eval`, the harness rubric dimensions (Test Coverage 30%, Architecture 25%, Error Handling 25%, Extensibility 20%) are loaded as the sprint contract criteria.
@@ -0,0 +1,271 @@
1
+ ---
2
+ name: fastapi-best-practices
3
+ description: FastAPI patterns for high-performance async APIs
4
+ scope: core
5
+ user-invocable: false
6
+ ---
7
+
8
+ ## Purpose
9
+
10
+ Apply FastAPI patterns for building high-performance async APIs.
11
+
12
+ ## Rules
13
+
14
+ ### 1. Project Structure
15
+
16
+ ```yaml
17
+ structure:
18
+ domain_based: true
19
+ module_contents:
20
+ - router.py: API endpoints
21
+ - schemas.py: Pydantic models
22
+ - models.py: Database models
23
+ - service.py: Business logic
24
+ - dependencies.py: Route validators
25
+ - constants.py: Module constants
26
+ - config.py: Module configuration
27
+ - exceptions.py: Custom exceptions
28
+ - utils.py: Helper functions
29
+
30
+ imports:
31
+ style: explicit
32
+ example: "from src.auth import constants as auth_constants"
33
+
34
+ layout: |
35
+ src/
36
+ ├── auth/
37
+ │ ├── router.py
38
+ │ ├── schemas.py
39
+ │ ├── models.py
40
+ │ ├── service.py
41
+ │ └── dependencies.py
42
+ ├── users/
43
+ │ └── ...
44
+ ├── config.py
45
+ └── main.py
46
+ ```
47
+
48
+ ### 2. Async Patterns
49
+
50
+ ```yaml
51
+ io_intensive:
52
+ use: "async def"
53
+ await: "asyncio.sleep(), httpx, asyncpg, etc."
54
+ example: |
55
+ async def fetch_data():
56
+ async with httpx.AsyncClient() as client:
57
+ response = await client.get(url)
58
+ return response.json()
59
+
60
+ sync_io:
61
+ use: "def (regular function)"
62
+ reason: FastAPI offloads to threadpool automatically
63
+ example: |
64
+ def read_file():
65
+ with open('file.txt') as f:
66
+ return f.read()
67
+
68
+ cpu_intensive:
69
+ avoid: async and threadpool
70
+ use: separate worker processes
71
+ example: "Use Celery or multiprocessing"
72
+
73
+ never:
74
+ - "time.sleep() in async functions"
75
+ - "Blocking I/O in async functions"
76
+ ```
77
+
78
+ ### 3. Pydantic Models
79
+
80
+ ```yaml
81
+ validation:
82
+ use_builtin: regex, enums, email, URL validators
83
+ custom_validators: for complex logic
84
+
85
+ base_model:
86
+ create_custom: true
87
+ purpose: enforce application-wide standards
88
+ example: |
89
+ from pydantic import BaseModel
90
+ from datetime import datetime
91
+
92
+ class AppBaseModel(BaseModel):
93
+ class Config:
94
+ from_attributes = True
95
+ json_encoders = {
96
+ datetime: lambda v: v.isoformat()
97
+ }
98
+
99
+ settings:
100
+ split: across modules
101
+ avoid: single global configuration
102
+ example: |
103
+ # auth/config.py
104
+ class AuthSettings(BaseSettings):
105
+ jwt_secret: str
106
+ jwt_algorithm: str = "HS256"
107
+
108
+ # database/config.py
109
+ class DatabaseSettings(BaseSettings):
110
+ url: str
111
+ pool_size: int = 5
112
+ ```
113
+
114
+ ### 4. Dependencies
115
+
116
+ ```yaml
117
+ usage:
118
+ - Dependency injection
119
+ - Validation against database
120
+ - Authentication/authorization
121
+ - Request scoped caching
122
+
123
+ patterns:
124
+ chain: avoid code repetition
125
+ cache: FastAPI caches within request scope
126
+ decouple: small, reusable functions
127
+
128
+ example: |
129
+ async def get_current_user(
130
+ token: str = Depends(oauth2_scheme),
131
+ db: Session = Depends(get_db)
132
+ ) -> User:
133
+ user = await db.get_user_by_token(token)
134
+ if not user:
135
+ raise HTTPException(status_code=401)
136
+ return user
137
+
138
+ async def get_active_user(
139
+ user: User = Depends(get_current_user)
140
+ ) -> User:
141
+ if not user.is_active:
142
+ raise HTTPException(status_code=403)
143
+ return user
144
+ ```
145
+
146
+ ### 5. Error Handling
147
+
148
+ ```yaml
149
+ custom_exceptions:
150
+ scope: module-specific
151
+ purpose: clarity and consistency
152
+
153
+ pattern: |
154
+ # auth/exceptions.py
155
+ class AuthException(Exception):
156
+ pass
157
+
158
+ class InvalidCredentials(AuthException):
159
+ pass
160
+
161
+ class TokenExpired(AuthException):
162
+ pass
163
+
164
+ # auth/router.py
165
+ @router.post("/login")
166
+ async def login(credentials: LoginSchema):
167
+ try:
168
+ return await auth_service.login(credentials)
169
+ except InvalidCredentials:
170
+ raise HTTPException(
171
+ status_code=401,
172
+ detail="Invalid credentials"
173
+ )
174
+
175
+ exception_handlers: |
176
+ @app.exception_handler(AuthException)
177
+ async def auth_exception_handler(request, exc):
178
+ return JSONResponse(
179
+ status_code=401,
180
+ content={"detail": str(exc)}
181
+ )
182
+ ```
183
+
184
+ ### 6. Database
185
+
186
+ ```yaml
187
+ naming:
188
+ establish: upfront conventions
189
+ consistency: across all models
190
+
191
+ migrations:
192
+ tool: Alembic
193
+ naming: explicit naming rules
194
+
195
+ design:
196
+ approach: SQL-first
197
+ then: add Pydantic models
198
+
199
+ patterns: |
200
+ # Use async database drivers
201
+ from sqlalchemy.ext.asyncio import AsyncSession
202
+
203
+ async def get_user(db: AsyncSession, user_id: int):
204
+ result = await db.execute(
205
+ select(User).where(User.id == user_id)
206
+ )
207
+ return result.scalar_one_or_none()
208
+ ```
209
+
210
+ ### 7. API Design
211
+
212
+ ```yaml
213
+ routing:
214
+ prefix: meaningful module prefix
215
+ tags: for documentation grouping
216
+
217
+ responses:
218
+ schema: always define response models
219
+ status_codes: document all possible codes
220
+
221
+ example: |
222
+ router = APIRouter(
223
+ prefix="/users",
224
+ tags=["users"]
225
+ )
226
+
227
+ @router.get(
228
+ "/{user_id}",
229
+ response_model=UserResponse,
230
+ responses={
231
+ 404: {"model": ErrorResponse}
232
+ }
233
+ )
234
+ async def get_user(user_id: int):
235
+ ...
236
+ ```
237
+
238
+ ### 8. Testing
239
+
240
+ ```yaml
241
+ setup:
242
+ async_client: from day one
243
+ structure: mirror module layout
244
+
245
+ patterns: |
246
+ import pytest
247
+ from httpx import AsyncClient
248
+
249
+ @pytest.fixture
250
+ async def client():
251
+ async with AsyncClient(app=app, base_url="http://test") as ac:
252
+ yield ac
253
+
254
+ @pytest.mark.asyncio
255
+ async def test_get_user(client):
256
+ response = await client.get("/users/1")
257
+ assert response.status_code == 200
258
+ ```
259
+
260
+ ## Application
261
+
262
+ When writing FastAPI code:
263
+
264
+ 1. **Always** use domain-based project structure
265
+ 2. **Always** use `async def` for I/O operations
266
+ 3. **Prefer** Pydantic for all validation
267
+ 4. **Use** dependencies for reusable logic
268
+ 5. **Define** module-specific exceptions
269
+ 6. **Document** API with response models
270
+ 7. **Test** with async client
271
+ 8. **Use** Ruff for code quality