core-fix-skill-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fix Skill Documentation

修复技能文档

Version: 2.1.0 | Last Updated: 2025-01-27
Check and fix missing reference files in dynamic skills.
版本: 2.1.0 | 最后更新: 2025-01-27
检查并修复动态技能中缺失的引用文件。

Usage

使用方法

/fix-skill-docs [crate_name] [--check-only] [--remove-invalid]
Arguments:
  • crate_name
    : Specific crate to check (optional, defaults to all)
  • --check-only
    : Only report issues, don't fix
  • --remove-invalid
    : Remove invalid references instead of creating files
/fix-skill-docs [crate_name] [--check-only] [--remove-invalid]
参数:
  • crate_name
    : 要检查的特定crate(可选,默认检查全部)
  • --check-only
    : 仅报告问题,不进行修复
  • --remove-invalid
    : 删除无效引用而非创建文件

Execution Mode Detection

执行模式检测

CRITICAL: Check if agent infrastructure is available.
This skill can run in two modes:
  • Agent Mode: Uses background agents for documentation fetching
  • Inline Mode: Executes directly using agent-browser CLI or WebFetch

重要提示:检查Agent基础设施是否可用。
该技能可在两种模式下运行:
  • Agent模式: 使用后台Agent获取文档
  • 内联模式: 直接通过agent-browser CLI或WebFetch执行

Agent Mode (Plugin Install)

Agent模式(插件安装)

When agent infrastructure is available, use background agents for fetching:
当Agent基础设施可用时,使用后台Agent进行获取:

Instructions

操作步骤

1. Scan Skills Directory

1. 扫描技能目录

bash
undefined
bash
undefined

If crate_name provided

如果提供了crate_name

skill_dir=~/.claude/skills/{crate_name}
skill_dir=~/.claude/skills/{crate_name}

Otherwise scan all

否则扫描所有技能

for dir in ~/.claude/skills/*/; do # Process each skill done
undefined
for dir in ~/.claude/skills/*/; do # 处理每个技能 done
undefined

2. Parse SKILL.md for References

2. 解析SKILL.md中的引用

Extract referenced files from Documentation section:
markdown
undefined
从文档部分提取引用的文件:
markdown
undefined

Documentation

文档

  • ./references/file1.md
    - Description
undefined
  • ./references/file1.md
    - 描述
undefined

3. Check File Existence

3. 检查文件是否存在

bash
if [ ! -f "{skill_dir}/references/{filename}" ]; then
    echo "MISSING: {filename}"
fi
bash
if [ ! -f "{skill_dir}/references/{filename}" ]; then
    echo "缺失: {filename}"
fi

4. Report Status

4. 报告状态

=== {crate_name} ===
SKILL.md: OK
references/:
  - sync.md: OK
  - runtime.md: MISSING

Action needed: 1 file missing
=== {crate_name} ===
SKILL.md: 正常
references/:
  - sync.md: 正常
  - runtime.md: 缺失

需要执行操作: 1个文件缺失

5. Fix Missing Files (Agent Mode)

5. 修复缺失文件(Agent模式)

Launch background agent to fetch documentation:
Task(
  subagent_type: "general-purpose",
  run_in_background: true,
  prompt: "Fetch documentation for {crate_name}/{module} from docs.rs.
           Use agent-browser CLI to navigate to https://docs.rs/{crate_name}/latest/{crate_name}/{module}/
           Extract the main documentation and save to ~/.claude/skills/{crate_name}/references/{module}.md"
)

启动后台Agent获取文档:
Task(
  subagent_type: "general-purpose",
  run_in_background: true,
  prompt: "从docs.rs获取{crate_name}/{module}的文档。
           使用agent-browser CLI导航至https://docs.rs/{crate_name}/latest/{crate_name}/{module}/
           提取主要文档内容并保存至~/.claude/skills/{crate_name}/references/{module}.md"
)

Inline Mode (Skills-only Install)

内联模式(仅技能安装)

When agent infrastructure is NOT available, execute directly:
当Agent基础设施不可用时,直接执行:

Step 1: Scan Skills Directory

步骤1:扫描技能目录

bash
undefined
bash
undefined

List all skills

列出所有技能

ls ~/.claude/skills/
ls ~/.claude/skills/

Or check specific skill

或检查特定技能

ls ~/.claude/skills/{crate_name}/
undefined
ls ~/.claude/skills/{crate_name}/
undefined

Step 2: Parse SKILL.md for References

步骤2:解析SKILL.md中的引用

Read SKILL.md and extract all
./references/*.md
patterns:
bash
undefined
读取SKILL.md并提取所有
./references/*.md
模式:
bash
undefined

Using Read tool

使用Read工具

Read("~/.claude/skills/{crate_name}/SKILL.md")
Read("~/.claude/skills/{crate_name}/SKILL.md")

Look for lines like:

查找如下格式的行:

-
./references/sync.md
- Sync primitives

-
./references/sync.md
- 同步原语

-
./references/runtime.md
- Runtime configuration

-
./references/runtime.md
- 运行时配置

undefined
undefined

Step 3: Check File Existence

步骤3:检查文件是否存在

bash
undefined
bash
undefined

Check each referenced file

检查每个引用文件

for ref in references; do if [ ! -f "~/.claude/skills/{crate_name}/references/${ref}.md" ]; then echo "MISSING: ${ref}.md" fi done
undefined
for ref in references; do if [ ! -f "~/.claude/skills/{crate_name}/references/${ref}.md" ]; then echo "缺失: ${ref}.md" fi done
undefined

Step 4: Report Status

步骤4:报告状态

Output format:
=== {crate_name} ===
SKILL.md: OK
references/:
  - sync.md: OK
  - runtime.md: MISSING

Action needed: 1 file missing
输出格式:
=== {crate_name} ===
SKILL.md: 正常
references/:
  - sync.md: 正常
  - runtime.md: 缺失

需要执行操作: 1个文件缺失

Step 5: Fix Missing Files (Inline)

步骤5:修复缺失文件(内联模式)

For each missing file:
Using agent-browser CLI:
bash
agent-browser open "https://docs.rs/{crate_name}/latest/{crate_name}/{module}/"
agent-browser get text ".docblock"
针对每个缺失文件:
使用agent-browser CLI:
bash
agent-browser open "https://docs.rs/{crate_name}/latest/{crate_name}/{module}/"
agent-browser get text ".docblock"

Save output to ~/.claude/skills/{crate_name}/references/{module}.md

将输出保存至~/.claude/skills/{crate_name}/references/{module}.md

agent-browser close

**Using WebFetch fallback:**
WebFetch("https://docs.rs/{crate_name}/latest/{crate_name}/{module}/", "Extract the main documentation content for this module")

Then write the content:
```bash
Write("~/.claude/skills/{crate_name}/references/{module}.md", <fetched_content>)
agent-browser close

**使用WebFetch备选方案:**
WebFetch("https://docs.rs/{crate_name}/latest/{crate_name}/{module}/", "提取该模块的主要文档内容")

然后写入内容:
```bash
Write("~/.claude/skills/{crate_name}/references/{module}.md", <fetched_content>)

Step 6: Update SKILL.md (if --remove-invalid)

步骤6:更新SKILL.md(如果使用--remove-invalid)

If
--remove-invalid
flag is set and file cannot be fetched:
bash
undefined
如果设置了
--remove-invalid
标志且无法获取文件:
bash
undefined

Read current SKILL.md

读取当前SKILL.md

Read("~/.claude/skills/{crate_name}/SKILL.md")
Read("~/.claude/skills/{crate_name}/SKILL.md")

Remove the invalid reference line

删除无效引用行

Edit("~/.claude/skills/{crate_name}/SKILL.md", old_string="-
./references/{invalid_file}.md
- Description", new_string="")

---
Edit("~/.claude/skills/{crate_name}/SKILL.md", old_string="-
./references/{invalid_file}.md
- 描述", new_string="")

---

Tool Priority

工具优先级

  1. agent-browser CLI - Primary tool for fetching documentation
  2. WebFetch - Fallback if agent-browser unavailable
  3. Edit SKILL.md - For removing invalid references (--remove-invalid only)

  1. agent-browser CLI - 获取文档的主要工具
  2. WebFetch - 当agent-browser不可用时的备选方案
  3. 编辑SKILL.md - 仅在使用--remove-invalid时用于删除无效引用

Examples

示例

Check All Skills (--check-only)

检查所有技能(--check-only)

bash
/fix-skill-docs --check-only
bash
/fix-skill-docs --check-only

Output:

输出:

=== tokio === SKILL.md: OK references/:
  • sync.md: OK
  • runtime.md: MISSING
  • task.md: OK
=== serde === SKILL.md: OK references/:
  • derive.md: OK
Summary: 1 file missing in 1 skill
undefined
=== tokio === SKILL.md: 正常 references/:
  • sync.md: 正常
  • runtime.md: 缺失
  • task.md: 正常
=== serde === SKILL.md: 正常 references/:
  • derive.md: 正常
摘要: 1个技能中存在1个缺失文件
undefined

Fix Specific Crate

修复特定Crate

bash
/fix-skill-docs tokio
bash
/fix-skill-docs tokio

Fetches missing runtime.md from docs.rs

从docs.rs获取缺失的runtime.md

Reports success

报告成功

undefined
undefined

Remove Invalid References

删除无效引用

bash
/fix-skill-docs tokio --remove-invalid
bash
/fix-skill-docs tokio --remove-invalid

If runtime.md cannot be fetched:

如果无法获取runtime.md:

Removes reference from SKILL.md instead

从SKILL.md中移除该引用


---

---

Error Handling

错误处理

ErrorCauseSolution
Agent not availableSkills-only installUse inline mode
Skills directory emptyNo skills installedRun /sync-crate-skills first
docs.rs unavailableNetwork issueRetry or use --remove-invalid
Permission deniedDirectory issueCheck ~/.claude/skills/ permissions
Invalid SKILL.md formatCorrupted skillRe-generate skill
错误原因解决方案
Agent不可用仅安装了技能使用内联模式
技能目录为空未安装任何技能先运行/sync-crate-skills
docs.rs不可用网络问题重试或使用--remove-invalid
权限被拒绝目录问题检查~/.claude/skills/的权限
SKILL.md格式无效技能已损坏重新生成技能