backend/api-development

A guide to building web APIs, including resource URLs, request validation, consistent responses, error handling, authentication, and security.

In plain words
What is it for?
Use it to implement REST or GraphQL endpoints, define request and response types, handle errors, validate input, add pagination, and protect API access.
Why use it?
It helps keep backend interfaces predictable and aligned with the project’s agreed API contract, which is the documented behavior frontend and backend share.

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/echovic/boss-skill/api-development
Any agent
npx skills add echoVic/boss-skill --skill api-development
Clone the repo
git clone --depth 1 https://github.com/echoVic/boss-skill

Made for: Claude Code, Codex.

Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,697 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.00026 $0.02697
Opus 5 $0.00013 $0.01349
Sonnet 5 $0.00005 $0.00539
Haiku 4.5 $0.00003 $0.00270

Measured yesterday against content hash 0aad2b0d3634, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

backend/api-development 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 yesterday.

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.

skill/skills/backend/api-development/SKILL.md · 427 lines

How it starts

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

后端 API 开发方法论

API 契约管理

契约来源

实现 API 前,必须阅读 architecture.md §5(API 设计),获取:

  • API 规范(RESTful/GraphQL)
  • 接口列表(方法、路径、描述、认证要求)
  • 请求/响应格式约定
  • 错误码规范

契约遵守原则

  1. 严格实现:API 端点的方法、路径、参数必须与 architecture.md §5 一致
  2. 响应格式:遵循统一的成功/错误响应结构
  3. 偏差记录:如需偏离契约,必须在输出报告中标注原因
  4. 类型导出:将请求/响应类型导出到共享文件,供前端引用

RESTful API 设计

资源命名规范

操作 HTTP 方法 路径 说明
列表 GET /api/users 获取用户列表
详情 GET /api/users/:id 获取单个用户
创建 POST /api/users 创建新用户
更新 PUT/PATCH /api/users/:id 更新用户
删除 DELETE /api/users/:id 删除用户

统一响应格式

成功响应

{
  "success": true,
  "data": { ... },
  "message": "Operation successful"
}

错误响应

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input data",
    "details": [
      { "field": "email", "message": "Invalid email format" }
    ]
  }
}

分页规范

请求参数

GET /api/users?page=1&pageSize=20&sortBy=createdAt&order=desc

响应格式

{
  "success": true,
  "data": {
    "items": [...],
    "pagination": {
      "page": 1,
      "pageSize": 20,
      "total": 100,
      "totalPages": 5
    }
  }
}

请求验证

输入验证层级

  1. 路由层:验证路径参数和查询参数
  2. 中间件层:验证请求体格式和必填字段
  3. Service 层:验证业务规则

验证示例

// 使用验证库(如 Zod、Joi、class-validator)
import { z } from 'zod';

const CreateUserSchema = z.object({
  name: z.string().min(1).max(100),
  email: z.string().email(),
  age: z.number().int().min(0).max(150).optional(),
});

// 在路由处理器中验证
app.post('/api/users', async (req, res) => {
  try {
    const validatedData = CreateUserSchema.parse(req.body);
    const user = await userService.create(validatedData);
    res.json({ success: true, data: user });
  } catch (error) {
    if (error instanceof z.ZodError) {
      res.status(400).json({
        success: false,
        error: {
          code: 'VALIDATION_ERROR',
          message: 'Invalid input data',
          details: error.errors,
        },
      });
    }
  }
});

Read the full file on GitHub · 427 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. yesterday First seen · 427 lines · 26 tokens per session scan A 0aad2b0d3634

Subscribe to this mod's changes

backend/api-development is a skill published in the GitHub repository echoVic/boss-skill (552 stars, last pushed yesterday), licensed MIT. It adds 26 tokens to every session and 2,697 once invoked, about $0.0001 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-30.

Related

Other skills, from other repositories

large-workspace-handling

To partition large workspaces (100+ files) into scoped subagent tasks when context is insufficient.

griddynamics/rosetta · 26 tokens

example-skill

Example skill template used for the CreateHub template. You should never use this skill directly as it is just a template made to be updated.

aws-samples/sample-well-architected-skills-and-steering · 32 tokens

bmad-github-story-dev

Set up a git worktree/branch (or reuse the current one) and run BMAD dev-story end-to-end: auto-commits per task, PR creation, label updates. Use when the user invokes the SD menu code in bmad help, or asks to start implementing the next ready story, or asks to begin dev on a story.

choucrifahed/agent-plugins · 78 tokens

bmad-github-story-create

Sync GitHub state then plan the next story end-to-end via the BMAD create-story flow. Detects blocking dependencies via GitHub labels and updates the GitHub issue label to ready. Use when the user invokes the SC menu code in bmad help, or asks to plan/create the next story, or asks to start the next BMAD story.

choucrifahed/agent-plugins · 78 tokens

bmad-github-story-sync

Reconcile GitHub state with BMAD files — detect merged PRs, mark stories done in sprint-status.yaml and story files, sync GitHub labels, and clean up worktrees and branches. Use when the user invokes the SS menu code in bmad help, or asks to sync BMAD with GitHub, or just merged a PR and wants BMAD updated.

choucrifahed/agent-plugins · 81 tokens

bmad-github-story-review

Run BMAD adversarial code review on the current story branch and push fixes. Does NOT mark the story done — the user merges the PR on GitHub. Use when the user invokes the SR menu code in bmad help, or asks to code-review the current story, or asks for an adversarial review of the open story PR.

choucrifahed/agent-plugins · 75 tokens