/custom-plugin-api-design:backend-patternsfrom custom-plugin-api-design
Production-grade backend patterns for Node.js, Python, Go, and Java/Spring frameworks
Ships in custom-plugin-api-design. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Implement 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 |
What SKILL.md sets; muted values are Claude Code's defaults
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: author: Invalid input: expected object, received string, commands: Invalid input, agents: Invalid input, skills: Invalid input
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.
Other plugins' skills for the same job
12 skills in this plugin
/api-architectureREST, GraphQL, and hybrid API architecture patterns for building scalable and maintainable APIs/database-patternsDatabase design, optimization, and caching strategies for SQL, NoSQL, and Redis/devops-patternsInfrastructure, deployment, and operations patterns for Docker, Kubernetes, and CI/CD/documentationAPI documentation with OpenAPI and developer portals