关于 obsidian-links
obsidian-links 是用于格式化、验证和修复 Obsidian Wiki 链接的技能,适合维护 Vault 文档时使用。它强调创建链接前先确认目标文件和标题文本。
主要功能
- 01使用完整文件名和文件夹路径
- 02链接到精确的章节标题
- 03在 YAML 属性中为链接加引号
- 04检查目标并修复失效链接
适用场景
- 01按 Vault 命名规范链接笔记
- 02链接到已核实的标题
- 03检查文档中的失效 Wiki 链接
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ jykim/ claude-obsidian-skills --skill obsidian-links安装后在 Claude Code 中输入/obsidian-links确认已加载。
详细介绍
Obsidian Wiki 链接
根据库的约定格式化、验证和修复 Wiki 链接。
何时使用此技能
在以下情况下启用:
- 创建指向其他库文件的 Wiki 链接
- 添加指向特定标题的章节链接
- 格式化 YAML frontmatter 属性中的链接
- 验证链接是否指向现有文件/章节
- 查找并修复失效链接
- 验证文档中的链接完整性
核心链接格式规则
1. 完整文件名格式
始终使用带日期前缀的完整文件名:
✅ CORRECT: [[2025-10-31 Project Notes]]
❌ INCORRECT: [[Project Notes]] (missing date)
❌ INCORRECT: [[2025-10-31]] (missing title)
2. 文件夹路径约定
为清晰起见,包含文件夹前缀:
✅ CORRECT: [[Journal/2025-10-31]]
✅ CORRECT: [[Articles/2025-10-31 Perennial Seller]]
✅ CORRECT: [[Roundup/2025-10-31]]
规则:使用一致的文件夹前缀,以便清晰导航。
3. 章节链接
使用与标题完全一致的文本,逐字符匹配:
Source file header:
## PKM System Maintenance
✅ CORRECT:
[[Journal/2025-10-31#PKM System Maintenance]]
❌ INCORRECT:
[[Journal/2025-10-31#PKM System]] (truncated)
[[Journal/2025-10-31#pkm-system-maintenance]] (slug format)
关键:确保字符、标点和空格与原文完全一致。
4. 链接到来源,而非索引
始终链接到原始内容,而非主题聚合页:
✅ CORRECT: [[Articles/2025-08-15 Skill Development]]
❌ INCORRECT: [[Topics/Career#Skill Development]]
Reason: Maintains source attribution and traceability
5. 属性链接格式
在 YAML 列表中使用链接时,将链接放在引号内:
sources:
- "[[Journal/2025-10-31]]"
- "[[Articles/2025-10-31 Title]]"
links:
- "[[Roundup/2025-10-31]]"
attendees:
- "[[People/John]]"
链接验证原则
1. 先搜索,再创建链接
创建链接前,务必确认目标存在:
Process:
1. Search for target file using Glob or Grep
2. Verify file exists
3. If section link, read file and verify header exists
4. Create link with exact filename and header text
❌ NEVER:
- Guess at filenames
- Assume files exist
- Fabricate section headers
2. 验证章节标题
创建章节链接时,阅读来源并确保完全匹配:
Steps:
1. Read target file
2. Search for exact header text
3. Copy character-for-character (including special characters)
4. Create section link
If unsure about exact header:
✅ Link to file only: [[Journal/2025-10-31]]
❌ Don't guess: [[Journal/2025-10-31#Guessed Header]]
3. 检查文件是否存在
使用合适的工具验证文件:
For specific file:
- Use Glob with full path pattern: "Journal/2025-10-31.md"
- Or Read the file directly
For finding files by keyword:
- Use Glob with pattern: "Articles/**/*keyword*.md"
- Check Topics directory before linking to topics
4. 立即修复失效链接
发现失效链接时,立即修复:
Process:
1. Identify broken link
2. Search for correct target file
3. Update link with correct path/filename (use Edit tool)
4. Verify section header if applicable
5. Report fix to user
完整工作流
创建新链接(格式化 + 验证)
Step 1: Determine Target
- Identify file to link to
- Note folder location
- Note complete filename
Step 2: Verify File Exists
- Use Glob: "**/{filename}.md"
- Or Read file directly
- If not found, search by keyword
Step 3: Verify Section (if needed)
- Read target file
- Search for exact header text
- Copy character-for-character
- If unsure, link to file only
Step 4: Format Link
- Use complete filename: [[YYYY-MM-DD Title]]
- Add folder prefix
- Add section if verified: [[File#Exact Header]]
- Wrap in quotes if in YAML property
Step 5: Create Link
- Link points to existing file
- Section header matches exactly (if used)
- Follows folder prefix conventions
查找并修复失效链接
Step 1: Detection
- Read document content
- Extract all wiki links
- For each link, verify file exists
- For section links, verify header exists
Step 2: Search for Correct Target
- Use context to determine intent
- Search vault with Glob/Grep
- Verify file exists
Step 3: Fix Link
- Use Edit tool to update broken link
- Replace with correct path/filename
- Verify section header if applicable
Step 4: Report
- Show old link (broken)
- Show new link (fixed)
- Explain reason for fix
特殊情况
日志/每日文件
Path: Journal/YYYY-MM-DD.md
Format: [[Journal/YYYY-MM-DD]]
Section links:
- Headers may vary by language
- ALWAYS verify exact text before linking
- If unsure, link to file only
Validation:
1. Check file: Journal/YYYY-MM-DD.md
2. Read file content
3. Search for exact header
4. Use exact match or file-only link
主题链接
CRITICAL: Search Topics directory BEFORE linking
Validation:
1. Use Glob: "Topics/**/*{keyword}*.md"
2. Find matching topic page
3. Use complete category path
Examples:
- [[Topics/Technology/PKM]]
- [[Topics/Career/Skills]]
❌ NEVER link to non-existent topic pages
人名
Simple name: [[John]]
With context: [[People/John]] (if folder exists)
Validation: Verify person file exists before linking
质量检查清单
完成链接操作前:
格式:
- 所有链接均使用完整文件名
- 文件夹前缀遵循约定
- 章节标题完全一致(逐字符匹配)
- YAML 属性中的链接均放在引号内
- 所有链接均指向来源,而非主题索引
验证:
- 已确认所有目标文件均存在
- 已验证章节标题(未凭猜测)
- 主题链接指向现有主题页面
- 已识别并修复失效链接
评论
支持 Markdown