Skill Doctor | OpenClaw Skill
Scans workspace/skills (or a given folder) to detect missing and unused Python dependencies, can fix requirements.txt (add missing, optionally remove unused), and can test a skill using the skill-tester in sandbox (default) or no-sandbox mode.
Description
- - Scan: For each skill, finds all Python files under the skill and its
scripts/ folder, extracts top-level imports, and compares them to requirements.txt. Reports:
-
Missing: Imported but not listed in requirements (suggests adding).
-
Unused: Listed in requirements but not imported (suggests removing).
- - Fix: Adds missing packages to
requirements.txt and/or removes unused ones (--fix-unused). - Test: Runs the skill-tester for the given skill. Use
--no-sandbox to run tests with full environment (e.g. network); default runs in sandbox.
Stdlib modules and local modules (same skill’s .py files) are excluded from “missing”.
Installation
CODEBLOCK0
Or clone into your skills directory:
CODEBLOCK1
Usage
CODEBLOCK2
Commands
| Command / flags | Description |
|---|
| INLINECODE8 | Scan skills and report missing/unused dependencies (default if no --fix/--test) |
| INLINECODE11 |
Limit to one skill |
|
--fix | Add missing packages to
requirements.txt |
|
--fix-unused | With
--fix, also remove unused packages |
|
--dry-run | With
--fix: only report what would be done |
|
--test | Run skill-tester for the skill |
|
--no-sandbox | Run tests with full env (no sandbox) |
|
--timeout N | Test timeout in seconds (default 60) |
|
--json | Output JSON |
|
--skills-dir PATH | Override skills root (default:
workspace/skills) |
What this skill does
- 1. Discover skills — Finds dirs with
SKILL.md or _meta.json under the skills folder. - Parse Python — Uses
ast to collect top-level import / import from names from all .py files in the skill and scripts/. - Exclude stdlib and local — Ignores standard library modules and local modules (same skill’s file names).
- Map to pip — Maps import names to pip package names (e.g.
bs4 → beautifulsoup4, yaml → PyYAML). - Compare — Compares required (from
requirements.txt) vs needed (from imports); reports missing and unused. - Fix — Writes
requirements.txt: append missing packages; optionally remove unused lines. - Test — Invokes
skill-tester/scripts/skill_tester.py --skill SLUG --json. Sandbox vs no-sandbox is controlled by --no-sandbox and the OPENCLAW_DOCTOR_NO_SANDBOX env var for the test run.
Requirements
- - Python 3.7+
- Optional: skill-tester for
--test (must be present under workspace/skills/skill-tester).
Security & privacy
- - Reads: Skill directories and their
.py and requirements.txt files. - Writes: Only
requirements.txt when using --fix (and --fix-unused). - Test: Runs skill-tester in a subprocess;
--no-sandbox means tests run with the current environment (e.g. network allowed).
技能医生 | OpenClaw 技能
扫描 workspace/skills(或指定文件夹)以检测缺失和未使用的 Python 依赖项,可以修复 requirements.txt(添加缺失项,可选移除未使用项),并可以使用沙箱(默认)或非沙箱模式通过技能测试器测试技能。
描述
- - 扫描: 针对每个技能,查找技能及其 scripts/ 文件夹下的所有 Python 文件,提取顶级导入,并与 requirements.txt 进行比较。报告:
-
缺失: 已导入但未在 requirements 中列出(建议添加)。
-
未使用: 在 requirements 中列出但未导入(建议移除)。
- - 修复: 将缺失的包添加到 requirements.txt 和/或移除未使用的包(--fix-unused)。
- 测试: 为指定技能运行技能测试器。使用 --no-sandbox 在完整环境下运行测试(例如网络);默认在沙箱中运行。
标准库模块和本地模块(同一技能的 .py 文件)不会被视为缺失。
安装
bash
clawhub install skill-doctor
或克隆到你的技能目录:
bash
git clone https://github.com/Org/skill-doctor.git workspace/skills/skill-doctor
用法
bash
扫描所有技能(或默认:扫描)
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py
扫描单个技能
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --skill SUBAGENT-DASHBOARD --scan
修复:将缺失的依赖添加到 requirements.txt
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --skill MY-SKILL --fix
修复:添加缺失并移除未使用的
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --skill MY-SKILL --fix --fix-unused
试运行修复(仅报告)
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --skill MY-SKILL --fix --fix-unused --dry-run
测试技能(沙箱)
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --skill gateway-guard --test
测试技能(非沙箱:完整环境)
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --skill gateway-guard --test --no-sandbox
JSON 输出
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --scan --json
python3 workspace/skills/skill-doctor/scripts/skill_doctor.py --skill X --test --json
命令
| 命令/标志 | 描述 |
|---|
| --scan | 扫描技能并报告缺失/未使用的依赖(如果没有 --fix/--test 则为默认) |
| --skill SLUG |
限制为单个技能 |
| --fix | 将缺失的包添加到 requirements.txt |
| --fix-unused | 与 --fix 一起使用,同时移除未使用的包 |
| --dry-run | 与 --fix 一起使用:仅报告将要执行的操作 |
| --test | 为技能运行技能测试器 |
| --no-sandbox | 在完整环境下运行测试(无沙箱) |
| --timeout N | 测试超时时间(秒,默认 60) |
| --json | 输出 JSON |
| --skills-dir PATH | 覆盖技能根目录(默认:workspace/skills) |
此技能的功能
- 1. 发现技能 — 在技能文件夹下查找包含 SKILL.md 或 meta.json 的目录。
- 解析 Python — 使用 ast 从技能和 scripts/ 中的所有 .py 文件收集顶级 import / import from 名称。
- 排除标准库和本地模块 — 忽略标准库模块和本地模块(同一技能的文件名)。
- 映射到 pip — 将导入名称映射到 pip 包名称(例如 bs4 → beautifulsoup4,yaml → PyYAML)。
- 比较 — 比较所需的(来自 requirements.txt)与需要的(来自导入);报告缺失和未使用的。
- 修复 — 写入 requirements.txt:追加缺失的包;可选移除未使用的行。
- 测试 — 调用 skill-tester/scripts/skilltester.py --skill SLUG --json。沙箱与非沙箱由 --no-sandbox 和测试运行的 OPENCLAWDOCTORNO_SANDBOX 环境变量控制。
要求
- - Python 3.7+
- 可选:技能测试器 用于 --test(必须存在于 workspace/skills/skill-tester 下)。
安全与隐私
- - 读取: 技能目录及其 .py 和 requirements.txt 文件。
- 写入: 仅在使用 --fix(和 --fix-unused)时写入 requirements.txt。
- 测试: 在子进程中运行技能测试器;--no-sandbox 表示测试在当前环境下运行(例如允许网络)。