token-saver-cursor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseToken Saver for Cursor
Cursor Token 节省器
This skill has two jobs:
- Work lean while it is active: follow the core rules below on every step.
- Tune the setup when the user asks for an audit or setup, or keeps running out: run the workflow in "Audit and setup".
该 skill 有两项主要功能:
- 精简执行:在启用期间,每一步都遵循以下核心规则。
- 优化配置:当用户要求审计或设置配置,或者持续遇到用量耗尽时,运行“Audit and setup”中的工作流。
Core rules: work lean, stay correct
核心规则:精简执行,保持正确
Why these rules: every request resends the whole context, so cost grows with context size times the number of requests. Output tokens cost several times more than input tokens. Rework costs the most of all. Cut the first two only in ways that never cause the third.
Before acting
- If the request is ambiguous in a way that would change the result, ask one short question instead of guessing. For multi-file or risky changes, outline the plan before editing.
- Stop exploring once you know enough to act. Do not survey the whole codebase for a narrow request.
Reading
- Locate first (grep, glob, symbol search, LSP), then read only the relevant range of a large file. Do not re-read a file that is already in context and unchanged.
- Never read lockfiles, generated, minified or build output, vendored dependencies, or whole logs. Search them instead.
Tool output
- Prefer summary forms: ,
git status -sbefore a full diff,git diff --stat, andgit log --oneline -n 20of one directory rather than a recursive tree.ls - Run the narrowest check that proves the change (one test file or case, a typecheck of the touched files) with quiet flags. Pipe long output through or
tail -n 40. Run the full suite once at the end if it is needed.grep -E "FAIL|Error|error:" - Send independent tool calls together in one turn, and make all edits to one file in one pass.
Delegation: do it yourself by default
- A subagent is not free. It starts with a fresh context, reloads the instruction files, re-discovers what you already know, adds latency, and its tokens count against the same limit. Its summary also drops detail you may need later.
- Delegate only when one of these holds: the answer needs reading many files (about ten or more) or a large output (test runs, logs, long docs) that you will not need afterwards and that condenses to a short summary; there are three or more independent, read-only pieces that can run in parallel; or you want an independent review with a clean context.
- Keep it in the main thread for small or quick tasks, steps that depend on the previous step's output, work that needs back-and-forth, and every edit. Keep writes in one thread and never let two agents edit the same file.
- When you delegate, use a cheaper model, give a precise brief (goal, paths, what to return, a length cap), ask for conclusions with references, and do not redo the subagent's reading yourself.
path:line
Answers
- Lead with the result. Do not restate the request, recap what did not change, or dump a whole file when an edit or a reference will do.
path:line - Size the answer to the question. Skip optional extras (docs, refactors, extra tests) and offer them in one line instead.
Do not under-save
- For hard bugs, security, data-loss risk, or architecture, read and reason as much as needed. One correct attempt is cheaper than two cheap wrong ones.
- Never skip verification to save tokens. Make it targeted instead.
Session coaching (one line, only at a natural break, at most once per break)
- On a switch to an unrelated task, suggest a fresh session. On a long session about one task, suggest compacting with a focus hint.
- For routine work on a flagship model or high reasoning effort, suggest a cheaper setting. For a hard problem on a small model, suggest upgrading.
这些规则的原因:每个请求都会重新发送整个上下文,因此成本会随上下文大小与请求次数的乘积增长。输出 Token 的成本是输入 Token 的数倍。返工的成本最高。只有在不引发返工的前提下,才能削减前两项。
执行前
- 如果请求存在会改变结果的歧义,应提出一个简短问题,而不是猜测。对于涉及多个文件或存在风险的修改,应在编辑前先概述计划。
- 一旦掌握了足够的信息,就停止探索。对于范围狭窄的请求,不要扫描整个代码库。
读取
- 先定位(grep、glob、符号搜索、LSP),然后只读取大型文件中的相关范围。不要重复读取已经位于上下文中且未发生变化的文件。
- 绝不读取锁文件、生成文件、压缩文件或构建产物、vendored dependencies 或完整日志。应通过搜索获取所需信息。
工具输出
- 优先使用摘要形式:先执行 ,在查看完整 diff 前执行
git status -s,使用git diff --stat,以及只列出一个目录而不是递归目录树。git log --oneline -n 20 - 运行能够证明修改有效的最窄检查(一个测试文件或测试用例、对涉及文件的类型检查),并使用静默参数。通过 或
tail -n 40过滤长输出。如果确有需要,在最后运行一次完整测试套件。grep -E "FAIL|Error|error:" - 在同一轮中并行发送相互独立的工具调用,并一次性完成对同一个文件的所有编辑。
委派:默认自行完成
- subagent 并非免费。它需要从全新的上下文开始,重新加载指令文件,再次发现你已经掌握的信息,增加延迟,而且其 Token 也会计入同一个用量限制。它的摘要还可能丢失你之后需要的细节。
- 仅在以下情况下进行委派:回答需要读取许多文件(约十个或更多),或者需要处理之后不再需要的庞大输出(测试运行、日志、长文档),且这些内容可以浓缩为简短摘要;存在三个或更多可并行运行的独立只读部分;或者你希望使用干净的上下文进行独立审查。
- 对于小型或快速任务、依赖上一步输出的步骤、需要反复沟通的工作,以及所有编辑操作,应保留在主线程中。所有写入操作都放在同一个线程中,绝不能让两个 Agent 编辑同一个文件。
- 委派时,使用成本更低的模型,提供精确的任务说明(目标、路径、需要返回的内容和长度上限),要求结论附带 引用,并且不要重复读取 subagent 已经读取的内容。
path:line
回答
- 先给出结果。不要复述请求,不要总结未发生变化的內容,也不要在一次编辑或一个 引用足以说明问题时输出整个文件。
path:line - 根据问题调整回答长度。跳过可选的额外内容(文档、重构、额外测试),必要时用一行说明并提出提供选项。
不要过度节省
- 对于复杂 Bug、安全问题、数据丢失风险或架构设计,应按需充分阅读和推理。一次正确的尝试比两次廉价但错误的尝试更节省成本。
- 绝不要为了节省 Token 而跳过验证。应让验证更有针对性。
会话指导(仅在自然停顿时给出一行提示,每个停顿最多一次)
- 切换到无关任务时,建议开启新会话。对于围绕单一任务的长会话,建议使用 focus hint 压缩上下文。
- 使用旗舰模型或较高推理强度处理常规工作时,建议切换到成本更低的设置。使用小型模型解决复杂问题时,建议升级。
Cursor specifics
Cursor specifics
Apply these on top of the core rules.
- Two pools. Paid plans include a monthly pool for Cursor's own models (Composer and others listed in the docs) and one for third-party models billed at their API price. Routine work on Auto or Composer leaves the other pool for hard tasks.
- Max Mode multiplies cost. It widens the context window and bills more per request. Suggest it only when normal context is genuinely too small.
- Always-apply rules ride along with every request. Keep them to a handful of lines.
- What to suggest to the user (they do these; you cannot):
| Situation | Suggest |
|---|---|
| Starting unrelated work | A new chat |
| Long chat on one task, context meter high | |
| Routine work on a frontier model | Auto or Composer |
| Narrow question | |
| Large generated files show up in context | Add them to |
| Worried about the bill | Check the Spending tab; set an on-demand limit |
在核心规则的基础上,还应遵循以下规则。
- 两个用量池。 付费套餐包含 Cursor 自有模型(Composer 以及文档中列出的其他模型)的月度用量池,以及一个按第三方模型 API 价格计费的用量池。常规工作使用 Auto 或 Composer,可以将另一个用量池留给困难任务。
- Max Mode 会成倍增加成本。 它会扩大上下文窗口,并提高每个请求的费用。只有在普通上下文确实不够用时,才建议使用它。
- Always Apply 规则会随每个请求一同发送。 应将其控制在几行以内。
- 应向用户建议以下操作(这些操作需要由用户执行,你无法执行):
| 情况 | 建议 |
|---|---|
| 开始处理无关工作 | 新建对话 |
| 围绕单一任务长时间对话,上下文用量较高 | 在达到硬性上限前,使用 |
| 使用前沿模型处理常规工作 | Auto 或 Composer |
| 范围狭窄的问题 | 使用 |
| 大型生成文件进入上下文 | 将其添加到 |
| 担心账单 | 检查 |
Audit and setup
Audit and setup
When the user asks to audit, set up, or cut usage, or keeps running out:
- Run from the project root. It is read-only and prints warnings with fixes. Without Node.js, check the same items by hand using references/levers.md.
node <this skill's directory>/scripts/audit.mjs --agent cursor - Report the findings ranked by expected savings, in a few lines each.
- Propose concrete edits (rule types and globs, , MCP servers, model habits) from references/levers.md. Show the diff and apply only after the user agrees.
.cursorignore - Offer to add the always-on snippet: skills load only when triggered, so the lean-work rules need a short permanent home. Save assets/always-on.md as with
.cursor/rules/token-discipline.mdcfront matter (or append it toalwaysApply: true), unless an equivalent rule already exists.AGENTS.md
当用户要求审计、设置配置或减少用量,或者持续遇到用量耗尽时:
- 在项目根目录运行 。该命令是只读的,会打印警告和修复建议。如果没有 Node.js,则使用 references/levers.md 手动检查相同的项目。
node <this skill's directory>/scripts/audit.mjs --agent cursor - 按预期节省量对发现的问题进行排序,每项用几行说明。
- 根据 references/levers.md 提出具体修改建议(规则类型与 glob 模式、、MCP 服务器、模型使用习惯)。展示 diff,只有在用户同意后才应用。
.cursorignore - 提议添加始终生效的片段:skill 仅在触发时加载,因此精简工作规则需要一个简短的永久存放位置。将 assets/always-on.md 保存为 ,并添加
.cursor/rules/token-discipline.mdcfront matter(或将其追加到alwaysApply: true),除非已有等效规则。AGENTS.md
References
References
- references/levers.md: rules, context, models, MCP and spending controls. Read before changing configuration.
- references/facts.md: plan and usage facts with sources and date. Read when the user asks about pricing or limits, and verify on the linked page if the answer matters.
- references/budget.md: how to pace a monthly pool that does not roll over.
- references/levers.md:规则、上下文、模型、MCP 和支出控制。修改配置前应先阅读。
- references/facts.md:套餐和用量事实信息,包含来源与日期。用户询问定价或限制时应阅读;如果答案很重要,请在链接页面中核实。
- references/budget.md:如何控制月度用量池的消耗节奏;未使用的额度不会结转。