src/skills/builtin/context_doctor/SKILL.md
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 skillsauth add letta-ai/letta-code Context DoctorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Your context is what makes you you across sessions. You are responsible for managing it (along with memory subagents). It includes:
system/)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.
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:
Your system prompt and memory filesystem should be well structured and clear.
Questions to ask:
Memories that are compiled as part of the system prompt (contained in system/) should only take up about 10% of the total context size (usually ~15-20K tokens), though this is a recommendation, not a hard requirement.
Use the following script to evaluate the token usage of the system prompt:
npx tsx <SKILL_DIR>/scripts/estimate_system_tokens.ts --memory-dir "$MEMORY_DIR"
Where <SKILL_DIR> is the Skill Directory shown when the skill was loaded (visible in the injection header).
Questions to ask:
Solution: Reduce the size of the system prompt if needed:
system/ so they are no longer part of the system promptsystem/ and reference it via [[path]] links to create discovery pathsScope: You may refine, tighten, and restructure prompts to improve clarity and adherence — but do not change the intended semantics. The goal is better signal, not different behavior.
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:
Solution: Read all memory files (use subagents for efficiency), then:
[[reference/api]])Files in the memory filesystem must follow certain structural requirements:
system/persona.mdsystem/human.md and system/human/identity.md)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
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 system prompt, and must be dynamically loaded. You must index your files to ensure your future self can discover them: for example, make sure that files have informative names and descriptions, or are referenced from parts of your system prompt via [[path]] links to create discovery paths. Otherwise, you will never discover the external context or make use of it.
Solution:
When running a migration, always use the skill [[skills/db-migrations]]
or external memory files:
Sarah's active projects are: Letta Code [[projects/letta_code.md]] and Letta Cloud [[projects/letta_cloud]]
Create a plan for what fixes you want to make, then implement them.
Before moving on, verify:
[[path]] references from in-context memory so it can be discoveredReview changes, then commit with a descriptive message:
cd $MEMORY_DIR
git status # Review what changed before staging
git add <specific files> # Stage targeted paths — avoid blind `git add -A`
git commit --author="<AGENT_NAME> <<ACTUAL_AGENT_ID>@letta.com>" -m "fix(doctor): <summary> 🏥
<identified issues and implemented solutions>"
git push
Tell the user what issues you identified, the fixes you made, the commit you made, and also recommend that they run /recompile to apply these changes to the current system prompt.
Before finishing make sure you:
/recompile to refresh the system prompt and apply changestools
Schedules reminders and recurring tasks via the letta cron CLI. Use when the user asks to be reminded of something, wants periodic messages, or needs to manage scheduled tasks.
tools
# Skill Execute a skill within the main conversation When users ask you to perform tasks, check if any of the available skills match. Skills provide specialized capabilities and domain knowledge. When users reference a "slash command" or "/<something>" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke it. How to invoke: - Use this tool with the skill name and optional arguments - Examples: - `skill: "pdf"` - invoke the pdf skill - `skill: "commit", a
documentation
Guide for working in parallel with other agents. Use when another agent is already working in the same directory, or when you need to work on multiple features simultaneously. Covers git worktrees as the recommended approach.
testing
Manage git-backed memory repos. Load this skill when working with git-backed agent memory, setting up remote memory repos, resolving sync conflicts, or managing memory via git workflows.