EmanuProds/dotfiles / skills/dynamic-context-pruning
dynamic-context-pruning"
UnverifiedOptimizes token usage by pruning obsolete tool outputs from conversation context. Reduces token consumption while maintaining relevant context for better performance.
Dynamic Context Pruning
Optimizes token usage by pruning obsolete tool outputs from conversation context.
Overview
This skill automatically identifies and removes outdated or irrelevant tool outputs from the conversation context, reducing token consumption while maintaining relevant information for better performance.
When to Use
Use this skill when:
- Working on long conversations with many tool calls
- Token usage is becoming a concern
- You want to maintain performance while reducing costs
- Working with models that have limited context windows
- Using MCP servers or skills that generate large outputs (e.g. firecrawl-web, web search) — MCP tool descriptions and results are a major source of context bloat
How It Works
Context Analysis
The skill continuously monitors:
- Tool outputs and their relevance to current tasks
- Age of information in the context
- Frequency of reference to specific context items
- Task progression and context needs
Pruning Criteria
Context items are pruned when they:
- Haven't been referenced in recent messages
- Are older than a specified threshold
- Are superseded by newer information
- Don't match current task focus
Preservation Rules
The skill preserves:
- Recent and frequently referenced information
- Critical context for current tasks
- User-provided instructions and preferences
- Error messages and debugging information
Workflow
Automatic Operation
The skill operates automatically:
- Monitors context after each tool call
- Analyzes relevance of existing context
- Identifies candidates for pruning
- Removes obsolete information
- Maintains context integrity
Manual Control
You can also manually trigger pruning:
/context prune
Or check what would be pruned:
/context analyze
Best Practices
Context Management
- Allow the skill to operate automatically for best results
- Use manual commands when you notice performance issues
- Review pruned context if information seems missing
Performance Optimization
- Combine with other context management skills
- Use focused prompts to reduce context needs
- Break complex tasks into smaller sessions when possible
Monitoring
Watch for these indicators:
- Increased token usage in long sessions
- Slower response times
- Model confusion about previous steps
Integration Points
With Other Skills
- agent-memory: Preserves references to stored memories
- napkin: Maintains napkin content in context
- dev-cli-tools: Prunes obsolete command outputs while preserving important results
Tool Integration
The skill works with:
- File operations (read, write, edit)
- Shell commands and their outputs
- API calls and responses
- Search results and findings
Configuration
Pruning Thresholds
Adjust sensitivity:
/context sensitivity high|medium|low
Preservation Rules
Specify what to always keep:
/context preserve "critical-file-name"
Monitoring
Enable detailed logging:
/context log enable
Example Scenarios
Long Debugging Session
- Multiple file reads and edits
- Shell command executions with verbose output
- Gradual pruning of resolved issues
- Focus on current debugging state
Code Review Process
- Read multiple files for context
- Run tests and analyze outputs
- Prune test results after addressing issues
- Maintain focus on current review points
Research Task
- Search and gather information
- Prune outdated search results
- Keep relevant findings in context
- Update context as research progresses
Troubleshooting
Missing Information
If important context seems missing:
/context restore
Performance Issues
If pruning seems too aggressive:
/context sensitivity low
Debugging
To see what's being pruned:
/context log enable
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |