reuse-not-rewrite-guard

reuse-not-rewrite-guard is a cursor rule for Cursor from TashanGKD/tashan-cursor-skills. It costs 787 tokens per session, scanned A, original, MIT.

A rule requiring an agent to locate an existing implementation before reusing it, then call or copy that implementation rather than rewriting its logic.

In plain words
What is it for?
Use it whenever a task says to reuse, reference, copy, or follow an existing implementation, including checking that the named code exists first.
Why use it?
It prevents an agent from replacing requested reuse with a different implementation that may behave differently.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it whenever a task says to reuse, reference, copy, or follow an existing implementation, including checking that the named code exists first.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/tashangkd/tashan-cursor-skills/reuse-not-rewrite-guard
Install

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.

Clone the repo
git clone --depth 1 https://github.com/TashanGKD/tashan-cursor-skills

Made for: Cursor.

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 reuse-not-rewrite-guard

README.md
[![agentmods](https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/reuse-not-rewrite-guard/github.svg)](https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/reuse-not-rewrite-guard)
Your own site
<a href="https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/reuse-not-rewrite-guard"><img src="https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/reuse-not-rewrite-guard/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 reuse-not-rewrite-guard

Your own site · 80×15
<a href="https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/reuse-not-rewrite-guard"><img src="https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/reuse-not-rewrite-guard.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 787 This file is loaded in full into every session.
When invoked 787 The same file — it is already loaded in full.
Security scan A 0 findings. 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.00787 $0.00787
Opus 5 $0.00394 $0.00394
Sonnet 5 $0.00157 $0.00157
Haiku 4.5 $0.00079 $0.00079

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

Security

Grade A, and why

reuse-not-rewrite-guard 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 11d 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.

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.

rules/reuse-not-rewrite-guard.mdc · 71 lines

What it actually says

「复用」≠「重写」强制约束(reuse-not-rewrite-guard)

根因(2026-03-22 跨3个对话发现的系统性语义错位): 用户说「复用X」,AI 理解为「理解X原理后重实现」; 用户的真实意图是「找到X代码直接调用/复制」。


核心规则(最高优先级,任何任务中生效)

当用户消息含以下词汇时,强制触发本规则:

  • 「复用」「完全复用」「全量复用」「直接用」「用xxx的方式」
  • 「参考xxx实现」「照着xxx做」「和xxx一样」

必须执行(顺序不可跳过):

Step 1  先 grep / Read 确认原始实现存在
        grep -rn "functionName\|ClassName" 相关目录
        → 找到 → 记录文件路径和函数名
        → 找不到 → 停止,告知用户「未找到原始实现,请确认路径」

Step 2  直接复制/调用原始实现
        → 不重写逻辑,不「优化」,不「精简」
        → 保留原始函数签名、参数名、注释
        → 调整的仅是:路径引用、模块导入、不兼容的接口适配

Step 3  遇到障碍时立即汇报,不自行重设计
        → 「发现原始实现有X不兼容,需要你决策」
        → 绝不自行替换方案后告知

禁止行为(违反即违规)

❌ 理解原理后自行重实现(即使结果功能相同)
❌ 说「我参考了X的设计,重新写了一个」
❌ 因为「部分不兼容」就「全盘否定,从头写」
❌ 自主换方案后才告知用户
❌ 调用不存在的函数(必须先验证存在性)

特别加强:「完全/全量」是硬性信号

用户说「完全复用」「全量复用」「注意是完全,全量」时:

  • 不允许任何精简、重构、优化
  • 即使 AI 认为原始实现「不够好」,也必须直接使用
  • 差异只能在「用户看不到的适配层」(路径、导入等)

变更记录

2026-03-23 — 初始创建

根因:project-retrospective-20260323 E1 类架构级发现。 跨3个对话(1dc992d0/9d4ef11b/a4a4b82a)出现同一错误模式: 用户说「复用X」→ AI 理解原理后重实现 → 用户发现后纠正。 5个根因:①架构理解劫持字面执行 ②精巧重写本能 ③不验证函数存在性 ④部分不兼容→全盘否定 ⑤自主换方案而非汇报。 本 Rule 作为 alwaysApply 约束,在所有对话中强制生效。

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. 11d ago First seen · 71 lines · 787 tokens per session scan A 5f1ff7ac70bf

Subscribe to this mod's changes

reuse-not-rewrite-guard is a cursor rule published in the GitHub repository TashanGKD/tashan-cursor-skills (20 stars, last pushed 5mo ago), licensed MIT. It adds 787 tokens to every session, about $0.0039 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-30.