git:20260705.6abb68b to git:20260801.45daefe

74 added, 47 removed. Audit A to A.

---
name: skill-link-check
- description: Audit the .agents/skills and .claude/skills directories at both the current project (./) and the global home (~/) to verify the convention where .agents/skills holds the real source files and .claude/skills mirrors them via symlinks — either a single parent-directory symlink or per-child symlinks. Use this whenever the user mentions a skill not loading or not appearing, a /command that should exist but doesn't, .claude/skills or .agents/skills by name, skill symlink, missing skill, ghost skill, "skill 没生效", "skill 不一致", "为什么 skill 没识别到", "检查 skill 链接", or wants to check, audit, verify, or diagnose the skills directory layout — even if they don't say "symlink" explicitly. Also use when the user reports a skill exists in one of the two directories but not the other.
+ description: Audit project and global .agents/skills and .claude/skills layouts. Verify that .agents/skills contains the real source and .claude/skills mirrors it through a parent or per-skill symlink. Use whenever a skill or slash command is missing, not loading, duplicated, inconsistent, or described as "skill 没生效", "skill 不一致", "为什么 skill 没识别到", "检查 skill 链接", ghost skill, broken skill link, or missing skill. Also use when a skill exists in one directory but not the other.
---
- # Skill link check
+ # Skill Link Check
- Audits the layout convention used in this user's setup:
+ ## 安装与更新
- - `.agents/skills/<name>/` holds the **real** source files.
- - `.claude/skills/<name>` mirrors them via a **symlink** into `.agents/skills`.
+ 来源:[Skills.sh](https://skills.sh/yan-labs/yan-skills)
- The most common drift mode is a skill that ended up in `.claude/skills/`
- directly as a real folder and was never copied back to `.agents/skills/`. It
- appears installed but isn't tracked alongside the other sources, so it gets
- forgotten on backup, sync, or migration.
+ ```bash
+ # 首次全局安装,或更新失败时重新安装
+ npx skills add yan-labs/yan-skills --skill skill-link-check -g -y
- ## How to run it
+ # 更新已安装的全局 Skill
+ npx skills update skill-link-check -g -y
+ ```
+ 若使用项目级安装,去掉安装命令中的 `-g`;项目级更新使用 `npx skills update skill-link-check -p -y`。
+
+ 本 Skill 只审计目录布局,不自动移动、删除或覆盖文件:
+
+ - `.agents/skills/<name>/` 保存真实源文件。
+ - `.claude/skills` 要么整体链接到 `.agents/skills`,要么通过逐个子项链接镜像它。
+
+ 最常见的漂移是 Skill 被直接创建成 `.claude/skills/<name>/` 真实目录,却没有进入 `.agents/skills/`。它看似已安装,实际不会随正常备份、同步或迁移流程保存。
+
+ ## Goal Contract
+
+ 在 `/goal`、autopilot 或其他持续执行器中,本 Skill 的完成条件是“审计证据完整”,不是“退出码必须为 0”。发现问题是有效结果,不能为了让检查通过而擅自修复。
+
+ ```xml
+ <goal>审计所有适用作用域,判定 Skill 源目录与运行时镜像是否一致,并为每个问题提供可复核证据和修复命令。</goal>
+ <gate>检查脚本已从用户目标项目运行;每个适用作用域都有布局模式、问题分类和退出状态。</gate>
+ <done-when>无问题时明确报告 clean;有问题时完整列出数量、类别、路径和建议命令;未自动修改任何被审计目录。</done-when>
+ ```
+
+ 因此:
+
+ - 退出码 `0`:审计完成且没有发现问题。
+ - 退出码 `1`:审计完成且发现问题,不代表 Skill 执行失败。
+ - Python traceback、参数错误或无法读取目标:才属于执行失败,需要修复后重跑。
+
+ ## 运行方式
+
```bash
python3 "$(dirname "$0")/check.py"
```
- By default the script audits two scopes:
+ 默认审计:
- - **Project** — `$PWD/.agents/skills` and `$PWD/.claude/skills`
- - **Global** — `$HOME/.agents/skills` and `$HOME/.claude/skills`
+ - **Project**:当前目录下的 `.agents/skills` 与 `.claude/skills`。
+ - **Global**:`$HOME` 下的同名目录。
- A scope where neither directory exists is silently skipped (the user just
- hasn't set up skills there). Exit code is non-zero when issues are found, so
- the same script works in CI or a git hook.
+ 自动化或 checker 可使用:
- ## Two valid layouts
+ ```bash
+ # 明确指定项目,避免依赖当前工作目录
+ python3 "$(dirname "$0")/check.py" --project-root /path/to/project
- Both pass the check:
+ # 只查一个作用域
+ python3 "$(dirname "$0")/check.py" --project-only
+ python3 "$(dirname "$0")/check.py" --global-only
- 1. **Parent symlink** — `.claude/skills` itself is a symlink to
- `.agents/skills`. Every entry is then automatically consistent. This is
- what the user's global home uses today.
- 2. **Per-child symlinks** — `.claude/skills` is a real directory, and each
- `.claude/skills/<name>` is a symlink to `../../.agents/skills/<name>`.
- This is what `skill-creator` produces by default.
+ # 输出稳定 JSON 证据;发现问题时仍返回 1
+ python3 "$(dirname "$0")/check.py" --json
+ ```
- The script detects which mode is in use and applies the right rules.
+ ## 两种合法布局
- ## What the script flags
+ 两种模式都应通过:
- - `orphan-in-claude` — entry exists in `.claude/skills/` but has no
- counterpart in `.agents/skills/`. **This is the failure mode the user
- usually hits.** Lead with these in the report.
- - `missing-link` — `.agents/skills/<name>` exists but `.claude/skills/<name>`
- does not, so the runtime won't actually find the skill.
- - `not-symlink` — in per-child mode, `.claude/skills/<name>` is a real
- directory or file when it should be a symlink. Often a forgotten duplicate
- of the real entry in `.agents/skills/`.
- - `broken-symlink` — symlink target is missing.
- - `wrong-target` — symlink resolves but doesn't point into `.agents/skills/`,
- or points at the wrong skill.
+ 1. **Parent symlink**:`.claude/skills` 本身指向 `.agents/skills`。新增 Skill 自动保持一致。
+ 2. **Per-child symlinks**:`.claude/skills` 是真实目录,每个 `.claude/skills/<name>` 指向 `../../.agents/skills/<name>`。
- ## Reporting back to the user
+ 脚本会自动识别模式,不要求为了统一风格而改造一个本来健康的布局。
- After running the check:
+ ## 问题分类
- 1. Lead with the headline: total issues, broken down by category. Mention
- `orphan-in-claude` first if any — that's the case the user cares about.
- 2. List each issue with its name and one-line detail.
- 3. Include the suggested fix commands verbatim. The user copy-pastes them.
- 4. Do **not** apply fixes automatically. An "orphan" might be in-progress
- work the user hasn't moved into `.agents/skills/` yet, and silently
- relocating it could surprise them.
+ - `orphan-in-claude`:`.claude/skills/` 中有真实条目,但 `.agents/skills/` 没有对应源文件。报告时优先列出。
+ - `missing-link`:源 Skill 存在,但运行时镜像缺失。
+ - `not-symlink`:逐子项模式下,镜像位置是重复的真实文件或目录。
+ - `broken-symlink`:链接目标不存在,包括损坏的父级链接。
+ - `wrong-target`:链接存在,但指向错误 Skill 或 `.agents/skills` 之外。
- If everything is clean, say so in one line and stop.
+ ## 报告规则
+
+ 1. 先给总问题数和分类计数;有 `orphan-in-claude` 时先报告它。
+ 2. 每项给出名称、证据路径和一行解释。
+ 3. 原样附上脚本生成的建议修复命令,便于用户复核后执行。
+ 4. 不自动修复。孤儿目录可能是用户尚未迁移的工作,重复目录也可能已经分叉;自动移动或删除会造成数据损失。
+ 5. 如果全部健康,一句话说明适用作用域及布局模式即可结束。
+
+ ## 验证 Skill 自身
+
+ ```bash
+ python3 -m unittest discover -s "$(dirname "$0")/tests" -v
+ ```