| name | code-gen |
| description | Story-driven code generation with strict quality principles. Use when implementing user stories, writing production code, creating unit tests, or generating code from specs. Enforces small modules, static typing, 50-line function limit, and 100% meaningful test coverage. |
Code Generation Skill
Core Principle: Story-Driven, Not Vibe-Driven
Every line of code traces back to a user story. No speculative features.
Story → Read Architecture → Write Code → Write Tests → Code Review → Done
The Six Quality Principles
Reference: "AI is forcing us to write good code" (Steve Krenzel)
For decades, we've known what good code looks like: thorough tests, clear documentation, small well-scoped modules, static typing, and reproducible dev environments. AI agents need these — they aren't great at making a mess and cleaning it up later. The only guardrails are the ones you set and enforce.
- Small, Well-Scoped Modules — one file = one responsibility. No
utils/helpers.py.
- Static Typing Everywhere — type-annotate all functions. Zero
any in TypeScript.
- Functions Under 50 Lines — decompose long functions into named subfunctions.
- Explicit Error Handling — typed error classes, no bare exceptions.
- No Dead Code — every line traces to a story. Delete, don't comment out.
- Self-Documenting — good names > comments. Types as primary documentation.
For detailed patterns and examples, see references/quality-principles.md.
Implementation Workflow
For each story:
- Read the story's acceptance criteria and layer assignment.
- Read architecture:
api-contracts.md, data-models.md, folder-structure.md.
- Write implementation code first, following patterns in references/patterns.md.
- Write unit tests for 100% meaningful coverage — see references/testing-rules.md.
- Run verification:
uv run pytest -x -q, uv run ruff check ., uv run mypy src/.
- Submit for code review.
Parallel Execution via Agent Teams
For independent stories (same parallel group):
- Read
dependency-graph.md to identify the parallel group.
- Create an agent team with one teammate per story.
- Each teammate owns distinct files — no overlapping edits.
- Require plan approval before teammates write code.
- Teammates communicate via agent team messaging about shared interfaces.
- After all teammates complete, run the full test suite.
For examples, see examples/agent-team-setup.md.
Code Review Gate
After implementation, the code-reviewer agent reviews all changes. See the review skill. All BLOCK findings must be resolved before the story is done.
Gotchas
These are common failure modes — check for them before marking code as done:
- Importing upward in layers. Service importing from API, or Repository importing from Service. Always check:
grep -rn "from src.api" src/service/ src/repository/.
- Functions creeping past 50 lines. It happens gradually. Count lines after writing — if over 50, split immediately.
any types sneaking into TypeScript. Especially in API response handling. Use unknown + type guards instead.
- Bare
except Exception: in Python. Always catch specific typed errors. If you're unsure which, that means the error types aren't defined yet — define them first.
- Mocking business logic in tests. Only mock external boundaries (DB, APIs, file I/O). If you're mocking a function in
src/service/, something is wrong.
- Test data like "test123" or "foo@bar.com". Use realistic data: "Sarah Chen", "sarah.chen@horizonequity.com", "$2,500,000".
- Writing code before reading the story. Every time. Read acceptance criteria first.
- Commented-out code blocks. Git remembers. Delete the code, don't comment it.
- Missing error path tests. If a function can throw, there must be a test that triggers that throw.
- Agent teammates editing the same file. Always verify file ownership in the plan before approving.
Additional Resources
Verification
After every story:
uv run pytest -x -q --cov=src --cov-report=term-missing
uv run ruff check .
uv run mypy src/
npm test -- --coverage
npm run lint
npm run typecheck