code-citation-clickable

A set of writing rules for making code references easier to open in Cursor, including file paths, line numbers, Markdown links, and code blocks.

In plain words
What is it for?
Use it when reviewing code, tracing how something works, answering where code lives, or linking to files, modules, and exact lines in a workspace.
Why use it?
It reduces the time spent searching for the implementation being discussed and explains why some references may not become clickable.

Cursor rule for Cursor

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/peiiii/nextclaw/code-citation-clickable
Clone the repo
git clone --depth 1 https://github.com/Peiiii/nextclaw

Made for: Cursor.

Per session 993 This file is loaded in full into every session.
When invoked 993 The same file — it is already loaded in full.
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.00993 $0.00993
Opus 5 $0.00496 $0.00496
Sonnet 5 $0.00199 $0.00199
Haiku 4.5 $0.00099 $0.00099

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

Security

Grade A, and why

code-citation-clickable 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 2d 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.

.cursor/rules/code-citation-clickable.mdc · 49 lines

What it actually says

可点击代码引用

在解释实现、走查链路或回答「代码在哪」时,优先给出带路径与行号的引用,便于在 Cursor 里打开文件并跳到行号;同时需知:并非所有界面都会把代码块变成可点击链接

为何「很多不能跳转」(预期内限制)

  • 渲染通道不同:助手回复里手打的 ```start:end:path 围栏,在部分会话/预览里只会语法高亮,不保证出现可点击 chip;能否跳转依赖 Cursor 当前面板实现与版本。
  • 缩进代码块不算:围栏前若有列表缩进或整段被缩进成「indented code block」,通常不会行:行:路径 解析,应视为不可跳转。
  • 路径必须落在当前工作区:相对路径需相对已打开的仓库根;路径错、文件不在本 workspace、或复制到外部工具查看时,都无法跳转。
  • 格式必须干净:起始行只能是 ```数字:数字:路径单独一行;不要 - ```... 同列一行、不要在反引号与行号之间插空格、不要用 HTML 转义路径。

首选:带行号的代码围栏(助手侧写法)

使用单独一行、无列表前缀、无整段缩进的起始围栏:```起始行:结束行:相对仓库根路径,下一行起为代码,最后一行单独 ``` 结束。

  • 路径使用相对仓库根,例如 packages/nextclaw/src/cli/commands/plugins.ts
  • 引用取最小连续区间;无关行用 ... 占位。
  • 反例:正文里只写裸文件名、无路径也无行号。

行内代码引用与模块引用

行内(句子里的文件/符号)反引号往往不可点;在需要「一点就开」时,应用 Markdown 链接,路径仍相对仓库根:

  • 文件:[plugin.controller.ts](packages/nextclaw-server/src/ui/router/marketplace/plugin.controller.ts);若需精确定位,在链接后加纯文本行号,如「见上文 L127–178」或单独再给一行号围栏。
  • 目录:链到该目录下的 README.md 或代表性入口文件,避免链到裸目录(部分渲染器不支持)。
  • Workspace 包 / 模块名(如 @nextclaw/server):链到本次讨论最相关的一个源码文件(例如正在改的 *.ts);若无单一文件,再退到该包 package.json 或包内 README.md仅当文件存在时再写链接,避免死链)。
  • 外部 npm 包(非本仓库):用 https:// 链到 registry、文档或源码仓库;不要随意写成指向本仓库的假路径。

行内链接与行号围栏互补:链接负责「打开对的文件」,围栏负责「锁定行区间」。

用户侧最稳打开方式

  • Quick OpenCmd+P / Ctrl+P)粘贴路径,打开后再 Cmd+G 跳行号。
  • 在 Chat 里用 @ 引用文件 让 Cursor 绑定工作区文件,再结合助手给出的行号跳转。

次选补充

  • 同一文件多段逻辑:拆成多个上述代码块,或第一段给全路径+行号,后续在同文件可用「同上文件」+ 行号范围;行内再次提到该文件时用 Markdown 链接缩短阅读路径。

避免

  • 大段粘贴无路径无行号的裸代码。
  • 用 HTML 实体代替 <& 等(围栏内保持字面量)。
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. 2d ago First seen · 49 lines · 993 tokens per session scan A 0f4427980df4

Subscribe to this mod's changes

code-citation-clickable is a cursor rule published in the GitHub repository Peiiii/nextclaw (253 stars, last pushed 2d ago), licensed MIT. It adds 993 tokens to every session, about $0.0050 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.