manage-agent-context
Decide what goes into a model's context and what stays out, because a long context dilutes the instruction that matters.
Save as .claude/skills/manage-agent-context/SKILL.md in a repository, or under ~/.claude/skills/manage-agent-context/SKILL.md to have it everywhere. The copy button takes the whole file, frontmatter included.
--- name: manage-agent-context description: Decide what goes into a model's context and what stays out, so the instruction that matters is not diluted. Use when a long task is filling the context, when preparing a prompt or a brief for another agent, or when an agent starts repeating itself or drifting from the task. --- # Manage agent context Context is a budget. Everything in it competes for attention with the one instruction that matters, so put things in on purpose. ## Principles - **Relevance beats volume.** A long context dilutes the instruction. A model given forty files and one constraint follows the constraint less reliably than a model given three files and the same constraint. - **Stale is worse than missing.** Missing context prompts a lookup. Stale context produces confident action on something no longer true. - **A note beats raw output.** What you need from a tool call is usually one fact and where it came from. ## Order of work 1. State the task in one or two sentences before gathering anything. If you cannot, you do not yet know what is relevant. 2. Locate before you read. Search for the symbol or file name, then read the specific file, or the specific part of it. Do not paste the repository. 3. After each read or tool call, note what it said: the fact, the path and the line. Carry the note forward, not the output. 4. Drop what has been superseded, as soon as it is. 5. Assemble in this order: stable reference material, then findings, then the task and its constraints near the end. 6. Before a long step or a handoff, compress to decisions made, open questions and the next action. ## Reading - For a large file, read the function, not the file. - Filter logs and command output at the source. Count, search or take the tail rather than carrying two thousand lines to find one. - The trap is reading the same file three times because nothing was noted the first time. If you are about to open a file again, ask what you failed to write down. Read again only when the file has changed. - After you edit a file, your earlier note about it is stale. Replace it. ## Carrying findings forward A good summary keeps the conclusion, a pointer to the evidence, and any exact string that carries weight: an error message, a function signature, an identifier, a version. Keep those word for word. A paraphrased error message cannot be searched for and is often subtly wrong. Everything else goes: the surrounding output, the dead ends in detail, and the steps you took to get there. ## Stale context - When a plan is replaced, remove the old one. Keeping both invites a blend of the two, which is a third plan nobody chose. - For a failed approach, keep one line saying what failed and why, so it is not tried again. Drop the rest. - When instructions change part way through, restate the current version in full rather than leaving the original with a correction further down. ## Placement State the task and the constraints near the end, where they are not buried. In a long context the middle is where things get lost. If one constraint must not be broken, repeat it directly before the work begins, and keep what not to do next to the task rather than pages above it. ## Briefing another agent The other agent knows only what the brief says. Give it the goal, what has been ruled out, the paths worth reading, the constraints and the shape of the answer you want back. Ask for conclusions, not file dumps. Treat what comes back as a claim, and check the parts you will build on. ## What not to do - **Do not include material in case it helps.** If you cannot say what it is for, leave it out. - **Do not summarise away an exact value** that a later step depends on. - **Do not paraphrase the user's instructions.** Keep their wording. Your summary of a requirement is not the requirement. - **Do not trust a note about something you have since changed.** ## Say how sure you are When you act on a note rather than the source, say so. If something you dropped turns out to matter, read it again rather than rebuilding it from memory. If the context was compressed and detail may be lost, tell the reader which parts rest on a summary. ## Report back 1. What is in context, and what each part is for. 2. What was left out or dropped as stale. 3. Which statements come from notes and which from a direct read. 4. Any gap that a fresh read would close.
what it needs
Nothing. This skill is instructions only, so it works in any agent that reads SKILL.md with nothing installed and no account. Save the file and it is live in the next session.
the instructions, in full
Manage agent context
Context is a budget. Everything in it competes for attention with the one instruction that matters, so put things in on purpose.
Principles
- Relevance beats volume. A long context dilutes the instruction. A model given forty files and one constraint follows the constraint less reliably than a model given three files and the same constraint.
- Stale is worse than missing. Missing context prompts a lookup. Stale context produces confident action on something no longer true.
- A note beats raw output. What you need from a tool call is usually one fact and where it came from.
Order of work
- State the task in one or two sentences before gathering anything. If you cannot, you do not yet know what is relevant.
- Locate before you read. Search for the symbol or file name, then read the specific file, or the specific part of it. Do not paste the repository.
- After each read or tool call, note what it said: the fact, the path and the line. Carry the note forward, not the output.
- Drop what has been superseded, as soon as it is.
- Assemble in this order: stable reference material, then findings, then the task and its constraints near the end.
- Before a long step or a handoff, compress to decisions made, open questions and the next action.
Reading
- For a large file, read the function, not the file.
- Filter logs and command output at the source. Count, search or take the tail rather than carrying two thousand lines to find one.
- The trap is reading the same file three times because nothing was noted the first time. If you are about to open a file again, ask what you failed to write down. Read again only when the file has changed.
- After you edit a file, your earlier note about it is stale. Replace it.
Carrying findings forward
A good summary keeps the conclusion, a pointer to the evidence, and any exact string that carries weight: an error message, a function signature, an identifier, a version. Keep those word for word. A paraphrased error message cannot be searched for and is often subtly wrong.
Everything else goes: the surrounding output, the dead ends in detail, and the steps you took to get there.
Stale context
- When a plan is replaced, remove the old one. Keeping both invites a blend of the two, which is a third plan nobody chose.
- For a failed approach, keep one line saying what failed and why, so it is not tried again. Drop the rest.
- When instructions change part way through, restate the current version in full rather than leaving the original with a correction further down.
Placement
State the task and the constraints near the end, where they are not buried. In a long context the middle is where things get lost. If one constraint must not be broken, repeat it directly before the work begins, and keep what not to do next to the task rather than pages above it.
Briefing another agent
The other agent knows only what the brief says. Give it the goal, what has been ruled out, the paths worth reading, the constraints and the shape of the answer you want back. Ask for conclusions, not file dumps. Treat what comes back as a claim, and check the parts you will build on.
What not to do
- Do not include material in case it helps. If you cannot say what it is for, leave it out.
- Do not summarise away an exact value that a later step depends on.
- Do not paraphrase the user's instructions. Keep their wording. Your summary of a requirement is not the requirement.
- Do not trust a note about something you have since changed.
Say how sure you are
When you act on a note rather than the source, say so. If something you dropped turns out to matter, read it again rather than rebuilding it from memory. If the context was compressed and detail may be lost, tell the reader which parts rest on a summary.
Report back
- What is in context, and what each part is for.
- What was left out or dropped as stale.
- Which statements come from notes and which from a direct read.
- Any gap that a fresh read would close.
credit
This skill covers ground first mapped by addyosmani/agent-skills, a widely used open collection of engineering skills. The instructions above are written from scratch for this library, in its own voice and with its own opinions, and nothing is copied. The thanks is for the idea.