.agents/skills/agent-implementer-sparc-coder/SKILL.md
name: sparc-coder type: development color: blue description: Transform specifications into working code with TDD practices capabilities:
This agent specializes in the implementation phases of SPARC methodology, focusing on transforming specifications and designs into high-quality, tested code.
[Parallel Test Creation]:
- Write("tests$unit$auth.test.js", authTestSuite)
- Write("tests$unit$user.test.js", userTestSuite)
- Write("tests$integration$api.test.js", apiTestSuite)
- Bash("npm test") // Verify all fail
[Parallel Implementation]:
- Write("src$auth$service.js", authImplementation)
- Write("src$user$model.js", userModel)
- Write("src$api$routes.js", apiRoutes)
- Bash("npm test") // Verify all pass
[Parallel Refactoring]:
- MultiEdit("src$auth$service.js", optimizations)
- MultiEdit("src$user$model.js", improvements)
- Edit("src$api$routes.js", cleanup)
- Bash("npm test && npm run lint")
// Pattern: Dependency Injection + Error Handling
class AuthService {
constructor(userRepo, tokenService, logger) {
this.userRepo = userRepo;
this.tokenService = tokenService;
this.logger = logger;
}
async authenticate(credentials) {
try {
// Implementation
} catch (error) {
this.logger.error('Authentication failed', error);
throw new AuthError('Invalid credentials');
}
}
}
// Pattern: Validation + Error Handling
router.post('$auth$login',
validateRequest(loginSchema),
rateLimiter,
async (req, res, next) => {
try {
const result = await authService.authenticate(req.body);
res.json({ success: true, data: result });
} catch (error) {
next(error);
}
}
);
// Pattern: Comprehensive Test Coverage
describe('AuthService', () => {
let authService;
beforeEach(() => {
// Setup with mocks
});
describe('authenticate', () => {
it('should authenticate valid user', async () => {
// Arrange, Act, Assert
});
it('should handle invalid credentials', async () => {
// Error case testing
});
});
});
src/
โโโ features/ # Feature-based structure
โ โโโ auth/
โ โ โโโ service.js
โ โ โโโ controller.js
โ โ โโโ auth.test.js
โ โโโ user/
โโโ shared/ # Shared utilities
โโโ infrastructure/ # Technical concerns
// Fallback mechanisms
try {
return await primaryService.getData();
} catch (error) {
logger.warn('Primary service failed, using cache');
return await cacheService.getData();
}
// Retry with exponential backoff
async function retryOperation(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await sleep(Math.pow(2, i) * 1000);
}
}
}
/**
* Authenticates user credentials and returns access token
* @param {Object} credentials - User credentials
* @param {string} credentials.email - User email
* @param {string} credentials.password - User password
* @returns {Promise<Object>} Authentication result with token
* @throws {AuthError} When credentials are invalid
*/