document-reference-guard

document-reference-guard is a cursor rule for coding agents from TashanGKD/tashan-cursor-skills. It costs 98 tokens per session (1,177 once invoked), scanned A, original, MIT.

A rule for tracking documents that are referenced by skills, rules, or other documents. It records which files depend on a document and requires related references to be reviewed when that document changes.

In plain words
What is it for?
Use it when adding a document reference or moving, updating, versioning, or archiving a referenced document.
Why use it?
Without dependency records, moving or changing one document can leave outdated paths or instructions elsewhere. This rule makes those relationships visible and prompts updates to affected files.

Cursor rule

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.

agentmods
npx agentmods add rules/tashangkd/tashan-cursor-skills/document-reference-guard
Clone the repo
git clone --depth 1 https://github.com/TashanGKD/tashan-cursor-skills

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 document-reference-guard

README.md
[![agentmods](https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/document-reference-guard.svg)](https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/document-reference-guard)
Your own site
<a href="https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/document-reference-guard"><img src="https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/document-reference-guard.svg" alt="Measured on agentmods" height="20"></a>
Per session 98 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,177 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00098 $0.01177
Opus 5 $0.00049 $0.00589
Sonnet 5 $0.00020 $0.00235
Haiku 4.5 $0.00010 $0.00118

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

Security

Grade A, and why

document-reference-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 5d 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/document-reference-guard.mdc · 101 lines

What it actually says

文档引用留痕与级联更新规则(document-reference-guard)

设计依据:F-033(引用留痕)+ F-034(引用级联更新),2026-03-20 核心原则:依赖可追溯,变动必传播。


触发条件

以下任一情况触发本规则:

场景A:新引用一个文档

  • AI 在 Skill/Rule/文档中写下某个文件路径并引用其内容
  • 例:role-后端开发 Step 1 新增「Read: 某个新文档.md」

场景B:被引用的文档发生变动

  • 移动路径(迁移到其他目录)
  • 更新内容(重大修改,如新增章节/更改格式要求)
  • 版本化(创建 v2.0,旧版归档)
  • 归档(移到 history/ 目录)

激活后执行

场景A:新引用一个文档

Step 1  在被引用的文档末尾,追加或更新 ## 引用记录 节:
        格式:
        ## 引用记录
        | 引用方路径 | 引用位置(章节/步骤)| 引用日期 | 引用用途 |
        |---|---|---|---|
        | .cursor/skills/role-后端开发/SKILL.md | Step 1 | 2026-03-20 | 读取技术架构 |

Step 2  若被引用文档不存在 ## 引用记录 节,自动创建(在文件末尾追加)
Step 3  告知用户:「✅ 引用留痕已更新:[文档路径] 的引用记录已追加」

场景B:被引用文档发生变动

Step 1  读取该文档的 ## 引用记录 节(若不存在,跳到 Step 4)
Step 2  列出所有引用方:
        「此文档被以下位置引用,变动后需要同步更新:
         - [引用方1]([引用位置])
         - [引用方2]([引用位置])」
Step 3  对每个引用方:
        IF AI 可以自动更新(路径变更/文件名变更)→ 直接更新,告知用户
        IF 需要人工判断(内容语义变化)→ 标注「⚠️ 需人工确认是否需要更新引用方」
Step 4  若无引用记录节 → 告知用户:
        「此文档没有引用记录,无法自动追踪引用方。建议手动检查是否有其他文件引用了它。」

引用记录节格式(模板)

被引用文档的末尾应包含此节:

## 引用记录

> 本节由 document-reference-guard 规则自动维护
> 最后更新:YYYY-MM-DD

| 引用方路径 | 引用位置 | 引用日期 | 引用用途 | 状态 |
|---|---|---|---|---|
| .cursor/skills/[Skill名]/SKILL.md | Step N | YYYY-MM-DD | [用途说明] | ✅ 有效 |

与现有体系的关系

现有组件 关系
cognitive-update-knowledge Step 6 本规则补充:Step 6 更新「联动文档」,本规则追加「反向引用方更新」
RULE-04(创建文件时声明关联关系) 本规则补充:RULE-04 是「单向出向声明」,本规则补充「双向引用追踪」
cognitive-structure-write-guard 并列:写 L1 文档时两个规则都会激活,互不冲突

变更记录

v1.0 — 2026-03-20 — 初始创建

根因:用户 20260320 提出 F-033(引用留痕)+ F-034(引用级联更新)原则,当前体系任何文档被引用/变动都不会触发级联检查,导致长期积累引用断链。文档被移动后,引用方如 Skills 里的 Read 路径会失效但无法感知。

设计决策

  • 约束类型:场景触发(非 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. 5d ago First seen · 101 lines · 98 tokens per session scan A db4e5ceade67

Subscribe to this mod's changes

document-reference-guard is a cursor rule published in the GitHub repository TashanGKD/tashan-cursor-skills (20 stars, last pushed 5mo ago), licensed MIT. It adds 98 tokens to every session and 1,177 once invoked, about $0.0005 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.