后端编码

A backend coding guide covering web APIs, databases, error handling, logging, and endpoint tests. Backend code runs on servers and handles data and application operations.

In plain words
What is it for?
Building or reviewing backend and full-stack features, including REST APIs, database tables, errors, logs, and tests.
Why use it?
It gives developers shared rules for designing interfaces and storing data consistently and safely.

Skill for Claude CodeCodex

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/jianchen08/agent-os-open/code-backend
Any agent
npx skills add jianchen08/Agent-os-open --skill code-backend
Clone the repo
git clone --depth 1 https://github.com/jianchen08/Agent-os-open

Made for: Claude Code, Codex.

Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,302 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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 $0.00049 $0.01302
Opus 5 $0.00024 $0.00651
Sonnet 5 $0.00010 $0.00260
Haiku 4.5 $0.00005 $0.00130

Measured 2d ago against content hash cad1c6187a3e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

后端编码 scanned grade A with 0 findings 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 2d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/code-backend/SKILL.md · 140 lines

How it starts

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

后端编码

API 设计规范

RESTful 规范

原则 说明
资源命名 使用名词复数表示资源
层级结构 使用嵌套表示资源关系
HTTP 方法 正确使用 GET/POST/PUT/PATCH/DELETE
统一接口 所有 API 遵循统一的接口约束
无状态 请求包含所有必要信息

HTTP 方法

方法 用途 幂等性 示例
GET 查询资源 幂等 GET /users/123
POST 创建资源 非幂等 POST /users
PUT 更新资源(全量) 幂等 PUT /users/123
PATCH 更新资源(部分) 非幂等 PATCH /users/123
DELETE 删除资源 幂等 DELETE /users/123

URL 设计

规范 正确 错误
使用名词复数 GET /users GET /getUsers
层级表示关系 GET /users/123/orders GET /getUserOrders?userId=123
小写字母 GET /user-profiles GET /UserProfiles
省略扩展名 GET /users/123 GET /users/123.json
查询参数过滤 GET /users?role=admin GET /adminUsers

版本控制

URL 路径版本(推荐):/v1/users, /v2/users

数据库规范

设计原则

  • 第三范式(3NF),消除传递依赖
  • 必须有主键,推荐自增 ID 或 UUID
  • 为高频查询字段添加索引
  • 表名和字段名使用 snake_case

命名规范

对象 命名 示例
表名 snake_case,复数名词 users, order_items
字段名 snake_case user_name, created_at
主键 id id
外键 {table_singular}_id user_id, order_id
索引 ix_{table}_{column} ix_users_email
唯一约束 uq_{table}_{column} uq_users_email

错误处理

错误响应格式

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "用户友好的错误消息",
    "details": {}
  },
  "request_id": "uuid-for-tracing"
}
HTTP 状态码 错误码 适用场景
400 VALIDATION_ERROR 请求参数验证失败
401 UNAUTHORIZED 未认证
403 FORBIDDEN 无权限
404 NOT_FOUND 资源不存在
409 CONFLICT 资源冲突
422 UNPROCESSABLE_ENTITY 请求格式正确但无法处理
500 INTERNAL_ERROR 服务器内部错误
503 SERVICE_UNAVAILABLE 服务不可用

日志规范

日志级别

级别 使用场景
DEBUG 开发时排查问题
INFO 正常业务流程记录
WARNING 潜在问题但不影响功能
ERROR 功能失败但应用可继续
CRITICAL 应用崩溃级错误

日志最佳实践

  • 使用 JSON 结构化日志,便于检索
  • 每个请求关联唯一 request_id
  • 敏感信息脱敏(不记录密码、Token)
  • 异常日志使用 exc_info=True 保留完整堆栈
  • 日志包含业务上下文(如 order_id、user_id)

Read the full file on GitHub · 140 lines

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. 2d ago First seen · 140 lines · 49 tokens per session scan A cad1c6187a3e

Subscribe to this mod's changes

后端编码 is a skill published in the GitHub repository jianchen08/Agent-os-open (5 stars, last pushed 7d ago), licensed Apache-2.0. It adds 49 tokens to every session and 1,302 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

deep-research

深度研究编排方法论:澄清范围、拆解规划、并行调度子智能体调研、对抗式核验、综合成带引用的结构化报告。当任务需要多来源、可追溯、需事实核查的深度研究时使用此技能。.

xerrors/Yuxi · 69 tokens

mysql reporter

生成 MySQL 查询报表并生成可视化图表。当用户需要查询 MySQL 数据库并以报表形式展示结果时使用此技能,包括:统计销售数据、分析用户行为、生成业务报表、查询业务指标等。.

xerrors/Yuxi · 55 tokens

frontend-feature

Build a new page, view, or data-driven feature in the Next.js frontend. Use when adding a route under the dashboard/marketing area, wiring UI to a backend endpoint, adding client state, or creating a localized page. Covers App Router, data fetching, Zustand stores, and i18n.

vstorm-co/full-stack-ai-agent-template · 64 tokens

rag-knowledge

Work with the RAG knowledge base — ingest documents, run semantic search, manage collections, or add a sync source/connector (Google Drive, S3). Use when populating or debugging the knowledge base, tuning retrieval, or adding a new document source. This project uses {{ cookiecutter.vectorstore }} + {{…

vstorm-co/full-stack-ai-agent-template · 76 tokens

alembic-migration

Create, review, and apply database schema changes with Alembic. Use whenever a SQLAlchemy model is added or changed, a column/index/constraint needs to change, or a data backfill is required — anything that alters the PostgreSQL schema.

vstorm-co/full-stack-ai-agent-template · 56 tokens

image-gen

在 Agent 沙盒中生成图片并保存到 outputs。当用户要求生成图片、海报、插画、文生图,或指定 Qwen-Image、其它兼容图片生成接口时使用此技能。.

xerrors/Yuxi · 48 tokens