Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/xc404/kiwi/read-before-editgit clone --depth 1 https://github.com/xc404/kiwiWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00457 | $0.00457 |
| Opus 5 | $0.00229 | $0.00229 |
| Sonnet 5 | $0.00091 | $0.00091 |
| Haiku 4.5 | $0.00046 | $0.00046 |
Grade A, and why
read-before-edit scanned grade A with 0 findings 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 yesterday.
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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
修改前同步工作区(避免覆盖)
原则
- 工作区磁盘上的文件是唯一真相;对话里缓存的代码片段、上一轮 tool 输出、或记忆中的版本都可能落后于用户在外部保存的改动。
- assistant 在修改任意文件之前,必须先拿到「当前将要写入的最终版本」,再基于该版本做最小差异编辑;不得仅凭会话上下文拼补丁。
必须执行的操作
- 在每次
apply_patch/ 实质性编辑之前,对目标路径使用 Read 工具重新读取文件全文或足够大的局部(含待改片段的上下文),以当前内容作为old_string/ 补丁基准。 - 若用户说明「已在外部改过」「与磁盘不一致」或涉及多人/多轮并行修改:对受影响路径再读一遍;必要时在仓库根目录执行
git diff -- <path>(或git diff)查看相对版本库的未提交差异,再合并意图。 - 若 Read 结果与对话中的假设不一致,以 Read 为准,并在回复中简要说明已按最新文件调整(无需长篇)。
禁止
- 在未重新 Read 目标文件的情况下,用大段替换「还原」助手记忆中的旧版本。
- 用过时行号或过时引用块作为补丁依据(行号会变;应以 Read 返回的当前文本为准)。
说明
「当前 session 的最终版本」在工程上等同于:用户已保存到工作区的文件;通过 Read(及可选 git diff)与之对齐,即完成与「外部改动」的 diff,避免覆盖。
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.
- yesterday First seen · 27 lines · 457 tokens per session scan A 30f68316a4dc
read-before-edit is a cursor rule published in the GitHub repository xc404/kiwi (7 stars, last pushed 7d ago), licensed MIT. It adds 457 tokens to every session, about $0.0023 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.