Implement Feature
Write code following established patterns and conventions.
When to Use
- •Implementing a planned feature (after plan-task)
- •Creating new commands or queries
- •Adding entities or repositories
- •Writing controller endpoints
Pre-Implementation Checklist (MANDATORY)
Before writing ANY code:
- •
Check Research Cache
bash# Verify technology docs are available cat .claude/ledger/research/prisma.md cat .claude/ledger/research/nestjs.md
If missing → STOP → invoke
skill:research-external - •
Load Required Contexts
Area Files Patterns contexts/patterns/cqrs.md,entities.md,repositories.md,controllers.mdStructure contexts/structure/feature-sliced.mdConventions contexts/conventions/naming.md,validations.md,error-handling.mdInfrastructure contexts/infrastructure/prisma-setup.mdChecklist contexts/checklists/implementation.md - •
Load Project-Specific Docs
bash# Check for ticket-specific documentation ls .claude/project_docs/
Implementation Order
For Commands (Write Operations)
- •
Entity (
domain/entities/)- •Factory method
create()with business validations - •
fromPersistence()for DB reconstitution - •Behavior methods for state changes
- •Use
AppException.businessRule()for violations
- •Factory method
- •
DTO (
application/commands/{feature}/)- •class-validator decorators (check research cache for syntax)
- •
@Type()for Date fields
- •
Command (
application/commands/{feature}/)- •Immutable, readonly properties
- •No logic
- •
Handler (
application/commands/{feature}/)- •Thin (<30 lines)
- •Uses Entity factory method
- •Returns
{ id: string }or Projection
- •
Mapper (
infrastructure/mappers/)- •
toPersistence()andtoEntity() - •Static methods, no dependencies
- •
- •
Repository (
infrastructure/repositories/)- •Uses Mapper for conversions
- •Check research cache for Prisma client syntax
- •No inline mapping
- •
Controller (
presentation/controllers/)- •
@SuccessMessage()decorator - •DTO → Command conversion only
- •
- •
Module registration
For Queries (Read Operations)
- •Projection (
application/projections/) - •Query DTO (
application/queries/{feature}/) - •Query (
application/queries/{feature}/) - •Handler (
application/queries/{feature}/) - •Mapper (add
to{X}Projection()methods) - •Read Repository (
infrastructure/repositories/) - •Controller endpoint
When Unsure About API Syntax
NEVER guess. If you don't know the exact syntax:
- •Check
.claude/ledger/research/{technology}.md - •If not there → Context7 MCP query
- •Update research cache with finding
- •Then implement
Example:
code
Unsure: Prisma 7 relation syntax → Check: .claude/ledger/research/prisma.md → Not found: Context7 "Prisma 7 relation syntax one-to-many" → Update research cache → Implement with verified syntax
Commit Checkpoints
After each logical unit, commit:
bash
# After entity
git commit -m "feat({domain}): add {Entity} entity"
# After command/handler
git commit -m "feat({domain}): add {Feature}Command"
# After repository
git commit -m "feat({domain}): add {Entity} repository"
Validation Checklist
Before completing, verify:
- • Research cache consulted for external APIs
- • Entity has factory method with validations
- • Handler is thin (<30 lines)
- • Mapper is separate class (not inline)
- • Repository uses Mapper
- • Controller has
@SuccessMessage() - • No linting errors (
pnpm check) - • Naming conventions followed
- • Commits made at checkpoints