Xpersona
C

Context Compressor

CLAWHUB · Unverified

Intelligently compress context — conversations, code, logs. Preserve key information while reducing token usage. Auto-detects content type and applies optima... Skill: Context Compressor Owner: besty0121 Summary: Intelligently compress context — conversations, code, logs. Preserve key information while reducing token usage. Auto-detects content type and applies optima... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-04-02T01:57:16.488Z | auto Initial release of context-compressor. - Provides intelligent compression for conversations, code, logs, and text, preserving key

62
Rank
84
Safety
994
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 994 downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s174yh6zn30ahdy1cgjzj31bes841kse:ctx-compress
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-besty0121-ctx-compress/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

6,920 characters of source documentation, loaded on request.

Extracted files

3 files captured from the source.

SKILL.md

---
name: context-compressor
description: Intelligently compress context — conversations, code, logs. Preserve key information while reducing token usage. Auto-detects content type and applies optimal compression.
tags:
  - context
  - compression
  - productivity
  - agent
  - memory
requires:
  bins:
    - python
  env: []
---

# 上下文压缩器 / Context Compressor

在有限的上下文窗口里装下无限的对话记忆。

Fit more context in less tokens. Not truncation — intelligent compression.

## 核心理念

```
普通截断:  "这是很长的对话..." → "这是很..."           (丢了信息)
智能压缩:  "这是很长的对话..." → "讨论了XX,决定用YY"  (保留核心)
```

**不同内容,不同压缩策略:**
- 💬 对话 → 提取决策、问题、结论
- 💻 代码 → 去噪音保逻辑
- 📋 日志 → 只留错误和关键事件
- 📄 文本 → 摘要式压缩

## 命令参考

COMPRESS = python <skill_dir>/scripts/ctxcompress.py

### 压缩文本

```bash
# 从文件
$COMPRESS compress --input conversation.txt --level medium --type chat

# 从管道
echo "很长的文本..." | $COMPRESS compress --type text

# 内联文本
$COMPRESS compress --text "你的文本内容..." --level aggressive
```

**压缩级别:**
- `light` — 去掉空行和注释,保留所有内容
- `medium` — 去噪音 + 摘要 + 去重(默认)
- `aggressive` — 只保留核心信息

**内容类型(自动检测或手动指定):**
- `chat` — 对话/聊天记录
- `code` — 代码
- `log` — 日志文件
- `text` — 普通文本

### 提取变更

比较两个文件的差异:

```bash
$COMPRESS diff --old v1.txt --new v2.txt
```

输出:新增了什么、删除了什么、修改了什么。

### 提取关键信息

从文本中提取结构化信息:

```bash
$COMPRESS extract --input chat_history.txt --type chat
```

输出 JSON:
```json
{
  "decisions": ["决定用 Flask 框架"],
  "errors_and_fixes": [{"error": "port 5000 in use", "fix": "改用 8080"}],
  "commands": ["pip install flask"],
  "urls": ["https://flask.palletsprojects.com"],
  "key_terms": ["Flask", "deploy", "gunicorn"]
}
```

### 链式压缩

把多个文件压缩成一个摘要:

```bash
$COMPRESS chain file1.py file2.log conversation.txt --level medium
```

适用于:一个任务涉及多个文件,想一次性了解全貌。

### 分析压缩潜力

```bash
$COMPRESS stats --input big_file.txt
```

显示:总行数、空行占比、注释占比、预估可压缩比例。

## Agent 使用场景

### 场景 1:对话历史压缩

当对话变长时,压缩旧消息以腾出上下文:

```bash
# 导出旧对话
cat old_messages.txt | $COMPRESS compress --type chat --level medium > compressed.txt

# 用压缩后的版本替换原文
```

压缩后保留:
- ✅ 做了什么决定
- ✅ 遇到什么问题,怎么解决的
- ✅ 关键代码片段
- ❌ 去掉了寒暄、重复讨论、中间过程

### 场景 2:错误调试压缩

20 轮试错 → 压缩成 1 段:

```bash
$COMPRESS compress --input debug_session.log --type log --level aggressive
```

输出类似:
```
📊 Log Summary: 15 errors, 3 warnings, 8 key events
ERROR: Connection refused on port 5432
ERROR: Permission denied /var/log/app.log
  (above error repeated 8x)
SUCCESS: Service started on port 8080
```

### 场景 3:跨 Session 记忆传递

把上一个 session 的精华传递给新 session:

```bash
$COMPRESS chain session1_notes.md session1_code.py session1_chat.txt --level aggressive
```

输出:一个紧凑的上下文摘要,注入新 session。

### 场景 4:代码 Review 压缩

长文件压缩后便于快速理解:

```bash
$COMPRESS compress --input big_module.py --type code --level medium
```

去掉了空行、注释、docstring,只留逻辑代码。

## 自动类型检测

根据文件扩展名和内容自动判断:

| 扩展名 | 类型 |
|--------|------|
| `.py`, `.js`, `.ts`, `.go` | code |
| `.log`, `.out`, `.err` | log |
| 包含 "User:" / "Agent:" | chat |
| 其他 | text |

## 数据输出格式

压缩结果包含元信息:

```
🗜️ Compressed: 5234 → 876 chars (83% reduction)
   Type: chat | Level: medium

_meta.json

{
  "ownerId": "kn782s7mb59fzr7b3y2sqz7vc9840rfc",
  "slug": "ctx-compress",
  "version": "1.0.0",
  "publishedAt": 1775095036488
}

skill-card.md

## Description:

Intelligently compress context - conversations, code, logs. Preserve key information while reducing token usage. Auto-detects content type and applies optimal compression.

This skill is ready for commercial/non-commercial use.

## Publisher:

[besty0121](https://clawhub.ai/user/besty0121)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and productivity agents use this skill to compress conversations, code, logs, and text into compact summaries that preserve decisions, issues, key code, and statistics for context-window management and cross-session handoff.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Compressed summaries are lossy and may omit details needed for later reasoning or replacement of original context.

Mitigation: Review compressed text before using it to replace original conversation history or source material.

Risk: Input files may contain secrets, sensitive logs, URLs, paths, or snippets that can appear in terminal output.

Mitigation: Run the skill only on files intentionally selected for compression or analysis, and avoid highly sensitive inputs unless that output exposure is acceptable.

Risk: Code compression can remove comments or docstrings that carry important operational or safety context.

Mitigation: Use light mode for code when comments may be significant, and inspect the compressed result before relying on it.

## Reference(s):


## Skill Output:

**Output Type(s):** [text, markdown, code, shell commands, configuration, guidance]

**Output Format:** [Terminal text, Markdown sections, and JSON for structured extraction.]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Supports light, medium, and aggressive compression levels; reads user-selected files, inline text, or stdin.]

## Skill Version(s):

1.0.0 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Context Compressor and adjacent AI workflows.