Implement Mode
Focused TDD implementation: make failing tests pass with minimal code.
Purpose
This is the DEV stage of the SDLC pipeline. Tests already exist from the TEST stage. Your job is to write the minimal implementation that makes them pass.
Prerequisites
Before starting:
- Tests exist and are failing (from TEST stage)
- Design/spec is available (from DESIGN stage)
- You know which files to create/modify
Workflow
Step 1: Verify Tests Exist and Fail
# Run the tests - they MUST fail initially
npm test -- path/to/feature.test.ts
# or
go test ./pkg/feature/...
If tests pass: The work is already done. Mark complete and move on.
If tests don't exist: This is wrong - go back to TEST stage.
Step 2: Read the Tests
Understand what the tests expect:
- What functions/methods need to exist?
- What are the expected inputs and outputs?
- What edge cases are covered?
# Read the test file
Read path/to/feature.test.ts
Step 3: Check Design Decisions
Use mcp__plugin_aide_aide__decision_get with the feature topic to review decisions from DESIGN stage.
Use mcp__plugin_aide_aide__decision_list to see all project decisions.
Step 4: Implement Incrementally
Write code to make tests pass one at a time:
- Pick the simplest failing test
- Write minimal code to pass it
- Run tests
- If passing, move to next test
- If failing, fix before proceeding
# Run specific test
npm test -- --grep "should create user"
# or
go test -run TestCreateUser ./pkg/...
Step 5: Backpressure Checkpoint (REQUIRED)
You CANNOT proceed until ALL tests pass.
# Full test run
npm test -- path/to/feature.test.ts
# or
go test -v ./pkg/feature/...
BLOCKING RULE: If any test fails:
- Analyze the failure
- Fix the issue
- Re-run tests
- Repeat until ALL pass
DO NOT skip failing tests. DO NOT proceed with red tests.
Step 6: Verify Build
# Ensure it compiles
npm run build
# or
go build ./...
Step 7: Commit
git add -A
git commit -m "feat: implement <feature> - tests passing"
Rules
- Tests First: Never write code without a failing test
- Minimal Code: Only write what's needed to pass tests
- No Gold Plating: Don't add features not covered by tests
- Red → Green: Tests must fail before they pass
- Atomic Commits: One logical change per commit
- No Skipping: Every test must pass
Common Patterns
TypeScript/JavaScript
// Read test expectations
describe('UserService', () => {
it('should create user with email and name', async () => {
const user = await service.createUser({ email: 'test@example.com', name: 'Test' });
expect(user.id).toBeDefined();
expect(user.email).toBe('test@example.com');
});
});
// Implement to match
export class UserService {
async createUser(input: CreateUserInput): Promise<User> {
return {
id: crypto.randomUUID(),
email: input.email,
name: input.name,
createdAt: new Date(),
};
}
}
Go
// Read test expectations
func TestCreateUser(t *testing.T) {
svc := NewUserService()
user, err := svc.CreateUser(context.Background(), CreateUserInput{
Email: "test@example.com",
Name: "Test",
})
require.NoError(t, err)
assert.NotEmpty(t, user.ID)
assert.Equal(t, "test@example.com", user.Email)
}
// Implement to match
func (s *UserService) CreateUser(ctx context.Context, input CreateUserInput) (*User, error) {
return &User{
ID: uuid.New().String(),
Email: input.Email,
Name: input.Name,
CreatedAt: time.Now(),
}, nil
}
Failure Handling
Test Won't Pass After Multiple Attempts
- Re-read the test - is the expectation correct?
- Check if test has a bug (it happens)
- Check design decisions - is implementation matching spec?
- Record blocker:
aide memory add --category=blocker "Cannot pass test X: <reason>" - If stuck after 3 attempts, ask for help
Build Fails
- Read error message carefully
- Check for missing imports
- Check for type mismatches
- Fix and re-run build
- Then re-run tests
Test Passes But Implementation Feels Wrong
- If tests pass, the contract is met
- Don't refactor during implement stage
- Note concerns for future:
aide memory add --category=issue "Implementation of X could be improved: <how>" - Proceed - refactoring is a separate concern
Verification Checklist
Before completing:
- All tests pass (not just some)
- Build succeeds
- Changes are committed
- No debug code left (console.log, fmt.Println for debugging)
Completion
When all tests pass:
# Final verification
npm test -- path/to/feature.test.ts && npm run build
# Or Go
go test -v ./pkg/feature/... && go build ./...
Output: "Implementation complete. All tests passing. Ready for VERIFY stage."
Integration with SDLC Pipeline
This skill is designed for the DEV stage:
[DESIGN] → [TEST] → [DEV/IMPLEMENT] → [VERIFY] → [DOCS]
↑
YOU ARE HERE
- Input: Failing tests from TEST stage
- Output: Passing tests, working implementation
- Next: VERIFY stage runs full validation
