ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified productivity Safety 4/5

context-shrink

Auto-compress session memories when context usage exceeds 85%

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/bg1avd/context-shrink
Or

What 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

  1. 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.
  2. Resource-Constrained Environments: Essential for users running smaller local models that have limited context windows and need aggressive management to prevent memory overflow.
  3. Automated Documentation: Perfect for maintaining a clean, readable summary of project progress, as the skill automatically archives granular daily logs into a structured MEMORY.md file, which is much easier to review than thousands of lines of individual log files.

Example Prompts

  1. "OpenClaw, verify my current memory state and tell me if context-shrink has performed any recent cleanup."
  2. "Compress my logs early, I am working on a new feature and need 90% of my context window cleared for the upcoming code analysis."
  3. "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:3b is 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_KEEP below 1 if you rely on rapid-fire iterative feedback.

Metadata

Author@bg1avd
Stars4473
Views0
Updated2026-05-01
View Author Profile
AI Skill Finder

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 skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-bg1avd-context-shrink": {
      "enabled": true,
      "auto_update": true
    }
  }
}

Tags(AI)

#automation#memory-management#token-optimization#cleanup
Safety Score: 4/5

Flags: file-write, file-read, code-execution