# context-doctor

Claude Code / Codex skill that audits the fixed context a coding agent auto-loads every session — tool/MCP definitions, connectors, plugins, skills, subagents, memory/rules files — and proposes ranked cuts to prune, gate, or route what's loaded but unused.

**Type:** guideline
**Added:** 2026-07-06
**Link:** https://www.skills.sh/mark-life/agent-skills/context-doctor
**Topics:** AI Coding, Dev Tools
**Tags:** agents, cli, observability

---

Install it with:

```bash
npx skills add Mark-Life/agent-skills@context-doctor -g
```

Then run it:

```bash
claude /context-doctor
```

Every session opens with a fixed tax paid before you say anything: system prompt, tool definitions, MCP servers, connectors, plugins, skill descriptions, subagents, memory/rules files. Some is load-bearing; much is junk — loaded in every repo, used in none — quietly shrinking the window and feeding context rot. `/context-doctor` is the cleanup pass for "why is my context so full", token-budget triage, or after you connect a pile of tools/MCP/skills and want to know what's actually earning its keep.

The trick is that the agent is the instrument: it can read its own loaded context, so instead of guessing what the harness injects it inventories what it was actually given this session — tools grouped by origin, auto-loaded vs. invoke-only skills, MCP servers and where each is configured, subagents, and memory/rules in effect. It then **correlates** against real usage — scanning past transcripts and cross-checking the repo — because bloat is precisely what's *loaded but unused*: a Supabase or Vercel connector riding along in a repo with no trace of that service, a plugin's 40 tool defs never once invoked here.

Rather than silently editing your config, it presents a ranked table — *surface → estimated saving → mechanism → scope → why safe* — and for every cut spells out plainly what you'd give up, so you make an informed decision instead of just chasing a smaller number. The fixes it draws from cover the full stack: pruning synced connectors (per-server, not blanket), gating rarely-used skills behind explicit invocation (`disable-model-invocation`), routing monolithic skills into a tiny dispatch table with heavy content read on demand, relocating conditional rules into nested `CLAUDE.md` / `AGENTS.md` that load only when you touch that subtree, and downgrading heavy `@import` bodies to light pointers.

It's opinionated about guardrails, too: treat every flag and path as illustrative and confirm today's mechanism in the agent's own docs; propose, never apply, since config edits are durable and user-owned; and judge a cut by its *reach* — a `.claude` + `.agents` dual-home is intentional cross-harness support, and a global-vs-project duplicate is usually deliberate, not waste. Killing something load-bearing is worse than the bloat, so the win is a smaller context that can still do the job.

---

## Links

- Directory entry: https://andrey-markin.com/directory/context-doctor
- All directory entries: https://andrey-markin.com/directory
- Contact: https://andrey-markin.com/#contact
