Production-grade backend patterns for Node.js, Python, Go, and Java/Spring frameworks
Implements production-ready backend services with proper error handling, validation, and logging patterns. Use when building Node.js, Python, Go, or Java APIs that need enterprise-grade structure and reliability.
/plugin marketplace add pluginagentmarketplace/custom-plugin-api-design/plugin install custom-plugin-api-design@pluginagentmarketplace-api-designThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/backend_config.yamlassets/config.yamlassets/schema.jsonreferences/BACKEND_GUIDE.mdreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyImplement production-ready backend services with proper patterns.
| Language | Framework | Best For |
|---|---|---|
| Node.js | Express | Simple APIs, quick prototypes |
| Node.js | NestJS | Enterprise, TypeScript |
| Node.js | Fastify | High performance |
| Python | FastAPI | Modern async, auto-docs |
| Python | Django | Full-featured, admin |
| Go | Gin | Fast, middleware |
| Java | Spring Boot | Enterprise, ecosystem |
// Error hierarchy
class AppError extends Error {
constructor(
public code: string,
message: string,
public status: number = 500,
) {
super(message);
this.name = this.constructor.name;
}
}
class NotFoundError extends AppError {
constructor(resource: string, id: string) {
super('NOT_FOUND', `${resource} ${id} not found`, 404);
}
}
class ValidationError extends AppError {
constructor(public errors: { field: string; message: string }[]) {
super('VALIDATION_ERROR', 'Validation failed', 400);
}
}
// Global handler
app.use((err, req, res, next) => {
if (err instanceof AppError) {
return res.status(err.status).json({
type: `https://api.example.com/errors/${err.code.toLowerCase()}`,
title: err.message,
status: err.status,
});
}
logger.error(err);
res.status(500).json({ title: 'Internal error', status: 500 });
});
// Request ID middleware
const requestId = (req, res, next) => {
req.id = req.headers['x-request-id'] || crypto.randomUUID();
res.setHeader('X-Request-ID', req.id);
next();
};
// Logging middleware
const requestLogger = (req, res, next) => {
const start = Date.now();
res.on('finish', () => {
logger.info({
method: req.method,
path: req.path,
status: res.statusCode,
duration: Date.now() - start,
requestId: req.id,
});
});
next();
};
// Error boundary
const asyncHandler = (fn) => (req, res, next) => {
Promise.resolve(fn(req, res, next)).catch(next);
};
import { z } from 'zod';
const CreateUserSchema = z.object({
email: z.string().email(),
name: z.string().min(1).max(100),
password: z.string().min(12),
});
function validate(schema) {
return (req, res, next) => {
const result = schema.safeParse(req.body);
if (!result.success) {
throw new ValidationError(
result.error.issues.map(i => ({
field: i.path.join('.'),
message: i.message,
}))
);
}
req.body = result.data;
next();
};
}
app.post('/users', validate(CreateUserSchema), createUser);
const server = app.listen(3000);
async function shutdown() {
console.log('Shutting down...');
// Stop accepting new connections
server.close();
// Close database connections
await db.destroy();
// Close Redis
await redis.quit();
process.exit(0);
}
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
describe('Backend Pattern: Error Handling', () => {
it('should return proper error response', async () => {
const res = await request(app)
.get('/users/invalid-id')
.expect(404);
expect(res.body).toMatchObject({
type: expect.stringContaining('not-found'),
status: 404,
});
});
});
| Issue | Cause | Solution |
|---|---|---|
| Memory leak | Event listeners | Remove on cleanup |
| Connection timeout | Pool exhausted | Increase pool size |
| Unhandled rejection | Missing catch | Add async handler |
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.