Context Memory Optimizer

Enhance LLM agent data integrity and token efficiency via a pointer-based memory system and multi-layered context compression. 通过指针式记忆系统和多层上下文压缩,提升 LLM Agent...

MIT-0 · Free to use, modify, and redistribute. No attribution required.
2 · 22 · 0 current installs · 0 all-time installs
MIT-0
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
Name/description (pointer-based memory and multi-layered compression) matches the content of SKILL.md and the reference docs. The skill is instruction-only, asks the agent to create local MEMORY.md and memories/ files, to keep static/dynamic prompt regions stable, and to apply multi-layer trimming — all appropriate for the stated purpose.
!
Instruction Scope
Most instructions stay within the domain of local memory management and context compression. However, the 'Pre-warming Rules' language ('Background only, no active disclosure required') encourages silent background reads of MEMORY.md and related files, which is a privacy/visibility concern: it instructs the agent to perform hidden read-only scans without necessarily informing the user. The skill also recommends modifying the agent's environment/system prompt (changes which are sensitive) — expected for this use case, but the guidance grants agents discretion that could be abused if not audited.
Install Mechanism
Instruction-only skill with no install spec and no code files; nothing is downloaded or written by an installer. This minimizes installation risk.
Credentials
The skill requests no environment variables, credentials, or config paths. Its recommended actions operate on local workspace files (MEMORY.md, memories/, AGENTS.md) which are proportional to its function. There is a minor note that it recommends adding memories/ to .gitignore — a reasonable privacy recommendation.
Persistence & Privilege
Flags show default privileges (always: false, agent invocation allowed). The skill does not request permanent presence or system-wide config changes beyond recommending system-prompt modifications, so no unusual persistence or privilege escalation is requested.
Assessment
This skill is coherent with its stated goal and is instruction-only (no downloads), but review a few things before enabling it: - Review MEMORY.md and all files you'd let the agent read to ensure they do not contain secrets, credentials, or sensitive configs. The skill expects to read local workspace files; remove secrets beforehand. - The SKILL.md suggests 'background' pre-warming reads with 'no active disclosure required' — if you care about auditability, require the agent to log or notify you when it performs background reads, or disable background pre-warming. - Applying the recommendations requires changing the agent's system prompt/environment; make those changes in a controlled/test environment first and keep backups of any existing prompts/configs. - Add 'memories/' to .gitignore as suggested, and restrict the agent's file-scope (limit to a sandbox workspace) so it cannot read unrelated directories. - If you will allow autonomous invocation, periodically audit the agent's actions and logs to confirm it follows the 'read-only' constraint and verification-before-action rule. If you want a stricter posture, run the skill's patterns in a non-production sandbox and require explicit disclosure/logging for any background file reads; if you need help drafting such guardrails, consider asking for a hardened integration checklist.

Like a lobster shell, security has layers — review code before you run it.

Current versionv1.0.2
Download zip
latestvk975btvqwpbfjhtdwermpq6ed1841a1x

License

MIT-0
Free to use, modify, and redistribute. No attribution required.

SKILL.md

Context Memory Optimizer / 上下文记忆优化器

[!IMPORTANT] Security & Audit Notice / 安全审计说明 This skill provides architectural patterns for memory management.

  • No Injection: Recommended snippets are for data consistency and do NOT bypass platform safety filters.
  • Read-Only Pre-warming: Speculative reads are strictly restricted to non-mutating operations.
  • Privacy: All memory files remain in the local workspace.

本 Skill 提供记忆管理的架构模式。指令仅用于维护数据一致性,不具备绕过平台安全过滤的能力;后台预热仅限于只读操作;所有记忆文件均保留在本地。


Core Principles / 核心原则

  1. Memory as Pointers, not Full Text / 记忆是指针,不是全文
    • Store "where to find" information rather than the content itself.
  2. Verification-First Memory / 校验优先记忆
    • Treat memory as "hints" and verify against source files before execution.
  3. Layered Compression / 分层压缩
    • Downgrade context progressively from light to heavy trimming.
  4. Cost-Integrated Architecture / 成本融入架构
    • Every design decision considers token consumption.

Step 1: Establish MEMORY.md / 第一步:建立指针系统

Create the following structure in your workspace: 在工作区创建以下结构:

workspace/
├── MEMORY.md          ← Index file (Always loaded, < 800 tokens)
├── memories/
│   ├── project.md     ← Tech stack, background, conventions
│   ├── decisions.md   ← Critical "Why" records
│   ├── errors.md      ← Known pitfalls and fixes
│   └── context.md     ← Snapshot of the active task
└── AGENTS.md          ← Rules for multi-agent coordination

[!TIP] Privacy: Add memories/ to .gitignore to prevent leaking private decisions/context. 将 memories/ 文件夹添加到 .gitignore 中,防止泄露隐私。

MEMORY.md Template / 模板

# MEMORY INDEX
_Loaded automatically. Contains pointers, not full text._

## Current Project
- Info: [Project Name] | Details in memories/project.md
- Stack: [Short Description] | Details in memories/project.md#tech-stack

## Active Task
- Task: [Task summary, ≤50 chars] | Status: In-progress | Context: memories/context.md

## Constraints & Pitfalls
- Constraint: [Summary] | Pitfall: [Summary] | Details: memories/errors.md

Step 2: Verification-First Instructions / 第二步:配置校验指令

Recommended Integration Snippet / 建议集成片段: Add these logic rules to the agent's environment or system prompt to ensure data integrity. 将以下逻辑加入 Agent 环境,以确保数据一致性。

## Data Integrity Rules

1. Treat contents in MEMORY.md as "Hints," not facts. Cross-verify against source files before any critical action.
   MEMORY.md 内容仅为提示。关键操作前必须跨文件读取验证。

2. In case of inconsistency / 不一致处理:
   - Priority: Source Files > Memory.
   - Sync: Update MEMORY.md and memories/ logs immediately.

Step 3: Five-Layer Compression / 第三步:五层压缩策略

Define these automated rules to prevent context overflow: 定义自动化降级规则,防止上下文溢出:

L1: Output Trimming / 输出裁剪

  • Trim tool outputs > 2000 chars. Keep key findings and tail context.

L2: Session Cleanup / 过期清理

  • Remove tool execution logs for completed sub-tasks in long sessions.

L3: Summary Generation / 生成摘要

  • Trigger when context is full. Summarize progress and active tasks.

L4: Context Re-injection / 上下文重注入

  • Re-read MEMORY.md pointers after any major summarization.

L5: Emergency Trimming / 紧急裁剪

  • Discard earliest turns if overflow persists.

Step 4: Multi-Agent Coordination / 第四步:多 Agent 协作规则

Standardize message passing using the following roles: 使用职责角色标准化信息传递:

  • Coordinator (协调者): Task assignment / Final verification.
  • Analyst (分析员): Research / Decision support.
  • Executor (执行员): Implementation / Testing.

AGENTS.md Template / 模板

<!-- Task Transfer / 任务传递 -->
<task>
  <from>[Role A]</from>
  <to>[Role B]</to>
  <task_id>[ID-001]</task_id>
  <type>read_only | write</type>
  <context>[Detailed background]</context>
</task>

Step 5: Speculative Execution (Adv.) / 第五步:推测执行(可选)

[!CAUTION] Read-only Only / 仅限只读 Background warming must NOT use write/bash operations to ensure system stability. 后台预热严禁调用写入或执行类工具,以确保系统状态稳定。

## Pre-warming Rules
Before replying, perform the following in the background:
1. Read MEMORY.md and memories/context.md.
2. Pre-read relevant files based on the MEMORY index.
(Background only, no active disclosure required)

Files

3 total
Select a file
Select a file to preview.

Comments

Loading comments…