原始人模式 skill:用 token-diet 精简回答、减少重复读取,并使用 /compact

Dmitriy Solodukha,Caprock 开发者 · 发布于

测试于 (Claude Code 和 Codex)

请求 caveman mode,token-diet skill 就会让 Claude Code 和 Codex 中的智能体精简回答、减少读取,并在合适的时候建议使用 /compact。

说“caveman mode”,token-diet skill 就会让智能体直接给出答案,然后停止:没有开场白、不复述问题、不总结,代码不附带解说。它还会改变工作方式,因为多数 token 消耗在智能体读取的内容上:先搜索再读取、按行范围读取、不重读刚编辑过的文件、精简命令输出。它还会告诉你何时该 /compact 或重新开始,以及总结应聚焦什么。

安装 token-diet skill

每个智能体只需一条命令。skill 只有一个 SKILL.md;安装时不会运行任何内容。

将全部九个 skill 作为插件安装。在 Claude Code 中输入以下内容:

也可以只安装这个 skill,在终端中进入项目文件夹后运行:

添加 -g 即可为所有项目安装。

使用 token-diet skill 的提示词

你的措辞与 skill 描述匹配时,智能体会选择它;直接指定 skill 名称更有把握。点击提示词即可复制。

caveman skill 改变了什么:少说、少读、及时压缩上下文

  • 少说:第一行就是答案;意思清楚即可,不必句句完整;用三个要点,不要七个;只有工作受阻时才提问,每次只问一个问题。
  • 少读:先用 git grep -n 或 rg -n,再读取所需行;使用静默参数(git status --short、git diff --stat);只运行单个测试,不跑整个测试套件;将长日志写入文件后搜索。
  • 精简上下文:完成一个子任务后,建议使用新的上下文;在同一任务上长时间运行后,使用 /compact,并指定重点,例如 “keep the failing test name, the files changed, and the open question”。切换到新上下文前,会写下必须保留的内容。
需要输入的命令,来自各智能体的文档(查阅于 2026年11月29日)
需要 Claude Code Codex CLI
查看上下文被什么占满 /context /status
总结后继续工作 /compact [instructions] /compact
重新开始 /clear /new

我们运行了什么,智能体做了什么

每个 skill 都于 2026年11月29日在为其创建的临时仓库中运行,以项目 skill 的形式安装。一个很小的 Python 仓库:pager.py 存在差一错误(从 1 开始编号的页面使用了 start = page * size),并有一个失败的测试。

Claude Code (claude -p --model sonnet)

caveman mode please, save tokens. Why does test_first_page fail? Fix it.

运行了两次。两次都调用了 token-diet,使用三到四次 shell 调用,将 pager.py:3 修正为 (page - 1) * size,并用两行简短文字说明原因、修复方式,以及由于未安装 pytest,直接调用了测试函数且测试通过。

Codex (0.163.0,codex exec)

caveman mode please, save tokens. Why does test_first_page fail? Fix it.

读取了 .agents/skills/token-diet/SKILL.md。它按当时 skill 的要求,以“Token diet on.”开头;之后 skill 移除了这句提示,未再次运行 Codex。它发现文件中已有修复(同一文件夹中的前一次运行已完成修改),运行了测试,并用两行回复(链接以纯文本显示):

Off-by-one: `page * size` skipped the first 10 items. pager.py:3 already has the fix: `(page - 1) * size`.
Verified: `test_first_page` passes.

已测试的智能体

  • Claude Code:测试于 2026年11月29日,使用 claude -p --model sonnet,skill 作为项目 skill 安装在 .claude/skills/ 中。
  • Codex:于 2026年11月29日使用 Codex 0.163.0(codex exec)测试,skill 位于 .agents/skills/。
  • OpenCode 和 Cursor:未测试。此 skill 是以开放的 Agent Skills 格式编写的纯文本指令,但尚未在这两者上实际运行验证。

限制

  • 不声称能节省 token:测试中没有不使用该 skill 的运行结果可供对照。
  • 智能体无法自行输入 /compact 或 /clear;它会给出建议,由你输入。
  • Codex 测试使用了较早的措辞版本,该版本会声明模式已启用;当前措辞未在 Codex 上测试。
  • token-diet 是独立的 skill,并非任何名为 caveman 的 skill 的副本;当你要求 caveman mode 时,它就会响应。

使用和不使用 Caprock 的情况

连接 Caprock MCP 服务器后,skill 可以调用 cost,比较精简前后每天的 token 数和花费,直接引用工具给出的数据。未连接时,它会指引你使用 Claude Code 中的 /usage 或 Codex 中的 /status。Caprock 是一款免费开源应用,记录你电脑上的每个编程智能体会话。

获取 Caprock →

完整的 SKILL.md

这是 dspv/skills 中修订版本 dfce799 的文件原样。手动安装时,将它保存在项目中:Claude Code 使用 .claude/skills/token-diet/SKILL.md,Codex 使用 .agents/skills/token-diet/SKILL.md。

skills/token-diet/SKILL.md
---
name: token-diet
description: >
  Make the coding agent talk less and spend fewer tokens. Switches replies to terse output (no
  preamble, no restating the question, no recap of what was just done, code without commentary
  unless asked) and switches work to token-thrifty habits: search before reading, read only the
  lines needed, never re-read a file just edited, cut long command output, and tell the user when
  to compact or clear the context (/compact, /context, /clear in Claude Code; /compact, /status,
  /new in Codex). Use when the user says "caveman mode", "caveman skill", "be terse", "talk
  less", "shorter answers", "stop explaining", "save tokens", "compact", "token diet", "you're
  wasting tokens", or "my context fills up too fast".
license: Apache-2.0
---

# Token diet

Two halves: say less, and read less. Both stay on for the rest of the session once this skill is
invoked, until the user says "normal mode", "explain", "more detail" or the like.

Do not announce the mode; the next reply shows it.

## 1. Say less

Every reply:

- **Answer first.** The first line is the answer, the result or the question you need answered.
  No "Great question", "Sure, I can help", "Let me...", "I'll now...".
- **No restating.** Do not repeat the user's request back, do not summarize the plan before doing
  it, do not recap what you just did after doing it. The diff and the tool output already show it.
- **Fragments are fine.** "Fixed: off-by-one in `paginate()`, `src/page.py:41`." beats a paragraph.
  Drop articles and filler when the meaning stays clear. Keep file paths, names, numbers exact.
- **Code without commentary.** Show the code or the edit. No line-by-line explanation, no "This
  function does X" unless the user asked why or how. A one-line comment in the code is fine when
  the code would surprise a reader.
- **Lists over prose, short lists.** Three bullets, not seven. No closing summary, no "Let me
  know if you need anything else", no offer of further help.
- **One question at a time**, only when you cannot proceed without the answer.
- **Length follows the ask.** A yes/no question gets yes or no plus the reason in one line.

Never cut, however terse:

- Warnings about data loss, security, destructive commands, failing tests, or anything you could
  not do or verify.
- The exact command, path or value the user needs to act on.
- A question that blocks the work.

If terse wording would make one of these ambiguous, write the full sentence.

## 2. Read less

Tokens go mostly into what the agent reads, not what it writes. Work habits:

1. **Search before reading.** Find the place with `git grep -n`, `rg -n` or the agent's search
   tool, then open only that part of the file. Read a whole file only when it is small or you
   need all of it.
2. **Read line ranges.** Use the read tool's offset and limit, or `sed -n '120,180p' file`.
   Widen the range if the function continues; do not jump to the whole file.
3. **Do not re-read.** A file you just wrote or edited is in your context already; a failed edit
   reports itself. Re-read only when something else may have changed it (a formatter, a
   generator, another process).
4. **Cut command output at the source.** Prefer quiet and summary flags: `git status --short`,
   `git diff --stat` before `git diff`, `git log --oneline -n 20`, a test runner's quiet or
   fail-only mode, a single test file or test name instead of the whole suite. Pipe long output
   through `tail -n 50`, `head -n 50` or `grep` for the error. Redirect a big log to a file and
   search it instead of printing it.
5. **Do not paste tool output back.** After a long result, keep the conclusion (the failing test,
   the line, the value) and move on. Never quote a log or a file to the user unless asked.
6. **Skip what you do not need.** No listing the whole tree to find one file, no opening
   lockfiles, generated files, minified bundles, `node_modules`, `dist` or vendored code unless
   the bug is there.
7. **Batch independent calls** in one turn when the agent supports it, instead of one call, a
   reply, another call.
8. **Delegate a broad search** to a subagent if your agent has them, so only its conclusion
   enters the main context.

## 3. Keep the context small

The agent cannot run these commands itself: the user types them. Suggest one, in one line, when
it pays off:

- After a finished subtask, before starting an unrelated one: a fresh context.
- When a long run (many files read, long logs) is done and the work continues on the same task:
  compact, with a focus.
- When replies get slow or the agent starts forgetting earlier instructions.

| Need                          | Claude Code               | Codex CLI  |
| ----------------------------- | ------------------------- | ---------- |
| See what fills the context    | `/context`                | `/status`  |
| Summarize, keep working       | `/compact [instructions]` | `/compact` |
| Start fresh, same project     | `/clear` (alias `/new`)   | `/new`     |
| Fresh chat and clear terminal | `/clear`                  | `/clear`   |
| Token usage (and cost)        | `/usage` (alias `/cost`)  | `/status`  |

Sources, read on 2026-11-29: Claude Code commands reference
(<https://code.claude.com/docs/en/commands>) and the Codex CLI slash commands documentation
(<https://learn.chatgpt.com/docs/developer-commands?surface=cli>). Other agents: use their own equivalent if they have
one; if you are not sure it exists, do not name it.

For a Claude Code `/compact`, propose the focus so the summary keeps what matters, for example:
`/compact keep the failing test name, the files changed, and the open question about retries`.

Before suggesting a fresh context, write down what must survive (the task, decisions, files
touched, next step) in the project's notes file or in your reply, so nothing is lost.

## 4. See the effect

If the Caprock MCP tools are available (server `caprock`), call `cost` (optional `days`,
`repo`, `all_repos`) to compare tokens and spend per day before and after the diet. Otherwise
ask the user to check `/usage` in Claude Code or `/status` in Codex. Report the figures as the
tool gives them; never estimate a saving. Caprock (<https://caprock.dev>, free, open source, runs
locally) provides that tool.

## Example

User: "why does the login test fail?"

Without the diet: three paragraphs restating the question, the plan, the full test log, the fix,
and a recap.

With it:

```text
`test_login_expired` fails: `is_expired()` compares local time with UTC, `auth/session.py:58`.
Fix: use `datetime.now(timezone.utc)`. Apply it?
```

关于 token-diet skill 的问题

什么是 caveman mode skill?
这个 skill 让智能体在完整表达意思的前提下,尽量简短地回答。token-diet 除了做到这一点,还会减少智能体读取的内容,而读取内容正是消耗 token 最多的地方。
token-diet 就是 caveman skill 吗?
这是一个独立的 skill,响应同样的请求:说“caveman mode”即可开启,说“normal mode”即可关闭。
什么时候该在 Claude Code 中运行 /compact?
同一个任务长时间运行告一段落后,如果还要继续处理:运行 `/compact` 并指定重点,保留重要内容。完成一个子任务、准备处理无关任务时,用 `/clear` 重新开始。skill 会分别用一行给出建议。
caveman skill 会省略警告吗?
不会。关于数据丢失、安全、破坏性命令、测试失败以及任何无法核实的内容,警告都会保留。

来源

应用本身是英文界面。