Skip to content
Back to skills

Strategic Compact

ASecurity

建议在逻辑间隔进行手动上下文压缩,以保留任务阶段的上下文,而不是依赖任意的自动压缩。

  • 225 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 4, 2026
tools

Security analysis

A100/100

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

Scanned September 4, 2026

npx -y skills add NeverSight/skills_feed --skill strategic-compact --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Strategic Compact?

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

Security grade badge for Strategic Compact
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/neversight-strategic-compact/badge)](https://www.skillsdirectory.com/skills/neversight-strategic-compact)

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: strategic-compact
description: 建议在逻辑间隔进行手动上下文压缩,以保留任务阶段的上下文,而不是依赖任意的自动压缩。
---

# 策略紧缩技能 (Strategic Compact Skill)

建议在工作流中的战略点手动 `/compact`,而不是依赖任意的自动压缩。

## 为什么需要策略紧缩?

自动压缩在任意点触发:
- 通常在任务中间,丢失重要上下文
- 无法意识到逻辑任务边界
- 可能会中断复杂的多步操作

在逻辑边界进行策略紧缩:
- **在探索之后,执行之前** - 压缩研究上下文,保留实施计划
- **在完成里程碑之后** - 为下一阶段重新开始
- **在主要上下文转换之前** - 在不同任务之前清除探索上下文

## 工作原理

`suggest-compact.sh` 脚本在 PreToolUse (Edit/Write) 上运行,并且:

1. **跟踪工具调用** - 统计会话中的工具调用
2. **阈值检测** - 在可配置阈值建议(默认:50 次调用)
3. **定期提醒** - 在阈值后每 25 次调用提醒一次

## Hook 设置

添加到你的 `~/.claude/settings.json`:

```json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "tool == \"Edit\" || tool == \"Write\"",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
      }]
    }]
  }
}
```

## 配置

环境变量:
- `COMPACT_THRESHOLD` - 首次建议前的工具调用数(默认:50)

## 最佳实践

1. **在规划后紧缩** - 计划确定后,紧缩以重新开始
2. **在调试后紧缩** - 在继续之前清除错误解决上下文
3. **不要在实施中途紧缩** - 保留相关更改的上下文
4. **阅读建议** - Hook 告诉你 *何时*,你决定 *是否*

## 相关

- [The Longform Guide](https://x.com/affaanmustafa/status/2014040193557471352) - Token 优化章节
- Memory persistence hooks - 用于在紧缩后保留状态

Files in this skill

  • SKILL.md1.9 KB
  • description_ar.txt225 B
  • description_cn.txt124 B
  • description_de.txt220 B
  • description_en.txt127 B
  • description_es.txt198 B
  • description_fr.txt215 B
  • description_it.txt205 B
  • description_ja.txt212 B
  • description_ko.txt189 B
  • description_ru.txt321 B
  • description_tw.txt121 B
  • stats.json68 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 tools →

Comments

Loading comments…

Newsletter

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