Coding Agent Skills

Skills 是 coding agent 中把高频任务的最佳实践、约束规则和工具链封装成可复用能力模块的机制,核心是 SKILL.md + references + scripts + assets 的渐进式加载结构。

#tech / ai #type / concept #status / growing

[!info] related notes

Coding Agent Skills

一句话定义

Coding Agent Skills 是把反复编写的长 prompt 沉淀为结构化、可复用的能力包,核心是 SKILL.md(指令)+ references/(知识)+ scripts/(确定性步骤)+ assets/(素材),按需渐进式加载而非全量塞入上下文。

为什么重要

在真实工程中,你经常重复同一类任务:修 bug 前先补测试、PR 前做 code review、架构分析要读特定目录。每次重新写 prompt 既不稳定又浪费时间。Skills 的价值在于:

  • 输出一致性:同一类任务用同一套约束和流程
  • 上下文效率:只在需要时加载,不占用主上下文
  • 团队复用:提交到仓库后团队成员共享

核心结构

skill-name/
├── SKILL.md          # 核心入口:frontmatter (name/description) + 指令正文
├── references/       # 按需加载的知识:schema、API 说明、规则、示例
├── scripts/          # 确定性步骤:bash/python 脚本,防止 LLM 临场发挥不稳定
└── assets/           # 输出素材:模板、样式、logo

渐进式加载机制

  1. 第一层 metadataname + description 决定何时触发
  2. 第二层 SKILL.md:选中后才读核心指令
  3. 第三层支持资源references/scripts/assets/ 按需读取

这是 Skills 省上下文的关键——大块知识放在 references/,脆弱步骤做成 scripts/SKILL.md 保持精炼。

各产品的实现差异

维度CodexClaude Code
入口文件SKILL.md(必须)SKILL.md(必须)
存储位置项目内 skills 目录~/.claude/skills/.claude/skills/
触发方式显式调用或 Codex 隐式选择/skill-name 或 Claude 自动匹配
脚本执行Codex 内置执行Claude Code Bash 工具执行
录制能力Record & Replay(macOS)/run-skill-generator
插件打包可随 Plugin 分发可随 Plugin 分发

Codex 特有

  • Record & Replay:在 macOS 上录制一次操作流程,Codex 自动整理成可复用 Skill
  • Plugin 打包:Skills 可以和 MCP servers、App integrations 一起打包成 Plugin 分发
  • 显式/隐式调用:可以通过 /skills 显式选择,也可以让 Codex 根据 description 自动匹配

Claude Code 特有

  • Slash command 调用/skill-name 直接触发
  • /run-skill-generator:录制项目启动和验证流程,自动生成 Skill
  • .claude/commands/:轻量级替代——纯 prompt 文件变成 /命令名,不需要完整 Skill 目录结构
  • 与 Workflow 联动:Skill 的指令可以要求使用 Workflow 引擎做多 Agent 编排

最小例子

focused-repair/
├── SKILL.md
│   ---
│   description: Use when fixing one explicit blocker with tests first and minimal scope.
│   ---
│   # Focused Repair Pass
│   1. Identify the exact blocker.
│   2. Add or identify a failing test.
│   3. Make the smallest implementation change.
│   4. Run targeted verification.
│   5. Report root cause, files changed, and remaining risks.
├── references/
│   └── repair-checklist.md
└── scripts/
    └── run-targeted-tests.sh

最适合承载什么

类型示例
固定流程focused-repair、PR 前审查、changelog 生成
领域知识 + 输出规范团队代码风格、架构文档模板
需要辅助脚本的任务测试运行、格式化、数据转换

不适合承载什么

  • 单个 API 调用 → 用 MCP tool
  • 单个数据库查询 → 用 function calling
  • 简单的一次性 prompt → 直接写在对话里

最短记忆方式

Skill = Prompt 入口 + Docs 参考 + Scripts 执行 + Assets 素材,按需渐进加载。

创建于 2026/7/4 更新于 2026/7/15