Agent skill
managing-context-window
Helps manage context window efficiently by summarizing, focusing, and pruning context to stay within token limits.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/managing-context-window-deancochran-gradientpeak
SKILL.md
Managing Context Window Skill
When to Use
- Context is approaching token limits
- User asks to summarize conversation history
- Need to focus on specific task
- Working with large files or codebases
What This Skill Does
- Analyzes current context usage
- Identifies non-essential information
- Creates summaries of conversation history
- Focuses context on current task
- Prunes redundant or outdated information
Strategies
1. Summarize Previous Work
Summary of work so far:
- Implemented activity recording service
- Added GPS tracking functionality
- Created activity list screen
- Working on: activity detail view
Current task: Add activity statistics calculation
2. Focus on Current Task
Keep only:
- Current implementation goal
- Relevant code files
- Recent error messages
- Specific questions to answer
3. Prune Redundant Information
- Remove completed sub-tasks
- Remove duplicate information
- Remove outdated context
- Remove exploratory messages
4. Use File References
Instead of pasting full file contents:
- Reference file paths
- Use Grep to find specific sections
- Read specific line ranges
Implementation
// Use TodoWrite to track progress instead of comments
const todos = [
{ id: "1", content: "Implement activity recording", status: "completed" },
{ id: "2", content: "Add GPS tracking", status: "completed" },
{ id: "3", content: "Create activity detail view", status: "in_progress" },
];
// When switching tasks, update context
function switchTask(newTask: string) {
return {
task: newTask,
relevantFiles: getRelevantFiles(newTask),
summary: summarizeCompletedWork(),
};
}
Best Practices
- Use TodoWrite for tracking
- Reference files instead of pasting
- Summarize completed work
- Focus on current task
- Remove outdated context
- Keep error messages relevant
- Use specific line ranges when reading
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?