# Phase: Lint — Wiki Health Check Run when user says "lint the wiki", "health check", "clean up the wiki", "find orphan pages". ## Step 1 — Inventory all pages ```bash find wiki/ -name "*.md" | sort ``` Count pages by type: ```bash grep -r "^type:" wiki/ | sed 's/.*type: //' | sort | uniq -c | sort -rn ``` ## Step 2 — Find orphan pages Orphans = pages with no inbound `[[WikiLink]]` references from other pages. ```bash # Get all page titles find wiki/ -name "*.md" -exec grep -l "^title:" {} \; | while read f; do title=$(grep "^title:" "$f" | sed 's/title: "//' | sed 's/"//') echo "$title|$f" done > /tmp/wiki-titles.txt # For each page, check if it's referenced elsewhere while IFS='|' read -r title filepath; do slug=$(basename "$filepath" .md) count=$(grep -r "\[\[$slug\|$title" wiki/ --include="*.md" | grep -v "^$filepath" | wc -l) if [ "$count" -eq 0 ]; then echo "ORPHAN: $filepath (title: $title)" fi done < /tmp/wiki-titles.txt ``` ## Step 3 — Find contradictions Search for contradiction signals: ```bash grep -rn "however\|contradicts\|disagrees\|disputes\|unlike\|but.*claims\|whereas" wiki/ --include="*.md" | head -30 ``` Read flagged pages and check if the contradiction is already noted or needs a new `## Contradictions` section. ## Step 4 — Find stale claims Look for pages that haven't been updated since a source that supersedes them was ingested: ```bash grep -r "last-updated:" wiki/ --include="*.md" | sort -t: -k2 | head -20 ``` Cross-reference with `wiki/log.md` to see if newer sources touch the same topics. ## Step 5 — Find missing concept pages Scan all pages for `[[WikiLinks]]` that point to non-existent files: ```bash # Extract all WikiLinks grep -roh '\[\[[^\]]*\]\]' wiki/ | sed 's/\[\[//' | sed 's/\]\]//' | sort -u > /tmp/wiki-links.txt # Check which ones have no corresponding file while read -r link; do slug=$(echo "$link" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed 's/[^a-z0-9-]//g') if ! find wiki/ -name "${slug}.md" | grep -q .; then echo "MISSING PAGE: $link (slug: $slug)" fi done < /tmp/wiki-links.txt ``` ## Step 6 — Check index completeness ```bash # Count pages total_pages=$(find wiki/ -name "*.md" | wc -l) # Count index entries index_entries=$(grep -c "^\|" wiki/index.md 2>/dev/null || echo 0) echo "Total pages: $total_pages | Index entries: $index_entries" ``` Pages missing from index = pages not listed in `wiki/index.md`. ## Step 7 — Write lint report Write `wiki/lint-.md`: ```markdown --- title: "Lint Report YYYY-MM-DD" date: YYYY-MM-DD type: lint --- # Wiki Health Check — YYYY-MM-DD ## Summary - Total pages: N - Orphan pages: N - Missing concept pages (broken WikiLinks): N - Potential contradictions: N - Index gaps: N ## Orphan Pages (list with suggested connections) ## Broken WikiLinks (Missing Pages) (list of WikiLinks with no target file — candidates for new pages) ## Potential Contradictions (flagged passages to review) ## Stale Pages (pages likely superseded by newer sources) ## Recommended Actions 1. Create page for [[Missing Concept A]] — referenced in 3 sources 2. Connect [[Orphan Page B]] to [[Related Page C]] 3. Review contradiction between [[Source X]] and [[Source Y]] on [topic] ## Suggested New Sources - Topics with thin coverage that warrant more research ``` ## Step 8 — Append to log ``` ## [YYYY-MM-DD] lint | Health check pass N - Report: wiki/lint-.md - Orphans found: N | Missing pages: N | Contradictions: N - Actions recommended: N ```