check-links

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Check Links Skill

检查链接Skill

Finds broken
[[wiki-links]]
across your vault by extracting link targets and verifying that each target file exists. Read-only — never modifies files.
通过提取链接目标并验证每个目标文件是否存在,查找你的知识库(vault)中所有失效的
[[wiki链接]]
。只读模式——绝不会修改文件。

Usage

使用方法

/check-links
Or ask:
  • "Check for broken links in my vault"
  • "Find dead wiki-links"
  • "Are there any broken links?"
/check-links
或者提问:
  • "检查我的知识库中的失效链接"
  • "查找失效的wiki链接"
  • "有没有失效的链接?"

How to Execute

执行步骤

Step 1: Extract all wiki-links

步骤1:提取所有wiki链接

Use Grep to find all
[[...]]
patterns in markdown files:
Grep:
  pattern: "\\[\\[([^\\]|]+)"
  glob: "*.md"
  output_mode: content
  -n: true
This captures the link target (before any
|
alias). Exclude
.claude/
and
.obsidian/
directories from results.
使用Grep在markdown文件中查找所有
[[...]]
模式:
Grep:
  pattern: "\\[\\[([^\\]|]+)"
  glob: "*.md"
  output_mode: content
  -n: true
这会捕获链接目标(在任何
|
别名之前的部分)。从结果中排除
.claude/
.obsidian/
目录。

Step 2: Build unique target list

步骤2:构建唯一目标列表

From the grep results, extract the unique link targets. For each match like
[[My Note]]
or
[[My Note|display text]]
, the target is
My Note
.
Strip:
  • Heading anchors:
    [[Note#heading]]
    → target is
    Note
  • Block references:
    [[Note^block-id]]
    → target is
    Note
  • Aliases:
    [[Note|alias]]
    → target is
    Note
从Grep结果中提取唯一的链接目标。对于像
[[My Note]]
[[My Note|显示文本]]
这样的匹配项,目标是
My Note
去除:
  • 标题锚点:
    [[Note#heading]]
    → 目标为
    Note
  • 块引用:
    [[Note^block-id]]
    → 目标为
    Note
  • 别名:
    [[Note|别名]]
    → 目标为
    Note

Step 3: Verify each target exists

步骤3:验证每个目标是否存在

For each unique target, use Glob to check if a matching file exists:
Glob:
  pattern: "**/<target>.md"
A link is broken if no file matches. A link is valid if at least one file matches.
对于每个唯一目标,使用Glob检查是否存在匹配的文件:
Glob:
  pattern: "**/<target>.md"
如果没有匹配的文件,则链接失效。如果至少有一个文件匹配,则链接有效

Step 4: Report results

步骤4:生成结果报告

Group broken links by source file:
markdown
undefined
按源文件分组显示失效链接:
markdown
undefined

Broken Links Report

失效链接报告

Daily Notes/2024-01-15.md

Daily Notes/2024-01-15.md

  • [[Projet Alpha]] — no matching file found
  • [[Old Goal]] — no matching file found
  • [[Projet Alpha]] — 未找到匹配文件
  • [[Old Goal]] — 未找到匹配文件

Projects/Project Beta.md

Projects/Project Beta.md

  • [[Meeting Notes Jan]] — no matching file found

Summary: 3 broken links across 2 files (out of 45 total links checked)
undefined
  • [[Meeting Notes Jan]] — 未找到匹配文件

摘要: 2个文件中存在3个失效链接(共检查45个链接)
undefined

Step 5: Suggest fixes

步骤5:建议修复方案

For each broken link, try to find a close match:
  1. Use Glob with a partial pattern:
    **/*<partial-target>*.md
  2. If a similar filename exists, suggest it:
    - [[Projet Alpha]] — Did you mean [[Project Alpha]]?
  3. If no close match, just report "no matching file found"
对于每个失效链接,尝试查找近似匹配项:
  1. 使用带部分模式的Glob
    **/*<partial-target>*.md
  2. 如果存在相似文件名,建议替换:
    - [[Projet Alpha]] — 你是不是想找 [[Project Alpha]]?
  3. 如果没有近似匹配项,仅报告“未找到匹配文件”

Edge Cases

边缘情况

  • Embedded images (
    ![[image.png]]
    ) — skip these, they reference attachments
  • External links (
    [text](https://...)
    ) — skip these, they are not wiki-links
  • Template placeholders (
    [[{{date}}]]
    ) — skip anything with
    {{
    in the target
  • Empty links (
    [[]]
    ) — report as malformed, not broken
  • 嵌入图片 (
    ![[image.png]]
    ) — 跳过这些,它们引用的是附件
  • 外部链接 (
    [text](https://...)
    ) — 跳过这些,它们不是wiki链接
  • 模板占位符 (
    [[{{date}}]]
    ) — 跳过目标中包含
    {{
    的链接
  • 空链接 (
    [[]]
    ) — 报告为格式错误,而非失效

No Broken Links

无失效链接

If all links are valid:
✅ All wiki-links verified — no broken links found across X files (Y links checked)
如果所有链接都有效:
✅ 所有wiki链接已验证——在X个文件中未找到失效链接(共检查Y个链接)

Tips

小贴士

  • Run
    /check-links
    periodically to catch link rot
  • After renaming files, run this to find links that need updating
  • Combine with
    /search
    to find notes that reference deleted content
  • 定期运行
    /check-links
    以避免链接失效
  • 重命名文件后,运行此工具查找需要更新的链接
  • /search
    结合使用,查找引用已删除内容的笔记