---
name: openclaw-claude-code-integration-edb621956f8d
description: "OpenClaw \u00d7 Claude Code \u7cbe\u534e\u6574\u5408 \u2014 \u8bb0\u5fc6\u7cfb\u7edf\u3001\u63d0\u793a\u8bcd\u67b6\u6784\u3001\u7194\u65ad\u673a\u5236"
---

# compact-guardian

## 用途

防止 auto-compact 连续失败导致记忆碎片堆积。

来源：Claude Code 源码泄露中发现的 `MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3` 机制。
原始数据：BQ 记录显示，未加保护的系统每天全球浪费约 25 万次 API 调用。

---

## 安装方式

复制到 `~/.openclaw/workspace/skills/compact-guardian/SKILL.md`，
然后发给你的 OpenClaw：

```
帮我注册 compact-guardian skill 并确认生效，同时在 memory-lancedb-pro 的
auto-capture 钩子里接入熔断逻辑。
```

---

## 熔断逻辑说明

```
auto-compact 触发
    ↓
成功 → 重置计数器
失败 → 计数器 +1
    ↓
计数器 >= 3
    ↓
当前 session 停止触发 auto-compact
发送通知：「压缩已熔断，请手动 /compact」
    ↓
session 结束时重置计数器
```

---

## 验证方法

```bash
openclaw skills list
# 应看到：✓ ready  📦 compact-guardian
```

检查 hooks 配置里是否包含：
- `checkCompactGuardian()` — 启动时检查是否熔断
- `recordGuardianFailure()` — compact 失败时调用
- `recordGuardianSuccess()` — compact 成功时重置计数器

---

## 注意

这个 skill 解决的是**熔断**问题，不是**清理**问题。
记忆碎片的定期清理由 `memory-compaction` skill 负责。
两者配合使用效果最好。


---
Source attribution: Ghenghis
Original project: https://github.com/Ghenghis/openclaw-claude-code-integration/blob/c96bed8f902f77d8ef75632000539fb17789a25a/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 ybbms

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: Ghenghis
Original project: https://github.com/Ghenghis/openclaw-claude-code-integration/blob/c96bed8f902f77d8ef75632000539fb17789a25a/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering
Roles: Backend Developer, DevOps / SRE, ML / AI Engineer
Specialties: Backend
Tools: Tool not specified
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 736756ae0fd2ae6c2ad1e73bba0f8a849ef96c07397652d42d29c609fecaa71c
