| name | backend |
| description | Build reliable, scalable, and secure server-side systems. |
Skill: Backend Engineering
Category: Backend
Priority: High
Description
Build reliable, scalable, and secure server-side systems.
Purpose
Ensure data integrity, system availability, and API correctness.
Trigger
Use this skill when:
- Designing a new service
- Adding API endpoints
- Implementing business logic
- Integrating with databases or external services
- Reviewing backend code
Context
- Programming language and framework
- Database and caching layer
- External dependencies
- Scale and latency requirements
Workflow
- Input Validation - Validate at the boundary. Fail fast.
- Error Handling - Catch exceptions, return structured errors.
- Logging - Structured logs with correlation IDs.
- Idempotency - Safe to retry operations.
- Transactions - Multi-step operations must be atomic.
- Caching - Cache reads, invalidate writes.
- Rate Limiting - Protect resources from abuse.
- Observability - Metrics, traces, health checks.
Examples
Good API Handler
export async function createOrder(req: Request, res: Response) {
const { userId, items } = CreateOrderSchema.parse(req.body);
const correlationId = req.headers["x-correlation-id"] || uuid();
logger.info({ correlationId, userId, itemCount: items.length }, "Creating order");
try {
const order = await db.transaction(async (trx) => {
const order = await OrderRepository.create({ userId }, trx);
await OrderItemRepository.createBulk(order.id, items, trx);
return order;
});
res.status(201).json(order);
} catch (error) {
logger.error({ correlationId, error }, "Order creation failed");
res.status(500).json({ error: "Order creation failed", correlationId });
}
}
Bad API Handler
function createOrder(req, res) {
const order = db.query(`INSERT INTO orders (user_id) VALUES (${req.body.userId})`);
res.send(order);
}
Anti-patterns
- SQL injection via string concatenation
- No input validation
- Swallowing exceptions
- No logging
- No transactions for multi-step operations
Verification
References