contextos-agents 1.5.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.
- package/.agents/AGENTS.md +421 -0
- package/.agents/adapters/aider/export.js +137 -0
- package/.agents/adapters/claude/export.js +55 -0
- package/.agents/adapters/copilot/export.js +107 -0
- package/.agents/adapters/cursor/export.js +210 -0
- package/.agents/adapters/gemini/export.js +115 -0
- package/.agents/adapters/shared.js +119 -0
- package/.agents/adapters/zed/export.js +111 -0
- package/.agents/core/profiles/backend.yaml +47 -0
- package/.agents/core/profiles/enterprise.yaml +46 -0
- package/.agents/core/profiles/frontend.yaml +46 -0
- package/.agents/core/profiles/hackathon.yaml +45 -0
- package/.agents/core/profiles/mvp.yaml +43 -0
- package/.agents/core/profiles/startup.yaml +48 -0
- package/.agents/core/skills/adapters/EXAMPLES.md +19 -0
- package/.agents/core/skills/adapters/SKILL.md +105 -0
- package/.agents/core/skills/adapters/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/adapters/VALIDATION.json +12 -0
- package/.agents/core/skills/adapters/skill.yaml +10 -0
- package/.agents/core/skills/architecture-diagrams/SKILL.md +108 -0
- package/.agents/core/skills/architecture-diagrams/VALIDATION.json +12 -0
- package/.agents/core/skills/architecture-diagrams/skill.yaml +8 -0
- package/.agents/core/skills/brutalist-design/SKILL.md +150 -0
- package/.agents/core/skills/brutalist-design/VALIDATION.json +12 -0
- package/.agents/core/skills/brutalist-design/skill.yaml +8 -0
- package/.agents/core/skills/context-manager/EXAMPLES.md +19 -0
- package/.agents/core/skills/context-manager/SKILL.md +126 -0
- package/.agents/core/skills/context-manager/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/context-manager/VALIDATION.json +12 -0
- package/.agents/core/skills/context-manager/skill.yaml +10 -0
- package/.agents/core/skills/context-os/EXAMPLES.md +21 -0
- package/.agents/core/skills/context-os/SKILL.md +169 -0
- package/.agents/core/skills/context-os/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/context-os/VALIDATION.json +12 -0
- package/.agents/core/skills/context-os/packs.yaml +59 -0
- package/.agents/core/skills/context-os/references/context-rules.md +68 -0
- package/.agents/core/skills/context-os/references/pipeline.md +119 -0
- package/.agents/core/skills/context-os/references/project-graph.md +103 -0
- package/.agents/core/skills/context-os/rules.yaml +135 -0
- package/.agents/core/skills/context-os/skill.yaml +10 -0
- package/.agents/core/skills/database/EXAMPLES.md +74 -0
- package/.agents/core/skills/database/SKILL.md +101 -0
- package/.agents/core/skills/database/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/database/VALIDATION.json +11 -0
- package/.agents/core/skills/database/skill.yaml +25 -0
- package/.agents/core/skills/ddd/EXAMPLES.md +42 -0
- package/.agents/core/skills/ddd/SKILL.md +247 -0
- package/.agents/core/skills/ddd/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ddd/VALIDATION.json +12 -0
- package/.agents/core/skills/ddd/ddd.md +178 -0
- package/.agents/core/skills/ddd/skill.yaml +10 -0
- package/.agents/core/skills/decisions/EXAMPLES.md +35 -0
- package/.agents/core/skills/decisions/SKILL.md +90 -0
- package/.agents/core/skills/decisions/TROUBLESHOOTING.md +13 -0
- package/.agents/core/skills/decisions/VALIDATION.json +12 -0
- package/.agents/core/skills/decisions/skill.yaml +10 -0
- package/.agents/core/skills/docker/EXAMPLES.md +56 -0
- package/.agents/core/skills/docker/SKILL.md +63 -0
- package/.agents/core/skills/docker/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/docker/VALIDATION.json +11 -0
- package/.agents/core/skills/docker/skill.yaml +23 -0
- package/.agents/core/skills/engineering-workflow/EXAMPLES.md +57 -0
- package/.agents/core/skills/engineering-workflow/SKILL.md +343 -0
- package/.agents/core/skills/engineering-workflow/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/engineering-workflow/VALIDATION.json +12 -0
- package/.agents/core/skills/engineering-workflow/skill.yaml +13 -0
- package/.agents/core/skills/fastapi/EXAMPLES.md +36 -0
- package/.agents/core/skills/fastapi/SKILL.md +148 -0
- package/.agents/core/skills/fastapi/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/fastapi/VALIDATION.json +12 -0
- package/.agents/core/skills/fastapi/fastapi.md +112 -0
- package/.agents/core/skills/fastapi/skill.yaml +10 -0
- package/.agents/core/skills/gemini-precision/SKILL.md +169 -0
- package/.agents/core/skills/gemini-precision/VALIDATION.json +12 -0
- package/.agents/core/skills/gemini-precision/skill.yaml +9 -0
- package/.agents/core/skills/generators/EXAMPLES.md +19 -0
- package/.agents/core/skills/generators/SKILL.md +112 -0
- package/.agents/core/skills/generators/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/generators/VALIDATION.json +12 -0
- package/.agents/core/skills/generators/skill.yaml +10 -0
- package/.agents/core/skills/generators/templates/API.md +77 -0
- package/.agents/core/skills/generators/templates/ARCHITECTURE.md +70 -0
- package/.agents/core/skills/generators/templates/DATABASE.md +42 -0
- package/.agents/core/skills/generators/templates/DECISION.md +46 -0
- package/.agents/core/skills/generators/templates/PRD.md +67 -0
- package/.agents/core/skills/generators/templates/PROJECT_GRAPH.md +56 -0
- package/.agents/core/skills/generators/templates/ROADMAP.md +51 -0
- package/.agents/core/skills/generators/templates/TASKS.md +43 -0
- package/.agents/core/skills/generators/templates/UI.md +73 -0
- package/.agents/core/skills/graphify/EXAMPLES.md +73 -0
- package/.agents/core/skills/graphify/SKILL.md +130 -0
- package/.agents/core/skills/graphify/VALIDATION.json +12 -0
- package/.agents/core/skills/graphify/skill.yaml +13 -0
- package/.agents/core/skills/gstack-roles/EXAMPLES.md +23 -0
- package/.agents/core/skills/gstack-roles/SKILL.md +152 -0
- package/.agents/core/skills/gstack-roles/TROUBLESHOOTING.md +13 -0
- package/.agents/core/skills/gstack-roles/VALIDATION.json +12 -0
- package/.agents/core/skills/gstack-roles/skill.yaml +12 -0
- package/.agents/core/skills/impeccable-design/EXAMPLES.md +26 -0
- package/.agents/core/skills/impeccable-design/SKILL.md +201 -0
- package/.agents/core/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/impeccable-design/VALIDATION.json +12 -0
- package/.agents/core/skills/impeccable-design/skill.yaml +14 -0
- package/.agents/core/skills/interview-me/SKILL.md +97 -0
- package/.agents/core/skills/interview-me/VALIDATION.json +12 -0
- package/.agents/core/skills/interview-me/skill.yaml +8 -0
- package/.agents/core/skills/microservices/EXAMPLES.md +38 -0
- package/.agents/core/skills/microservices/SKILL.md +164 -0
- package/.agents/core/skills/microservices/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/microservices/VALIDATION.json +12 -0
- package/.agents/core/skills/microservices/microservices.md +119 -0
- package/.agents/core/skills/microservices/skill.yaml +10 -0
- package/.agents/core/skills/minimalist-design/SKILL.md +113 -0
- package/.agents/core/skills/minimalist-design/VALIDATION.json +12 -0
- package/.agents/core/skills/minimalist-design/skill.yaml +8 -0
- package/.agents/core/skills/nestjs/EXAMPLES.md +40 -0
- package/.agents/core/skills/nestjs/SKILL.md +139 -0
- package/.agents/core/skills/nestjs/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/nestjs/VALIDATION.json +12 -0
- package/.agents/core/skills/nestjs/nestjs.md +103 -0
- package/.agents/core/skills/nestjs/skill.yaml +10 -0
- package/.agents/core/skills/nextjs/EXAMPLES.md +40 -0
- package/.agents/core/skills/nextjs/SKILL.md +163 -0
- package/.agents/core/skills/nextjs/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/nextjs/VALIDATION.json +12 -0
- package/.agents/core/skills/nextjs/nextjs.md +67 -0
- package/.agents/core/skills/nextjs/skill.yaml +10 -0
- package/.agents/core/skills/node/EXAMPLES.md +80 -0
- package/.agents/core/skills/node/SKILL.md +128 -0
- package/.agents/core/skills/node/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/node/VALIDATION.json +12 -0
- package/.agents/core/skills/node/node.md +87 -0
- package/.agents/core/skills/node/skill.yaml +10 -0
- package/.agents/core/skills/performance/EXAMPLES.md +30 -0
- package/.agents/core/skills/performance/SKILL.md +75 -0
- package/.agents/core/skills/performance/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/performance/VALIDATION.json +12 -0
- package/.agents/core/skills/performance/performance.md +52 -0
- package/.agents/core/skills/performance/skill.yaml +10 -0
- package/.agents/core/skills/ponytail-mindset/EXAMPLES.md +45 -0
- package/.agents/core/skills/ponytail-mindset/SKILL.md +193 -0
- package/.agents/core/skills/ponytail-mindset/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ponytail-mindset/VALIDATION.json +12 -0
- package/.agents/core/skills/ponytail-mindset/skill.yaml +14 -0
- package/.agents/core/skills/react/EXAMPLES.md +79 -0
- package/.agents/core/skills/react/SKILL.md +132 -0
- package/.agents/core/skills/react/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/react/VALIDATION.json +12 -0
- package/.agents/core/skills/react/react.md +93 -0
- package/.agents/core/skills/react/skill.yaml +10 -0
- package/.agents/core/skills/react-best-practices/SKILL.md +155 -0
- package/.agents/core/skills/react-best-practices/VALIDATION.json +12 -0
- package/.agents/core/skills/react-best-practices/skill.yaml +10 -0
- package/.agents/core/skills/redesign-audit/SKILL.md +117 -0
- package/.agents/core/skills/redesign-audit/VALIDATION.json +12 -0
- package/.agents/core/skills/redesign-audit/skill.yaml +8 -0
- package/.agents/core/skills/security/EXAMPLES.md +64 -0
- package/.agents/core/skills/security/SKILL.md +158 -0
- package/.agents/core/skills/security/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/security/VALIDATION.json +12 -0
- package/.agents/core/skills/security/security.md +106 -0
- package/.agents/core/skills/security/skill.yaml +10 -0
- package/.agents/core/skills/soft-design/SKILL.md +108 -0
- package/.agents/core/skills/soft-design/VALIDATION.json +12 -0
- package/.agents/core/skills/soft-design/skill.yaml +8 -0
- package/.agents/core/skills/state-management/EXAMPLES.md +56 -0
- package/.agents/core/skills/state-management/SKILL.md +48 -0
- package/.agents/core/skills/state-management/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/state-management/VALIDATION.json +11 -0
- package/.agents/core/skills/state-management/skill.yaml +22 -0
- package/.agents/core/skills/subagent-orchestrator/SKILL.md +100 -0
- package/.agents/core/skills/subagent-orchestrator/VALIDATION.json +12 -0
- package/.agents/core/skills/subagent-orchestrator/skill.yaml +8 -0
- package/.agents/core/skills/system-design/EXAMPLES.md +75 -0
- package/.agents/core/skills/system-design/SKILL.md +419 -0
- package/.agents/core/skills/system-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/system-design/VALIDATION.json +12 -0
- package/.agents/core/skills/system-design/skill.yaml +13 -0
- package/.agents/core/skills/system-design/system-design.md +112 -0
- package/.agents/core/skills/testing/EXAMPLES.md +71 -0
- package/.agents/core/skills/testing/SKILL.md +70 -0
- package/.agents/core/skills/testing/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/testing/VALIDATION.json +11 -0
- package/.agents/core/skills/testing/skill.yaml +26 -0
- package/.agents/core/skills/typescript/EXAMPLES.md +64 -0
- package/.agents/core/skills/typescript/SKILL.md +112 -0
- package/.agents/core/skills/typescript/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/typescript/VALIDATION.json +12 -0
- package/.agents/core/skills/typescript/skill.yaml +10 -0
- package/.agents/core/skills/typescript/typescript.md +71 -0
- package/.agents/core/skills/ui-design/EXAMPLES.md +21 -0
- package/.agents/core/skills/ui-design/SKILL.md +124 -0
- package/.agents/core/skills/ui-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ui-design/VALIDATION.json +12 -0
- package/.agents/core/skills/ui-design/skill.yaml +10 -0
- package/.agents/core/skills/ui-design/ui.md +88 -0
- package/.agents/core/skills/ui-ux-pro/EXAMPLES.md +62 -0
- package/.agents/core/skills/ui-ux-pro/SKILL.md +375 -0
- package/.agents/core/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ui-ux-pro/VALIDATION.json +12 -0
- package/.agents/core/skills/ui-ux-pro/skill.yaml +13 -0
- package/.agents/core/skills/ux-design/EXAMPLES.md +36 -0
- package/.agents/core/skills/ux-design/SKILL.md +116 -0
- package/.agents/core/skills/ux-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ux-design/VALIDATION.json +12 -0
- package/.agents/core/skills/ux-design/skill.yaml +10 -0
- package/.agents/core/skills/ux-design/ux.md +80 -0
- package/.agents/core/skills/vercel-optimize/SKILL.md +83 -0
- package/.agents/core/skills/vercel-optimize/VALIDATION.json +12 -0
- package/.agents/core/skills/vercel-optimize/skill.yaml +10 -0
- package/.agents/core/skills/web-accessibility/EXAMPLES.md +39 -0
- package/.agents/core/skills/web-accessibility/SKILL.md +170 -0
- package/.agents/core/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/web-accessibility/VALIDATION.json +12 -0
- package/.agents/core/skills/web-accessibility/accessibility.md +63 -0
- package/.agents/core/skills/web-accessibility/skill.yaml +10 -0
- package/.agents/ctx.js +370 -0
- package/.agents/generated/claude/skills/adapters/SKILL.md +126 -0
- package/.agents/generated/claude/skills/architecture-diagrams/SKILL.md +101 -0
- package/.agents/generated/claude/skills/brutalist-design/SKILL.md +145 -0
- package/.agents/generated/claude/skills/context-manager/SKILL.md +147 -0
- package/.agents/generated/claude/skills/context-os/SKILL.md +191 -0
- package/.agents/generated/claude/skills/database/SKILL.md +191 -0
- package/.agents/generated/claude/skills/ddd/SKILL.md +305 -0
- package/.agents/generated/claude/skills/decisions/SKILL.md +134 -0
- package/.agents/generated/claude/skills/docker/SKILL.md +135 -0
- package/.agents/generated/claude/skills/engineering-workflow/SKILL.md +414 -0
- package/.agents/generated/claude/skills/fastapi/SKILL.md +200 -0
- package/.agents/generated/claude/skills/gemini-precision/SKILL.md +161 -0
- package/.agents/generated/claude/skills/generators/SKILL.md +133 -0
- package/.agents/generated/claude/skills/graphify/SKILL.md +198 -0
- package/.agents/generated/claude/skills/gstack-roles/SKILL.md +184 -0
- package/.agents/generated/claude/skills/impeccable-design/SKILL.md +241 -0
- package/.agents/generated/claude/skills/interview-me/SKILL.md +90 -0
- package/.agents/generated/claude/skills/microservices/SKILL.md +218 -0
- package/.agents/generated/claude/skills/minimalist-design/SKILL.md +108 -0
- package/.agents/generated/claude/skills/nestjs/SKILL.md +195 -0
- package/.agents/generated/claude/skills/nextjs/SKILL.md +219 -0
- package/.agents/generated/claude/skills/node/SKILL.md +224 -0
- package/.agents/generated/claude/skills/performance/SKILL.md +121 -0
- package/.agents/generated/claude/skills/ponytail-mindset/SKILL.md +252 -0
- package/.agents/generated/claude/skills/react/SKILL.md +227 -0
- package/.agents/generated/claude/skills/react-best-practices/SKILL.md +146 -0
- package/.agents/generated/claude/skills/redesign-audit/SKILL.md +112 -0
- package/.agents/generated/claude/skills/security/SKILL.md +237 -0
- package/.agents/generated/claude/skills/soft-design/SKILL.md +103 -0
- package/.agents/generated/claude/skills/state-management/SKILL.md +120 -0
- package/.agents/generated/claude/skills/subagent-orchestrator/SKILL.md +93 -0
- package/.agents/generated/claude/skills/system-design/SKILL.md +507 -0
- package/.agents/generated/claude/skills/testing/SKILL.md +157 -0
- package/.agents/generated/claude/skills/typescript/SKILL.md +192 -0
- package/.agents/generated/claude/skills/ui-design/SKILL.md +161 -0
- package/.agents/generated/claude/skills/ui-ux-pro/SKILL.md +451 -0
- package/.agents/generated/claude/skills/ux-design/SKILL.md +168 -0
- package/.agents/generated/claude/skills/vercel-optimize/SKILL.md +76 -0
- package/.agents/generated/claude/skills/web-accessibility/SKILL.md +225 -0
- package/.agents/generated/gemini/skills/adapters/SKILL.md +135 -0
- package/.agents/generated/gemini/skills/architecture-diagrams/SKILL.md +107 -0
- package/.agents/generated/gemini/skills/brutalist-design/SKILL.md +151 -0
- package/.agents/generated/gemini/skills/context-manager/SKILL.md +156 -0
- package/.agents/generated/gemini/skills/context-os/SKILL.md +200 -0
- package/.agents/generated/gemini/skills/database/SKILL.md +200 -0
- package/.agents/generated/gemini/skills/ddd/SKILL.md +314 -0
- package/.agents/generated/gemini/skills/decisions/SKILL.md +143 -0
- package/.agents/generated/gemini/skills/docker/SKILL.md +144 -0
- package/.agents/generated/gemini/skills/engineering-workflow/SKILL.md +423 -0
- package/.agents/generated/gemini/skills/fastapi/SKILL.md +209 -0
- package/.agents/generated/gemini/skills/gemini-precision/SKILL.md +167 -0
- package/.agents/generated/gemini/skills/generators/SKILL.md +142 -0
- package/.agents/generated/gemini/skills/graphify/SKILL.md +205 -0
- package/.agents/generated/gemini/skills/gstack-roles/SKILL.md +193 -0
- package/.agents/generated/gemini/skills/impeccable-design/SKILL.md +250 -0
- package/.agents/generated/gemini/skills/interview-me/SKILL.md +96 -0
- package/.agents/generated/gemini/skills/microservices/SKILL.md +227 -0
- package/.agents/generated/gemini/skills/minimalist-design/SKILL.md +114 -0
- package/.agents/generated/gemini/skills/nestjs/SKILL.md +204 -0
- package/.agents/generated/gemini/skills/nextjs/SKILL.md +298 -0
- package/.agents/generated/gemini/skills/node/SKILL.md +323 -0
- package/.agents/generated/gemini/skills/performance/SKILL.md +185 -0
- package/.agents/generated/gemini/skills/ponytail-mindset/SKILL.md +261 -0
- package/.agents/generated/gemini/skills/react/SKILL.md +332 -0
- package/.agents/generated/gemini/skills/react-best-practices/SKILL.md +152 -0
- package/.agents/generated/gemini/skills/redesign-audit/SKILL.md +118 -0
- package/.agents/generated/gemini/skills/security/SKILL.md +355 -0
- package/.agents/generated/gemini/skills/soft-design/SKILL.md +109 -0
- package/.agents/generated/gemini/skills/state-management/SKILL.md +129 -0
- package/.agents/generated/gemini/skills/subagent-orchestrator/SKILL.md +99 -0
- package/.agents/generated/gemini/skills/system-design/SKILL.md +631 -0
- package/.agents/generated/gemini/skills/testing/SKILL.md +166 -0
- package/.agents/generated/gemini/skills/typescript/SKILL.md +275 -0
- package/.agents/generated/gemini/skills/ui-design/SKILL.md +170 -0
- package/.agents/generated/gemini/skills/ui-ux-pro/SKILL.md +460 -0
- package/.agents/generated/gemini/skills/ux-design/SKILL.md +177 -0
- package/.agents/generated/gemini/skills/vercel-optimize/SKILL.md +82 -0
- package/.agents/generated/gemini/skills/web-accessibility/SKILL.md +300 -0
- package/.agents/mcp/runtime.py +454 -0
- package/.agents/mcp/server.mjs +189373 -0
- package/.agents/plugins.js +574 -0
- package/.agents/profiles.js +267 -0
- package/.agents/resolver.js +336 -0
- package/.agents/skills-index.json +200 -0
- package/.agents/skills.json +6 -0
- package/.agents/validate.js +500 -0
- package/LICENSE +21 -0
- package/README.md +415 -0
- package/benchmarks/gemini-issues.js +533 -0
- package/bin/index.js +458 -0
- package/package.json +70 -0
- package/registry.json +53 -0
- package/registry.schema.json +32 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: engineering-workflow
|
|
3
|
+
description: >
|
|
4
|
+
Senior engineering workflow skill inspired by Addy Osmani's agent-skills. Enforces the full development lifecycle: spec → plan → build → test → review → ship. AI must never write code before a spec and plan are approved.
|
|
5
|
+
---
|
|
6
|
+
# engineering-workflow
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Systematic 6-phase engineering pipeline (DEFINE → PLAN → BUILD → VERIFY → REVIEW → SHIP) enforcing role declarations, atomic task execution, quality gates, regression prevention, and structured requirements elicitation.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Activate on all project tasks to orchestrate structured development, spec definition, architectural planning, and verification gates.
|
|
15
|
+
|
|
16
|
+
## Rules & Patterns
|
|
17
|
+
|
|
18
|
+
Inspired by [addyosmani/agent-skills](https://github.com/addyosmani/agent-skills) by Addy Osmani (Google Chrome) and [obra/superpowers](https://github.com/obra/superpowers).
|
|
19
|
+
|
|
20
|
+
### Core Principle
|
|
21
|
+
|
|
22
|
+
> **A junior writes code immediately. A senior writes a spec first.**
|
|
23
|
+
> You are a senior. You never write code until the spec and plan are approved.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### The 6-Phase Development Pipeline
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
DEFINE PLAN BUILD VERIFY REVIEW SHIP
|
|
31
|
+
┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐
|
|
32
|
+
│ Idea │ ───▶ │ Spec │ ───▶ │ Code │ ───▶ │ Test │ ───▶ │ QA │ ───▶ │ Go │
|
|
33
|
+
│Refine│ │ PRD │ │ Impl │ │Debug │ │ Gate │ │ Live │
|
|
34
|
+
└──────┘ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘
|
|
35
|
+
/spec /plan /build /test /review /ship
|
|
36
|
+
|
|
37
|
+
[ROLE: Product Manager] [ROLE: Architect] [ROLE: Senior Dev] [ROLE: QA Lead] [ROLE: Staff Eng] [ROLE: Release Eng]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**IRON RULE**: In interactive development, no phase can be skipped and no code is written before `/plan` is approved.
|
|
41
|
+
**Direct Build Exception**: When the prompt/caller explicitly requests a standalone implementation, or declares `[PHASE: Build]`, execute the BUILD phase directly and deliver the complete, self-contained production code without conversational pauses.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### Phase 1: DEFINE — /spec
|
|
46
|
+
|
|
47
|
+
**Auto-activates → `[ROLE: Product Manager]`**
|
|
48
|
+
|
|
49
|
+
Turn vague intent into a precise, executable specification.
|
|
50
|
+
|
|
51
|
+
#### Step 1.1: The Interview Protocol (`interview-me`)
|
|
52
|
+
|
|
53
|
+
Before writing the spec, if there is ambiguity, high blast radius, or multiple architectural paths, stop and ask the user **one question at a time** (or up to 2 tightly coupled questions):
|
|
54
|
+
|
|
55
|
+
1. **Clarify Business Intent**: What user problem are we solving? What is explicitly out of scope?
|
|
56
|
+
2. **Clarify Constraints**: Runtime versions, database engines, performance bounds.
|
|
57
|
+
3. **Clarify Edge Cases**: What happens on offline state, empty lists, unauthorized requests?
|
|
58
|
+
|
|
59
|
+
#### Step 1.2: Spec Template
|
|
60
|
+
|
|
61
|
+
```markdown
|
|
62
|
+
## Feature Spec: [Feature Name]
|
|
63
|
+
|
|
64
|
+
### Why (Problem)
|
|
65
|
+
[What pain does this solve? Who has it? How often?]
|
|
66
|
+
|
|
67
|
+
### Scope (What's In / Out)
|
|
68
|
+
|
|
69
|
+
**In-Scope**:
|
|
70
|
+
- [Specific item 1]
|
|
71
|
+
- [Specific item 2]
|
|
72
|
+
|
|
73
|
+
**Out-of-Scope**:
|
|
74
|
+
- [Thing we're NOT doing and why]
|
|
75
|
+
|
|
76
|
+
### Technical Approach
|
|
77
|
+
[Read the relevant code. Understand what changes where.]
|
|
78
|
+
Files affected:
|
|
79
|
+
- `src/X.js` — [what changes]
|
|
80
|
+
- `src/Y.js` — [what changes]
|
|
81
|
+
|
|
82
|
+
### Acceptance Criteria
|
|
83
|
+
- [ ] Given [context], when [action], then [result]
|
|
84
|
+
- [ ] Given [context], when [action], then [result]
|
|
85
|
+
|
|
86
|
+
### Open Questions
|
|
87
|
+
- [Unresolved decision 1]
|
|
88
|
+
- [Unresolved decision 2]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Phase 2: PLAN — /plan
|
|
94
|
+
|
|
95
|
+
**Auto-activates → `[ROLE: Architect]`**
|
|
96
|
+
|
|
97
|
+
Break the spec into atomic, independently testable tasks.
|
|
98
|
+
|
|
99
|
+
#### Thin Vertical Slices (`incremental-implementation`)
|
|
100
|
+
|
|
101
|
+
Organize tasks as **Thin Vertical Slices** rather than horizontal layers:
|
|
102
|
+
|
|
103
|
+
- **Bad (Horizontal)**: Task 1: All DB migrations. Task 2: All API routes. Task 3: All UI components. (Nothing works until step 3).
|
|
104
|
+
- **Good (Vertical Slices)**: Slice 1: Minimal DB table + minimal API + minimal UI button end-to-end. Verify and commit. Slice 2: Add validation + edge cases. Slice 3: Polish UI & telemetry.
|
|
105
|
+
|
|
106
|
+
#### Plan Rules
|
|
107
|
+
|
|
108
|
+
- Each task must be **completable in < 2 hours** of focused work.
|
|
109
|
+
- Each task must be **independently testable**.
|
|
110
|
+
- Tasks must be **ordered by dependency** (blocking tasks first).
|
|
111
|
+
- Each task gets a **test requirement** — no task without a test.
|
|
112
|
+
|
|
113
|
+
#### Plan Template
|
|
114
|
+
|
|
115
|
+
```markdown
|
|
116
|
+
## Implementation Plan: [Feature Name]
|
|
117
|
+
|
|
118
|
+
### Tasks
|
|
119
|
+
|
|
120
|
+
**Task 1: [Slice 1 Name]** (est. 30min)
|
|
121
|
+
- What: [Specific implementation detail]
|
|
122
|
+
- Files: [file1.js, file2.js]
|
|
123
|
+
- Test: [How will you verify this works?]
|
|
124
|
+
- Blocked by: [nothing / Task N]
|
|
125
|
+
|
|
126
|
+
**Task 2: [Slice 2 Name]** (est. 45min)
|
|
127
|
+
- What: [Specific implementation detail]
|
|
128
|
+
- Files: [file3.js]
|
|
129
|
+
- Test: [Test description]
|
|
130
|
+
- Blocked by: Task 1
|
|
131
|
+
|
|
132
|
+
### Risk Assessment
|
|
133
|
+
- [Risk 1]: [Mitigation]
|
|
134
|
+
- [Risk 2]: [Mitigation]
|
|
135
|
+
|
|
136
|
+
### STOP — Awaiting Approval
|
|
137
|
+
Do not proceed to BUILD until this plan is approved.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### Phase 3: BUILD — /build
|
|
143
|
+
|
|
144
|
+
**Auto-activates → `[ROLE: Senior Developer]`**
|
|
145
|
+
|
|
146
|
+
Implement one task at a time. Commit after each task.
|
|
147
|
+
|
|
148
|
+
#### Build Rules
|
|
149
|
+
|
|
150
|
+
1. **One task per commit** — atomic, descriptive commit messages.
|
|
151
|
+
2. **Write the test FIRST** (TDD — red-green-refactor).
|
|
152
|
+
3. **No dead code** — if it's not tested, it's not shipped.
|
|
153
|
+
4. **No TODOs in committed code** — resolve or create a tracked issue.
|
|
154
|
+
5. **Read before writing** — understand the surrounding code before changing it.
|
|
155
|
+
6. **Limit the blast radius** — modify ONLY the files explicitly listed in the current task's plan. Do NOT rewrite adjacent components, hooks, or utilities unless strictly required AND approved.
|
|
156
|
+
|
|
157
|
+
#### Commit Message Format
|
|
158
|
+
|
|
159
|
+
```text
|
|
160
|
+
type(scope): short description (max 72 chars)
|
|
161
|
+
|
|
162
|
+
- Detail 1
|
|
163
|
+
- Detail 2
|
|
164
|
+
|
|
165
|
+
Refs: #issue-number
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### Phase 4: VERIFY — /test
|
|
173
|
+
|
|
174
|
+
**Auto-activates → `[ROLE: QA Lead]`**
|
|
175
|
+
|
|
176
|
+
Tests are proof, not an afterthought.
|
|
177
|
+
|
|
178
|
+
#### Test Strategy by Code Type
|
|
179
|
+
|
|
180
|
+
**Logic & Services (TDD)**:
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
1. RED: Write a failing test for the next small behavior
|
|
184
|
+
2. GREEN: Write the minimum code to make it pass
|
|
185
|
+
3. REFACTOR: Clean up without breaking tests
|
|
186
|
+
4. REPEAT
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**UI Components & User Flows (BDD)**:
|
|
190
|
+
|
|
191
|
+
For complex React components, prioritize testing _user behavior_ over internal state:
|
|
192
|
+
|
|
193
|
+
- Use **React Testing Library** (`userEvent`, `screen.getByRole`) — test what the user sees.
|
|
194
|
+
- Use **Playwright** for critical user flows (login, checkout, form submit).
|
|
195
|
+
- Do NOT test implementation details (internal state, private methods, component structure).
|
|
196
|
+
- Focus on: "When user clicks X, does Y appear?" not "Does `useState` hold the right value?"
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
// [GOOD] BDD: Test behavior
|
|
200
|
+
test("shows error when email is invalid", async () => {
|
|
201
|
+
render(<LoginForm />);
|
|
202
|
+
await userEvent.type(screen.getByLabelText("Email"), "not-an-email");
|
|
203
|
+
await userEvent.click(screen.getByRole("button", { name: /sign in/i }));
|
|
204
|
+
expect(screen.getByText(/invalid email/i)).toBeInTheDocument();
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### Test Quality Gates
|
|
209
|
+
|
|
210
|
+
Before moving to Review, verify:
|
|
211
|
+
|
|
212
|
+
- [ ] All new code has tests
|
|
213
|
+
- [ ] Tests are meaningful (not just coverage theater)
|
|
214
|
+
- [ ] Edge cases are covered (null, empty, overflow, unauthorized)
|
|
215
|
+
- [ ] Tests fail when the implementation is broken (anti-regression)
|
|
216
|
+
- [ ] Test names are readable: `it("returns 404 when user not found")`
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
### Phase 5: REVIEW — /review
|
|
221
|
+
|
|
222
|
+
**Auto-activates → `[ROLE: Staff Engineer]` + `[ROLE: Senior Designer]` for UI tasks**
|
|
223
|
+
|
|
224
|
+
Review before merging. Always.
|
|
225
|
+
|
|
226
|
+
#### Subagent / Peer Code Review Protocol
|
|
227
|
+
|
|
228
|
+
Inspired by [obra/superpowers](https://github.com/obra/superpowers):
|
|
229
|
+
|
|
230
|
+
1. **Self-Review First**: The implementer runs git diff and verifies against the original acceptance criteria.
|
|
231
|
+
2. **Review Checklist**:
|
|
232
|
+
- **Correctness**: Does it do what the spec says? Are all criteria met?
|
|
233
|
+
- **Architecture**: Single Responsibility, DRY without premature abstraction, no business logic in API routes.
|
|
234
|
+
- **Security**: No secrets hardcoded, inputs validated via Zod/schemas, auth checked before data access.
|
|
235
|
+
- **Performance**: No N+1 queries, expensive operations cached, sets paginated.
|
|
236
|
+
- **Design**: If UI, passes `impeccable-design` quick audit (typography, colors, spacing, animations).
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
### Phase 5.5: SIMPLIFY — /simplify
|
|
241
|
+
|
|
242
|
+
**Auto-activates → `[ROLE: Staff Engineer]` (Ponytail Mindset)**
|
|
243
|
+
|
|
244
|
+
Before merging, ruthlessly simplify:
|
|
245
|
+
|
|
246
|
+
1. Did we introduce abstractions that are only used once? (Inline them).
|
|
247
|
+
2. Can 3 lines of standard JavaScript replace a 50-line custom utility?
|
|
248
|
+
3. Is any configuration or generic handler premature? (YAGNI).
|
|
249
|
+
4. Is the code obvious to a mid-level engineer without reading a documentation manual?
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### Phase 6: SHIP — /ship
|
|
254
|
+
|
|
255
|
+
**Auto-activates → `[ROLE: Release Engineer]`**
|
|
256
|
+
|
|
257
|
+
Only ship when all gates are green.
|
|
258
|
+
|
|
259
|
+
#### Pre-Ship Checklist
|
|
260
|
+
|
|
261
|
+
- [ ] All tests pass in CI
|
|
262
|
+
- [ ] No lint errors
|
|
263
|
+
- [ ] Feature works in staging environment
|
|
264
|
+
- [ ] Docs updated (README, API docs, changelogs)
|
|
265
|
+
- [ ] Breaking changes documented
|
|
266
|
+
- [ ] Rollback plan exists
|
|
267
|
+
- [ ] Vercel Preview Deployment is successful and manually verified
|
|
268
|
+
- [ ] Core Web Vitals pass in preview (LCP < 2.5s, CLS < 0.1, INP < 200ms)
|
|
269
|
+
|
|
270
|
+
#### Operational Self-Improvement
|
|
271
|
+
|
|
272
|
+
Before completing a workflow, review the session for durable learnings. Write them to `.agents/learnings.md`. If no durable learning occurred, state "No durable learnings this session" in your final output.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Code Examples
|
|
277
|
+
|
|
278
|
+
### Vertical Slice Example
|
|
279
|
+
|
|
280
|
+
```javascript
|
|
281
|
+
// Slice 1: Minimal functional endpoint
|
|
282
|
+
// POST /api/v1/projects -> creates project with basic validation
|
|
283
|
+
import { z } from 'zod';
|
|
284
|
+
import { projectService } from '@/services/project';
|
|
285
|
+
|
|
286
|
+
const CreateProjectSchema = z.object({
|
|
287
|
+
name: z.string().min(1).max(100),
|
|
288
|
+
description: z.string().optional()
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
export async function POST(req) {
|
|
292
|
+
const session = await auth();
|
|
293
|
+
if (!session?.userId) return Response.json({ error: 'Unauthorized' }, { status: 401 });
|
|
294
|
+
|
|
295
|
+
const body = await req.json();
|
|
296
|
+
const parsed = CreateProjectSchema.parse(body);
|
|
297
|
+
const project = await projectService.create({ ...parsed, userId: session.userId });
|
|
298
|
+
|
|
299
|
+
return Response.json(project, { status: 201 });
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Validation Checklist
|
|
306
|
+
|
|
307
|
+
- [ ] Specification exists with clear In-Scope and Out-of-Scope boundaries.
|
|
308
|
+
- [ ] Implementation plan broken down into vertical tasks < 2 hours each.
|
|
309
|
+
- [ ] Tests written before implementation (TDD/BDD).
|
|
310
|
+
- [ ] Code reviewed against correctness, security, performance, and design gates.
|
|
311
|
+
- [ ] Simplification ladder executed before shipping.
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Common Mistakes
|
|
316
|
+
|
|
317
|
+
- **Writing code before approval**: Skipping `/spec` or `/plan` in interactive sessions.
|
|
318
|
+
- **Horizontal task splitting**: Building all DB models first without verifying end-to-end integration.
|
|
319
|
+
- **Premature refactoring**: Changing unrelated adjacent code during a feature task.
|
|
320
|
+
- **Ignoring non-happy paths**: Testing only 200 OK responses while ignoring 400, 401, 404, 500 scenarios.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Integration Notes
|
|
325
|
+
|
|
326
|
+
- Integrates with `gstack-roles` for automated role switching across all 6 phases.
|
|
327
|
+
- Triggers `ponytail-mindset` during the BUILD and SIMPLIFY phases.
|
|
328
|
+
- Hands off to `impeccable-design` for UI quality review.
|
|
329
|
+
- Coordinates with `security` during Phase 5 for pre-merge compliance.
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Completion Status Protocol
|
|
334
|
+
|
|
335
|
+
When completing a task or workflow, you must explicitly report your final status as the last part of your output:
|
|
336
|
+
|
|
337
|
+
- **DONE** — completed with evidence.
|
|
338
|
+
- **DONE_WITH_CONCERNS** — completed, but list concerns.
|
|
339
|
+
- **BLOCKED** — cannot proceed; state blocker and what was tried.
|
|
340
|
+
- **NEEDS_CONTEXT** — missing info; state exactly what is needed.
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
<!-- Source: EXAMPLES.md -->
|
|
344
|
+
|
|
345
|
+
# engineering-workflow Examples — Anti-patterns vs ContextOS Standard
|
|
346
|
+
|
|
347
|
+
## Example 1: Handling a New Feature Request
|
|
348
|
+
|
|
349
|
+
### Anti-pattern: Jumping Straight to Code
|
|
350
|
+
|
|
351
|
+
```text
|
|
352
|
+
User: "Add a user referral system."
|
|
353
|
+
Agent: Immediately creates src/referral.js, starts writing database queries, guesses schema,
|
|
354
|
+
and misses requirements like rate limiting, expiry dates, and fraud prevention.
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Best practice: ContextOS Standard (DEFINE -> PLAN -> BUILD)
|
|
358
|
+
|
|
359
|
+
```markdown
|
|
360
|
+
[DOMAIN: Full-Stack] [PHASE: Define] [ROLE: Product Manager]
|
|
361
|
+
Skills loaded: engineering-workflow, interview-me
|
|
362
|
+
|
|
363
|
+
## Feature Spec: User Referral System
|
|
364
|
+
### Why (Problem)
|
|
365
|
+
Increase user acquisition through organic word-of-mouth incentives.
|
|
366
|
+
|
|
367
|
+
### Scope
|
|
368
|
+
In-Scope:
|
|
369
|
+
- Unique referral code generation per registered user
|
|
370
|
+
- Referral code attribution on signup
|
|
371
|
+
- Credit reward trigger after first completed purchase
|
|
372
|
+
Out-of-Scope:
|
|
373
|
+
- Multi-tier MLM rewards
|
|
374
|
+
- Cash payout integrations
|
|
375
|
+
|
|
376
|
+
### Acceptance Criteria
|
|
377
|
+
- [ ] Given a registered user, when visiting /referrals, then unique code is displayed.
|
|
378
|
+
- [ ] Given a new user with code, when signing up, then referrer_id is stored with status 'pending'.
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## Example 2: Atomic Task Execution in PLAN Phase
|
|
384
|
+
|
|
385
|
+
### Anti-pattern: Monolithic Mega-Task
|
|
386
|
+
|
|
387
|
+
```text
|
|
388
|
+
Task: "Implement entire referral system end-to-end in one shot."
|
|
389
|
+
Result: 15 files modified simultaneously, uncompilable intermediate state, untestable diff.
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Best practice: ContextOS Standard (Atomic Tasks with Test Gate)
|
|
393
|
+
|
|
394
|
+
```markdown
|
|
395
|
+
[DOMAIN: Full-Stack] [PHASE: Plan] [ROLE: Architect]
|
|
396
|
+
Atomic Tasks:
|
|
397
|
+
1. Database migration: referrals and referral_rewards tables + indexes. (Test: Migration rollback & apply)
|
|
398
|
+
2. Domain service: ReferralService.createCode() and ReferralService.claimCode(). (Test: Unit tests)
|
|
399
|
+
3. API route: POST /api/referrals/claim with Zod validation. (Test: Supertest integration)
|
|
400
|
+
4. UI component: <ReferralCard /> with copy button. (Test: RTL component test)
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
<!-- Source: TROUBLESHOOTING.md -->
|
|
404
|
+
|
|
405
|
+
# engineering-workflow Troubleshooting & Common Mistakes
|
|
406
|
+
|
|
407
|
+
## 1. Premature Code Generation
|
|
408
|
+
|
|
409
|
+
- **Symptom**: Agent starts spitting out code blocks while the user is still clarifying requirements.
|
|
410
|
+
- **Root Cause**: Failure to enforce the IRON RULE of Phase 1 (DEFINE) and Phase 2 (PLAN).
|
|
411
|
+
- **Fix**: Halt code output immediately. Announce `[PHASE: Define]` or `[PHASE: Plan]` and provide the structured spec or task breakdown for user sign-off.
|
|
412
|
+
|
|
413
|
+
## 2. Blast Radius Creep
|
|
414
|
+
|
|
415
|
+
- **Symptom**: A simple bugfix in one module modifies 8 unrelated configuration and styling files.
|
|
416
|
+
- **Root Cause**: Missing isolation boundaries and speculative cleanup.
|
|
417
|
+
- **Fix**: Restrict edits strictly to files explicitly declared in the current atomic task's plan.
|
|
418
|
+
|
|
419
|
+
## 3. Unverified Claims of Completion
|
|
420
|
+
|
|
421
|
+
- **Symptom**: Agent reports "Task complete! Everything is working" without running tests or builds.
|
|
422
|
+
- **Root Cause**: Skipping Phase 4 (VERIFY).
|
|
423
|
+
- **Fix**: Always execute tests (`npm test`, validator, compiler) and quote actual terminal exit codes and outputs before declaring completion.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: FastAPI
|
|
3
|
+
description: >
|
|
4
|
+
ContextOS skill for FastAPI
|
|
5
|
+
---
|
|
6
|
+
# FastAPI
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
High-performance Python backend engineering using FastAPI, Pydantic v2, and async SQLAlchemy/Tortoise ORM. Enforces type-driven request validation, OpenAPI contracts, and async non-blocking endpoints.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Activate when building Python REST APIs, microservices, asynchronous background jobs, or integrating Python ML services into web backends.
|
|
15
|
+
|
|
16
|
+
## Rules & Patterns
|
|
17
|
+
<!-- Source: fastapi.md -->
|
|
18
|
+
|
|
19
|
+
## FastAPI — Best Practices
|
|
20
|
+
|
|
21
|
+
## Project Structure
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
app/
|
|
25
|
+
├── main.py # App entry, CORS, middleware
|
|
26
|
+
├── config.py # Settings with Pydantic BaseSettings
|
|
27
|
+
├── database.py # Database session, engine
|
|
28
|
+
├── models/ # SQLAlchemy models
|
|
29
|
+
│ ├── __init__.py
|
|
30
|
+
│ └── user.py
|
|
31
|
+
├── schemas/ # Pydantic schemas (request/response)
|
|
32
|
+
│ ├── __init__.py
|
|
33
|
+
│ └── user.py
|
|
34
|
+
├── api/ # Route handlers
|
|
35
|
+
│ ├── __init__.py
|
|
36
|
+
│ ├── deps.py # Dependency injection
|
|
37
|
+
│ └── v1/
|
|
38
|
+
│ ├── __init__.py
|
|
39
|
+
│ └── users.py
|
|
40
|
+
├── services/ # Business logic
|
|
41
|
+
│ └── user_service.py
|
|
42
|
+
├── repositories/ # Database access
|
|
43
|
+
│ └── user_repo.py
|
|
44
|
+
└── tests/
|
|
45
|
+
└── test_users.py
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Pydantic Models
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from pydantic import BaseModel, EmailStr, Field
|
|
52
|
+
|
|
53
|
+
class UserCreate(BaseModel):
|
|
54
|
+
email: EmailStr
|
|
55
|
+
name: str = Field(..., min_length=1, max_length=100)
|
|
56
|
+
|
|
57
|
+
class UserResponse(BaseModel):
|
|
58
|
+
id: int
|
|
59
|
+
email: str
|
|
60
|
+
name: str
|
|
61
|
+
|
|
62
|
+
model_config = ConfigDict(from_attributes=True)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Dependency Injection
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from fastapi import Depends
|
|
69
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
|
70
|
+
|
|
71
|
+
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
72
|
+
async with async_session() as session:
|
|
73
|
+
yield session
|
|
74
|
+
|
|
75
|
+
async def get_current_user(
|
|
76
|
+
token: str = Depends(oauth2_scheme),
|
|
77
|
+
db: AsyncSession = Depends(get_db)
|
|
78
|
+
) -> User:
|
|
79
|
+
# Verify token, return user
|
|
80
|
+
...
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Async
|
|
84
|
+
|
|
85
|
+
- **Use async** for all I/O operations (database, HTTP calls, file I/O)
|
|
86
|
+
- **Never block the event loop** — no sync I/O in async endpoints
|
|
87
|
+
- **Use `asyncio.gather`** for parallel async operations
|
|
88
|
+
- **Background tasks** — `BackgroundTasks` for non-critical work
|
|
89
|
+
|
|
90
|
+
## Error Handling
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from fastapi import HTTPException
|
|
94
|
+
|
|
95
|
+
class AppException(HTTPException):
|
|
96
|
+
def __init__(self, status_code: int, detail: str, code: str):
|
|
97
|
+
super().__init__(status_code=status_code, detail=detail)
|
|
98
|
+
self.code = code
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Security
|
|
102
|
+
|
|
103
|
+
- **OAuth2 with JWT** — use `python-jose`
|
|
104
|
+
- **Password hashing** — bcrypt via `passlib`
|
|
105
|
+
- **CORS** — configure explicitly
|
|
106
|
+
- **Rate limiting** — use `slowapi`
|
|
107
|
+
- **Input validation** — Pydantic handles this automatically
|
|
108
|
+
|
|
109
|
+
## Testing
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import pytest
|
|
113
|
+
from httpx import AsyncClient
|
|
114
|
+
|
|
115
|
+
@pytest.mark.asyncio
|
|
116
|
+
async def test_create_user(client: AsyncClient):
|
|
117
|
+
response = await client.post("/api/v1/users", json={
|
|
118
|
+
"email": "test@example.com",
|
|
119
|
+
"name": "Test User"
|
|
120
|
+
})
|
|
121
|
+
assert response.status_code == 201
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Anti-Patterns
|
|
125
|
+
|
|
126
|
+
- [FAIL] Business logic in route handlers — use services
|
|
127
|
+
- [FAIL] Raw SQL without ORM — use SQLAlchemy
|
|
128
|
+
- [FAIL] Sync database calls — use async drivers
|
|
129
|
+
- [FAIL] Hardcoded settings — use Pydantic BaseSettings
|
|
130
|
+
- [FAIL] No schema validation — always use Pydantic models
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
## Code Examples
|
|
134
|
+
|
|
135
|
+
See `EXAMPLES.md` for detailed code examples.
|
|
136
|
+
|
|
137
|
+
## Validation Checklist
|
|
138
|
+
|
|
139
|
+
What to verify during the review phase before completing the task.
|
|
140
|
+
|
|
141
|
+
## Common Mistakes
|
|
142
|
+
|
|
143
|
+
Anti-patterns and things to explicitly avoid. See `TROUBLESHOOTING.md`.
|
|
144
|
+
|
|
145
|
+
## Integration Notes
|
|
146
|
+
|
|
147
|
+
How this skill interacts with other skills.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
<!-- Source: EXAMPLES.md -->
|
|
151
|
+
|
|
152
|
+
# fastapi Examples — Anti-patterns vs ContextOS Standard
|
|
153
|
+
|
|
154
|
+
## Example 1: Asynchronous Route Handlers
|
|
155
|
+
|
|
156
|
+
### Anti-pattern: Blocking I/O inside `async def`
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
# BAD: time.sleep or synchronous requests blocks the entire asyncio event loop!
|
|
160
|
+
import time
|
|
161
|
+
import requests
|
|
162
|
+
|
|
163
|
+
@app.get("/slow")
|
|
164
|
+
async def slow_route():
|
|
165
|
+
time.sleep(5) # BLOCKS ALL CONCURRENT USERS!
|
|
166
|
+
return {"status": "done"}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Best practice: ContextOS Standard (Non-blocking Async or Def Offload)
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
# GOOD: Use async non-blocking client (httpx) or standard def for sync CPU work
|
|
173
|
+
import asyncio
|
|
174
|
+
import httpx
|
|
175
|
+
|
|
176
|
+
@app.get("/fast")
|
|
177
|
+
async def fast_route():
|
|
178
|
+
async with httpx.AsyncClient() as client:
|
|
179
|
+
response = await client.get("https://api.example.com/data")
|
|
180
|
+
return response.json()
|
|
181
|
+
|
|
182
|
+
# Or standard def (FastAPI automatically runs it in a background threadpool):
|
|
183
|
+
@app.get("/sync-worker")
|
|
184
|
+
def sync_worker():
|
|
185
|
+
time.sleep(5) # Runs in worker thread without blocking event loop
|
|
186
|
+
return {"status": "done"}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
<!-- Source: TROUBLESHOOTING.md -->
|
|
190
|
+
|
|
191
|
+
# fastapi Troubleshooting & Common Mistakes
|
|
192
|
+
|
|
193
|
+
## 1. Pydantic v1 vs v2 Deprecations
|
|
194
|
+
|
|
195
|
+
- **Symptom**: Warnings or crashes regarding @validator or .dict() methods.
|
|
196
|
+
- **Root Cause**: FastAPI projects upgrading to Pydantic v2.
|
|
197
|
+
- **Fix**: Use @field_validator instead of @validator, and .model_dump() instead of .dict().
|
|
198
|
+
|
|
199
|
+
## 2. Database Session Leaks
|
|
200
|
+
|
|
201
|
+
- **Symptom**: Database pool runs out of connections after a few requests.
|
|
202
|
+
- **Root Cause**: Database sessions opened manually without proper try...finally or dependency injection.
|
|
203
|
+
- **Fix**: Always provide database sessions via Depends(get_db) with a yield block.
|
|
204
|
+
|
|
205
|
+
## 3. Unhandled Validation Errors Returning Inconsistent JSON
|
|
206
|
+
|
|
207
|
+
- **Symptom**: Frontend receives raw 422 arrays without matching standard API error response envelope.
|
|
208
|
+
- **Root Cause**: Missing custom RequestValidationError handler.
|
|
209
|
+
- **Fix**: Register an app-level exception handler for RequestValidationError that normalizes error shapes.
|