yapi-to-code

yapi-to-code is a skill for Claude Code, Codex from willnie9/agent-skills. It costs 84 tokens per session (2,792 once invoked), scanned A, original, MIT.

A workflow that turns YApi interface documentation into front-end TypeScript files. TypeScript is JavaScript with extra checks, and YApi is a tool for documenting APIs.

In plain words
What is it for?
It helps generate interface modules from one or more YApi links, including types, API calls, mock data, and common create-read-update-delete sets.
Why use it?
It removes repetitive work when translating documented request fields and responses into types, API functions, and mock data that match a project's conventions.

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/willnie9/agent-skills/yapi-to-code
Any agent
npx skills add willnie9/agent-skills --skill yapi-to-code
Clone the repo
git clone --depth 1 https://github.com/willnie9/agent-skills

Made for: Claude Code, Codex.

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 yapi-to-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/willnie9/agent-skills/yapi-to-code.svg)](https://agentmods.dev/skills/willnie9/agent-skills/yapi-to-code)
Your own site
<a href="https://agentmods.dev/skills/willnie9/agent-skills/yapi-to-code"><img src="https://agentmods.dev/badge/skills/willnie9/agent-skills/yapi-to-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,792 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.00084 $0.02792
Opus 5 $0.00042 $0.01396
Sonnet 5 $0.00017 $0.00558
Haiku 4.5 $0.00008 $0.00279

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

Security

Grade A, and why

yapi-to-code 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 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/validate-define.mjs), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

yapi-to-code/SKILL.md · 236 lines

How it starts

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

YApi-to-Code · 接口对接流水线

Auto Mode(无确认模式)

触发:用户输入含任一关键词 → 全跑 / 一气呵成 / auto / yolo / 别问 / 自动,或被 module-flow 委托(auto 透传)。

行为:

  • 跳过 Step 3 类型映射预览(强制 showPreview: false,复杂接口也直接写)
  • 智能发现接口(Step 1.1)自动选分数 ≥ 7 的全要,不弹候选清单
  • validate-define.mjs 失败不阻断(verdict=warn 也继续,落 issues 给上层处理)

保留:

  • 文件冲突时仍弹三选(覆盖/重命名/跳过) —— 这是数据安全,不能默认覆盖
  • 铁律 1-5 不变

本 skill 读取 .claude/skills/project.config.json 获取项目接口目录/响应壳/HTTP 客户端约定。<config.xxx> 占位指向该配置;Step 0 同时做"现场探测兜底"。

决策树

输入形态
  │
  ├─ 单个/多个 YApi URL                  → Step 1.0 直接解析 projectId+apiId
  ├─ 自然语言("xxx 模块的接口")          → Step 1.1 调 yapi_search_apis 模糊搜
  └─ 仅给项目名                          → Step 1.2 调 yapi_list_projects 列接口让用户选

产出形态
  │
  ├─ 简单接口(< 5字段,无嵌套,无枚举)    → 直接写文件
  ├─ 复杂接口(嵌套≥2/含数组对象/含枚举) → Step 3 给用户预览类型映射后再写
  └─ 多接口批量(CRUD 5 件套)             → 按"查询→新增→修改→删除→详情"排序写

工作流

Step 0 · Reconnaissance(自检 + 探测项目风格)

执行任何步骤前先自检:

  1. YApi MCP 可用:调一次 mcp__yapi-auto-mcp__yapi_list_projects 验证。失败立刻告知用户"YApi MCP 未配置"并停止。

  2. 读项目配置:config.conventions.responseWrappers / httpClient / httpClientFile / commonTypesFile,以及 config.structure.cacheDir(接口目录)。

  3. 配置缺字段时回退到 grep 探测:

    # 项目主流响应壳
    grep -rEho "[A-Z][A-Za-z]*Response<" <config.structure.cacheDir>/ | sort | uniq -c | sort -rn | head -5
    # 项目 HTTP 客户端调用方式
    cat <config.conventions.httpClientFile> | head -20
    

    关注:函数签名、请求体位置、是否强制类型断言、错误返回值。

把探测到的"项目主流响应壳 + HTTP 客户端调用方式 + 接口目录约定"记下,后续 Step 2/4 直接沿用。

Step 1 · 拉接口定义

三种入口分支:

Step 1.0 — 精确路径(已知 projectId + apiId)
mcp__yapi-auto-mcp__yapi_get_api_desc({ projectId, apiId })

返回字段速查:method / path / req_params / req_query / req_body_other / res_body / req_body_is_json_schema

批量场景:并行调,按业务语义排序(查询/新增/修改/删除/详情)。

Step 1.1 — 智能发现(只给 projectId + 模块语义)

适用:被 module-flow 调度时,只拿到模块语义和 YApi 项目 ID,自动找出该模块需要的接口

// 1. 从模块语义提关键词组(中英文 + camelCase + kebab-case + 拆词)
const keywords = [semantic, moduleSlug, kebab, ...semantic.split(/\s+/)];

// 2. 并行搜每个关键词
const candidates = await Promise.all(
  keywords.map((kw) =>
    mcp__yapi-auto-mcp__yapi_search_apis({
      projectKeyword: String(projectId),
      nameKeyword: kw,
      limit: 10,
    })
  )
);

// 3. 去重 + 评分 + 给用户候选清单

Read the full file on GitHub · 236 lines

Files

What ships with it

3 files 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. 3d ago First seen · 236 lines · 84 tokens per session scan A b06ca9996c52

Subscribe to this mod's changes

yapi-to-code is a skill published in the GitHub repository willnie9/agent-skills (2 stars, last pushed 2mo ago), licensed MIT. It adds 84 tokens to every session and 2,792 once invoked, about $0.0004 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

ts-sdk-author

Design, build, verify, and publish production-grade TypeScript SDKs as npm packages inside a pnpm monorepo. Covers workspace layout, public API and module boundaries, plugin extension points, branded types and library-tuned tsconfig, tsdown bundling (vs tsup/tsc-only/unbuild), package.json exports with dual ESM+CJS…

mindfold-ai/Trellis · 219 tokens

fest-standalone-workflows

Create and run lightweight standalone WORKFLOW.md loops with fest create workflow, fest next, and fest workflow advance. Use when a user wants step-by-step workflow guidance inside any ordinary directory, explore/design work item, project folder, or thin-start workflow.

Obedience-Corp/festival · 62 tokens

fest-execution

Execute active festival tasks. Use when finding the next task, marking tasks completed/blocked/reset, committing with festival traceability, advancing workflow steps, and validating sequence progress.

Obedience-Corp/festival · 38 tokens

fest-planning

Plan and scaffold festivals. Use when creating festival/phase/sequence/task structure, enforcing naming rules, linking festivals to projects, and promoting lifecycle states.

Obedience-Corp/festival · 34 tokens

regenerate-grpc-stubs

Regenerate Python + TypeScript gRPC stubs after editing proto files. Use when proto/.proto changes, imports from bindu.grpc.generated fail, CI reports generated-code drift, or HandleMessages calls fail with proto mismatch.

GetBindu/Bindu · 52 tokens

campaign-commit

Choose the correct commit command in a campaign workspace. Use when you are about to commit and need to select camp commit, camp p commit, fest commit, or intentional root pointer sync via camp refs-sync.

Obedience-Corp/festival · 49 tokens