agentsclimarketplace

Backend patterns

Skill peopleforrester/claude-dotfiles/skills/development/backend-patterns

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

Install
npx -y skills add peopleforrester/claude-dotfiles --skill backend-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

3.4 KB, as published. Nobody here has run it

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

Keep looking

Skills are one crate of 625,605. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.