Command Palette

Search for a command to run...

Назад к скиллам
скилл № 49978

backend-patterns

Backend development patterns and best practices. Use for API design, database optimization, microservice architecture, authentication, caching strategies, and…

БесплатноБез исполняемых скриптов
Andersonlimahwот Andersonlimahw★ 19 звёзд на GitHub

Установить backend-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Backend Patterns

You are the backend engineering expert. You apply proven server-side patterns for APIs, databases, security, and observability. Every recommendation must be concrete, with code examples and anti-patterns to avoid.


1. API Design

REST Conventions

URL Structure

GET    /api/v1/users              → List users (paginated)
GET    /api/v1/users/:id          → Get single user
POST   /api/v1/users              → Create user
PATCH  /api/v1/users/:id          → Partial update
PUT    /api/v1/users/:id          → Full replace
DELETE /api/v1/users/:id          → Soft delete

Naming Rules

  • Plural nouns for collections: /users, not /user.
  • Kebab-case for multi-word: /user-profiles, not /userProfiles.
  • Nest for ownership: /users/:id/posts (user's posts).
  • Max 2 levels deep: /users/:id/posts/:postId — no deeper.
  • Query params for filtering: GET /users?role=admin&status=active.

Response Envelope

{
  "data": { ... },
  "meta": {
    "page": 1,
    "per_page": 20,
    "total": 142,
    "total_pages": 8
  },
  "links": {
    "self": "/api/v1/users?page=1",
    "next": "/api/v1/users?page=2",
    "prev": null
  }
}

HTTP Status Codes

Code Usage
200 Success with body
201 Created — return created resource + Location header
204 Success, no body (DELETE, some PATCH)
400 Validation error — include field-level errors
401 Unauthenticated — token missing or expired
403 Unauthorized — valid token but insufficient permissions
404 Resource not found
409 Conflict — duplicate key, version mismatch
422 Unprocessable entity — business rule violation
429 Rate limited — include Retry-After header
500 Server error — log details, return generic message

Pagination

Use cursor-based pagination for large datasets:

{
  "data": [...],
  "meta": {
    "has_next": true,
    "cursor": "eyJpZCI6MTAwfQ=="
  }
}

Use offset-based only for small, stable datasets where random page access is needed.

GraphQL Schema Design

Schema-First Approach

type User {
  id: ID!
  email: String!
  displayName: String!
  avatar: String
  posts(first: Int = 10, after: String): PostConnection!
  createdAt: DateTime!
}

type PostConnection {
  edges: [PostEdge!]!
  pageInfo: PageInfo!
}

type PostEdge {
  node: Post!
  cursor: String!
}

input CreateUserInput {
  email: String!
  displayName: String!
  password: String!
}

type Mutation {
  createUser(input: CreateUserInput!): CreateUserPayload!
}

type CreateUserPayload {
  user: User
  errors: [UserError!]!
}

GraphQL Rules

  • Use Relay-style connections for lists (edges + pageInfo).
  • Input types for mutations — never inline arguments.
  • Payload types for mutations — always include an errors field.
  • DataLoader for N+1 prevention — batch all database calls.
  • Limit query depth to 5 and complexity scoring to prevent abuse.
  • Never expose internal IDs directly — use opaque, base64-encoded cursors.

gRPC Proto Design

syntax = "proto3";
package user.v1;

service UserService {
  rpc GetUser(GetUserRequest) returns (GetUserResponse);
  rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
  rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
}

message GetUserRequest {
  string user_id = 1;
}

message GetUserResponse {
  User user = 1;
}

message User {
  string id = 1;
  string email = 2;
  string display_name = 3;
  google.protobuf.Timestamp created_at = 4;
}

gRPC Rules

  • Package versioning: package user.v1; — version in package name.
  • Field numbers are forever — never reuse deleted field numbers.
  • Use google.protobuf.Timestamp for dates, not strings.
  • Wrap responses in response messages — allows adding metadata later.
  • Use server streaming for real-time feeds, bidirectional for chat.

2. Database Patterns

Query Optimization

The Query Checklist

  1. EXPLAIN ANALYZE every query touching >1000 rows.
  2. Select only needed columns — never SELECT * in production.
  3. Avoid N+1 — use JOINs or batch queries.
  4. Parameterize everything — never concatenate user input.
  5. Limit result sets — always paginate.

Common Optimizations

-- BAD: Full table scan
SELECT * FROM orders WHERE YEAR(created_at) = 2024;

-- GOOD: Sargable query, uses index
SELECT id, total, status
FROM orders
WHERE created_at >= '2024-01-01'
  AND created_at < '2025-01-01';

Indexing Strategy

Pattern Index Type
Exact match (WHERE status = 'active') B-tree
Range query (WHERE created_at > X) B-tree
Text search (WHERE name ILIKE '%query%') GIN / trigram
JSON field access GIN
Geospatial GiST / SP-GiST
Composite filters Composite index (most selective first)

Index Rule

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл backend-patterns?

Backend development patterns and best practices. Use for API design, database optimization, microservice architecture, authentication, caching strategies, and server-side implementation.

Как установить скилл backend-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл backend-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить backend-patterns с