context-shrink
Auto-compress session memories when context usage exceeds 85%
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/bg1avd/context-shrinkWhat This Skill Does
The context-shrink skill is a vital utility for OpenClaw users managing long-running sessions. When your interaction history grows, it consumes precious context window tokens, which can lead to degradation in model reasoning or truncated responses. This skill functions as an automated garbage collector, monitoring your session token usage. When your context usage hits a defined threshold (defaulting to 85%), the skill initiates a cleanup routine. It distinguishes between recent daily logs and older entries, preserving the last 3 days of interaction data while migrating older data into a consolidated MEMORY.md file. By automating the compression of long-term history, this skill ensures your AI agent maintains a lean, efficient state without losing historical context.
Installation
To add this skill to your OpenClaw environment, execute the following command in your terminal:
clawhub install openclaw/skills/skills/bg1avd/context-shrink
Once installed, you can modify the default parameters—such as the memory compression model or the retention period—within your local configuration file to suit your specific token budget requirements.
Use Cases
- Long-Term Project Continuity: Ideal for developers using OpenClaw to manage multi-week coding projects where context windows become cluttered with outdated documentation and old scratchpads.
- Resource-Constrained Environments: Essential for users running smaller local models that have limited context windows and need aggressive management to prevent memory overflow.
- Automated Documentation: Perfect for maintaining a clean, readable summary of project progress, as the skill automatically archives granular daily logs into a structured
MEMORY.mdfile, which is much easier to review than thousands of lines of individual log files.
Example Prompts
- "OpenClaw, verify my current memory state and tell me if
context-shrinkhas performed any recent cleanup." - "Compress my logs early, I am working on a new feature and need 90% of my context window cleared for the upcoming code analysis."
- "Show me the last entry added to MEMORY.md to ensure the automated compression captured my project requirements correctly."
Tips & Limitations
- Token Optimization: While
ollama/qwen2.5:3bis the default, choosing a more capable model for compression can yield more coherent long-term summaries, though it may consume more local resources. - Git Tracking: The skill automatically commits changes to your repository. Ensure your git configuration is correctly set up, as the skill will attempt to push these compression snapshots to your configured branch.
- Safety Note: Because this skill performs file-write and repository commits, ensure you have a standard backup routine for your project directory before enabling it on mission-critical repositories. Avoid setting
DAYS_TO_KEEPbelow 1 if you rely on rapid-fire iterative feedback.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-bg1avd-context-shrink": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: file-write, file-read, code-execution
Related Skills
Latex Verbatim Center
Skill by bg1avd
markdown-table-to-image
将 Markdown 表格转换为清晰图片。当用户说"表格看不清"、"生成图片"、"转成图片"时触发。
youtube-downloader-skimmer
下载 YouTube 视频并自动剪辑关键片段
task-queue-by-model-source
Multi-queue task orchestration system. Tasks are routed to queues by model source, with support for task dependencies, context passing, and failure handling. Each model source has its own FIFO queue, executing one task at a time.
QQBot Media Sender
一键发送图片/视频/文件到 QQ,支持批量发送和自动压缩