Step 3 · Implement
Goal
Execute the technical design, task by task, fully verified after each change. No partially-done tasks. No skipped verification.
Instructions
You are in workflow step 3 of the feature-cycle. The design is complete. Now build it.
Apply the AUTODEV core loop for every single task:
READ task from TODO.md
↓
EXPLORE — read every file you will touch before touching it
↓
THINK — does my implementation match the technical design?
↓
IMPLEMENT — one logical unit
↓
VERIFY — run tests, lint, type check
↓
FIX — root cause any failure; do not revert; do not skip
↓
MARK DONE in TODO.md
↓
git commit — conventional message
↓
REPEAT
Implementation Order
Always implement in this order (each layer depends on the one before it):
1. Database migrations first
# Create the migration
# Run it against the test/dev database
# Verify schema matches spec: inspect the table structure
- Migration must be reversible (down/rollback defined)
- Migration must be safe to run without downtime
- Test data is not hardcoded in migrations (use seeders)
2. Data models and repositories
- Add new fields with correct types and validation rules
- Define relationships
- Add any required scopes or query methods
3. Service / business logic
- Implement the core logic
- Every decision point has a unit test before moving to the next
- Guard clauses first: check all preconditions before doing work
- Error paths: every failure returns or throws explicitly, never silently succeeds
4. API / interface layer
- Route definition
- Request validation (all fields, all rules)
- Controller: thin — delegates to service, returns response
- Response: follows the project's standard envelope format
5. Tests
Write tests alongside implementation, not after:
- Unit tests for each service method
- Integration test for the endpoint: success, validation error, unauthorised
- Edge cases identified in the design document
6. Documentation
- Update
README.mdif this changes the public interface - Update API reference if endpoints changed
- Add changelog entry
Code Quality Gate (before each commit)
Before committing any task, verify:
# Run tests — all must pass
[test runner command]
# Run linter / static analysis
[lint command]
# Check for debug output left in
grep -rn "var_dump\|console\.log\|dd(\|print_r\|debugger" src/ | grep -v "// " | grep -v test
- [ ] Tests pass
- [ ] Linter passes
- [ ] No debug output left in
- [ ] No commented-out code left in
- [ ] No TODO comments left in committed code (add them to TODO.md instead)
Stuck? Debug Protocol
If an implementation is blocked:
- Read the error message completely — do not skim it
- Trace the call stack to the exact failure point
- Read the code at the failure point
- Form one hypothesis, test it
- If wrong, form the next hypothesis
Never modify code randomly hoping it will fix the problem. Each change must be motivated by evidence.
Exit Criteria
This step is complete when:
- [ ] All tasks in TODO.md for this feature are marked done
- [ ] All tests pass
- [ ] No lint errors
- [ ] Each task has a corresponding commit
- [ ] You are ready to move to Step 4 (Testing)