backend-patterns

Implements backend architecture patterns for Node.js, Express, and Next.js API development.

5|Updated Jul 8, 2019
One-click install
npx skills add https://github.com/rinchsan/dotfiles --skill backend-patterns-rinchsan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/rinchsan/dotfiles/tree/main/.claude/skills/backend-patterns
Command: npx skills add https://github.com/rinchsan/dotfiles --skill backend-patterns-rinchsan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building scalable server-side applications requires consistent patterns for API design, database access, caching, and error handling, and this Skill provides proven implementations that prevent common pitfalls like N+1 queries, missing rate limits, and inconsistent error responses. ## Core Features & Use Cases - API Design Patterns: Repository, service layer, and middleware patterns with TypeScript examples for structuring Express and Next.js API routes. - Database Optimization: Query optimization, N+1 prevention, transaction handling with Supabase, and connection-aware data access. - Infrastructure Patterns: Redis caching (cache-aside), JWT authentication, role-based access control, rate limiting, background job queues, and structured logging. - Use Case: When building a new REST endpoint, apply the included API endpoint checklist covering HTTP status codes, pagination (cursor vs offset), filtering, versioning, and standardized error response formats. ## Quick Start Use the backend-patterns skill to design a paginated, authenticated REST API endpoint with proper error handling for my Next.js application.

Frequently Asked Questions about backend-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Node.js API with repository and service layers?

Define a repository interface abstracting data access, then implement it for your database such as Supabase. A service layer sits above it containing business logic, keeping controllers thin and data access testable.

How to prevent N+1 query problems in database queries?

Batch fetch related records instead of querying in a loop. Collect all foreign keys, run one query to fetch related entities, build a lookup map, and merge results in memory.

Should I use cursor-based or offset-based pagination for my API?

Use offset pagination for admin dashboards and small datasets under 10K rows where users expect page numbers. Use cursor-based pagination for infinite scroll, feeds, and large datasets since performance stays consistent regardless of position.

How do I implement rate limiting in an Express or Next.js API?

Track request timestamps per client identifier in a sliding window and reject requests exceeding the limit with HTTP 429. The in-memory approach works for single instances; use Redis for distributed deployments.

When should I version my REST API?

Version only when making breaking changes like removing fields, changing types, or altering authentication. Adding fields, optional parameters, or new endpoints is non-breaking. Maintain at most two active versions and announce deprecation six months ahead.