-
Notifications
You must be signed in to change notification settings - Fork 4
Coder Agent
Alessio Rocchi edited this page Jan 27, 2026
·
1 revision
Expert software engineer for writing clean, maintainable code.
Write, edit, and refactor code with clean, maintainable implementations.
You are an expert software developer focused on writing clean, efficient code.
Core Principles:
- Write simple, readable code that solves the problem directly
- Follow established patterns in the codebase
- Avoid over-engineering - only add complexity when truly needed
- Use meaningful names and clear structure
Approach:
1. Understand the requirement fully before coding
2. Check existing code for patterns and conventions
3. Write minimal code that achieves the goal
4. Include only essential error handling
5. Test your changes work correctly
Guidelines:
- Prefer editing existing files over creating new ones
- Match the style of surrounding code
- Don't add features that weren't requested
- Keep functions focused and small
- Use types effectively for clarity
-
write-code- Create new code from scratch -
edit-code- Modify existing code -
refactor- Improve code quality -
debug- Fix bugs and issues -
implement-features- Build complete features
- Implementing new features
- Fixing bugs
- Refactoring code
- Adding functionality
- Optimizing code
Spawn a coder agent named "auth-coder" to implement JWT token validation
// Start session
const session = await memory.createSession({ feature: 'authentication' });
// Spawn coder in session
const coder = spawnAgent('coder', {
name: 'auth-coder',
sessionId: session.id
});
// Store requirements in memory
await memory.store('requirements:jwt', 'JWT should use HS256, expire in 1h', {
namespace: `session:${session.id}`
});
// Coder can access these requirementsUsing the auth-coder agent:
1. Implement a function to generate JWT tokens
2. Use HS256 algorithm
3. Set expiration to 1 hour
4. Include user ID and email in payload
5. Add proper TypeScript types
Expected Output:
import jwt from 'jsonwebtoken';
interface JWTPayload {
userId: string;
email: string;
}
/**
* Generates a JWT token for a user
* @param userId - The user's unique identifier
* @param email - The user's email address
* @returns JWT token string
*/
export function generateToken(userId: string, email: string): string {
const payload: JWTPayload = {
userId,
email
};
const secret = process.env.JWT_SECRET;
if (!secret) {
throw new Error('JWT_SECRET environment variable not set');
}
return jwt.sign(payload, secret, {
algorithm: 'HS256',
expiresIn: '1h'
});
}Using the auth-coder agent, refactor this function to be more maintainable:
function auth(u,p){return u&&p&&db.query("SELECT*FROM users WHERE name='"+u+"'AND pass='"+p+"'")}
Expected Output:
interface User {
id: string;
name: string;
passwordHash: string;
}
/**
* Authenticates a user with username and password
* @param username - User's username
* @param password - User's password (will be hashed for comparison)
* @returns User object if authenticated, null otherwise
*/
export async function authenticateUser(
username: string,
password: string
): Promise<User | null> {
if (!username || !password) {
return null;
}
// Use parameterized query to prevent SQL injection
const query = `
SELECT id, name, password_hash
FROM users
WHERE name = ?
`;
const user = await db.queryOne<User>(query, [username]);
if (!user) {
return null;
}
// Compare password hash (using bcrypt or similar)
const isValid = await comparePassword(password, user.passwordHash);
return isValid ? user : null;
}✓ GOOD:
"Implement a function to validate email addresses using a regex pattern, return boolean"
✗ BAD:
"Do email stuff"
✓ GOOD:
"In the user authentication module, add rate limiting to the login endpoint (max 5 attempts per minute)"
✗ BAD:
"Add rate limiting"
✓ GOOD:
"Using TypeScript and Express, create a middleware for request logging"
✗ BAD:
"Create a middleware"
1. Researcher explores existing patterns
2. Architect designs the feature
3. Coder implements
4. Tester creates tests
5. Reviewer validates
1. Researcher finds the bug location
2. Coder fixes the issue
3. Tester adds regression test
1. Analyst identifies code smells
2. Architect designs better structure
3. Coder refactors
4. Tester ensures behavior preserved
Store patterns and conventions for reuse:
await memory.store('pattern:error-handling',
'Use custom AppError class with status codes',
{ namespace: 'coding-standards' }
);
// Coder can reference these patternsconst session = await memory.createSession({ feature: 'user-profile' });
// All coders in this session share context
const frontendCoder = spawnAgent('coder', { sessionId: session.id });
const backendCoder = spawnAgent('coder', { sessionId: session.id });1. Spawn coder agent
2. Implement feature
3. Spawn adversarial agent
4. Review for security issues
5. Coder fixes issues
Getting Started
Core Concepts
Agent Guides
- Overview
- Coder
- Researcher
- Tester
- Reviewer
- Adversarial
- Architect
- Coordinator
- Analyst
- DevOps
- Documentation
- Security Auditor
MCP Tools
- Overview
- Agent Tools
- Memory Tools
- Task Tools
- Session Tools
- System Tools
- GitHub Tools
- Review Loop Tools
- Identity Tools
Recipes
- Index
- Code Review
- Doc Sync
- Multi-Agent
- Adversarial Testing
- Full-Stack Feature
- Memory Patterns
- GitHub Integration
Advanced
- Plugin Development
- Custom Agent Types
- Workflow Engine
- Vector Search Setup
- Web Dashboard
- Programmatic API
- Resource Monitoring
Reference