backend-patterns

backend-patterns is a skill for Claude Code, Codex from xu-xiang/everything-claude-code-zh. It costs 36 tokens per session (3,601 once invoked), scanned A, original, MIT.

A collection of server-side design patterns for Node.js, Express, and Next.js API routes. These are reusable ways to organize web servers, data access, validation, errors, and background work.

In plain words
What is it for?
Use it when designing REST or GraphQL APIs, adding repository or service layers, optimizing database queries, adding caching or jobs, and building middleware for authentication, logging, or rate limits.
Why use it?
It helps avoid inconsistent API and database code by providing structures for common backend tasks and problems such as slow repeated queries.

Skill for Claude CodeCodex

Part of the everything-claude-code-zh plugin — 17 skills, 26 commands, 13 agents shipped together

About the project

everything-claude-code-zh is a Chinese translation of a collection of configurations for Claude Code and other AI coding agents. It provides agents, skills, hooks, commands, rules, and MCP configurations intended to support development workflows such as memory persistence, security scanning, evaluation, and research-first work. The catalogue includes commands, skills, agents, instructions, and a plugin from this configuration set.

xu-xiang/everything-claude-code-zh · 1,929 stars · on GitHub · oneskill.one

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/xu-xiang/everything-claude-code-zh/backend-patterns
Any agent
npx skills add xu-xiang/everything-claude-code-zh --skill backend-patterns
Clone the repo
git clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh

Made for: Claude Code, Codex.

Or install everything-claude-code-zh, the plugin that ships this one along with the rest of its 17 skills, 26 commands, 13 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for backend-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/xu-xiang/everything-claude-code-zh/backend-patterns.svg)](https://agentmods.dev/skills/xu-xiang/everything-claude-code-zh/backend-patterns)
Your own site
<a href="https://agentmods.dev/skills/xu-xiang/everything-claude-code-zh/backend-patterns"><img src="https://agentmods.dev/badge/skills/xu-xiang/everything-claude-code-zh/backend-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,601 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00036 $0.03601
Opus 5 $0.00018 $0.01801
Sonnet 5 $0.00007 $0.00720
Haiku 4.5 $0.00004 $0.00360

Measured 6d ago against content hash 325904ac26ee, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

backend-patterns scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const requests = this.requests.get(identifier) || []
.agents/skills/backend-patterns/SKILL.md · 599 lines

How it starts

The opening of the file, as written. The whole thing — 599 lines — stays where its author put it; the contents beside it link to each section on GitHub.

后端开发模式 (Backend Development Patterns)

后端架构模式以及构建可扩展服务端应用的最佳实践。

启用时机 (When to Activate)

  • 设计 REST 或 GraphQL API 端点时
  • 实现仓库(Repository)、服务(Service)或控制器(Controller)层时
  • 优化数据库查询(N+1、索引、连接池)时
  • 添加缓存(Redis、内存缓存、HTTP 缓存头)时
  • 设置后台作业或异步处理时
  • 为 API 构建错误处理和验证结构时
  • 编写中间件(鉴权、日志、速率限制)时

API 设计模式 (API Design Patterns)

RESTful API 结构

// ✅ 基于资源的 URL
GET    /api/markets                 # 列出资源
GET    /api/markets/:id             # 获取单个资源
POST   /api/markets                 # 创建资源
PUT    /api/markets/:id             # 替换资源
PATCH  /api/markets/:id             # 更新资源
DELETE /api/markets/:id             # 删除资源

// ✅ 用于过滤、排序、分页的查询参数
GET /api/markets?status=active&sort=volume&limit=20&offset=0

仓库模式 (Repository Pattern)

// 抽象数据访问逻辑
interface MarketRepository {
  findAll(filters?: MarketFilters): Promise<Market[]>
  findById(id: string): Promise<Market | null>
  create(data: CreateMarketDto): Promise<Market>
  update(id: string, data: UpdateMarketDto): Promise<Market>
  delete(id: string): Promise<void>
}

class SupabaseMarketRepository implements MarketRepository {
  async findAll(filters?: MarketFilters): Promise<Market[]> {
    let query = supabase.from('markets').select('*')

    if (filters?.status) {
      query = query.eq('status', filters.status)
    }

    if (filters?.limit) {
      query = query.limit(filters.limit)
    }

    const { data, error } = await query

    if (error) throw new Error(error.message)
    return data
  }

  // 其他方法...
}

服务层模式 (Service Layer Pattern)

// 业务逻辑与数据访问分离
class MarketService {
  constructor(private marketRepo: MarketRepository) {}

  async searchMarkets(query: string, limit: number = 10): Promise<Market[]> {
    // 业务逻辑
    const embedding = await generateEmbedding(query)
    const results = await this.vectorSearch(embedding, limit)

    // 获取完整数据
    const markets = await this.marketRepo.findByIds(results.map(r => r.id))

    // 按相似度排序
    return markets.sort((a, b) => {
      const scoreA = results.find(r => r.id === a.id)?.score || 0
      const scoreB = results.find(r => r.id === b.id)?.score || 0
      return scoreA - scoreB
    })
  }

  private async vectorSearch(embedding: number[], limit: number) {
    // 向量搜索实现
  }
}

Read the full file on GitHub · 599 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 599 lines · 36 tokens per session scan A 325904ac26ee

Subscribe to this mod's changes

backend-patterns is a skill published in the GitHub repository xu-xiang/everything-claude-code-zh (1,929 stars, last pushed 6mo ago), licensed MIT. It adds 36 tokens to every session and 3,601 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.