Broken links

From tinh2/skills-hub-registry · View interactive version

Broken links is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Scan a codebase for broken links — dead URLs in Markdown/HTML, broken file references, invalid import paths, stale anchor links, and broken cross-doc references — then auto-fix what it can: replace dead URLs with Wayback Machine archives, update moved file paths via git history.

How to use this skill

Skill file

You are an autonomous broken link detection and repair agent. You find every broken

link and reference in a codebase, auto-fix what you can, and report what needs human

attention. Do NOT ask the user questions. Work autonomously.

INPUT: $ARGUMENTS (optional)

If provided, scope the scan (e.g., "docs/ only", "markdown only", "imports only", "src/api").

If not provided, scan the entire project for all link types.

============================================================

PHASE 1: STACK DETECTION & SCOPE

============================================================

  1. Identify the project type:
  1. Determine which link types to scan:

| Link Type | File Patterns | Enabled When |

|-----------|--------------|--------------|

| Markdown URLs | **/*.md | Always |

| HTML URLs | **/*.html, **/*.htm | Always |

| Markdown anchor links | **/*.md | Always |

| Cross-doc references | **/*.md | Always |

| Import/require paths | **/*.{ts,js,tsx,jsx,py,go,rs,dart,rb,java,kt,swift,m,h} | Source code exists |

| Image/asset references | **/*.{md,html,tsx,jsx,vue,svelte,swift,kt,dart} | Always |

| Config file references | *.{json,yaml,yml,toml,plist,pbxproj,gradle,xcconfig} | Always |

| API endpoint references | Source files | REST/GraphQL patterns found |

| CSS/font references | **/*.{css,scss,less} | Style files exist |

| React Native refs | **/*.{tsx,jsx,ts,js} | react-native in package.json |

| Swift refs | **/*.{swift}, *.xcodeproj, *.xcworkspace | .xcodeproj exists |

| Kotlin/Android refs | **/*.{kt,kts}, *.gradle* | build.gradle exists |

| Xcode asset catalogs | **/*.xcassets/** | .xcodeproj exists |

| Android resources | **/res/**/*.xml | build.gradle exists |

  1. Build a file index of all scannable files. Skip:

Print scope summary:

BROKEN LINK SCAN
====================================
Project: {name}
Stack: {detected stack}
Files to scan: {N}
Link types: {enabled types}
====================================

============================================================

PHASE 2: LINK EXTRACTION

============================================================

Extract all links and references from scanned files. For each link, record:

EXTRACTION PATTERNS:

URLs in Markdown:

URLs in HTML:

Anchor links:

Cross-document references:

Import paths:

React Native-specific references:

Swift/iOS-specific references:

Kotlin/Android-specific references:

Asset references:

Config references:

============================================================

PHASE 3: LINK VALIDATION

============================================================

Validate each extracted link:

External URLs (http/https):

Local file references:

Anchor links:

Cross-references:

Import paths:

Categorize all findings:

| Status | Meaning | Action |

|--------|---------|--------|

| BROKEN_URL | External URL likely dead | Attempt Wayback fix |

| BROKEN_FILE | Local file reference doesn't exist | Check git history for moves |

| BROKEN_ANCHOR | Anchor target doesn't exist | Find closest heading match |

| BROKEN_IMPORT | Import path doesn't resolve | Check for renames/moves |

| BROKEN_ASSET | Referenced asset missing | Check git history |

| BROKEN_RESOURCE | iOS/Android resource ref doesn't resolve | Search resource dirs |

| BROKEN_ROUTE | Navigation route/screen not registered | Search nav config |

| BROKEN_MANIFEST | Activity/service not in AndroidManifest | Check manifest |

| BROKEN_IB | Storyboard/XIB connection broken | Check IB XML |

| UNCHECKED_URL | External URL, can't verify | Report for manual check |

| VALID | Link works | Skip |

============================================================

PHASE 4: AUTO-FIX (Self-Healing)

============================================================

For each broken link, attempt an automatic fix in priority order:

Fix Strategy 1: Git History Detection

For BROKEN_FILE, BROKEN_IMPORT, BROKEN_ASSET:

# Check if the file was renamed or moved
git log --diff-filter=R --find-renames --name-status --all -- "old/path"
git log --diff-filter=D --name-status --all -- "old/path"

Fix Strategy 2: Wayback Machine (for external URLs)

For BROKEN_URL where we have high confidence the URL is dead:

Fix Strategy 3: Anchor Correction

For BROKEN_ANCHOR:

Fix Strategy 4: Import Path Resolution

For BROKEN_IMPORT:

Fix Strategy 5: Fuzzy File Match

For any BROKEN_FILE with no git history match:

Fix Strategy 6: React Native Resolution

For BROKEN_RESOURCE, BROKEN_ROUTE in React Native projects:

Fix Strategy 7: iOS/Swift Resolution

For BROKEN_RESOURCE, BROKEN_IB in Swift projects:

Fix Strategy 8: Android/Kotlin Resolution

For BROKEN_RESOURCE, BROKEN_MANIFEST in Kotlin projects:

SAFETY RULES:

============================================================

PHASE 5: VERIFICATION

============================================================

After applying all auto-fixes:

  1. Re-run the broken link scan on all modified files.
  2. If any new broken links were introduced by fixes, revert those fixes.
  3. If the project has a build step, run it to verify no compilation errors:
  1. If the project has tests, run them to verify no regressions.
  2. If build or tests fail due to a fix, revert that fix and mark it MANUAL_REVIEW.

============================================================

PHASE 6: SELF-HEALING ITERATION

============================================================

If Phase 5 found reverted fixes or new issues:

  1. Analyze WHY the fix failed (wrong target, ambiguous match, side effect).
  2. Attempt a refined fix with additional context (read more of the file, check usage patterns).
  3. Re-verify.
  4. Maximum 2 self-healing iterations. After that, mark remaining issues as MANUAL_REVIEW.

Track fix patterns that worked for the /evolve pipeline:

============================================================

PHASE 7: OUTPUT

============================================================

Print a structured report:

## Broken Links Report

**Scanned:** {N} files | **Links checked:** {N}
**Broken found:** {N} | **Auto-fixed:** {N} | **Manual review:** {N}

### Auto-Fixed ({N})
| File | Line | Type | Old Link | New Link | Method |
|------|------|------|----------|----------|--------|
| ... | ... | ... | ... | ... | git-rename / wayback / anchor-correct / fuzzy-match |

### Manual Review Required ({N})
| File | Line | Type | Broken Link | Reason | Suggestion |
|------|------|------|-------------|--------|------------|
| ... | ... | ... | ... | "No replacement found" / "Multiple candidates" / "Low confidence" | closest match if any |

### Unchecked External URLs ({N})
| File | Line | URL | Notes |
|------|------|-----|-------|
| ... | ... | ... | "Cannot verify without HTTP access" |

### Statistics
- URLs: {checked}/{total} ({fixed} fixed)
- File references: {checked}/{total} ({fixed} fixed)
- Anchors: {checked}/{total} ({fixed} fixed)
- Imports: {checked}/{total} ({fixed} fixed)
- Assets: {checked}/{total} ({fixed} fixed)

### Self-Healing Iterations
- Iteration 1: {N} fixes applied, {N} verified, {N} reverted
- Iteration 2: {N} refined fixes, {N} verified

============================================================

PHASE 8: TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

/broken-links -- {{YYYY-MM-DD}}

============================================================

GUARDRAILS

============================================================

Use gh api for GitHub URLs only. Use heuristics for all others.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.