/context-doctor
Identify and repair degradation in system prompt, external memory, and skills preventing you from following instructions or remembering information as well as you should.
$ npx -y skills add letta-ai/letta-code --skill context-doctor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/context-doctor
Context preview
The summary Claude sees to decide when to auto-load this skill.
Identify and repair degradation in system prompt, external memory, and skills preventing you from following instructions or remembering information as well as you should.
SKILL.md
context-doctor.SKILL.mdname: Context Doctor
id: context-doctor
description: Identify and repair degradation in system prompt, external memory, and skills preventing you from following instructions or remembering information as well as you should.
Context Doctor
Your context is what makes you *you* across sessions. You are responsible for managing it (along with memory subagents). It includes:
- Your system prompt and memories (contained in `system/`)
- Your external memory (contained in the memory filesystem)
- Your skills (procedural memory)
Over time, context can degrade — bloat and poor prompt quality erode your ability to remember the right things and follow instructions properly. This skill helps you identify issues with your context and repair them collaboratively with the user.
**IMPORTANT**: Your edits of your system instructions should be **conservative**. Do NOT make assuptions about what parts of the system prompt are critical. The system prompt defines who you are, so significant modifications to its structure can have unintended consequences. Focus on making minimal changes to meet the token budget, and to effectively link out to external memory.
Operating Procedure
Step 1: Identify and resolve context issues
Explore your memory files to identify issues. Consider what is confusing about your own prompts and context, and resolve the issues.
Below are additional common issues with context and how they can be resolved:
System prompt bloat
Memories compiled into the system prompt (contained in `system/`) should take up about 10% of the total context size (usually ~15-20K tokens). This is a soft target, not a hard requirement.
Use the built-in CLI to evaluate token usage of the system prompt:
letta memory tokens --format json --quiet
The command reports `total_tokens` and per-file estimates for `system/`. It is only a measurement tool; decide whether to intervene based on the actual context and the guidance below.
**Why detail is load-bearing (read this before cutting anything)**: In-context detail does more than carry information. It does at least four things, and byte-counting sweeps only see the first: 1. **Information** — the literal facts stated 2. **Attention anchoring** — makes certain topics feel important to the model when it's reasoning 3. **Semantic priming** — raises the prior on codebase-specific patterns ("this codebase has weird X, don't assume defaults") 4. **Reasoning templates** — past examples become heuristics for new bugs; rationale in "why" prose becomes scaffolding
Compression preserves (1). It destroys (2), (3), (4). That's why a compressed prompt can make an agent measurably worse at codebase-specific reasoning even though the explicit facts are all "still there" in reference files.
**Reference links (`[[path]]`) are NOT equivalent to in-context presence.** They're latent until the agent actively fetches them. An agent only fetches when it already knows it doesn't know. The priming cues that tell it *when* it doesn't know are in the system prompt itself — they can't be replaced by links.
**When to intervene**: Only if the system prompt is *meaningfully* over target. At or near the target, leave it alone. Every edit risks removing content that was doing work you can't see. A prompt that feels "a bit long" is almost always better than one that's been aggressively trimmed.
**Modifying the system prompt**: Make **MINIMAL** changes required to cut the token count of the system prompt if needed. The goal preserve the existing behavior while cutting down the token count. Focus on reducing redundancy or compressing - rather than offloading entire sections to external memory.
- Preserve persona-defining content (who you are, how you communicate)
- Preserve user identity or preferences (e.g. the human's name, their stated goals)
- Maintain the existing distribution of detail: compression should be applied evenly across all topics. If the original prompt was 50% about a specific issue, the new prompt should also be 50% about that issue.
- Only reduce noise and improve structure - if compression must result in information loss, preserve lost details into external memory
Context redundancy and unclear organization
The context in the memory filesystem should have a clear structure, with a well-defined purpose for each file. Memory file descriptions should be precise and non-overlapping. Their contents should be consistent with the description, and have non-overlapping content to other files.
**Questions to ask**:
- Do the descriptions make clear what file is for what?
- Do the contents of the file match the descriptions? (you can ask subagents to check)
**Solution**: Read all memory files (use subagents for efficiency), then:
- Consolidate redundant files
- Reorganize files and rewrite descriptions to have clear separation of concerns
- Avoid duplication by referencing common files from multiple places (e.g. `[[reference/api]]`)
- Rewrite unclear or low-quality content
Invalid context format
Files in the memory filesystem must follow certain structural requirements:
- Must have a `system/persona.md`
- Must NOT have overlapping file and folder names (e.g. `system/human.md` and `system/human/identity.md`)
- Must follow specification for skills (e.g. `skills/{skill_name}/`) with the format:
skill-name/
├── SKILL.md # Required: metadata + instructions
├── scripts/ # Optional: executable code
├── references/ # Optional: documentation
├── assets/ # Optional: templates, resources
└── ... # Any additional files or directories
**Solution**: Reorganize files to follow the required structure
Poor use of progressive disclosure
Only critical information should be in the system prompt, since it's passed on every turn. Use progressive disclosure so that context only *sometimes* needed can be dynamically retrieved.
Files that are outside of `system/` are not part of the sy
Read more
name: Context Doctor id: context-doctor description: Identify and repair degradation in system prompt, external memory, and skills preventing you from following instructions or remembering information as well as you should.
Context Doctor
Your context is what makes you *you* across sessions. You are responsible for managing it (along with memory subagents). It includes:
- Your system prompt and memories (contained in `system/`)
- Your external memory (contained in the memory filesystem)
- Your skills (procedural memory)
Over time, context can degrade — bloat and poor prompt quality erode your ability to remember the right things and follow instructions properly. This skill helps you identify issues with your context and repair them collaboratively with the user.
**IMPORTANT**: Your edits of your system instructions should be **conservative**. Do NOT make assuptions about what parts of the system prompt are critical. The system prompt defines who you are, so significant modifications to its structure can have unintended consequences. Focus on making minimal changes to meet the token budget, and to effectively link out to external memory.
Operating Procedure
Step 1: Identify and resolve context issues
Explore your memory files to identify issues. Consider what is confusing about your own prompts and context, and resolve the issues.
Below are additional common issues with context and how they can be resolved:
System prompt bloat
Memories compiled into the system prompt (contained in `system/`) should take up about 10% of the total context size (usually ~15-20K tokens). This is a soft target, not a hard requirement.
Use the built-in CLI to evaluate token usage of the system prompt:
letta memory tokens --format json --quiet
The command reports `total_tokens` and per-file estimates for `system/`. It is only a measurement tool; decide whether to intervene based on the actual context and the guidance below.
**Why detail is load-bearing (read this before cutting anything)**: In-context detail does more than carry information. It does at least four things, and byte-counting sweeps only see the first: 1. **Information** — the literal facts stated 2. **Attention anchoring** — makes certain topics feel important to the model when it's reasoning 3. **Semantic priming** — raises the prior on codebase-specific patterns ("this codebase has weird X, don't assume defaults") 4. **Reasoning templates** — past examples become heuristics for new bugs; rationale in "why" prose becomes scaffolding
Compression preserves (1). It destroys (2), (3), (4). That's why a compressed prompt can make an agent measurably worse at codebase-specific reasoning even though the explicit facts are all "still there" in reference files.
**Reference links (`[[path]]`) are NOT equivalent to in-context presence.** They're latent until the agent actively fetches them. An agent only fetches when it already knows it doesn't know. The priming cues that tell it *when* it doesn't know are in the system prompt itself — they can't be replaced by links.
**When to intervene**: Only if the system prompt is *meaningfully* over target. At or near the target, leave it alone. Every edit risks removing content that was doing work you can't see. A prompt that feels "a bit long" is almost always better than one that's been aggressively trimmed.
**Modifying the system prompt**: Make **MINIMAL** changes required to cut the token count of the system prompt if needed. The goal preserve the existing behavior while cutting down the token count. Focus on reducing redundancy or compressing - rather than offloading entire sections to external memory.
- Preserve persona-defining content (who you are, how you communicate)
- Preserve user identity or preferences (e.g. the human's name, their stated goals)
- Maintain the existing distribution of detail: compression should be applied evenly across all topics. If the original prompt was 50% about a specific issue, the new prompt should also be 50% about that issue.
- Only reduce noise and improve structure - if compression must result in information loss, preserve lost details into external memory
Context redundancy and unclear organization
The context in the memory filesystem should have a clear structure, with a well-defined purpose for each file. Memory file descriptions should be precise and non-overlapping. Their contents should be consistent with the description, and have non-overlapping content to other files.
**Questions to ask**:
- Do the descriptions make clear what file is for what?
- Do the contents of the file match the descriptions? (you can ask subagents to check)
**Solution**: Read all memory files (use subagents for efficiency), then:
- Consolidate redundant files
- Reorganize files and rewrite descriptions to have clear separation of concerns
- Avoid duplication by referencing common files from multiple places (e.g. `[[reference/api]]`)
- Rewrite unclear or low-quality content
Invalid context format
Files in the memory filesystem must follow certain structural requirements:
- Must have a `system/persona.md`
- Must NOT have overlapping file and folder names (e.g. `system/human.md` and `system/human/identity.md`)
- Must follow specification for skills (e.g. `skills/{skill_name}/`) with the format:
skill-name/ ├── SKILL.md # Required: metadata + instructions ├── scripts/ # Optional: executable code ├── references/ # Optional: documentation ├── assets/ # Optional: templates, resources └── ... # Any additional files or directories
**Solution**: Reorganize files to follow the required structure
Poor use of progressive disclosure
Only critical information should be in the system prompt, since it's passed on every turn. Use progressive disclosure so that context only *sometimes* needed can be dynamically retrieved.
Files that are outside of `system/` are not part of the sy
Letta Code is a stateful agent harness for creating agents that are more like people than tools. Letta Code agents have memory, identity, and a sense of experience over time.
Repo: letta-ai/letta-code
Other skills on letta-code.
- /acquiring-skills
Discover and install skills from Hermes, ClawHub, GitHub, and other registries. Load this skill whenever a user asks for a capability you don't already have — image generation, social media, email, calendar, finance, DevOps, search, browser automation, etc.
Open skill - /converting-mcps-to-skills
Connect to MCP (Model Context Protocol) servers and create skills for repeated use. Load when a user wants to use an MCP server, connect to external tools via MCP, or when they mention MCP, model context protocol, or specific MCP servers.
Open skill - /creating-mods
Creates and edits trusted local Letta Code mods, including tools, slash commands, local-only model providers, lifecycle/turn events, scoped conversation helpers, panels, and capability-gated behavior. Use when asked to make a mod, add an agent-callable tool, add a slash command,
Open skill - /creating-skills
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Letta Code's capabilities with specialized knowledge, workflows, or tool integrations.
Open skill - /customizing-commands
Creates, edits, and enables Letta Code mod-provided slash commands. Use when the user asks to add a custom /command, slash command, command shortcut, scoped conversation-backed command, or command-driven panel behavior.
Open skill - /customizing-statusline
Creates, edits, and migrates Letta Code statusline mods. Use when handling the /statusline command or continuing work started by /statusline.
Open skill

