

























假设我们要写一个审查当前未提交改动的 skill。用 ox-skills 的方式,Org 文件长这样,
#+SKILL_NAME: git-review #+SKILL_DESCRIPTION: Review current uncommitted changes and suggest improvements #+SKILL_ALLOWED_TOOLS: Bash Read #+SKILL_USER_INVOCABLE: true #+SKILL_BASE_DIR: ~/.claude/skills Review the current uncommitted changes for: 1. *Bugs*: Logic errors, edge cases, missing error handling 2. *Style*: Naming, function length, code organization 3. *Security*: Input validation, injection risks Be constructive. Prioritize findings by severity. * Current changes #+begin_src sh :inject yes git diff HEAD #+end_src
按 C-c C-e s s (或者 M-x org-export-dispatch 选 s s )导出后,ox-skills 在 ~/.claude/skills/git-review/SKILL.md 生成这样的文件,
name: git-review description: Review current uncommitted changes and suggest improvements allowed-tools: [Bash, Read] user-invocable: true Review the current uncommitted changes for: 1. **Bugs**: Logic errors, edge cases, missing error handling 2. **Style**: Naming, function length, code organization 3. **Security**: Input validation, injection risks Be constructive. Prioritize findings by severity. ```! git diff HEAD ```
对比源文件和产物,能看出 ox-skills 做了什么。 #+SKILL_* 关键字变成 YAML frontmatter 里的对应字段,Org 的正文变成 Markdown 正文, *Current changes* 标题变成 ## Current changes ,加了 :inject yes 的 src block 变成了带叹号的代码围栏(区别于普通的代码围栏)。
带叹号的代码围栏是关键差异。普通代码块是静态内容,带叹号的围栏会被 Claude Code / OpenCode 在调用 skill 时实际执行,把运行结果注入到上下文里。你调用 git-review skill 的时候,AI 工具先跑 git diff HEAD ,拿到当前改动,再基于这个结果做审查。手写 SKILL.md 也可以直接写带叹号的围栏,但 ox-skills 让你用 Org 语法( :inject yes )来表达,跟其他 src block 的写法一致。
*关键词对照。 * ox-skills 支持的 #+SKILL_* 关键字和对应的 YAML 字段如下,
| Org 关键字 | YAML 字段 | 类型 |
|---|---|---|
#+SKILL_NAME |
name |
字符串 |
#+SKILL_DESCRIPTION |
description |
字符串 |
#+SKILL_WHEN_TO_USE |
when_to_use |
字符串 |
#+SKILL_ALLOWED_TOOLS |
allowed-tools |
列表(空格分隔) |
#+SKILL_USER_INVOCABLE |
user-invocable |
布尔( true=/=false ) |
#+SKILL_MODEL |
model |
字符串 |
#+SKILL_EFFORT |
effort |
字符串 |
上表是常用字段,完整列表(含 SKILL_ARGUMENTS 、 SKILL_CONTEXT 、 SKILL_AGENT 等)见 项目 README 。另外示例里的 #+SKILL_BASE_DIR 控制输出文件写到哪个目录,它不会被导出到 YAML 里。
列表类型的值用空格分隔,多个词用引号括起来。布尔类型接受 true=/=yes 或 false=/=no 。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。