Skip to content

Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.

feat(hosts): add Opencode skill discovery and validation (#216)

yhzef510730bc32
diff --git a/README.md b/README.md
index a39fa72..78f0a80 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,7 @@
</p>
<p align="center">
- <strong>Turn any technical book, document folder, or collection of sources into a unified agent skill — ready to study, reference, and use while you work in GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, or OpenClaw.</strong>
-</p>
+<strong>Turn any technical book, document folder, or collection of sources into a unified agent skill — ready to study, reference, and use while you work in GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, OpenCode, or OpenClaw.</strong></p>
<p align="center">
<a href="https://github.com/virgiliojr94/book-to-skill/releases"><img src="https://img.shields.io/github/v/release/virgiliojr94/book-to-skill?style=for-the-badge&color=blueviolet" alt="Latest release"></a>
@@ -67,13 +66,12 @@ The usual workarounds don't help:
Once installed, you just type `/your-book-slug replication` and the agent reads the right chapter and answers from the actual content. No hallucination. No digging through PDFs. The book becomes part of your workflow.
-Works with any host that supports the open [Agent Skills](https://github.com/agentskills/agentskills) standard — GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, and OpenClaw all read the same `SKILL.md` format.
-
+Works with any host that supports the open [Agent Skills](https://github.com/agentskills/agentskills) standard — GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, and OpenCode, OpenClaw all read the same `SKILL.md` format.
---
## 📦 What it generates
-Running `/book-to-skill your-book.pdf` (or a folder, glob, or list of files) creates a full skill in the user-level cross-agent skills directory `~/.agents/skills/<slug>/` — one copy that Copilot CLI, Amp, and Codex discover natively; OpenClaw also discovers it when using its default state directory. With a non-default `OPENCLAW_STATE_DIR`, use the active state's `skills/` root or a workspace/extra directory instead. When run under Claude Code, the converter also attempts a verified symlink at `~/.claude/skills/<slug>/` — Claude Code sees the skill when the link read-back confirms it; otherwise the run report says so. Hermes Agent partitions its personal skills by category and does not scan the cross-agent root, so a Hermes install lands in `$HERMES_HOME/skills/<category>/<slug>/` instead. OpenClaw-managed and project-local destinations remain available when explicitly requested:
+Running `/book-to-skill your-book.pdf` (or a folder, glob, or list of files) creates a full skill in the user-level cross-agent skills directory `~/.agents/skills/<slug>/` — one copy that Copilot CLI, Amp, Codex, OpenCode, and OpenClaw discover natively (OpenCode also reads its own managed root `~/.config/opencode/skills/<slug>/`; OpenClaw also discovers it when using its default state directory, with a non-default `OPENCLAW_STATE_DIR` use the active state's `skills/` root instead). When run under Claude Code, the converter also attempts a verified symlink at `~/.claude/skills/<slug>/` — Claude Code sees the skill when the link read-back confirms it; otherwise the run report says so. Hermes Agent partitions its personal skills by category and does not scan the cross-agent root, so a Hermes install lands in `/skills/<category>/<slug>/` instead. OpenClaw-managed, OpenCode-managed, and project-local destinations remain available when explicitly requested:
| File | Purpose | Size |
|------|---------|------|
@@ -138,6 +136,7 @@ git clone https://github.com/virgiliojr94/book-to-skill.git ~/.claude/skills/boo
# (Copilot CLI: ~/.copilot/skills/ · Amp/cross-agent: ~/.agents/skills/)
# (Hermes Agent: ${HERMES_HOME:-$HOME/.hermes}/skills/<category>/)
# (OpenClaw: ${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/skills/; ~/.agents/skills/ only with default state)
+# (OpenCode: ~/.agents/skills/ — it also reads ~/.config/opencode/skills/)
```
📥 **All hosts, optional extractors, and the standalone CLI → [docs/install.md](docs/install.md)**
@@ -216,7 +215,7 @@ book-to-skill/
│ └── parsers/ # Format-specific parsers (pdf, epub, docx, html, rtf, calibre, text)
├── tools/
│ ├── discovery_tax.py # measures token cost vs context-dump / discovery loop
-│ └── validate_skill.py # checks a generated SKILL.md against host rules (--lens claude|copilot|amp)
+│ └── validate_skill.py # checks a generated SKILL.md against host rules (--lens claude|copilot|amp|hermes|opencode)
├── tests/ # pytest suite (extraction, detection, discovery tax)
├── docs/
│ ├── performance.md # measured benchmarks, discovery tax, cost
@@ -259,3 +258,5 @@ Every sponsor is listed in [BACKERS.md](BACKERS.md). Thank you for keeping open,
## License
MIT — applies to the converter (code + skill definition) in this repository, **not** to any book or document you process with it.
+
+
diff --git a/README.ru.md b/README.ru.md
index 7df037e..f2e94fc 100644
--- a/README.ru.md
+++ b/README.ru.md
@@ -16,8 +16,7 @@
> Чтобы увидеть drift: `git log 903d102..master -- README.md`
<p align="center">
- <strong>Превратите любую техническую книгу, папку документов или набор источников в единый agent skill — чтобы изучать, ссылаться и использовать в GitHub Copilot CLI, Amp, Claude Code, Hermes Agent или OpenClaw.</strong>
-</p>
+<strong>Превратите любую техническую книгу, папку документов или набор источников в единый agent skill — чтобы изучать, ссылаться и использовать в GitHub Copilot CLI, Amp, Claude Code, Hermes Agent или OpenCode, OpenClaw.</strong></p>
<p align="center">
<a href="https://github.com/virgiliojr94/book-to-skill/releases"><img src="https://img.shields.io/github/v/release/virgiliojr94/book-to-skill?style=for-the-badge&color=blueviolet" alt="Latest release"></a>
@@ -71,13 +70,13 @@
После установки: `/your-book-slug replication` — агент читает нужную главу и отвечает из текста. Без галлюцинаций и копания в PDF.
-Работает с хостами open [Agent Skills](https://github.com/agentskills/agentskills) — GitHub Copilot CLI, Amp, Claude Code, Hermes Agent и OpenClaw (общий формат `SKILL.md`).
-
+Работает с хостами open [Agent Skills](https://github.com/agentskills/agentskills) — GitHub Copilot CLI, Amp, Claude Code, Hermes Agent и OpenCode, OpenClaw (общий формат `SKILL.md`).
---
## 📦 Что получается
`/book-to-skill your-book.pdf` (или folder/glob) создаёт skill в директории skills агента (`~/.copilot/skills/<slug>/`, `~/.agents/skills/<slug>/`, `~/.claude/skills/<slug>/`, `$HERMES_HOME/skills/<category>/<slug>/` для Hermes Agent, или `${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/skills/<slug>/` для OpenClaw):
+`/book-to-skill your-book.pdf` (или folder/glob) создаёт skill в директории skills агента (`~/.copilot/skills/<slug>/`, `~/.agents/skills/<slug>/`, `~/.claude/skills/<slug>/` `$HERMES_HOME/skills/<category>/<slug>/` для Hermes Agent или `~/.config/opencode/skills/<slug>/` для OpenCode):
| File | Purpose | Size |
|------|---------|------|
@@ -142,6 +141,7 @@ git clone https://github.com/virgiliojr94/book-to-skill.git ~/.claude/skills/boo
# (Copilot: ~/.copilot/skills/ · Amp: ~/.agents/skills/)
# (Hermes Agent: ${HERMES_HOME:-$HOME/.hermes}/skills/<category>/)
# (OpenClaw: ${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/skills/; ~/.agents/skills/ только в состоянии по умолчанию)
+# (OpenCode: ~/.agents/skills/ — также читает ~/.config/opencode/skills/)
```
📥 **Все хосты → [docs/install.md](docs/install.md)**
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 22de269..a4d1429 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -15,8 +15,7 @@
> 查看差异:`git log 907be50..master -- README.md`
<p align="center">
- <strong>将任意技术书籍、文档文件夹或资料集合,转换为统一的 Agent Skill——可在 GitHub Copilot CLI、Amp、Claude Code、Hermes Agent 或 OpenClaw 中随时学习、查阅并在工作中使用。</strong>
-</p>
+<strong>将任意技术书籍、文档文件夹或资料集合,转换为统一的 Agent Skill——可在 GitHub Copilot CLI、Amp、Claude Code、Hermes Agent 或 OpenCode, OpenClaw 中随时学习、查阅并在工作中使用。</strong></p>
<p align="center">
<a href="https://github.com/virgiliojr94/book-to-skill/releases"><img src="https://img.shields.io/github/v/release/virgiliojr94/book-to-skill?style=for-the-badge&color=blueviolet" alt="Latest release"></a>
@@ -71,13 +70,13 @@
安装后,输入 `/your-book-slug replication`,Agent 会读取对应章节,基于实际内容回答。没有幻觉,不用翻 PDF。书成为你工作流的一部分。
-兼容任何支持开放 [Agent Skills](https://github.com/agentskills/agentskills) 标准的宿主 —— GitHub Copilot CLI、Amp、Claude Code、Hermes Agent 和 OpenClaw 都读取相同的 `SKILL.md` 格式。
-
+兼容任何支持开放 [Agent Skills](https://github.com/agentskills/agentskills) 标准的宿主 —— GitHub Copilot CLI、Amp、Claude Code、Hermes Agent 和 OpenCode, OpenClaw 都读取相同的 `SKILL.md` 格式。
---
## 📦 生成内容
运行 `/book-to-skill your-book.pdf`(或文件夹、glob、文件列表)后,会在 Agent 的 skills 目录下生成完整 skill(Copilot CLI:`~/.copilot/skills/<slug>/`;Amp 或跨 Agent:`~/.agents/skills/<slug>/`;Claude Code:`~/.claude/skills/<slug>/`;Hermes Agent:`$HERMES_HOME/skills/<category>/<slug>/`;OpenClaw:`${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/skills/<slug>/`):
+运行 `/book-to-skill your-book.pdf`(或文件夹、glob、文件列表)后,会在 Agent 的 skills 目录下生成完整 skill(Copilot CLI:`~/.copilot/skills/<slug>/`;Amp 或跨 Agent:`~/.agents/skills/<slug>/`;Claude Code:`~/.claude/skills/<slug>/`;Hermes Agent:`$HERMES_HOME/skills/<category>/<slug>/`;OpenCode:`~/.agents/skills/<slug>/`(目录与其他宿主共享;如需独立,也可用 `~/.config/opencode/skills/<slug>/`)):
| 文件 | 用途 | 大小 |
|------|------|------|
@@ -141,6 +140,7 @@ git clone https://github.com/virgiliojr94/book-to-skill.git ~/.claude/skills/boo
# (Copilot CLI:~/.copilot/skills/ · Amp/跨 Agent:~/.agents/skills/)
# (Hermes Agent:${HERMES_HOME:-$HOME/.hermes}/skills/<category>/)
# (OpenClaw:${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/skills/;~/.agents/skills/ 仅限默认状态)
+# (OpenCode:~/.agents/skills/ —— 同时也读取 ~/.config/opencode/skills/)
```
📥 **所有宿主、可选提取器与独立 CLI → [docs/install.md](docs/install.md)**
diff --git a/SKILL.md b/SKILL.md
index ecc0d97..aebe394 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -1,6 +1,6 @@
---
name: book-to-skill
-description: "Converts books and documents (PDF, EPUB, DOCX, HTML, Markdown, plain text, RTF, MOBI/AZW with Calibre) into structured agent skills, extracting frameworks, mental models, principles, techniques, and anti-patterns. Use when the user wants to study a document through GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, or OpenClaw, apply an author's frameworks while working, or build a reusable knowledge base from a file."
+description: "Converts books and documents (PDF, EPUB, DOCX, HTML, Markdown, plain text, RTF, MOBI/AZW with Calibre) into structured agent skills, extracting frameworks, mental models, principles, techniques, and anti-patterns. Use when the user wants to study a document through GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, OpenCode, or OpenClaw, apply an author's frameworks while working, or build a reusable knowledge base from a file."
---
<!--
@@ -11,6 +11,8 @@ Cross-agent notes (informational; ignored by host agents):
Hermes Agent ($HERMES_HOME/skills, .hermes/skills, .agents/skills),
OpenClaw (${OPENCLAW_STATE_DIR:-~/.openclaw}/skills, .agents/skills, skills/;
~/.agents/skills only with the default state).
+ OpenCode (~/.config/opencode/skills, ~/.claude/skills, .opencode/skills,
+ ~/.agents/skills, .agents/skills).
- `allowed-tools` is intentionally omitted to stay agent-neutral: Copilot CLI uses
`shell`/MCP-server names, Claude uses `Bash`/`Read`/`Write`/`Glob`/`Grep`, Amp
adds `shell_command`. The skill needs shell (to run extract.py) and file
@@ -24,8 +26,7 @@ Transform written knowledge into actionable agent skills by extracting structure
## Philosophy
-Books contain crystallized expertise: frameworks, principles, and techniques that took years to develop. This skill extracts that knowledge into a format GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, OpenClaw, or another compatible agent can leverage repeatedly.
-
+Books contain crystallized expertise: frameworks, principles, and techniques that took years to develop. This skill extracts that knowledge into a format GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, OpenCode, OpenClaw, or another compatible agent can leverage repeatedly.
**Extract structure, not summaries.** A skill isn't a book report. It's a toolkit of:
- Named frameworks (mental models with clear application)
- Actionable principles (rules that guide decisions)
@@ -81,6 +82,8 @@ This converter can run from multiple skill systems. When looking for this conver
10. Hermes Agent project skills: `.hermes/skills/` or `.agents/skills/`
11. OpenClaw personal skills: `${OPENCLAW_STATE_DIR:-~/.openclaw}/skills/` (active state; `~/.agents/skills/` is shared only with the default state)
12. OpenClaw project skills: `.agents/skills/` or `skills/`
+11. OpenCode personal skills: `~/.config/opencode/skills/` or `~/.agents/skills/`
+12. OpenCode project skills: `.opencode/skills/` or `.agents/skills/`
For **generated** book skills, prefer the user-level cross-agent root `~/.agents/skills/` — one physical copy serves the cross-agent hosts and OpenClaw when it uses its default state. Copilot CLI and Amp discover it natively; Claude Code needs a symlink from `~/.claude/skills/<skill_name>` (created in Step 10, see Step 5 for the rules). Pick a host-private or project-local root only when the user explicitly asks for one. `BOOK_TO_SKILL_SCOPE=project` or `personal` can make that choice explicit for automation; do not ask a mandatory scope question merely because both scopes are available.
@@ -162,10 +165,24 @@ CANDIDATES=(
"${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/*/*/book-to-skill/scripts/extract.py
"${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/*/*/*/book-to-skill/scripts/extract.py
"${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/*/*/*/*/book-to-skill/scripts/extract.py
+ "$HOME/.config/opencode/skills/book-to-skill/scripts/extract.py"
"$HERMES_HOME_RESOLVED/skills/book-to-skill/scripts/extract.py"
"$HERMES_HOME_RESOLVED"/skills/*/book-to-skill/scripts/extract.py
)
if [ "${HERMES_AGENT:-}" != true ]; then
+ # Project-local roots are resolved against the git worktree, not the current
+ # directory: an agent can be invoked from anywhere inside the project (e.g.
+ # `src/nested`) and these roots still have to be found — that is how OpenCode
+ # and the other hosts discover project skills. The CWD-relative forms are kept
+ # so the probe also works outside a git repository.
+ if [ -n "$PROJECT_ROOT" ]; then
+ CANDIDATES+=(
+ "$PROJECT_ROOT/.github/skills/book-to-skill/scripts/extract.py"
+ "$PROJECT_ROOT/.claude/skills/book-to-skill/scripts/extract.py"
+ "$PROJECT_ROOT/.agents/skills/book-to-skill/scripts/extract.py"
+ "$PROJECT_ROOT/.opencode/skills/book-to-skill/scripts/extract.py"
+ )
+ fi
CANDIDATES+=(
".github/skills/book-to-skill/scripts/extract.py"
".claude/skills/book-to-skill/scripts/extract.py"
@@ -177,6 +194,7 @@ if [ "${HERMES_AGENT:-}" != true ]; then
"skills"/*/*/*/*/book-to-skill/scripts/extract.py
"skills"/*/*/*/*/*/book-to-skill/scripts/extract.py
"skills"/*/*/*/*/*/*/book-to-skill/scripts/extract.py
+ ".opencode/skills/book-to-skill/scripts/extract.py"
)
if [ -n "$PROJECT_ROOT" ]; then
CANDIDATES+=(
@@ -384,6 +402,11 @@ Choose the destination skill root (`SKILLS_HOME`). First resolve **scope** from
Hermes Agent is the one host that keeps its own personal root: it partitions personal skills by category and does not scan the cross-agent root. Use the active profile's `HERMES_HOME` and choose a category that matches the generated skill's subject. Do not construct profile paths manually. If the user selects a project-local Hermes root, run `hermes skills trust <project-root>` after generation and verify discovery with `hermes skills list`; project skills remain unavailable until the project is trusted.
For OpenClaw, use the active state directory's `skills/` root: `${OPENCLAW_STATE_DIR:-~/.openclaw}/skills/`. The shared `~/.agents/skills` compatibility root is discoverable only when `OPENCLAW_STATE_DIR` is unset or the default `~/.openclaw`; with a non-default state, do not claim that OpenClaw will see a shared-root install. Verify discovery with `openclaw skills list` after generation.
+| **OpenCode** | `~/.agents/skills` (discovered natively; `~/.config/opencode/skills` and `~/.claude/skills` are read too) | `.opencode/skills` → `.agents/skills` → `.claude/skills` |
+
+Hermes Agent is the one host that keeps its own personal root: it partitions personal skills by category and does not scan the cross-agent root. Use the active profile's `HERMES_HOME` and choose a category that matches the generated skill's subject. Do not construct profile paths manually. If the user selects a project-local Hermes root, run `hermes skills trust <project-root>` after generation and verify discovery with `hermes skills list`; project skills remain unavailable until the project is trusted.
+
+OpenCode scans the cross-agent `~/.agents/skills` root natively, so the generated-skill default above already serves it — no symlink and no trust step. It also reads its own managed `~/.config/opencode/skills` root and the Claude compatibility root `~/.claude/skills`; use the OpenCode-managed root only when the user asks for it. Project skills are discovered by walking up from the working directory to the git worktree, so start a new session after generation if the skill does not appear. (`~/.cache/opencode/skills` is the remote-skill download cache from `skills.urls`, not an authoring root — never write a generated skill there.)
Selection rules:
1. Personal install: set `SKILLS_HOME` to `~/.agents/skills` (create the directory if missing). One exception, so the default does not invent a convention in someone else's house: if `~/.agents/skills` does not exist **and** the host's private root already contains skills, use the private root instead and say why in the report.
@@ -391,7 +414,7 @@ Selection rules:
3. **Hermes Agent personal installs use the Hermes row above**, not the cross-agent root, and take no symlink.
4. If the user explicitly asks for a host-private root (`~/.copilot/skills`, `~/.claude/skills`, `~/.config/agents/skills`, `~/.config/amp/skills`), honor it and skip the symlink.
5. If the user explicitly asked for project-local output, use the project-local row for their host.
-6. If the choice requires knowing the host (project-local output, the Hermes personal root, the OpenClaw state root, or the Claude Code symlink) and you cannot identify it, ask: "Which agent are you running in — OpenClaw, Hermes Agent, GitHub Copilot CLI, Amp, Codex, or Claude Code?"
+6. If the choice requires knowing the host (project-local output, the Hermes personal root, the OpenClaw state root, or the Claude Code symlink) and you cannot identify it, ask: "Which agent are you running in — OpenCode, OpenClaw, Hermes Agent, GitHub Copilot CLI, Amp, Codex, or Claude Code?"
7. For OpenClaw personal output, use `${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/skills`. The shared `~/.agents/skills` root is a valid OpenClaw destination only when `OPENCLAW_STATE_DIR` is unset or equals the default `$HOME/.openclaw`; otherwise use the active state root or a project/extra directory.
8. If the user explicitly asks for an OpenClaw-managed personal root, use the active state root and verify discovery with `openclaw skills list`.
@@ -720,6 +743,7 @@ Reload (if your agent doesn't auto-detect new skills):
Amp: restart the session
Hermes Agent: start a new session
OpenClaw: openclaw skills list (new session if watcher disabled)
+ OpenCode: start a new session
Share this skill (optional):
GitHub repo, installable on any host (Step 11): say "publish"
diff --git a/docs/architecture.md b/docs/architecture.md
index 94bc416..6e66f83 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -46,6 +46,8 @@ document into clean text + metadata; the agent turns that into a structured skil
.github/skills/ | .claude/skills/ | .agents/skills/ project-local (any host)
.hermes/skills/<category>/ Hermes project-local
skills/ OpenClaw workspace
+ ~/.config/opencode/skills/ OpenCode (own root; on request)
+ .opencode/skills/ OpenCode project-local
scope: personal vs project-local (Step 5, BOOK_TO_SKILL_SCOPE)
SKILL.md core frameworks + chapter & topic index (~4K)
chapters/*.md on-demand, loaded only when asked
@@ -84,6 +86,7 @@ converter does not infer arbitrary `skills.load.extraDirs`.
| `book_to_skill/sanitize.py` | strips zero-width / Unicode-tag-block characters from extracted text (see Security) |
| `tools/discovery_tax.py` | measures token cost vs context-dump / discovery loop |
| `tools/validate_skill.py` | checks a generated SKILL.md against host rules (`--lens claude\|copilot\|amp\|hermes\|openclaw`) |
+| `tools/validate_skill.py` | checks a generated SKILL.md against host rules (`--lens claude\|copilot\|amp\|hermes\|opencode`) |
| `tools/scan_generated_skill.py` | advisory prompt-injection scan of a generated skill (see Security) |
| `SKILL.md` | the generator spec (Steps 0–10 + fold-in workflow) |
diff --git a/docs/how-it-works.md b/docs/how-it-works.md
index ee75db5..d416104 100644
--- a/docs/how-it-works.md
+++ b/docs/how-it-works.md
@@ -37,7 +37,7 @@ scripts/extract.py <paths…> --mode <technical|text>
│
▼
Skill written to:
- ~/.agents/skills/<slug>/ (cross-agent: Copilot CLI, Amp, Codex)
+ ~/.agents/skills/<slug>/ (cross-agent: Copilot CLI, Amp, Codex, OpenCode)
~/.claude/skills/<slug>/ (symlink → above, attempted under
Claude Code and verified by
read-back; report states the result)
@@ -47,6 +47,10 @@ scripts/extract.py <paths…> --mode <technical|text>
$HERMES_HOME/skills/<category>/<slug>/
(Hermes Agent: its own personal root,
not the cross-agent one, no symlink)
+ ~/.config/opencode/skills/<slug>/
+ (OpenCode: its own managed root,
+ used on request; the cross-agent
+ root above is the default)
/tmp/book_skill_work/ 🗑️ cleaned up
```
diff --git a/docs/index.md b/docs/index.md
index 683a35b..38eac35 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -1,6 +1,5 @@
---
-description: "Turn any book, PDF or EPUB into a structured agent skill for Claude Code, GitHub Copilot CLI, Amp, Hermes Agent and OpenClaw. Named frameworks and decision rules, loaded on demand."
-seo_title: "book-to-skill - Turn Any Book Into an AI Agent Skill"
+description: "Turn any book, PDF or EPUB into a structured agent skill for Claude Code, GitHub Copilot CLI, Amp, Hermes Agent and OpenCode, OpenClaw. Named frameworks and decision rules, loaded on demand."seo_title: "book-to-skill - Turn Any Book Into an AI Agent Skill"
hide:
- navigation
- toc
@@ -13,8 +12,7 @@ hide:
"name": "book-to-skill",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Linux, macOS, Windows",
- "description": "Converts books and documents (PDF, EPUB, DOCX, HTML, Markdown, RTF, MOBI/AZW) into structured, on-demand agent skills for Claude Code, GitHub Copilot CLI, Amp, Hermes Agent and OpenClaw.",
- "url": "https://booktoskill.is-a.dev/",
+"description": "Converts books and documents (PDF, EPUB, DOCX, HTML, Markdown, RTF, MOBI/AZW) into structured, on-demand agent skills for Claude Code, GitHub Copilot CLI, Amp, Hermes Agent and OpenCode, OpenClaw.", "url": "https://booktoskill.is-a.dev/",
"codeRepository": "https://github.com/virgiliojr94/book-to-skill",
"license": "https://opensource.org/licenses/MIT",
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
@@ -63,15 +61,13 @@ Turn any book or document into a structured, on-demand agent skill — named fra
---
- One `SKILL.md` runs on Claude Code, GitHub Copilot CLI, Amp, Hermes Agent, and OpenClaw
- through the open Agent Skills standard.
+One `SKILL.md` runs on Claude Code, GitHub Copilot CLI, Amp, Hermes Agent, and OpenCode, OpenClaw through the open Agent Skills standard.
</div>
## Install
-**As an agent skill** (gives you the `/book-to-skill` command in Claude Code, Copilot CLI, Amp, Hermes Agent, or OpenClaw):
-
+**As an agent skill** (gives you the `/book-to-skill` command in Claude Code, Copilot CLI, Amp, Hermes Agent, OpenCode, or OpenClaw):
```bash
npx skills add virgiliojr94/book-to-skill
# or manually:
diff --git a/docs/install.md b/docs/install.md
index 1f7b201..780dbe8 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -1,13 +1,12 @@
---
-description: "Install book-to-skill as an agent skill for Claude Code, GitHub Copilot CLI, Amp, Codex, Hermes Agent and OpenClaw, or as a standalone pip CLI. Every host path and optional extractor covered."
-seo_title: "Install book-to-skill - Claude Code, Copilot CLI, Amp, Hermes, OpenClaw, or pip"
----
+description: "Install book-to-skill as an agent skill for Claude Code, GitHub Copilot CLI, Amp, Codex, Hermes Agent and OpenCode, OpenClaw, or as a standalone pip CLI. Every host path and optional extractor covered."
+
+seo_title: "Install book-to-skill - Claude Code, Copilot CLI, Amp, Hermes, OpenCode, OpenClaw, or pip"---
## 📥 Install
> **Two ways to use it, do not confuse them:**
-> - **As an agent skill** (the `/book-to-skill` command in Claude Code, Copilot CLI, Amp, Codex, Hermes Agent, or OpenClaw) → **`git clone` into your skills folder** (below). This is what gives you the slash command and the full convert-a-book flow.
-> - **As a standalone CLI** (just the text extractor) → `pip install` it from the repository, then `book-to-skill --help`. This does **not** register the agent skill; it only installs the extraction engine. See [the CLI section](#standalone-cli-pip).
+> - **As an agent skill** (the `/book-to-skill` command in Claude Code, Copilot CLI, Amp, Codex, Hermes Agent, OpenCode, or OpenClaw) → **`git clone` into your skills folder** (below). This is what gives you the slash command and the full convert-a-book flow.> - **As a standalone CLI** (just the text extractor) → `pip install` it from the repository, then `book-to-skill --help`. This does **not** register the agent skill; it only installs the extraction engine. See [the CLI section](#standalone-cli-pip).
The skill follows the open [Agent Skills](https://github.com/agentskills/agentskills) standard, so a single install works for any compatible host.
@@ -55,6 +54,20 @@ The converter probes the active OpenClaw state root and workspace `skills/` layo
```bash
openclaw skills list
```
+**OpenCode**: it scans the shared cross-agent root natively, so the clone above is all it needs:
+
+```bash
+# Cross-agent root (shared with Copilot CLI, Amp and Codex) — recommended:
+git clone https://github.com/virgiliojr94/book-to-skill.git ~/.agents/skills/book-to-skill
+# Or OpenCode's own managed root, if you'd rather keep it separate:
+# git clone https://github.com/virgiliojr94/book-to-skill.git ~/.config/opencode/skills/book-to-skill
+```
+
+OpenCode discovers skills from `~/.agents/skills`, `~/.config/opencode/skills` and
+`~/.claude/skills` (global) and `.opencode/skills`, `.agents/skills`,
+`.claude/skills` (project-local, walking up from your working directory to the
+git worktree). Discovery is automatic — no trust step required. Start a new
+OpenCode session if the skill does not appear immediately.
**Hermes Agent**:
diff --git a/tests/test_opencode_host_support.py b/tests/test_opencode_host_support.py
new file mode 100644
index 0000000..56369b8
--- /dev/null
+++ b/tests/test_opencode_host_support.py
@@ -0,0 +1,285 @@
+"""OpenCode host-discovery contract in the converter spec.
+
+OpenCode has no project-trust gate (unlike Hermes Agent): it discovers skills
+automatically by walking up from the working directory to the git worktree, and
+it reads `~/.config/opencode/skills`, `~/.agents/skills` and `~/.claude/skills`
+as global roots. So these tests cover path discovery plus the guarantee that
+OpenCode does not pick up another host's directory — not trust behavior.
+"""
+
+import os
+from pathlib import Path
+import shlex
+import shutil
+import subprocess
+
+import pytest
+
+
+ROOT = Path(__file__).resolve().parent.parent
+SKILL = (ROOT / "SKILL.md").read_text(encoding="utf-8")
+
+# Candidate bashes, most reliable first. On Windows a bare "bash" cannot be
+# used: CreateProcess resolves bare names against the system directory before
+# PATH, so it always picks C:\Windows\System32\bash.exe — a WSL stub that exits
+# 255 when no distro is installed, even though a perfectly good Git bash sits
+# elsewhere. So we keep absolute candidates and invoke those directly.
+_BASH_CANDIDATES = ["bash", "/usr/bin/bash", "/bin/bash"]
+
+
+def _bash_candidates():
+ cands = list(_BASH_CANDIDATES)
+ if os.name == "nt":
+ # Git for Windows ships a real bash next to git.exe (cmd/git.exe ->
+ # ../../bin/bash.exe). Also honour the same override OpenCode uses.
+ override = os.environ.get("OPENCODE_GIT_BASH_PATH")
+ if override:
+ cands.insert(0, override)
+ git = shutil.which("git")
+ if git:
+ cands.insert(
+ 0,
+ str(Path(git).resolve().parent.parent / "bin" / "bash.exe"),
+ )
+ return cands
+
+
+def _find_bash():
+ """Return a bash that actually executes `bash -c true`, or None.
+
+ Detection must agree with execution, so every candidate is invoked exactly
+ the way the tests will invoke it: `bash -c <script>`.
+ """
+ for cand in _bash_candidates():
+ if not (os.path.isabs(cand) or shutil.which(cand)):
+ continue
+ try:
+ probe = subprocess.run(
+ [cand, "-c", "true"],
+ capture_output=True,
+ timeout=30,
+ )
+ except (OSError, subprocess.SubprocessError):
+ continue
+ if probe.returncode == 0:
+ return cand
+ return None
+
+
+BASH = _find_bash()
+
+# The probe block in SKILL.md is a bash snippet; on hosts with no working bash
+# at all the discovery contract cannot be exercised.
+pytestmark = pytest.mark.skipif(BASH is None, reason="no working bash available")
+
+
+def _extract_probe_script():
+ start = SKILL.index('SCRIPT_PATH=""')
+ end = SKILL.index('\nif [ -z "$SCRIPT_PATH" ]', start)
+ return SKILL[start:end] + '\nprintf "%s" "$SCRIPT_PATH"\n'
+
+
+def _env(tmp_path, home):
+ env = os.environ.copy()
+ env.update({"HOME": str(home)})
+ env.pop("HERMES_AGENT", None)
+ return env
+
+
+def _git_project(tmp_path, name="project"):
+ project = tmp_path / name
+ project.mkdir(parents=True, exist_ok=True)
+ subprocess.run(["git", "init", "-q"], cwd=project, check=True)
+ return project
+
+
+def _touch(path):
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.touch()
+
+
+def _run_probe(cwd, env):
+ # Use the very bash `_find_bash()` validated, so detection and execution can
+ # never disagree.
+ result = subprocess.run(
+ [BASH, "-c", _extract_probe_script()],
+ cwd=cwd,
+ env=env,
+ check=True,
+ capture_output=True,
+ text=True,
+ )
+ return result.stdout
+
+
+def _to_host_path(raw):
+ """Convert a path produced by bash into one the host Python understands.
+
+ Git bash (MSYS) reports Windows paths in its own form — `$HOME` comes back
+ as `/tmp/...` or `/c/Users/...` rather than `C:/Users/...`. Comparing that
+ against a `pathlib` path fails for reasons that have nothing to do with the
+ code under test, so normalise through `cygpath -w` when it is available.
+ """
+ if os.name != "nt" or not raw.startswith("/"):
+ return raw
+ try:
+ out = subprocess.run(
+ [BASH, "-lc", "cygpath -w -- " + shlex.quote(raw)],
+ capture_output=True,
+ text=True,
+ timeout=30,
+ )
+ except (OSError, subprocess.SubprocessError):
+ return raw
+ if out.returncode != 0:
+ return raw
+ return out.stdout.strip()
+
+
+def _resolve(cwd, raw):
+ selected = Path(_to_host_path(raw))
+ if not selected.is_absolute():
+ selected = cwd / selected
+ return selected.resolve()
+
+
+def test_opencode_is_named_as_supported_host():
+ assert "OpenCode" in SKILL
+
+
+ "layout",
+ ["personal-native", "personal-agents", "personal-claude", "project-opencode"],
+)
+def test_opencode_extractor_probe_discovers_supported_layouts(tmp_path, layout):
+ home = tmp_path / "home"
+ project = _git_project(tmp_path)
+ nested = project / "src" / "nested"
+ nested.mkdir(parents=True)
+
+ roots = {
+ "personal-native": home / ".config" / "opencode" / "skills" / "book-to-skill",
+ "personal-agents": home / ".agents" / "skills" / "book-to-skill",
+ "personal-claude": home / ".claude" / "skills" / "book-to-skill",
+ "project-opencode": project / ".opencode" / "skills" / "book-to-skill",
+ }
+ extractor = roots[layout] / "scripts" / "extract.py"
+ _touch(extractor)
+
+ # Every layout is exercised from a NESTED directory on purpose. The probe
+ # must find project-local roots no matter how deep the agent's CWD is —
+ # that is the whole point of walking up to the project root. Running these
+ # from the project root would hide a real discovery failure.
+ raw = _run_probe(nested, _env(tmp_path, home))
+ assert _resolve(nested, raw) == extractor.resolve()
+
+
[email protected]("project_skill_dir", [".opencode", ".agents", ".claude"])
+def test_opencode_project_probe_resolves_project_root_from_nested_cwd(
+ tmp_path, project_skill_dir
+):
+ """Project-local roots must resolve from a deeply nested CWD.
+
+ Regression guard: the probe used to list project roots as bare CWD-relative
+ paths (`.opencode/skills/...`), so it only worked when the agent happened to
+ sit at the project root. OpenCode itself walks up to the git worktree, so
+ the spec has to do the same.
+ """
+ home = tmp_path / "home"
+ project = _git_project(tmp_path)
+ nested = project / "src" / "nested" / "deeper"
+ nested.mkdir(parents=True)
+
+ project_local = (
+ project / project_skill_dir / "skills" / "book-to-skill" / "scripts" / "extract.py"
+ )
+ _touch(project_local)
+
+ raw = _run_probe(nested, _env(tmp_path, home))
+ assert _resolve(nested, raw) == project_local.resolve()
+
+
[email protected]("project_skill_dir", [".opencode", ".agents", ".claude"])
+def test_opencode_project_extractor_is_discoverable(tmp_path, project_skill_dir):
+ home = tmp_path / "home"
+ project = _git_project(tmp_path)
+
+ project_local = (
+ project / project_skill_dir / "skills" / "book-to-skill" / "scripts" / "extract.py"
+ )
+ _touch(project_local)
+
+ raw = _run_probe(project, _env(tmp_path, home))
+ assert _resolve(project, raw) == project_local.resolve()
+
+
+def test_opencode_personal_root_is_reachable_beside_compatibility_roots(tmp_path):
+ """The OpenCode root is probed even when a shared compatibility root exists.
+
+ Probe order is spec-wide (not OpenCode-specific): `~/.claude/skills` is
+ checked before `~/.config/opencode/skills`. This locks in only that the
+ OpenCode root wins once the earlier compatibility roots are absent, so the
+ host can be installed into its own directory without surprises.
+ """
+ home = tmp_path / "home"
+ project = _git_project(tmp_path)
+
+ native = home / ".config" / "opencode" / "skills" / "book-to-skill" / "scripts" / "extract.py"
+ compat = home / ".claude" / "skills" / "book-to-skill" / "scripts" / "extract.py"
+ _touch(native)
+ _touch(compat)
+
+ _run_probe(project, _env(tmp_path, home)) # spec order: compatibility first
+
+ compat.unlink()
+ selected = _resolve(project, _run_probe(project, _env(tmp_path, home)))
+ assert selected == native.resolve()
+
+
+def test_opencode_does_not_execute_hermes_only_project_layout(tmp_path):
+ """A Hermes-only project layout is not an OpenCode discovery root.
+
+ `~/.hermes` is deliberately left empty here: the spec probes the resolved
+ Hermes home unconditionally, so a Hermes install under HOME would be picked
+ up regardless of host. This asserts the project-local half — `.hermes/` is
+ only reachable through the Hermes trust gate, never for OpenCode.
+ """
+ home = tmp_path / "home"
+ home.mkdir(parents=True)
+ project = _git_project(tmp_path)
+
+ _touch(project / ".hermes" / "skills" / "book-to-skill" / "scripts" / "extract.py")
+
+ assert _run_probe(project, _env(tmp_path, home)) == ""
+
+
+def test_opencode_ignores_foreign_project_roots(tmp_path):
+ """`.hermes/` is Hermes-only; OpenCode must not select it."""
+ home = tmp_path / "home"
+ home.mkdir(parents=True)
+ project = _git_project(tmp_path)
+
+ _touch(project / ".hermes" / "skills" / "book-to-skill" / "scripts" / "extract.py")
+ _touch(project / ".github" / "skills" / "book-to-skill" / "scripts" / "extract.py")
+
+ # `.github/skills` is shared and legitimately discoverable, so assert the
+ # Hermes root specifically is not what gets selected.
+ selected = _resolve(project, _run_probe(project, _env(tmp_path, home)))
+ assert ".hermes" not in selected.parts
+
+
+def test_opencode_destination_and_project_roots_are_documented():
+ assert "**OpenCode**" in SKILL
+ assert "~/.config/opencode/skills" in SKILL
+ assert ".opencode/skills" in SKILL
+
+
+def test_opencode_is_in_unknown_host_prompt_and_reload_guidance():
+ # The prompt lists every supported host; new hosts are added as they land
+ # (#209 added OpenClaw), so assert OpenCode's presence rather than the
+ # frozen sentence from before that host list grew.
+ prompt_line = next(
+ line for line in SKILL.splitlines() if "Which agent are you running" in line
+ )
+ assert "OpenCode" in prompt_line
+ assert "OpenCode: start a new session" in SKILL
diff --git a/tests/test_scope_selection_contract.py b/tests/test_scope_selection_contract.py
index 38fe339..878afbd 100644
--- a/tests/test_scope_selection_contract.py
+++ b/tests/test_scope_selection_contract.py
@@ -1,5 +1,6 @@
"""Scope-selection contract documented by the book-to-skill skill."""
+import re
from pathlib import Path
@@ -8,6 +9,38 @@ SKILL = (ROOT / "SKILL.md").read_text(encoding="utf-8")
INSTALL = (ROOT / "docs" / "install.md").read_text(encoding="utf-8")
+def _opencode_table_row() -> str:
+ """The single markdown table row describing the OpenCode host."""
+ rows = [
+ line
+ for line in SKILL.splitlines()
+ if line.lstrip().startswith("|") and "**OpenCode**" in line
+ ]
+ assert len(rows) == 1, f"expected exactly one OpenCode host row, got {rows!r}"
+ return rows[0]
+
+
+def _selection_rules() -> list[str]:
+ """Every numbered line in the `Selection rules:` block, in document order.
+
+ The block ends at the first non-blank line that is not numbered (the
+ `Set SKILLS_HOME ...` paragraph), so a second list restarting at `1.`
+ is still collected and makes the sequence assertion fail.
+ """
+ assert SKILL.count("Selection rules:") == 1, "expected exactly one `Selection rules:` block"
+ tail = SKILL.split("Selection rules:", 1)[1].splitlines()
+ rules: list[str] = []
+ for raw in tail:
+ line = raw.strip()
+ if not line:
+ continue
+ if re.match(r"^\d+\.\s", line):
+ rules.append(line)
+ continue
+ break
+ return rules
+
+
def test_scope_defaults_to_personal_without_a_mandatory_prompt():
assert "preserve the established personal default" in SKILL
assert "Do not ask a mandatory scope question" in SKILL
@@ -25,3 +58,76 @@ def test_personal_destination_does_not_claim_approval_free_writes():
assert "may still require host approval before writing" in SKILL
assert "may require host approval to write inside the project" in INSTALL
assert "no extra approval" not in SKILL
+
+
+def test_skill_has_no_merge_residue():
+ """A bad conflict resolution must not ship a literal HEAD line or a marker."""
+ residue = [n for n, line in enumerate(SKILL.splitlines(), 1) if line.strip() == "HEAD"]
+ assert not residue, f"literal `HEAD` merge residue on line(s) {residue}"
+ for marker in ("<<<<<<<", "=======", ">>>>>>>"):
+ assert marker not in SKILL, f"conflict marker {marker!r} left in SKILL.md"
+
+
+def test_skill_has_exactly_one_selection_rule_list():
+ """#125 replaced the ask-on-fresh-install policy; its residue must not return.
+
+ The list must be ONE contiguous block (no duplicate or orphan rules) and the
+ host-identification prompt in the final rule must name every host the spec
+ supports. The rule count itself is expected to grow as hosts are added
+ (OpenClaw added rules 7-8); asserting a frozen count made this test fail on
+ every host addition (review request, 2026-09-22).
+ """
+ assert "fresh machine" not in SKILL, "pre-#125 `fresh machine` policy text reappeared"
+ assert "ask the user which root to create" not in SKILL, (
+ "pre-#125 `ask the user which root to create` policy text reappeared"
+ )
+ rules = _selection_rules()
+ numbers = [int(re.match(r"^(\d+)\.", rule).group(1)) for rule in rules]
+ assert numbers and numbers == list(range(1, len(numbers) + 1)), (
+ f"`Selection rules:` must be ONE contiguous 1..N list with no gaps or "
+ f"duplicates, got {numbers}"
+ )
+ prompt_rules = [r for r in rules if "Which agent are you running" in r]
+ assert len(prompt_rules) == 1, (
+ f"exactly one rule must ask the user which host they are running, "
+ f"got {len(prompt_rules)}: {[r[:60] for r in prompt_rules]}"
+ )
+ for host in ("Copilot CLI", "Amp", "Codex", "Claude Code"):
+ assert host in prompt_rules[0], f"host prompt must name {host}"
+
+
+def test_personal_default_stays_cross_agent_after_opencode_support():
+ assert 'preserve the established personal default' in SKILL
+ assert "~/.agents/skills" in SKILL
+ rules = _selection_rules()
+ assert "`SKILLS_HOME` to `~/.agents/skills`" in rules[0], (
+ "rule 1 must set SKILLS_HOME to the cross-agent root"
+ )
+
+
+def test_opencode_row_prefers_the_cross_agent_default():
+ """#125 keeps ~/.agents/skills as the personal root; OpenCode is no exception."""
+ row = _opencode_table_row()
+ assert "~/.agents/skills" in row, "OpenCode row must keep the cross-agent personal root"
+ assert row.index("~/.agents/skills") < row.index("~/.config/opencode/skills"), (
+ "OpenCode row must present ~/.agents/skills before the private root"
+ )
+
+
+def test_opencode_prose_has_no_private_root_preference():
+ assert "prefer the OpenCode-managed" not in SKILL, (
+ "the private-root preference contradicts the #125 default"
+ )
+ assert "use the OpenCode-managed root only when the user asks for it" in SKILL, (
+ "OpenCode prose must say the private root is opt-in"
+ )
+
+
+def test_opencode_cache_root_is_not_an_authoring_destination():
+ assert "~/.cache/opencode/skills" not in _opencode_table_row(), (
+ "the download cache must never appear as a host skill root"
+ )
+ if "~/.cache/opencode/skills" in SKILL:
+ assert "not an authoring root" in SKILL, (
+ "when mentioned, the cache must be labelled as a cache, not a destination"
+ )
diff --git a/tests/test_validate_skill.py b/tests/test_validate_skill.py
index 4a6e60d..2390d36 100644
--- a/tests/test_validate_skill.py
+++ b/tests/test_validate_skill.py
@@ -3,6 +3,8 @@
import importlib.util
from pathlib import Path
+import pytest
+
_SPEC = importlib.util.spec_from_file_location(
"validate_skill", Path(__file__).resolve().parent.parent / "tools" / "validate_skill.py"
)
@@ -157,3 +159,82 @@ def test_hermes_lens_rejects_unsupported_identifier_characters(tmp_path):
)
errors, _ = validate_skill.audit(str(p), lens="hermes")
assert any("name:" in error for error in errors)
+
+
+def test_opencode_lens_accepts_standard_skill(tmp_path):
+ p = tmp_path / "SKILL.md"
+ p.write_text(_SKILL, encoding="utf-8")
+ errors, _ = validate_skill.audit(str(p), lens="opencode")
+ assert errors == []
+
+
+def test_opencode_lens_recognizes_documented_frontmatter_keys(tmp_path):
+ # OpenCode documents exactly five keys; anything else is ignored.
+ p = tmp_path / "SKILL.md"
+ p.write_text(
+ "---\n"
+ "name: my-skill\n"
+ "description: A test skill.\n"
+ "license: MIT\n"
+ "compatibility: opencode\n"
+ "metadata:\n"
+ " audience: maintainers\n"
+ "---\n\n# Body\n",
+ encoding="utf-8",
+ )
+ errors, warns = validate_skill.audit(str(p), lens="opencode")
+ assert errors == []
+ assert not [warning for warning in warns if "frontmatter" in warning]
+
+
+def test_opencode_lens_warns_on_keys_it_silently_ignores(tmp_path):
+ p = tmp_path / "SKILL.md"
+ p.write_text(
+ "---\n"
+ "name: my-skill\n"
+ "description: A test skill.\n"
+ "allowed-tools:\n"
+ " - Bash\n"
+ "---\n\n# Body\n",
+ encoding="utf-8",
+ )
+ errors, warns = validate_skill.audit(str(p), lens="opencode")
+ assert errors == []
+ assert any("allowed-tools" in warning for warning in warns)
+
+
+ "name",
+ ["valid_skill", "valid.skill", "-leading", "trailing-", "double--hyphen", "Mixed"],
+)
+def test_opencode_lens_rejects_names_outside_official_pattern(tmp_path, name):
+ p = tmp_path / "SKILL.md"
+ p.write_text(
+ f"---\nname: {name}\ndescription: A test skill.\n---\n\n# Body\n",
+ encoding="utf-8",
+ )
+ errors, _ = validate_skill.audit(str(p), lens="opencode")
+ assert any("name:" in error for error in errors)
+
+
+def test_opencode_lens_accepts_single_hyphen_separators(tmp_path):
+ p = tmp_path / "SKILL.md"
+ p.write_text(
+ "---\nname: git-release-2026\ndescription: A test skill.\n---\n\n# Body\n",
+ encoding="utf-8",
+ )
+ errors, _ = validate_skill.audit(str(p), lens="opencode")
+ assert errors == []
+
+
+def test_opencode_lens_does_not_impose_description_soft_limit(tmp_path):
+ # Hermes warns past 60 chars; OpenCode only enforces the 1024 hard cap.
+ p = tmp_path / "SKILL.md"
+ description = "A " + "long " * 20 + "description."
+ p.write_text(
+ f"---\nname: my-skill\ndescription: {description}\n---\n\n# Body\n",
+ encoding="utf-8",
+ )
+ errors, warns = validate_skill.audit(str(p), lens="opencode")
+ assert errors == []
+ assert not [warning for warning in warns if "description:" in warning]
diff --git a/tools/validate_skill.py b/tools/validate_skill.py
index 303b779..b623535 100644
--- a/tools/validate_skill.py
+++ b/tools/validate_skill.py
@@ -11,6 +11,7 @@ Lenses:
amp — Sourcegraph Amp rules
hermes — Hermes Agent rules
openclaw — OpenClaw rules
+ opencode — OpenCode rules
The SKILL.md format itself is an open standard
(https://github.com/agentskills/agentskills) — `name` + `description` are the
@@ -28,6 +29,11 @@ Refs:
OpenClaw https://docs.openclaw.ai/tools/skills
Usage: python3 tools/validate_skill.py [--lens claude|copilot|amp|hermes|openclaw] [path/to/SKILL.md]
+ Amp https://ampcode.com/manual#skills
+ Hermes https://hermes-agent.nousresearch.com/docs/user-guide/features/skills
+ OpenCode https://opencode.ai/docs/skills
+
+Usage: python3 tools/validate_skill.py [--lens claude|copilot|amp|hermes|opencode] [path/to/SKILL.md]
"""
import argparse
import re
@@ -120,6 +126,28 @@ LENSES = {
"name_pattern": r"[a-z0-9][a-z0-9-]*",
"name_charset": "lowercase letters/digits/hyphens and start with a letter or digit",
},
+ "opencode": {
+ "label": "OpenCode",
+ "tools": set(),
+ # OpenCode recognizes only these five keys; unknown frontmatter is
+ # silently ignored (https://opencode.ai/docs/skills#write-frontmatter).
+ "recognized_keys": {
+ "name", "description", "license", "compatibility", "metadata",
+ },
+ "reserved_name_words": set(),
+ "bash_tool_names": set(),
+ "unknown_tool_severity": "warn",
+ # OpenCode grants tool access through `permission.skill` in
+ # opencode.json, not through `allowed-tools`.
+ "enforces_allowed_tools": False,
+ # Official pattern: 1-64 chars, lowercase alphanumeric with single
+ # hyphen separators (no leading/trailing `-`, no `--`, no dots or
+ # underscores). Stricter than the general Agent Skills default.
+ "name_pattern": r"[a-z0-9]+(-[a-z0-9]+)*",
+ "name_charset": (
+ "1-64 lowercase letters/digits with single hyphen separators"
+ ),
+ },
}
@@ -266,3 +294,5 @@ def main():
if __name__ == "__main__":
main()
+
+