everything-claude-code-zh: Skill for Claude Code

.agents/skills/strategic-compact/SKILL.md

strategic-compact is a skill for Claude Code, Codex from xu-xiang/everything-claude-code-zh. It costs 44 tokens per session (1,188 once invoked), scanned B, original, MIT.

A workflow for deciding when to manually shorten a long coding conversation. It watches tool use and suggests a context reset at configured points, such as after research or a completed milestone.

In plain words
What is it for?
Use it during multi-step work such as research, planning, implementation, and testing. It can monitor edit and write actions and use a configurable tool-call threshold for reminders.
Why use it?
Long conversations can make important details harder to track, while automatic shortening may happen in the middle of a task. Planned shortening keeps the next stage focused.

Skill for Claude CodeCodex

Written for Claude Code and Codex: PreToolUse hook event, but also agents/openai.yaml present. Also seen: reads .claude/ paths; mentions CLAUDE.md; names the TodoWrite tool.

This is xu-xiang/everything-claude-code-zh's own configuration. It tells Claude Code and Codex how to work on everything-claude-code-zh itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything everything-claude-code-zh configures →

Part of the everything-claude-code-zh plugin — 17 skills, 26 commands, 13 agents shipped together

About the project

everything-claude-code-zh is a Chinese translation of a collection of configurations for Claude Code and other AI coding agents. It provides agents, skills, hooks, commands, rules, and MCP configurations intended to support development workflows such as memory persistence, security scanning, evaluation, and research-first work. The catalogue includes commands, skills, agents, instructions, and a plugin from this configuration set.

xu-xiang/everything-claude-code-zh · 1,935 stars · on GitHub · oneskill.one

Reuse

Borrowing it

Nothing to install: this file belongs to xu-xiang/everything-claude-code-zh. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/xu-xiang/everything-claude-code-zh/main/.agents/skills/strategic-compact/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh

Made for: Claude Code, Codex.

Or install everything-claude-code-zh, the plugin that ships this one along with the rest of its 17 skills, 26 commands, 13 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for strategic-compact

README.md
[![agentmods](https://agentmods.dev/badge/skills/xu-xiang/everything-claude-code-zh/strategic-compact/github.svg)](https://agentmods.dev/skills/xu-xiang/everything-claude-code-zh/strategic-compact)
Your own site
<a href="https://agentmods.dev/skills/xu-xiang/everything-claude-code-zh/strategic-compact"><img src="https://agentmods.dev/badge/skills/xu-xiang/everything-claude-code-zh/strategic-compact/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for strategic-compact

Your own site · 80×15
<a href="https://agentmods.dev/skills/xu-xiang/everything-claude-code-zh/strategic-compact"><img src="https://agentmods.dev/badge/skills/xu-xiang/everything-claude-code-zh/strategic-compact.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,188 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00044 $0.01188
Opus 5 $0.00022 $0.00594
Sonnet 5 $0.00009 $0.00238
Haiku 4.5 $0.00004 $0.00119

Measured 9d ago against content hash 03a7e6718c37, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade B, and why

strategic-compact scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

添加到你的 `~/.claude/settings.json` 中:
.agents/skills/strategic-compact/SKILL.md · 104 lines

How it starts

The opening of the file, as written. The whole thing — 104 lines — stays where its author put it; the contents beside it link to each section on GitHub.

策略性压缩(Strategic Compact)技能

建议在工作流的策略点手动执行 /compact 命令,而不是依赖任意的自动压缩(Auto-compaction)。

何时启用

  • 运行接近上下文限制(200K+ tokens)的长会话(Long Sessions)时
  • 处理多阶段任务(研究 → 规划 → 实现 → 测试)时
  • 在同一会话中切换到不相关的任务时
  • 完成重大里程碑(Milestone)并开始新工作后
  • 当响应变慢或连贯性下降(上下文压力)时

为什么要进行策略性压缩?

自动压缩在任意点触发:

  • 通常在任务中间,导致重要上下文丢失
  • 缺乏对逻辑任务边界的感知
  • 可能会中断复杂的多步骤操作

逻辑边界处的策略性压缩:

  • 在探索之后,执行之前 —— 压缩研究上下文,保留实现方案
  • 完成里程碑之后 —— 为下一阶段提供全新的开始
  • 重大上下文转移之前 —— 在开始不同任务前清除探索上下文

工作原理

suggest-compact.js 脚本在 PreToolUseEdit/Write)钩子(Hook)上运行,并且:

  1. 跟踪工具调用 —— 统计会话中的工具调用(Tool Calls)次数
  2. 阈值检测 —— 在达到可配置的阈值(默认:50 次调用)时提出建议
  3. 定期提醒 —— 达到阈值后,每隔 25 次调用提醒一次

钩子配置(Hook Setup)

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

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit",
        "hooks": [{ "type": "command", "command": "node ~/.claude/skills/strategic-compact/suggest-compact.js" }]
      },
      {
        "matcher": "Write",
        "hooks": [{ "type": "command", "command": "node ~/.claude/skills/strategic-compact/suggest-compact.js" }]
      }
    ]
  }
}

配置

环境变量:

  • COMPACT_THRESHOLD —— 第一次建议前的工具调用次数(默认:50)

压缩决策指南

使用下表来决定何时压缩:

阶段转换 是否压缩? 原因
研究 → 规划 研究上下文很臃肿;方案是提炼后的产出
规划 → 实现 方案已在 TodoWrite 或文件中;为代码腾出上下文空间
实现 → 测试 可能 如果测试引用了近期代码则保留;如果切换关注点则压缩
调试 → 下一功能 调试追踪(Debug traces)会污染不相关工作的上下文
实现中 丢失变量名、文件路径和部分状态的代价很高
方案失败后 在尝试新方案前清除死胡同式的推理

压缩后保留的内容

了解哪些内容会持久化,有助于你充满信心地进行压缩:

保留 丢失
CLAUDE.md 指令 中间推理和分析
TodoWrite 任务列表 之前读取过的文件内容
记忆文件(~/.claude/memory/ 多步骤对话上下文
Git 状态(提交、分支) 工具调用历史和计数
磁盘上的文件 口头陈述的细微用户偏好

最佳实践

  1. 规划完成后压缩 —— 一旦方案在 TodoWrite 中确定,就进行压缩以全新开始
  2. 调试完成后压缩 —— 在继续之前清除错误解决上下文
  3. 不要在实现过程中压缩 —— 保留相关更改的上下文
  4. 阅读建议 —— 钩子告诉你何时,你决定是否
  5. 压缩前写入 —— 在压缩前将重要上下文保存到文件或记忆中
  6. 使用带有总结的 /compact —— 添加自定义消息:/compact 下一步重点实现认证中间件

相关内容

  • 长篇指南(The Longform Guide) —— 令牌(Token)优化章节
  • 记忆持久化钩子(Memory persistence hooks) —— 用于压缩后仍保留的状态
  • continuous-learning 技能 —— 在会话结束前提取模式

Read the full file on GitHub · 104 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 104 lines · 44 tokens per session scan B 03a7e6718c37

Subscribe to this mod's changes

strategic-compact is a skill published in the GitHub repository xu-xiang/everything-claude-code-zh (1,935 stars, last pushed 6mo ago), licensed MIT. It adds 44 tokens to every session and 1,188 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

save-md

Saves a named source to Markdown with provenance and faithful extraction through direct export endpoints. Use when asked to "save this article", "get the markdown", "transcribe this", or "keep this source". A URL supplied as task context alone does not trigger conversion; a chat summary stays in chat.

mblode/agent-skills · 64 tokens

memory

Unified project memory management: update, prune, reflect, and maintain knowledge. Combines conversation scanning, deduplication, contradiction detection, confidence scoring, and consistency checks in a single skill. Usage: /memory update [topic] — scan conversation, persist learnings /memory prune [type] — find…

SomeStay07/claude-memory-skill · 130 tokens

honcho

Configure and troubleshoot Honcho memory for Hermes.

NousResearch/hermes-agent · 12 tokens

agent-carnet

Use this skill when the user asks to save, recall, find, or organize notes. Triggers on: 'remember this', 'save this', 'note this', 'what did we discuss about...', 'check the notebook', 'find in carnet'. Also use proactively when discovering findings worth preserving across sessions.

yamadashy/repomix · 67 tokens

hermes-agent

Use, configure, theme, extend, and orchestrate Hermes Agent.

NousResearch/hermes-agent · 18 tokens

taiyi-compress

A workflow tool for shrinking large coding-agent conversations and work files into shorter context notes. It can also coordinate separate agents for parallel development and create handoff notes for continuing work in a new session.

Dong90/oh-my-taiyiforge · 51 tokens