Doctor

From lza6/Armor-piercing-system-prompts · View interactive version

Doctor is an AI agent skill from the GitHub repository lza6/Armor-piercing-system-prompts. Health-check the user's Claude Code setup and fix issues: diagnose installation health — what the `claude doctor` terminal diagnostics cover — from local data (duplicate or leftover installs, PATH, unparseable settings files, broken or colliding agent definitions, skills whose frontmatter fails to p

How to use this skill

Skill file

Claude Code Doctor

Health-check my Claude Code setup and fix what's wrong: diagnose installation health (what the claude doctor terminal diagnostics cover), find extensions that cost context but never get used, deduplicate my LOCAL memory files against checked-in ones, trim checked-in CLAUDE.md files down to what a session can't derive on its own, migrate the always-loaded guidance that survives to lazy loading, flag slow hooks, verify my installed version is current, make auto mode my default permission mode, and pre-approve the read-only commands I keep getting denied on.

Ground rules

Data sources (all local — the ONLY permitted network access is check 7's read-only latest-version lookup, and even that is skipped in essential-traffic mode)

Check 0 — setup health (installation, settings, agent and skill definitions)

Diagnose the installation itself, from local data only. The claude doctor terminal command prints the same read-only install/settings diagnostics; replicate its checks here rather than shelling out to it, because this check must also turn each finding into a concrete fix proposal:

Check 1 — unused skills, MCP servers, and plugins

For each user-installed skill, MCP server, and plugin, collect its lifetime usage total (the counters above are cumulative since install — never windowed) and whether it was used in the scan window (lastUsedAt inside the window, plus transcript hits: <command-name> entries, Skill tool_use entries with the skill in input.skill, and MCP tool calls — transcripts are the ONLY window signal for MCP servers, which have no counter), plus estimated always-in-context cost.

Context-cost rules — be deferral-aware:

Signal quality — know what a zero means before judging:

Verdicts: zero invocations in the window → recommend disabling. Rarely used but expensive, or any other keep-vs-remove judgment call → still take a position: verdict "remove" or "keep" with a one-line reason ("2 uses in 300 sessions for 1.1k est. resident tokens — remove; re-enabling is one command" / "keep — used weekly and costs almost nothing"). Never park a borderline case as "up to you" with no verdict; the user can always override at the confirmation gate. "Not touching" is reserved for exactly two cases: bundled/built-in skills and anything enabled by managed policy (never propose disabling those — user-installed extensions only), and items with real observed usage in the window. Everything else unused gets a removal recommendation, with the signal quality stated honestly per item. Note honestly when the window is too thin to judge (few sessions, recent install) — thin data is the one case where withholding a verdict beats guessing; never stretch that to the no-signal component types above, where more sessions will never produce data — ask the user instead.

Disable mechanics (after confirmation — every name/key written below is harvested, so the never-inline ground rule applies to these edits):

Check 2 — LOCAL CLAUDE.md dedup and contradictions

LOCAL files: ~/.claude/CLAUDE.md and CLAUDE.local.md (project root and ancestor dirs). Checked-in files: CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md in the project, including nested directories.

Check 3 — trim derivable content from checked-in CLAUDE.md files

A line of a checked-in CLAUDE.md that a fresh session could reconstruct with a few tool calls (ls, cat, reading the manifest, --help) is dead weight every session it loads into pays for. Scan each checked-in CLAUDE.md file — the root file and .claude/CLAUDE.md (always loaded), nested-directory CLAUDE.md files (loaded when working under that directory), and .claude/rules/*.md — for content that is derivable from the codebase and propose deleting it outright. Always-loaded files matter most; nested files still get scanned. LOCAL files (~/.claude/CLAUDE.md, CLAUDE.local.md) are check 2's domain; leave them alone here.

The derivability test, per section: could a session working in this repo reconstruct this by reading the code? If yes, cut it. If no, keep it.

Prioritize files at or near the large-CLAUDE.md warning threshold — Claude Code warns when a single loaded memory file exceeds roughly 5% of the model's context window in characters, with a floor of ~40,000 chars (getMaxMemoryCharacterCount in src/utils/claudemd.ts in the Claude Code repo) — and state in the report which files trip it before vs after the proposed cuts. Files under the threshold with substantial derivable content still get a trim proposal; files that are already lean get one line ("already lean — nothing to cut") and no proposal.

Propose per file: the categories being cut with approximate line counts ("directory layout — 31 lines", "tech stack — 8 lines"), the est. resident tokens saved, and what remains. Quote each removed block verbatim in the proposal so the user can judge and so the edit is reversible from the report. This check runs BEFORE check 4's migration so that migration operates on the kept content only — don't propose migrating anything this check proposes to delete.

Check 4 — migrate always-loaded CLAUDE.md content to lazy loading

Of the checked-in CLAUDE.md content that survives check 3's cuts, every line of a root file is still in context in every session. Scan the remaining content for guidance that doesn't need to be always-loaded:

Propose the full migration set (source lines → destination file) and apply only after confirmation. Estimate the resident-token savings.

Check 5 — slow hooks

Aggregate durationMs per hookName/hookEvent from the transcript attachment entries above (typical and worst-case). Treat hook_cancelled entries with timedOut: true as slow-hook evidence — the hook ran until its timeout fired, so durationMs (≈ timeoutMs) is a duration floor, and a repeatedly-timing-out hook is the worst blocking-hook case even though it never logs a success. Key on timedOut/timeoutMs to separate these from user-Esc cancellations, which lack both fields and say nothing about hook speed. Warn on hooks that run often and slowly — as a rule of thumb: >2s typical for per-tool-call/per-prompt events (PreToolUse, PostToolUse, UserPromptSubmit — these block the loop every time they fire), >10s for SessionStart or Stop. For configured hooks with no recorded runs in the window, inspect the command strings in settings and flag obviously heavy patterns (network calls, package-manager invocations, cold interpreter startups), clearly labeled "no timing data — config inspection only". Note: successful runs with empty output are never persisted to transcripts, so config inspection is the EXPECTED path for silent hooks — zero recorded runs does not mean the hook rarely fires. Only execute a hook command yourself to measure it if it is plainly read-only AND the user explicitly agrees; run it with a timeout. Fixes to suggest: make the hook async, cache its output, narrow its matcher, or remove it — but slow-hook findings are warnings; don't edit hook config unless asked.

Check 6 — context-heavy extensions

Summarize estimated always-resident context by component: each CLAUDE.md file, the skill/command listing total (vs its ~1% budget), non-deferred MCP tool schemas, and plugins' resident contributions. Deferral rules from check 1 apply — deferred MCP tools are ~0. Call out the largest few. Recommend /context for the exact live measurement; your figures are disk-based estimates.

Check 7 — Claude Code version

Check whether the installed Claude Code is the latest for its release channel. Everything here is read-only.

Check 8 — auto mode as the default permission mode

Auto mode ("auto") delegates per-action permission decisions to a safety classifier instead of prompting the user for each one. Check whether it is the user's default permission mode; if not, propose making it so.

Check 9 — pre-approve frequently denied read-only commands

Find tool calls that keep getting denied even though they only read state, and propose permission allow rules for the top ones so they stop costing a prompt (or a classifier block) every time.

Report format

  1. Plain-language summary first, and keep it SHORT — 2-3 sentences: what you found, what it costs, that cleanup is reversible (see the beginner-friendly ground rule). Anything that doesn't change the user's decision belongs in the detail table, not the lead. Then the detail table: | Component | Type | Scope | Uses (total since install) | Used in window? | Est. resident tokens | Verdict |. One row per skill/MCP server/plugin/CLAUDE.md file; MCP servers have no counter — put "n/a (no counter)" in the total column and answer the window column from transcript hits; use "deferred" in the tokens column for deferred MCP servers, and "no signal (passive)" across both usage columns for components with no usage counter. State the scan window under the table.
  2. Proposed actions grouped by check (0, 1, 2, 3, 4, 7, 8, 9), each item with exact file + exact edit (or exact command, for checks 0 and 7).
  3. Warnings (checks 5 and 6) — no actions, just findings.
  4. Confirmation gates: at most TWO AskUserQuestions (mechanics in the propose-then-confirm ground rule) — the consolidated cleanup question for checks 0-4 and 7, then the separate permission question for checks 8 and 9. Each RECOMMENDS rather than neutrally offers, in 2-3 sentences: plain-language counts, the concrete benefit ("saves about 1.5k tokens of context every session"), and honest reversibility — "You can ask me to undo it later" wherever that's true (the disable mechanics above all are; for deletions, the report quotes what was removed so it can be restored). Don't restate the report's per-item detail — except in the permission question, which must name every change it grants. Models to follow:

Everything above is unused and safe to remove: 4 skills, 2 plugins, and 1 MCP server (a connection to an external tool). Cleaning up saves about 1.5k tokens of context every session, and you can ask me to undo it later. Clean up everything?

1. Clean up everything (recommended)

2. Let me pick

3. No, keep everything

If the user picks "Let me pick", ask ONE follow-up multiSelect question — an option per group, its label a short name plus the benefit ("37 unused skills — saves ~2.2k est. tokens/session") — then apply only the selected groups.

Then, only if check 8 or 9 proposed anything, the permission question — explicit because these widen what runs without asking:

Separately from the cleanup: I recommend two permission changes. (1) Make auto mode your default — a safety classifier approves routine actions instead of prompting you each time. (2) Pre-approve 2 read-only commands you denied 14 times: Bash(git log --oneline -20), Bash(gh pr view). Apply both?

1. Apply both (recommended)

2. Let me pick

3. No, keep prompting me

"Let me pick" here follows the same follow-up multiSelect pattern, one option per proposed permission change.

  1. After applying, list exactly what changed, file by file, and how to undo it.

If a check has no findings, say so in one line and move on. Keep the report tight — no padding, no restating these instructions.

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.