Context Compressor for Openclaw

Context Compressor turns verbose Markdown conversation logs into compact, structured memory summaries while preserving critical decisions, lessons, and follow-up tasks.

thcjp
v1.0.0
Jul 22, 2026
0
377
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install context-compressor-free

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install context-compressor-free using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Context Compressor?

Context Compressor is a local Node.js utility for reducing the size of AI agent conversation logs and long-term memory files. It typically delivers 4–8x compression by removing repetition, retaining turning points, summarizing processes into outcomes, and preserving important context for future sessions.

Designed for Openclaw Skills workflows and compatible with AI agents that support SKILL.md instructions, the skill organizes memory into identity, strategic memory, and detailed daily logs. It helps developers, personal assistants, students, and automation teams control token usage without discarding key decisions or lessons.

Context Compressor Use Cases

  • Compress daily or monthly Markdown logs before adding them to an agent's MEMORY.md.
  • Prevent long-running AI coding sessions from overwhelming the context window.
  • Archive independent developer logs while keeping technical decisions easy to retrieve.
  • Reduce token consumption and improve response speed for personal AI assistants.
  • Create concise project decision summaries from several months of agent activity.
  • Maintain memory every 2–3 days as part of an agent heartbeat or maintenance routine.
  • Process mixed Chinese and English logs using keyword-based extraction patterns.
  • Run a privacy-focused local compression workflow without uploading log data.

How Context Compressor Works

  1. The agent or developer provides a Markdown log file and, optionally, an output path.
  2. The script reads the source file, handles UTF-8 content and removes a possible BOM header.
  3. A hybrid extraction strategy scans headings and content for event, decision, lesson, growth, insight, and task patterns in Chinese and English.
  4. Matching sections are retained through keyword extraction; sections without recognized keywords use a fallback extraction strategy so important content is not silently omitted.
  5. The compressor applies four principles: remove repetition, retain turning points, replace lengthy process descriptions with outcomes, and omit details that can be inferred from structure.
  6. The result is rendered as a structured Markdown summary containing key events, lessons, and pending or follow-up items.
  7. The developer reviews the summary and appends it to MEMORY.md, archives it, or combines multiple summaries into a project decisions document.
  8. The original log remains available as the detailed third memory layer, while the compressed summary becomes the efficient long-term reference.

Context Compressor Setup

Requirements

  • An AI agent platform that supports SKILL.md, such as Claude Code, Cursor, Codex, or Gemini CLI.
  • Windows, macOS, or Linux.
  • Node.js 14 or newer.
  • The bundled scripts/context-compressor.js file.
  • An LLM with tool-use capability when the skill is invoked through an agent. The free local script does not require an additional API key.

Installation and first run

Place the skill and its scripts directory in the agent workspace, confirm Node.js is available, and run the compressor against a Markdown memory file:

node --version
node scripts/context-compressor.js --help
node scripts/context-compressor.js memory/2026-03-14.md

Write the compressed result to a specific location with:

node scripts/context-compressor.js memory/2026-03-14.md /tmp/compressed.md

After reviewing the output, append it to long-term memory:

cat /tmp/compressed.md >> MEMORY.md
date +%s > .last-memory-maintenance

For recurring Openclaw Skills maintenance, execute the command every 2–3 days or whenever daily logs become large. The free version processes one file at a time, so batch jobs require a shell loop.

Context Compressor Data Schema & Taxonomy

Memory layers

Layer File or location Purpose
Identity profile IDENTITY.md Stable agent identity, priorities, and essential operating context.
Strategic memory MEMORY.md Compressed long-term knowledge, decisions, lessons, and pending work.
Detailed archive memory/YYYY-MM-DD.md Complete daily conversation or activity logs retained for reference.

Compressed summary structure

  • ## or ### headings from the source are used to identify sections.
  • Important events and decisions are preserved as key turning points.
  • Lessons, insights, and improvements are retained as reusable knowledge.
  • Pending, urgent, and next-step items are retained as actionable tasks.
  • Multi-day input can preserve date information while combining extracted sections.
  • Output is Markdown and can be written to standard output or a specified file.

Input and output behavior

Item Behavior
Supported input Markdown logs using #, ##, and ### headings.
Plain text without structure Produces a friendly notice about the missing Markdown structure.
Empty file Skips cleanly without treating it as a fatal error.
Encoding Detects and removes BOM; warns on non-UTF-8 input and continues when possible.
Missing output directory Creates the directory automatically.
Output format Structured Markdown summary suitable for MEMORY.md, archives, or project decision documents.
Metadata Operational metadata can include the maintenance timestamp stored in .last-memory-maintenance.

Context Compressor Advanced Features

  • Hybrid extraction combines keyword matching with fallback top-of-section extraction to reduce the risk of losing useful information.
  • Recognizes more than 40 Chinese and English event, lesson, growth, and task-oriented patterns.
  • Uses a three-layer memory architecture that separates stable identity, compressed strategy memory, and complete historical logs.
  • Supports standard output or an explicit destination file for review and archival workflows.
  • Handles empty files, BOM-encoded content, non-UTF-8 warnings, missing output directories, and multi-day merged logs.
  • Works locally and does not upload source logs, improving privacy for sensitive agent memory.
  • Can be integrated into heartbeat routines, scheduled maintenance, shell loops, and Openclaw Skills automation workflows.
  • Supports manual review before summaries are merged into long-term memory, providing a safer migration path.
  • Free-version limitations include single-file processing, a fixed output template, basic keyword matching, and no built-in incremental compression, quality scoring, custom templates, compression history, or automatic classification; those capabilities are reserved for context-compressor-pro.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*