build-api

build-api is a command for coding agents from dhslegen/digital-delivery-team. It costs 35 tokens per session (2,154 once invoked), scanned B, original, MIT.

A command for implementing backend APIs from an API contract and data-model documents. An API contract describes how software communicates, while a data model describes the data it stores and uses.

In plain words
What is it for?
Use it to build server-side API code from docs/api-contract.yaml and docs/data-model.md, run validation checks, and verify the result.
Why use it?
It provides a visible sequence for exploring the project, planning, implementing, checking, and summarizing the backend work. It also checks required files and API-contract rules before coding.

Command

Part of the digital-delivery-team plugin — 13 skills, 21 commands, 9 agents, 8 hooks shipped together

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 commands/dhslegen/digital-delivery-team/build-api
Clone the repo
git clone --depth 1 https://github.com/dhslegen/digital-delivery-team

Or install digital-delivery-team, the plugin that ships this one along with the rest of its 13 skills, 21 commands, 9 agents, 8 hooks.

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 build-api

README.md
[![agentmods](https://agentmods.dev/badge/commands/dhslegen/digital-delivery-team/build-api.svg)](https://agentmods.dev/commands/dhslegen/digital-delivery-team/build-api)
Your own site
<a href="https://agentmods.dev/commands/dhslegen/digital-delivery-team/build-api"><img src="https://agentmods.dev/badge/commands/dhslegen/digital-delivery-team/build-api.svg" alt="Measured on agentmods" height="20"></a>
Per session 35 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,154 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 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.00035 $0.02154
Opus 5 $0.00017 $0.01077
Sonnet 5 $0.00007 $0.00431
Haiku 4.5 $0.00003 $0.00215

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

Security

Grade B, and why

build-api scanned grade B with 2 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 4d 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

[ -f "$DDT_PLUGIN_ROOT/bin/aggregate.mjs" ] || DDT_PLUGIN_ROOT=$(cat "${HOME}/.claude/delivery-metrics/.ddt-plugin-root" 2>/dev/null)

Makes network callslowCapability

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

curl http://localhost:3001/health
commands/build-api.md · 223 lines

How it starts

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

/build-api

docs/api-contract.yamldocs/data-model.md 实现后端 API。M6.4 起改用 main thread + 6-phase 范式,每步流式可见,每文件 validation,每 step checkpoint commit。

输入:$ARGUMENTS


Phase 1 — 前置校验

test -f docs/api-contract.yaml || { echo "❌ 请先运行 /design"; exit 1; }
test -f docs/data-model.md || { echo "❌ 请先运行 /design 生成数据模型"; exit 1; }
[ -f "$DDT_PLUGIN_ROOT/bin/aggregate.mjs" ] || DDT_PLUGIN_ROOT=$(cat "${HOME}/.claude/delivery-metrics/.ddt-plugin-root" 2>/dev/null)
[ -f "$DDT_PLUGIN_ROOT/bin/aggregate.mjs" ] || DDT_PLUGIN_ROOT="${HOME}/.claude/plugins/marketplaces/digital-delivery-team"
[ -f "$DDT_PLUGIN_ROOT/bin/aggregate.mjs" ] || { echo "❌ DDT plugin root 未解析,请重启会话或运行 /digital-delivery-team:doctor"; exit 1; }
export DDT_PLUGIN_ROOT
if printf '%s' "$ARGUMENTS" | grep -q -- '--dry-run'; then
  node "$DDT_PLUGIN_ROOT/bin/print-dry-run.mjs" --phase build-api --inputs "docs/api-contract.yaml,docs/data-model.md,.ddt/tech-stack.json" --outputs "server/" --next "/verify"
  exit 0
fi
node "$DDT_PLUGIN_ROOT/bin/emit-phase.mjs" --phase build-api --action start
"$DDT_PLUGIN_ROOT/bin/check-blockers.sh" || exit 2

# 契约 lint 硬门禁
if command -v npx >/dev/null 2>&1; then
  npx --yes @redocly/cli lint docs/api-contract.yaml || exit 4
else
  echo "OpenAPI lint tool missing"; exit 5
fi

Phase 2 — EXPLORE(理解现有代码)

main thread 必读

  • skills/backend-development/SKILL.md(实现知识包)
  • docs/api-contract.yaml + docs/data-model.md
  • .ddt/tech-stack.json

EXPLORE 行动

如果 server/ 已存在:用 Grep / Glob / Read 扫描结构、找类似实现作参照。 如果 server/ 为空或缺失:跑 tech-stack.json::backend.scaffold_cmd 生成骨架。

落盘 docs/build-api-exploration.md(用户可见 — 去黑盒):

# Build-API Exploration

## 现有代码扫描结果
- 已有文件: <count>
- 框架: <detected>
- 测试套: <jest/vitest/junit/...>

## 类似实现参照
- <文件路径>: <pattern>

## 复用清单
- 复用: <类/函数>
- 不复用 + 原因: <...>

## 集成点
- DB 连接: <文件:行号>
- 错误处理: <middleware 位置>
- 日志: <logger 实例>

Phase 3 — PLAN(implementation blueprint)

skills/backend-development/SKILL.md::Phase 2 PLANdocs/build-api-plan.md

  • Files to Create / Modify 表
  • Build Sequence(按依赖序:types → db → service → routing → middleware → entry)
  • Validation Strategy(每步要跑什么 validation 命令)
  • 估算时间

Read the full file on GitHub · 223 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. 4d ago First seen · 223 lines · 35 tokens per session scan B ef8b1aeafefc

Subscribe to this mod's changes

build-api is a command published in the GitHub repository dhslegen/digital-delivery-team (1 stars, last pushed 3mo ago), licensed MIT. It adds 35 tokens to every session and 2,154 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 2 findings (reads agent configuration directories, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.