Execute work orders and implement code using coding agents and development tools
Input:
project-docs/work-orders/work-orders-latest.md ā Work orders from Plannerproject-docs/blueprint/blueprint-latest.md ā Technical referenceOutput:
src/ ā Implementation code (git-versioned, not file-versioned)Workflow:
project-docs/work-orders/work-orders-latest.mdsrc/WO-001: Implement auth service)Note: Unlike other agents, Assembler outputs code which is versioned via git, not via numbered markdown files.
The Assembler Agent is the fourth stage in the software factory workflow. It takes work orders from the Planner and executes them - either by writing code directly, coordinating with coding agents (like Letta Code, Cursor, Copilot), or delegating to human developers. It's where the actual implementation happens.
Use the Assembler Agent pattern when:
Implement the specified work:
Maintain code standards:
Integrate with development ecosystem:
Monitor implementation status:
Ensure code works:
Work Order ā Context Gathering ā Implementation Plan
Read the work order carefully:
Gather context:
Work Order + Context ā Implementation Strategy ā Code Outline
Break down the implementation:
For a backend API endpoint:
For a frontend component:
Create an implementation checklist:
Work Order: WO-005 "Implement Task Creation API"
Implementation Steps:
- [ ] Create route handler in src/api/tasks.ts
- [ ] Add validation schema for request body
- [ ] Implement createTask service function
- [ ] Add error handling
- [ ] Write unit tests for validation
- [ ] Write unit tests for service function
- [ ] Write integration test for endpoint
- [ ] Update API documentation
Implementation Plan ā Code Generation ā Working Code
Execution modes:
Mode 1: Direct Implementation (AI agent writes code)
- Agent reads work order
- Agent generates complete implementation
- Agent writes files
- Agent runs tests
- Agent verifies acceptance criteria
Mode 2: Assisted Implementation (Human + AI pair programming)
- Human outlines approach
- AI generates code blocks
- Human reviews and refines
- AI runs tests and fixes issues
- Human does final review
Mode 3: Delegated Implementation (Human developer)
- Assign work order to developer
- Developer implements
- Developer submits for review
- AI or human reviews
- Developer addresses feedback
Best practices during execution:
Code Generation ā Quality Checks ā Production-Ready Code
Code quality checklist:
Correctness:
Maintainability:
Testability:
Performance:
Security:
Working Code ā Testing ā Verified Code
Testing strategy:
Unit Tests:
// Test individual functions
describe('createTask', () => {
it('should create a task with valid input', async () => {
const input = { title: 'Test Task', description: 'Test' };
const task = await createTask(input);
expect(task).toHaveProperty('id');
expect(task.title).toBe('Test Task');
});
it('should throw error with invalid input', async () => {
const input = { title: '' }; // Invalid
await expect(createTask(input)).rejects.toThrow();
});
});
Integration Tests:
// Test API endpoints
describe('POST /api/tasks', () => {
it('should create task and return 201', async () => {
const response = await request(app)
.post('/api/tasks')
.send({ title: 'Test Task', description: 'Test' })
.set('Authorization', `Bearer ${token}`);
expect(response.status).toBe(201);
expect(response.body).toHaveProperty('id');
});
});
Manual Testing:
Verified Code ā Documentation ā Complete Work Package
Documentation types:
Code Comments:
/**
* Creates a new task in the system
* @param input - Task creation data
* @returns Created task with generated ID
* @throws ValidationError if input is invalid
* @throws AuthorizationError if user lacks permission
*/
async function createTask(input: CreateTaskInput): Promise<Task> {
// Implementation
}
API Documentation:
## POST /api/tasks
Create a new task.
**Authentication**: Required
**Request Body**:
{
"title": "string (required, 1-200 chars)",
"description": "string (optional)",
"assigneeId": "string (optional, valid user ID)",
"priority": "low | medium | high (optional, default: medium)"
}
**Response 201**:
{
"id": "uuid",
"title": "string",
...
}
**Errors**:
- 400: Invalid input
- 401: Not authenticated
- 403: Not authorized
Implementation Notes:
## Work Order WO-005: Task Creation API
**Implemented**: 2025-12-17
**Developer**: Assembler Agent
**Key Decisions**:
- Used UUID for task IDs (more scalable than auto-increment)
- Default priority is 'medium' if not specified
- Task owner defaults to creator if assigneeId not provided
**Known Limitations**:
- No support for bulk task creation yet (future work order)
- Task attachments not implemented in this work order
**Testing**:
- Unit tests: 12 cases, 100% coverage
- Integration tests: 6 endpoints scenarios
- Manual testing: Completed via Postman
Complete Implementation ā Review ā Refinement
Review checklist:
Self-Review:
Peer Review (if applicable):
Quality Gate:
# Implementation Report: WO-005
## Work Order
**Title**: Implement Task Creation API
**Priority**: P1
**Estimated Hours**: 4
**Actual Hours**: 5
## Status
ā
**Completed** - 2025-12-17 15:30 UTC
## Implementation Summary
Implemented the POST /api/tasks endpoint with full validation, error handling, and testing. The endpoint allows authenticated users to create tasks with optional assignment to team members.
## Files Created
- `src/api/tasks.ts` - Route handler and validation
- `src/services/taskService.ts` - Business logic
- `src/models/Task.ts` - Task type definitions
- `tests/unit/taskService.test.ts` - Unit tests
- `tests/integration/taskApi.test.ts` - Integration tests
## Files Modified
- `src/api/index.ts` - Added tasks route
- `src/db/schema.sql` - Already existed (no changes needed)
- `docs/api.md` - Added endpoint documentation
## Acceptance Criteria
ā
POST /api/tasks endpoint creates new task
ā
Endpoint validates input (title required, valid types)
ā
Returns 201 with created task
ā
Returns 400 for invalid input
ā
Unit tests cover all service functions (100% coverage)
ā
Integration tests verify API behavior (6 test cases)
ā
API documentation updated
## Testing Results
- **Unit Tests**: 12/12 passing
- **Integration Tests**: 6/6 passing
- **Coverage**: 100% (business logic)
- **Manual Testing**: Verified via Postman
## Key Implementation Details
### Validation Schema
Used Zod for request validation:
```typescript
const createTaskSchema = z.object({
title: z.string().min(1).max(200),
description: z.string().optional(),
assigneeId: z.string().uuid().optional(),
priority: z.enum(['low', 'medium', 'high']).default('medium')
});
Implemented consistent error responses:
Issue 1: TypeScript type mismatch with Zod schema
Issue 2: Integration test failing due to timezone handling
Self-Review: Completed Peer Review: N/A (solo implementation) Approved By: Assembler Agent Approved Date: 2025-12-17
Status: Ready for staging Migration Required: No Config Changes: No Rollback Plan: Simple rollback, no DB changes
## Best Practices
### DO:
- **Follow existing patterns**: Match the codebase style
- **Test as you go**: Don't wait until the end
- **Commit frequently**: Small, atomic commits
- **Document decisions**: Explain non-obvious choices
- **Ask for clarification**: Don't guess requirements
- **Refactor as needed**: Leave code better than you found it
### DON'T:
- **Skip tests**: Every work order needs tests
- **Hardcode values**: Use configuration
- **Ignore errors**: Handle them properly
- **Over-engineer**: Solve the current problem, not future ones
- **Break existing code**: Run existing tests
- **Mix concerns**: One work order = one focused change
## Integration with Other Agents
### Input ā Planner Agent
Receives work orders containing:
- Task description
- Acceptance criteria
- Technical details
- File paths
- Testing requirements
### Output ā Validator Agent
Provides implemented code for validation:
- All created/modified files
- Test results
- Implementation notes
- Known issues
### Feedback Loop ā Planner Agent
May provide feedback on:
- Work orders that were under-specified
- Missing dependencies discovered
- Estimation accuracy improvements
## Example Usage
### Input Work Order
WO-005: Implement Task Creation API Priority: P1 Estimated: 4 hours Dependencies: WO-002 (Task Model)
Acceptance Criteria:
### Assembler Execution
1. **Read work order**: Understand requirements
2. **Gather context**: Review existing API patterns
3. **Plan implementation**:
- Create route handler
- Add validation
- Write service function
- Write tests
4. **Execute**: Generate code files
5. **Test**: Run unit + integration tests
6. **Document**: Update API docs
7. **Report**: Create implementation report
### Output Implementation
Files Created:
Files Modified:
Status: ā Complete Tests: 18/18 passing Coverage: 100%
## Tips for Effective Assembly
1. **Read the whole work order first**: Don't start coding immediately
2. **Understand the context**: Review related code before implementing
3. **Start with tests**: TDD can clarify requirements
4. **Keep it simple**: Solve the problem at hand, no more
5. **Verify continuously**: Test after each small change
6. **Document as you go**: Don't save documentation for the end
## Common Pitfalls
- **Scope creep**: Implementing more than the work order specifies
- **Pattern inconsistency**: Not following existing codebase conventions
- **Insufficient testing**: Skipping edge cases or error scenarios
- **Poor error messages**: Generic errors that don't help debugging
- **Tight coupling**: Making components too dependent on each other
- **Premature optimization**: Optimizing before there's a problem
## Working with AI Coding Agents
### Effective Prompting
Good Prompt: "Implement the createTask function according to WO-005. It should validate input using Zod, save to database using the existing taskRepository pattern, and return the created task. Handle validation errors with 400 response."
Bad Prompt: "Make a task creation function"
### Reviewing AI-Generated Code
- **Always review**: Don't trust AI output blindly
- **Test thoroughly**: AI can miss edge cases
- **Check patterns**: Ensure consistency with codebase
- **Verify security**: AI might miss security concerns
- **Refactor if needed**: AI code isn't always optimal
### Iterating with AI
## Summary
The Assembler Agent is where the plan becomes reality. It bridges the gap between specification and working software, ensuring that code is not just functional but also maintainable, tested, and well-documented.
**Remember**: Good implementation is:
- **Correct**: Meets all acceptance criteria
- **Tested**: Comprehensive test coverage
- **Maintainable**: Clean, readable code
- **Documented**: Clear comments and docs
- **Consistent**: Follows codebase patterns
- **Reviewed**: Quality-checked before completion