backend-patterns

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

1|Updated May 10, 2026
One-click install
npx skills add https://github.com/Tgoldi/claude-skills --skill backend-patterns-tgoldi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/Tgoldi/claude-skills/tree/main/backend-patterns
Command: npx skills add https://github.com/Tgoldi/claude-skills --skill backend-patterns-tgoldi

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 TypeScript implementations so you avoid reinventing fragile solutions. ## Core Features & Use Cases - API & Layering Patterns: RESTful route design, repository pattern, service layer separation, and middleware composition for Next.js API routes. - Database & Caching: Query optimization, N+1 prevention, Supabase transactions, Redis cache-aside, and cached repository decorators. - Resilience & Security: Centralized error handling, retry with exponential backoff, JWT authentication, role-based access control, rate limiting, job queues, and structured logging. - Use Case: When building a Next.js API that queries Supabase, apply the repository pattern with Redis caching and JWT middleware to get a maintainable, performant endpoint without designing the architecture from scratch. ## Quick Start Ask the assistant to apply backend patterns to design a cached, authenticated Next.js API route backed by Supabase.

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 Next.js API route with authentication?

Wrap your handler in a withAuth middleware that extracts the Bearer token, verifies it with jwt.verify, and attaches the user to the request. The pattern returns 401 responses for missing or invalid tokens before the handler runs.

How to prevent N+1 queries when fetching related data?

Batch fetch related records instead of querying in a loop. Collect all foreign keys, run one query to fetch the related entities, build a Map keyed by id, and merge results in memory.

What is the repository pattern in TypeScript backend development?

The repository pattern abstracts data access behind an interface like MarketRepository with findAll, findById, and create methods. Concrete implementations such as SupabaseMarketRepository handle the actual queries, keeping business logic independent of the database.

Does the cache-aside pattern work with Redis and Supabase?

Yes, cache-aside works with any database. Check Redis for a cached key first, and on a miss fetch from Supabase, then write the result back to Redis with a TTL such as 300 seconds.

When should I use a database transaction instead of separate inserts?

Use a transaction when multiple writes must succeed or fail together, such as creating a market and its initial position. A Postgres function via Supabase rpc wraps both inserts atomically with automatic rollback on error.

Why is in-memory rate limiting not suitable for production?

In-memory rate limiters store request timestamps per process, so limits reset on restart and do not coordinate across multiple server instances. Distributed deployments need a shared store like Redis for accurate limiting.