Skip to content
Back to skills

Context Shrink

ASecurity

Auto-compress session memories when context usage exceeds 60%

  • 33 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 5, 2026
developmenttypescriptgit

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add dvcrn/openclaw-skills-marketplace --skill context-shrink --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Context Shrink?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Context Shrink
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dvcrn-context-shrink/badge)](https://www.skillsdirectory.com/skills/dvcrn-context-shrink)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: context-shrink
description: "Auto-compress session memories when context usage exceeds 60%"
---

# Context Shrink Hook

Auto-compresses session memories when context usage exceeds 60% threshold. Cleans up old daily logs and compresses them into MEMORY.md for long-term storage.

## Features

- **自动触发**: 当 context 使用率 ≥ 60% 时自动执行
- **智能清理**: 保留最近 3 天的详细日志
- **压缩存储**: 旧日志压缩后写入 MEMORY.md
- **Git 提交**: 自动 commit 变更记录

## Configuration

```typescript
CONTEXT_THRESHOLD = 0.6     // 60% 触发阈值
DAYS_TO_KEEP = 3           // 保留最近 N 天日志
MIN_FILES_TO_KEEP = 5      // 至少保留文件数
COMPRESSION_MODEL = 'ollama-remote/qwen2.5:3b'
```

## Changelog

### 1.0.0
- Initial release
- Auto-compression at 60% threshold
- Git commit on cleanup

Files in this skill

  • HOOK.md2.8 KB
  • SKILL.md864 B
  • handler.ts7.3 KB
  • package.json380 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.