
Backend Patterns
Apply proven Node/Express and Next.js API patterns while designing routes, data access, caching, and middleware for a solo-built backend.
Overview
Backend Patterns is an agent skill for the Build phase that teaches repository-style API design, database optimization, caching, and middleware patterns for Node.js, Express, and Next.js routes.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill backend-patternsWhat is this skill?
- RESTful resource URLs with filtering, sorting, and pagination query patterns
- Repository pattern examples to separate data access from route handlers
- Guidance for N+1 fixes, indexing, and connection pooling
- Caching strategies including Redis, in-memory, and HTTP cache headers
- Middleware patterns for auth, logging, rate limiting, and structured API errors
Adoption & trust: 7.9k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent keeps generating flat route handlers with tangled SQL, missing pagination, and no consistent error or caching strategy.
Who is it for?
Indie SaaS or API products where you want opinionated TypeScript backend structure without rereading framework docs each session.
Skip if: Greenfield stack choices on non-Node runtimes, pure frontend UI work, or production security sign-off without a dedicated review skill.
When should I use this skill?
Designing REST or GraphQL endpoints, repository/service/controller layers, DB query optimization, caching, background jobs, API error handling, or auth/logging/rate-limit middleware.
What do I get? / Deliverables
You get API modules aligned to REST conventions, repository boundaries, and performance-minded database and cache patterns you can extend feature by feature.
- REST-shaped route and handler structure
- Repository-layer data access boundaries
- Middleware and caching patterns applied to new endpoints
Recommended Skills
Journey fit
Build is the canonical shelf because the skill encodes implementation-time architecture for server-side code and APIs, not discovery or launch work. Backend subphase matches REST/GraphQL design, repositories, query optimization, jobs, and API middleware—the core server layer of the product.
How it compares
Pattern and snippet guidance for implementation—not an MCP server or ORM-specific code generator.
Common Questions / FAQ
Who is backend-patterns for?
Solo builders shipping Node.js or Next.js APIs who want consistent REST, repository, and performance patterns while pair-programming with an agent.
When should I use backend-patterns?
During Build/backend when defining endpoints, refactoring data access, adding Redis or HTTP caching, or implementing auth, logging, and rate-limit middleware.
Is backend-patterns safe to install?
Check the Security Audits panel on this Prism page for license, risk level, and any published audits; the skill is instructional and does not inherently require elevated permissions.
SKILL.md
READMESKILL.md - Backend Patterns
# Backend Development Patterns Backend architecture patterns and best practices for scalable server-side applications. ## When to Activate - Designing REST or GraphQL API endpoints - Implementing repository, service, or controller layers - Optimizing database queries (N+1, indexing, connection pooling) - Adding caching (Redis, in-memory, HTTP cache headers) - Setting up background jobs or async processing - Structuring error handling and validation for APIs - Building middleware (auth, logging, rate limiting) ## API Design Patterns ### RESTful API Structure ```typescript // PASS: Resource-based URLs GET /api/markets # List resources GET /api/markets/:id # Get single resource POST /api/markets # Create resource PUT /api/markets/:id # Replace resource PATCH /api/markets/:id # Update resource DELETE /api/markets/:id # Delete resource // PASS: Query parameters for filtering, sorting, pagination GET /api/markets?status=active&sort=volume&limit=20&offset=0 ``` ### Repository Pattern ```typescript // Abstract data access logic interface MarketRepository { findAll(filters?: MarketFilters): Promise<Market[]> findById(id: string): Promise<Market | null> create(data: CreateMarketDto): Promise<Market> update(id: string, data: UpdateMarketDto): Promise<Market> delete(id: string): Promise<void> } class SupabaseMarketRepository implements MarketRepository { async findAll(filters?: MarketFilters): Promise<Market[]> { let query = supabase.from('markets').select('*') if (filters?.status) { query = query.eq('status', filters.status) } if (filters?.limit) { query = query.limit(filters.limit) } const { data, error } = await query if (error) throw new Error(error.message) return data } // Other methods... } ``` ### Service Layer Pattern ```typescript // Business logic separated from data access class MarketService { constructor(private marketRepo: MarketRepository) {} async searchMarkets(query: string, limit: number = 10): Promise<Market[]> { // Business logic const embedding = await generateEmbedding(query) const results = await this.vectorSearch(embedding, limit) // Fetch full data const markets = await this.marketRepo.findByIds(results.map(r => r.id)) // Sort by similarity return markets.sort((a, b) => { const scoreA = results.find(r => r.id === a.id)?.score || 0 const scoreB = results.find(r => r.id === b.id)?.score || 0 return scoreA - scoreB }) } private async vectorSearch(embedding: number[], limit: number) { // Vector search implementation } } ``` ### Middleware Pattern ```typescript // Request/response processing pipeline export function withAuth(handler: NextApiHandler): NextApiHandler { return async (req, res) => { const token = req.headers.authorization?.replace('Bearer ', '') if (!token) { return res.status(401).json({ error: 'Unauthorized' }) } try { const user = await verifyToken(token) req.user = user return handler(req, res) } catch (error) { return res.status(401).json({ error: 'Invalid token' }) } } } // Usage export default withAuth(async (req, res) => { // Handler has access to req.user }) ``` ## Database Patterns ### Query Optimization ```typescript // PASS: GOOD: Select only needed columns const { data } = await supabase .from('markets') .select('id, name, status, volume') .eq('status', 'active') .order('volume', { ascending: false }) .limit(10) // FAIL: BAD: Select everything const { data } = await supabase .from('markets') .select('*') ``` ### N+1 Query Prevention ```typescript // FAIL: BAD: N+1 query problem co