Skill Doc Formatter | ClawHub
Description
Formats SKILL.md (OpenClaw/Cursor skill docs) for optimal display on ClawHub. Produces a consistent structure—Description, Installation, Usage with benefit-focused examples, and Commands—so skill pages are clear and scannable.
Skill Doc Formatter | ClawHub
Formats SKILL.md skill documentation for optimal display on ClawHub. Output uses a consistent structure so skill pages are easy to scan: Description, Installation, Usage (with examples that showcase benefits), and Commands.
Clear description: what the skill does and when to use it. Scannable.
Installation
CODEBLOCK0
Usage
- - Preparing or updating a skill for publication on ClawHub
- Converting an existing SKILL.md into the ClawHub-recommended layout
- Generating usage examples from a skill's description when examples are missing
- Standardizing multiple skills to the same doc structure
- 1. Step or scenario one.
- Step or scenario two.
- When to run which command (point to Commands below).
Examples
Example 1: [benefit]
Scenario: User wants to do X.
Action: Run your-command --foo.
Outcome: Brief result that showcases the benefit.
Example 2: [benefit]
(Same pattern.)
Commands
CODEBLOCK1
- - command — Short description.
- other — Short description.
## Target structure (ClawHub-optimized)
The formatter produces or normalizes these sections:
| Section | Purpose |
|--------|--------|
| **Description** | One clear blurb (from frontmatter `description` + optional short intro). What the skill does and when to use it. |
| **Installation** | How to install: `clawhub install <skill>`, `git clone`, or other steps. Copy-paste ready. |
| **Usage** | How to use the skill: steps, scenarios, or workflow. Concise. |
| **Examples** | Concrete examples that showcase benefits (e.g. before/after, sample commands with outcomes). Generated if missing. |
| **Commands** | All CLI commands in one block with brief descriptions. Absolute paths or placeholders like `<skill-dir>`. |
## How to run
From the skill you want to format, or from the formatter skill:
bash
Format a skill by path (output to stdout)
python3 /path/to/skill-doc-formatter/scripts/format
skilldoc.py /path/to/other-skill/SKILL.md
Write formatted result back to a new file
python3 scripts/format
skilldoc.py /path/to/skill/SKILL.md -o /path/to/skill/SKILL.clawhub.md
Use formatter's own SKILL.md as input (demo)
python3 scripts/format
skilldoc.py SKILL.md
Options:
- `-o FILE` — Write output to FILE instead of stdout.
- `--generate-examples` — Generate example usage blocks from the description when Examples section is missing or thin.
- `--inplace` — Overwrite the input SKILL.md with the formatted version (use with care; prefer `-o` for review).
- `--security-check` — Run security review checks after formatting to identify ClawHub security scan issues.
## Security Review
The formatter includes a security review checker (`security_review.py`) that helps identify issues that may cause ClawHub security scans to flag skills as "Suspicious". Run it with:
bash
python3 scripts/security_review.py
Or use the `--security-check` flag when formatting:
bash
python3 scripts/formatskilldoc.py /SKILL.md --security-check
The security review checks for:
- **Missing Requirements**: Skills that use system dependencies (CLI tools like `openclaw`, `lsof`, `ps`, `launchctl`) but don't declare them in SKILL.md
- **Secret Logging**: Commands or values containing secrets/tokens/passwords being written to log files
- **Missing Files**: Install scripts referencing files that don't exist in the skill package
- **Environment Variables**: Scripts using env vars that aren't documented
- **Persistent Behavior**: LaunchAgent/daemon installations without `always: true` in `_meta.json`
- **File Permissions**: Log files containing sensitive data without restricted permissions
- **Metadata vs docs consistency**: Env vars in `_meta.json` `env` (required) vs `optionalEnv` must match SKILL.md/README (no "optional" for required, no "required" for optional)
- **openclaw.json read disclosure**: If scripts read `openclaw.json`, SKILL.md/README must disclose it and which fields are used; recommend a "Before installing" / "verify you are comfortable granting read access" note
- **CLI vs safe subprocess**: If docs show CLI examples with user-supplied task/message in quotes (e.g. `spawn --json "..."`), docs must warn that programmatic use must use subprocess with a list of arguments (no shell interpolation)
**Common fixes for ClawHub security reviews:**
1. **Add Requirements section** listing all CLI tools and system dependencies
2. **Mask secrets in logs** - don't log full command strings with `--token` or `--password` arguments
3. **Document environment variables** in SKILL.md Requirements section
4. **Add `always: true`** to `_meta.json` if the skill runs persistently (LaunchAgent/daemon)
5. **Set restrictive permissions** on log files containing sensitive data (`os.chmod(log_path, 0o600)`)
6. **Align env metadata and docs** - Keep `requires.env` / `optionalEnv` in `_meta.json` in sync with SKILL.md/README (required vs optional)
7. **Disclose openclaw.json reads** - State which fields are read (e.g. `tools.exec.host` / `tools.exec.node` only) and add "Before installing, verify you are comfortable granting read access to that file"
8. **Warn about safe invocation** - Above Commands/CLI, add that bash examples are for manual/CLI use only and that from code callers must use `subprocess.run(..., [..., user_message], ...)` with a list of arguments
## What the script does
1. **Parse** the existing SKILL.md (YAML frontmatter + markdown body).
2. **Map** existing `##` sections to Description / Installation / Usage / Examples / Commands (by title and content).
3. **Normalize** section order and headings to the ClawHub structure.
4. **Extract or generate**:
- Description: frontmatter `description` + first paragraph or intro.
- Installation: looks for "install", "clawhub", "clone", "npm" etc.; otherwise adds a placeholder.
- Usage: keeps or merges "Usage", "When to use", "How to use" content.
- Examples: keeps existing examples; with `--generate-examples`, adds 1–2 benefit-focused examples from the description.
- Commands: collects fenced bash/code blocks and list items that look like CLI commands; merges into one **Commands** section.
5. **Emit** a single markdown document with clean headings and optional table of contents.
6. **Security Review** (optional): Run security checks to identify issues that may affect ClawHub security scans.
## Manual template
If you prefer to edit by hand, use this structure in your SKILL.md:
markdown
name: your-skill
displayName: Your Skill | OpenClaw Skill
description: One-sentence description. Use when [trigger scenarios].
version: 1.0.0
Your Skill Name
Short intro: what it does and why it matters (1–2 sentences).
Requirements
- - Python 3.7+
- Input: valid SKILL.md with YAML frontmatter (at least
name, description).
Files in this skill
- -
SKILL.md — This file (instructions for the formatter skill). - INLINECODE4 — Parser and formatter script.
- INLINECODE5 — Copy-paste template for ClawHub-optimized SKILL.md.
Skill Doc Formatter | ClawHub
描述
格式化 SKILL.md(OpenClaw/Cursor 技能文档),使其在 ClawHub 上获得最佳展示效果。生成一致的结构——描述、安装、使用(附有突出优势的示例)和命令——确保技能页面清晰且易于浏览。
Skill Doc Formatter | ClawHub
格式化 SKILL.md 技能文档,使其在 ClawHub 上获得最佳展示效果。输出采用一致的结构,便于技能页面快速浏览:描述、安装、使用(附有展示优势的示例)和命令。
清晰的描述:说明技能的功能及使用场景。易于浏览。
安装
bash
clawhub install your-skill
或:git clone https://github.com/Org/your-skill.git workspace/skills/your-skill
使用
- - 准备或更新要在 ClawHub 上发布的技能
- 将现有的 SKILL.md 转换为 ClawHub 推荐的布局
- 当缺少示例时,根据技能描述生成使用示例
- 将多个技能标准化为相同的文档结构
- 1. 步骤或场景一。
- 步骤或场景二。
- 何时运行哪个命令(指向下方的命令部分)。
示例
示例 1:[优势]
场景: 用户想要执行 X 操作。
操作: 运行 your-command --foo。
结果: 展示优势的简要结果。
示例 2:[优势]
(相同模式。)
命令
bash
python3 /scripts/script.py command [options] # 功能说明
python3 /scripts/script.py other # 功能说明
- - command — 简短描述。
- other — 简短描述。
目标结构(ClawHub 优化版)
格式化程序生成或规范化以下部分:
| 部分 | 目的 |
|---|
| 描述 | 一段清晰的说明(来自前置元数据 description 加上可选的简短介绍)。说明技能的功能及使用场景。 |
| 安装 |
如何安装:clawhub install
、git clone 或其他步骤。可直接复制粘贴。 |
| 使用 | 如何使用技能:步骤、场景或工作流程。简洁明了。 |
| 示例 | 展示优势的具体示例(例如前后对比、带结果的示例命令)。如果缺少则自动生成。 |
| 命令 | 所有 CLI 命令集中在一个代码块中,附有简短描述。使用绝对路径或 等占位符。 |
如何运行
从要格式化的技能目录或格式化技能目录运行:
bash
按路径格式化技能(输出到标准输出)
python3 /path/to/skill-doc-formatter/scripts/formatskilldoc.py /path/to/other-skill/SKILL.md
将格式化结果写入新文件
python3 scripts/formatskilldoc.py /path/to/skill/SKILL.md -o /path/to/skill/SKILL.clawhub.md
使用格式化程序自身的 SKILL.md 作为输入(演示)
python3 scripts/formatskilldoc.py SKILL.md
选项:
- - -o FILE — 将输出写入文件而非标准输出。
- --generate-examples — 当示例部分缺失或内容不足时,根据描述生成示例使用块。
- --inplace — 用格式化版本覆盖输入的 SKILL.md(谨慎使用;建议使用 -o 进行审查)。
- --security-check — 格式化后运行安全审查检查,以识别 ClawHub 安全扫描问题。
安全审查
格式化程序包含一个安全审查检查器(security_review.py),可帮助识别可能导致 ClawHub 安全扫描将技能标记为可疑的问题。运行方式:
bash
python3 scripts/security_review.py
或在格式化时使用 --security-check 标志:
bash
python3 scripts/formatskilldoc.py /SKILL.md --security-check
安全审查检查以下内容:
- - 缺少依赖声明:使用系统依赖项(CLI 工具如 openclaw、lsof、ps、launchctl)但未在 SKILL.md 中声明的技能
- 秘密日志记录:包含密钥/令牌/密码的命令或值被写入日志文件
- 缺少文件:安装脚本引用了技能包中不存在的文件
- 环境变量:脚本使用了未记录的环境变量
- 持久行为:LaunchAgent/守护进程安装但未在 meta.json 中设置 always: true
- 文件权限:包含敏感数据的日志文件未设置限制性权限
- 元数据与文档一致性:meta.json 中的 env(必需)与 optionalEnv(可选)环境变量必须与 SKILL.md/README 一致(必需变量不能标记为可选,可选变量不能标记为必需)
- openclaw.json 读取披露:如果脚本读取 openclaw.json,SKILL.md/README 必须披露此行为并说明读取了哪些字段;建议添加安装前 / 确认您愿意授予读取权限的说明
- CLI 与安全子进程:如果文档展示了包含用户提供的任务/消息(例如 spawn --json ...)的 CLI 示例,文档必须警告程序化使用必须使用带参数列表的 subprocess(无 shell 插值)
ClawHub 安全审查的常见修复方法:
- 1. 添加依赖声明部分,列出所有 CLI 工具和系统依赖项
- 在日志中屏蔽密钥——不要记录包含 --token 或 --password 参数的完整命令字符串
- 在 SKILL.md 的依赖声明部分记录环境变量
- 如果技能持续运行(LaunchAgent/守护进程),在 meta.json 中添加 always: true
- 对包含敏感数据的日志文件设置限制性权限(os.chmod(logpath, 0o600))
- 保持环境变量元数据与文档一致——确保 meta.json 中的 requires.env / optionalEnv 与 SKILL.md/README 同步(必需 vs 可选)
- 披露 openclaw.json 读取行为——说明读取了哪些字段(例如仅读取 tools.exec.host / tools.exec.node),并添加安装前,请确认您愿意授予对该文件的读取权限
- 警告安全调用方式——在命令/CLI 部分上方添加说明,指出 bash 示例仅适用于手动/CLI 使用,代码调用者必须使用带参数列表的 subprocess.run(..., [..., usermessage], ...)
脚本功能
- 1. 解析 现有的 SKILL.md(YAML 前置元数据 + Markdown 正文)。
- 映射 现有的 ## 部分到描述/安装/使用/示例/命令(根据标题和内容)。
- 规范化 部分顺序和标题,使其符合 ClawHub 结构。
- 提取或生成:
- 描述:前置元数据 description + 第一段或介绍。
- 安装:查找install、clawhub、clone、npm等关键词;否则添加占位符。
- 使用:保留或合并使用、何时使用、如何使用的内容。
- 示例:保留现有示例;使用 --generate-examples 时,根据描述添加 1-2 个突出优势的示例。
- 命令:收集所有围栏 bash/代码块和看起来像 CLI 命令的列表项;合并到一个命令部分。
- 5. 输出 一个带有清晰标题和可选目录的单一 Markdown 文档。
- 安全审查(可选):运行安全检查,识别可能影响 ClawHub 安全扫描的问题。
手动模板
如果您更喜欢手动编辑,请在 SKILL.md 中使用以下结构:
markdown
name: your-skill
displayName: Your Skill | OpenClaw Skill
description: 一句话描述。在[触发场景]时使用。
version: 1.0.0
您的技能名称
简短介绍:功能说明及其重要性(1-2 句话)。
依赖声明
- - Python 3.7+
- 输入:有效的 SKILL.md,包含 YAML 前置元数据(至少包含 name、description)。
技能文件
- - SKILL.md — 本文件(格式化技能的使用说明)。
- scripts/formatskilldoc.py — 解析和格式化脚本。
- TEMPLATECLAWHUBSKILL.md — 适用于 ClawHub 优化的 SKILL.md 的复制粘贴模板。