Run the wiki system doctor to validate wiki structure, skills, rules, automations, and config sync. Use when the user says "doctor", "audit", "health check", "validate wiki", "check my system", "run doctor", or when you suspect something is misconfigured after a large edit session.
Unified health check for Kevin's agent system. Validates five layers: wiki structure, skills, rules, automations, and config sync.
From the wiki repo root (~/Documents/GitHub/kevin-wiki):
# Run all doctors
npx tsx scripts/doctor.ts
# Run a specific doctor
npx tsx scripts/doctor.ts --only wiki # frontmatter, wikilinks, index
npx tsx scripts/doctor.ts --only skills # SKILL.md validity, wiki pages, symlinks
npx tsx scripts/doctor.ts --only rules # .mdc integrity, hub refs
npx tsx scripts/doctor.ts --only automations # staleness, missing refs
npx tsx scripts/doctor.ts --only x-bookmarks # per-bookmark review ledger
npx tsx scripts/doctor.ts --only config-sync # symlink health
# Output modes
npx tsx scripts/doctor.ts --verbose # expand per-item detail + info findings
npx tsx scripts/doctor.ts --quiet # summary table only
npx tsx scripts/doctor.ts --json # machine-readable results (incl. scores)
npx tsx scripts/doctor.ts --min-score 90 # CI gate: exit 1 if composite score < 90Findings are aggregated: each check prints one summary line (e.g. "111 broken body wikilink(s)"); the individual items are info lines shown only under --verbose. This keeps the default output high-signal while staying exhaustive underneath.
Each doctor earns a 0-100 score, plus a composite across all five. The formula mirrors [[react-doctor]]:
score = 100 − 1.5 × (error rules) − 0.75 × (warn rules) # clamped to [0,100]The critical design choice: scoring is on unique rules (check keys), not occurrences. A check is one "rule"; its worst severity decides whether it's an error rule (any fail) or a warn rule (warn, no fail). 132 broken wikilinks is one warn rule, not 132 penalty points. This rewards systemic fixes — silence a whole check once and the score jumps — instead of grinding down individual items (the same incentive react-doctor's per-rule scoring creates).
The composite score and its fail/warn-rule counts are appended to wiki/meta/doctor-history.json on every full run (skipped under --only so the trend stays comparable). The summary prints the delta vs the last run so drift is visible.
Adapted from react-doctor's triage playbook — fix the score up, don't whack-a-mole:
fail rule, then re-run the doctor (or the narrowest validation) after each. If a fix breaks something, revert that one and move on. Errors are weighted 2× warnings, so they move the score most.warn rules, then validate once at the end. If the batch breaks something, fall back to fixing them serially to isolate the offender.title required (fail), type/created recommended (warn)type is a recognized value; updated is not before created or in the future[[wikilinks]] in body or related:/frontmatter## Backlinks section (backlinks are computed)person/project/tool pages have a ## Timelinelongform: true (length follows the content — good long pages opt out) — infoscripts/lib/placeholders.ts (e.g. "catalog stub auto-created", "replace with a real summary", TODO: replace/fill, "to be written", template "{compiled truth"). Catches auto-generated pages (dedalus catalog stubs) that were synced but never written — these sit at exactly 15 lines and dodge the length nudge. log.md is exempt (it quotes the sentinels when recording fixes). Same check runs as a fast pre-commit gate (scripts/check-placeholders.ts, scoped to staged wiki/*.md) and at session start (check-freshness.ts)._index.md has no dangling entries (links to missing pages); flags staleness when many pages are uncatalogued (root docs excluded)log.md has valid YAML frontmatterSKILL.md under skills/{engineering,productivity,personal,misc,in-progress,deprecated}/ exists with valid frontmatter where applicablewiki/meta/skill-registry.json and wiki/meta/skill-registry.mdwiki/concepts/*-skills.mdwiki/skills/<slug>.md mirrors fail as article sprawl; wiki/skills/README.md remains the thin hubname matches dir slug (info); description ≤ 1024 chars; body ≤ 500 lines (info)skills/README.md present; runtime skill symlinks are intact across Cursor, Claude, Codex, and ~/.agents/skills.mdc in config/cursor/rules/ is non-empty and has a frontmatter descriptionagent-operations-hub.md exist on diskinfo (cloud runs aren't tracked locally)raw/x-bookmarks/bookmarks.jsonl exists and parseswiki/meta/x-bookmark-artifact-audit.json exists, parses, and covers every raw bookmark IDarticles, skills, tools, objects, and versioning, plus reviewedArtifacts evidencepromoted rows must list promotedPages~/.agents/skills bridge| Severity | Scores as | Meaning |
|---|---|---|
| pass | — | Check passed |
| info | — | Stat or low-priority finding; hidden unless --verbose |
| warn | warn rule (−0.75) | Non-critical issue, should be fixed when convenient |
| fail | error rule (−1.5) | Critical issue, fix before committing (doctor exits 1) |
Results are written to wiki/meta/doctor-results.json (now including per-doctor and composite score), the score trend is appended to wiki/meta/doctor-history.json, and state.json is updated. The doctor exits 1 if there are any fails or (with --min-score N) if the composite score is below the threshold. If there are fails, fix them before committing. If there are warns, batch-fix during maintenance and watch the score climb run-over-run.
The doctor detects and scores; it does not fix. To close the loop autonomously — triage each finding, auto-fix the provably-safe class, propose content fixes behind a PR, escalate the destructive ones, and notify selectively — run the self-heal layer built on top of this doctor:
npx tsx scripts/self-heal.ts # detect + triage + selective digest (no writes)
npx tsx scripts/self-heal.ts --apply # apply safe deterministic fixes + verify (re-run doctor)See automations/self-heal.md (the agentic loop + PR step) and the wiki/concepts/self-maintaining-systems.md concept for the full pattern.
scripts/self-heal.ts — closes the loop: triage + auto-safe fix + selective digest (automations/self-heal.md)scripts/lint.ts — compatibility alias for doctor.ts --only wikiscripts/build-discovery.ts — generates wiki/meta/discovery-index.json and wiki/llms.txtscripts/check-freshness.ts — sync + automation staleness checks