repair-broken-references
정보
이 스킬은 코드베이스 내부의 깨진 참조를 자동으로 감지하고 수정합니다. 여기에는 죽은 링크, 오래된 임포트, 고아 파일 등이 포함됩니다. 내부 링크가 끊어지거나 외부 URL이 실패하거나 모듈 임포트가 구버전이 될 때 프로젝트 무결성을 유지하려면 이 스킬을 사용하세요. 이 스킬은 프로젝트 전체의 연결을 스캔하고 복구하여 모든 상호 참조가 유효한 상태를 유지하도록 보장합니다.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/repair-broken-referencesClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
壊れた参照の修復
使用タイミング
Use this skill when project references have become stale:
- Documentation contains broken internal links
- External URLs return 404 errors
- Import statements reference moved or deleted modules
- Cross-references between files are out of sync
- Files exist but are never referenced anywhere
Do NOT use for refactoring module dependencies or redesigning information architecture. This skill repairs existing references, not restructures them.
入力
| Parameter | Type | Required | Description |
|---|---|---|---|
project_path | string | Yes | Absolute path to project root |
check_external | boolean | No | Verify external URLs (default: true, slow) |
fix_mode | enum | No | auto (fix obvious), report (document only), interactive (prompt) |
orphan_threshold | integer | No | Days since last modified to flag as orphan (default: 180) |
手順
ステップ1: Scan for Broken Internal Links
Find all markdown links pointing to non-existent files.
# Find all markdown files
find . -name "*.md" -type f > markdown_files.txt
# Extract all markdown links: [text](path)
grep -oP '\[.*?\]\(\K[^)]+' *.md | sort | uniq > all_links.txt
# For each link:
while read link; do
# Skip external URLs (http/https)
if [[ "$link" =~ ^https?:// ]]; then
continue
fi
# Resolve relative path
target=$(realpath -m "$link")
# Check if target exists
if [ ! -e "$target" ]; then
echo "BROKEN: $link (referenced in $file)" >> broken_internal.txt
fi
done < all_links.txt
期待結果: broken_internal.txt lists all broken internal references
失敗時: If realpath unavailable, manually check each link
ステップ2: Check External URLs
Verify that external links are still accessible (HTTP 200 response).
# Extract external URLs
grep -ohP 'https?://[^\s\)]+' *.md | sort | uniq > external_urls.txt
# Check each URL (rate-limit to avoid bans)
while read url; do
status=$(curl -o /dev/null -s -w "%{http_code}" "$url")
if [ "$status" -ge 400 ]; then
echo "DEAD ($status): $url" >> dead_urls.txt
fi
sleep 0.5 # Rate limit
done < external_urls.txt
期待結果: dead_urls.txt lists URLs returning 4xx/5xx errors
失敗時: If curl unavailable or blocked, use online link checker or skip
Note: Some URLs may return 403 due to bot detection but work in browsers. Manual review required.
ステップ3: Find Broken Imports
Check that all import/require statements reference existing modules.
JavaScript/TypeScript:
# Find all import statements
grep -rh "^import.*from ['\"]" . | sed -E "s/.*from ['\"]([^'\"]+)['\"].*/\1/" > imports.txt
# For each import:
while read import; do
# Skip node_modules and external packages
if [[ "$import" =~ ^[./] ]]; then
# Resolve to file path
target="${import}.js" # Try .js, .ts, .jsx, .tsx
if [ ! -e "$target" ]; then
echo "BROKEN IMPORT: $import" >> broken_imports.txt
fi
fi
done < imports.txt
Python:
# Find all import statements
grep -rh "^from .* import\|^import " . --include="*.py" | \
sed -E "s/from ([^ ]+) import.*/\1/" | \
sed -E "s/import ([^ ]+)/\1/" > imports.txt
# For each local import (starts with .)
# Check if module file exists
R:
# Find library() and source() calls
grep -rh "library(\\|source(" . --include="*.R" | \
sed -E 's/.*library\("([^"]+)"\).*/\1/' > packages.txt
# For source() calls, check if file exists
# For library() calls, check if package installed
Rscript -e "installed.packages()[,'Package']" > installed_packages.txt
期待結果: broken_imports.txt lists all references to deleted/moved modules
失敗時: If language-specific tool unavailable, manually review recent refactoring commits
ステップ4: Find Orphaned Files
Identify files that exist but are never referenced anywhere.
# Find all code files
find . -type f \( -name "*.js" -o -name "*.py" -o -name "*.R" \) > all_files.txt
# For each file:
while read file; do
basename=$(basename "$file")
# Search for references (import, require, source, href, link)
refs=$(grep -r "$basename" . --exclude-dir=node_modules --exclude-dir=.git | wc -l)
# If only 1 reference (itself):
if [ "$refs" -le 1 ]; then
# Check last modified date
last_mod=$(git log -1 --format="%ci" "$file")
# If modified more than orphan_threshold days ago
# Flag as potential orphan
echo "ORPHAN: $file (last modified: $last_mod)" >> orphans.txt
fi
done < all_files.txt
期待結果: orphans.txt lists files not referenced elsewhere
失敗時: If git log fails, use filesystem mtime instead
Note: Some files (e.g., CLI entry points, top-level scripts) are legitimately unreferenced but not orphans. Requires manual review.
ステップ5: Fix Internal Links
Repair broken internal references using one of three strategies:
Strategy 1: Find Moved Files
# For each broken link, search for file by name
while read broken_link; do
filename=$(basename "$broken_link")
# Search for file in project
found=$(find . -name "$filename" | head -1)
if [ -n "$found" ]; then
# Update link to new path
old_path="$broken_link"
new_path="$found"
# Use Edit tool to replace in all markdown files
echo "FIX: $old_path -> $new_path"
fi
done < broken_internal.txt
Strategy 2: Create Redirect Stub
# If file was deleted intentionally, create redirect stub
echo "# Moved" > "$broken_link"
echo "This content moved to [new location](new_path.md)" >> "$broken_link"
Strategy 3: Remove Dead Link
# If content no longer exists, remove link (keep text)
# Replace [text](broken_link) with text (plain)
期待結果: All broken internal links either fixed, redirected, or removed
失敗時: If automated fix breaks context, escalate for manual review
ステップ6: Fix Broken Imports
Update import statements to reference correct paths after moves.
JavaScript Example:
// Before (broken)
import { helper } from './utils/helper';
// After (fixed — file moved to lib/)
import { helper } from './lib/helper';
For each broken import:
- Locate the moved module (similar to Step 5)
- Update import path in all files referencing it
- Run linter/type checker to verify fix
期待結果: All imports resolve correctly; no module-not-found errors
失敗時: If module was truly deleted, escalate to determine if functionality still needed
ステップ7: Document Orphaned Files
For files flagged as orphans, determine disposition:
- Keep: Legitimately unreferenced (entry points, scripts, templates)
- Archive: Old code no longer needed but preserve history
- Delete: Dead code with no value
# Orphaned Files Review
| File | Last Modified | Recommendation | Reason |
|------|---------------|----------------|--------|
| scripts/old_deploy.sh | 2024-01-05 | Archive | Replaced by CI/CD |
| src/legacy_api.js | 2023-06-12 | Delete | API v1 fully deprecated |
| bin/cli.py | 2025-12-01 | Keep | CLI entry point (unreferenced by design) |
期待結果: Orphan review document created; automated decisions flagged for human approval
失敗時: (N/A — document even if no clear disposition)
ステップ8: Generate Repair Report
Summarize all broken references and fixes applied.
# Reference Repair Report
**Date**: YYYY-MM-DD
**Project**: <project_name>
**Fix Mode**: auto | report | interactive
## Broken Internal Links
- Total: X
- Fixed: Y
- Redirected: Z
- Escalated: W
Details:
- [file.md](file.md) line 45: Fixed broken link to moved doc
- [another.md](another.md) line 12: Created redirect stub
## Dead External URLs
- Total: X
- Fixed (wayback machine): Y
- Removed: Z
Details:
- https://example.com/old-page (404) → Removed
- https://api.old.com/docs (gone) → Replaced with new docs
## Broken Imports
- Total: X
- Fixed: Y
- Escalated: Z
Details:
- src/main.js line 3: Updated import path after refactor
## Orphaned Files
- Total: X
- Kept: Y
- Archived: Z
- Escalated for review: W
See ORPHAN_REVIEW.md for full analysis.
## Validation
- [x] All tests pass after fixes
- [x] Linter reports no module-not-found errors
- [x] Dead links documented in report
期待結果: Report saved to REFERENCE_REPAIR_REPORT.md
失敗時: (N/A — generate report regardless)
バリデーション Checklist
After repairs:
- No broken internal links in documentation
- Dead external URLs documented (not all fixable)
- All imports resolve correctly
- Orphaned files reviewed and dispositioned
- Tests pass after import fixes
- Linter reports no unresolved references
- Git history preserved (used
git mvfor any moves)
よくある落とし穴
-
Automatic URL Fixes Break Context: Replacing dead links with web.archive.org URLs may not be what the author intended. Some links are better removed.
-
Over-Aggressive Orphan Deletion: Entry points, CLI scripts, and templates are often unreferenced by design. Don't delete without review.
-
Import Path Assumptions: Assuming all relative imports use the same base path. Different module systems (CommonJS, ES6, TypeScript) handle paths differently.
-
External URL False Positives: Some sites block curl/bots but work fine in browsers. Always manually verify dead URLs.
-
Circular Reference Traps: File A imports B, B imports A. Updating one breaks the other. Requires simultaneous fix.
-
Ignoring Fragment Identifiers: Fixing
[link](#section)requires checking if#sectionanchor exists, not just if file exists. -
Wrong R binary on hybrid systems: On WSL or Docker,
Rscriptmay resolve to a cross-platform wrapper instead of native R. Check withwhich Rscript && Rscript --version. Prefer the native R binary (e.g.,/usr/local/bin/Rscripton Linux/WSL) for reliability. See Setting Up Your Environment for R path configuration.
関連スキル
- clean-codebase — Remove dead code after confirming orphans
- tidy-project-structure — Reorganize files (may create broken references)
- escalate-issues — Route complex reference issues to specialists
- compliance/documentation-audit — Comprehensive documentation review
- web-dev/link-checker — Advanced external URL validation
GitHub 저장소
연관 스킬
railway-docs
문서이 스킬은 Railway의 기능, 작동 방식 또는 특정 문서 URL에 대한 질문에 답하기 위해 최신 Railway 문서를 가져옵니다. 개발자들이 Railway의 공식 소스로부터 정확하고 최신 정보를 직접 받을 수 있도록 보장합니다. 사용자가 Railway의 작동 방식을 묻거나 Railway 문서를 참조할 때 사용하세요.
n8n-code-python
문서이 Claude Skill은 n8n의 Code 노드에서 Python 코드를 작성할 때 전문적인 지침을 제공하며, 특히 Python 표준 라이브러리 사용과 n8n의 특수 구문인 `_input`, `_json`, `_node` 작업에 중점을 둡니다. 이는 개발자가 n8n 내에서 Python의 제한 사항을 이해하도록 돕고, 대부분의 워크플로에는 JavaScript 사용을 권장하면서도 특정 데이터 변환 요구사항에 대한 Python 솔루션을 제안합니다.
archon
문서Archon 스킬은 REST API를 통해 RAG 기반 시맨틱 검색과 프로젝트 관리를 제공합니다. 이 스킬을 사용하여 문서 검색, 계층적 프로젝트/태스크 관리, 문서 업로드 기능을 갖춘 지식 검색을 수행할 수 있습니다. 외부 문서를 검색할 때는 다른 소스를 사용하기 전에 항상 Archon을 최우선으로 활용하세요.
n8n-code-javascript
문서이 Claude Skill은 n8n의 Code 노드에서 JavaScript 코드 작성에 대한 전문적인 지침을 제공합니다. `$input`/`$json` 변수, HTTP 헬퍼, DateTime 처리와 같은 필수적인 n8n 특정 구문을 다루며 일반적인 오류를 해결합니다. Code 노드에서 사용자 정의 JavaScript 처리가 필요한 n8n 워크플로우를 개발할 때 활용하세요.
