agentleFS
peopleforresterpeopleforrester/claude-dotfiles/skills/development/backend-patterns/SKILL.md

backend-patterns

Skill3 starsChanged 8 months agoMITView on GitHub

Common backend development patterns for APIs, databases, caching, and service architecture. Language-agnostic principles with examples in Python, TypeScript, and Go.

49 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use configure-ecc, swift-protocol-di-testing and 6 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 10 projects that use this

  • InfopibeSkill

    swift-protocol-di-testing

    Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.

    Also in 9 projects that use this

  • InfopibeSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 9 projects that use this

  • WorldFlowAISkill

    clickhouse-io

    ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

    Also in 13 projects that use this

  • joneqianSkill

    postgres-patterns

    PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.

    Also in 20 projects that use this

  • +3 more from Infopibe

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add indexes for WHERE, JOIN, and ORDER BY columns

    line 77
  2. Distinctive:

    Use EXPLAIN to verify query plans

    line 78
  3. Distinctive:

    Avoid SELECT * — select only needed columns

    line 79
  4. Distinctive:

    Use pagination for list endpoints (LIMIT/OFFSET or cursor-based)

    line 80
  5. Distinctive:

    Always make migrations reversible

    line 84
  6. Distinctive:

    Add columns as nullable first, then backfill, then add constraint

    line 86
  7. Distinctive:

    Never rename columns — add new, migrate data, remove old

    line 87
  8. Distinctive:

    Use sliding window algorithm for accuracy

    line 141
  9. Distinctive:

    Stop accepting new connections

    line 144

“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Backend Development Patterns

API Design

RESTful Conventions

GET    /api/users          # List (with pagination)
GET    /api/users/:id      # Read single
POST   /api/users          # Create
PUT    /api/users/:id      # Full update
PATCH  /api/users/:id      # Partial update
DELETE /api/users/:id      # Delete

Response Format

{
  "data": { ... },
  "meta": {
    "page": 1,
    "per_page": 20,
    "total": 142
  }
}

Error Response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input",
    "details": [
      { "field": "email", "message": "must be a valid email" }
    ]
  }
}

HTTP Status Codes

CodeUse
200Successful read/update
201Successful create
204Successful delete
400Validation error
401Not authenticated
403Not authorized
404Resource not found
409Conflict (duplicate)
429Rate limited
500Server error

Database Patterns

Repository Pattern

Separate data access from business logic:

Service (business logic) → Repository (data access) → Database

Query Optimization

  • Add indexes for WHERE, JOIN, and ORDER BY columns
  • Use EXPLAIN to verify query plans
  • Avoid SELECT * — select only needed columns
  • Use pagination for list endpoints (LIMIT/OFFSET or cursor-based)
  • Batch operations instead of N+1 queries

Migration Safety

  • Always make migrations reversible
  • Use CREATE INDEX CONCURRENTLY (PostgreSQL)
  • Add columns as nullable first, then backfill, then add constraint
  • Never rename columns — add new, migrate data, remove old

Caching Patterns

Cache-Aside (Lazy Loading)

1. Check cache for key
2. If miss: query database, store in cache, return
3. If hit: return cached value
4. On write: invalidate cache

Cache Invalidation

  • Time-based: TTL appropriate to data freshness needs
  • Event-based: Invalidate on write/update
  • Version-based: Include version in cache key

What to Cache

  • Database query results (especially aggregations)
  • External API responses
  • Computed values (rendered templates, transformed data)
  • Session data

What NOT to Cache

  • Frequently changing data (< 1 second TTL)
  • Sensitive data without encryption
  • Large blobs that exceed memory budget

Service Architecture

Middleware Pattern

Request → Auth → Rate Limit → Validate → Handler → Response
                                              ↓
                                          Logging

Health Check Endpoint

GET /health
{
  "status": "healthy",
  "checks": {
    "database": "connected",
    "cache": "connected",
    "disk": "sufficient"
  }
}

Rate Limiting

  • Per-user rate limits for authenticated endpoints
  • Per-IP rate limits for public endpoints
  • Return 429 with Retry-After header
  • Use sliding window algorithm for accuracy

Graceful Shutdown

  1. Stop accepting new connections
  2. Finish processing in-flight requests (with timeout)
  3. Close database connections
  4. Close cache connections
  5. Exit

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.