f2s-knowledge-preflight

A repository rule that tells an agent to read the project's knowledge index before answering questions about its code or setup. The index routes the agent to more detailed project documentation.

In plain words
What is it for?
Use it when answering implementation, configuration, debugging, or project-structure questions in a repository with a .Knowledge directory.
Why use it?
It prevents answers based only on assumptions or general knowledge when the repository already contains relevant guidance. It also keeps the investigation focused on the right documents first.

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/double-coding-lab/flow2spec/f2s-knowledge-preflight
Clone the repo
git clone --depth 1 https://github.com/double-coding-lab/Flow2Spec

Made for: Cursor.

Per session 2,248 This file is loaded in full into every session.
When invoked 2,248 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.02248 $0.02248
Opus 5 $0.01124 $0.01124
Sonnet 5 $0.00450 $0.00450
Haiku 4.5 $0.00225 $0.00225

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

Security

Grade A, and why

f2s-knowledge-preflight 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/f2s-knowledge-preflight.mdc · 73 lines

How it starts

The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Flow2Spec 知识库首读(KB Preflight)

本条与 f2s-flow2spec-unified-entry 并存;凡涉及当前仓库内实现、配置、排错与 Flow2Spec 知识路由的回答,以本条约束「何时必须先读磁盘上的知识库」为准。统一入口中的读取顺序在满足本条之后继续适用。

适用范围(须执行首读)

用户问题若可能依赖下列任一类信息,即视为「须先走知识库」:

  • 当前仓库中的实现代码、目录与模块约定、构建/部署/运行时行为、.Knowledge/f2s-* 技能、manifest-routing 所描述的主题路由等;
  • 用户未明确声明「与当前仓库无关」、但语境明显依赖本仓库事实时。

硬约束:首工具调用

在给出实质性结论或修改建议之前:

  1. 在本轮用户消息下,若尚未用工具读取过 .Knowledge/manifest-routing.json,则 第一个 使用的代码/知识库类工具 必须 为:

    Read → 路径 .Knowledge/manifest-routing.json(项目根相对路径,与统一入口一致)。

  2. 读完 manifest 后,再按 taskToTopicRules / matcherPath 按需 Read 单个 matcher 分片与 .Knowledge/topics/<topic>.md(及 topicDependencies),然后才允许对 .Knowledge/ 以外的业务源码路径 使用 SemanticSearchGrepRead

  3. 禁止:在未执行步骤 1 的情况下,用「凭记忆/凭训练数据」直接断言本仓库特有的路径、配置或行为;若 manifest 或 topic 已明确覆盖,须以 KB 为准,源码用于印证或补全 KB 未写细节。

  4. 回答末尾(简短一行即可):注明本轮依据的 KB 路径(例如「已读 manifest + topics/<topic>.md」);若 manifest 无命中且已读 fallbackTopic 对应 topic,写明「走 fallback 分诊」。

可跳过首读(极少数)

  • 用户仅询问 IDE/编辑器本身用法、且与当前仓库目录无关;
  • 用户给出 绝对路径 + 明确指令(例如「只把该行改为 x」)且与业务知识无关的纯机械编辑;
  • 同一会话内已对当前工作区执行过 Read(".Knowledge/manifest-routing.json") 且用户未要求「重新路由/全量检查」的直接续问:可在回答首句写「manifest 已读本会话,沿用上次路由」,不再重复 Read manifest。

回答收口检查(源码补答后)

普通问答读取业务源码后的知识库补充建议,以 f2s-kb-feedback-closing 为单一规则源。本条只保留触发关系:读完首个业务源码文件后,视为本轮已触发 sourceFallbackUsed=true;若最终答案引用源码事实,发出回答前必须执行 f2s-kb-feedback-closing 的四 case 自检。若本轮已经进入 f2s-* 技能、implement-tech-designf2s-git-commit 或其他已有后续流程,不重复提示。

f2s-flow2spec-unified-entry「知识缺口与对策」 一致;命中 1b(命中但上下文不够)2(库里没有对应文档) 时,还须遵守:

  1. 先对用户说明,再扩工具:在已读 manifest-routing.json 与应读的 topics/*.md(及依赖 topic)之后,若仍无法仅凭 KB 精确回答用户问题,必须先用自然语言说明:已读哪些 KB 路径仍缺哪类信息你打算只读哪 1~2 个源码文件请用户补哪篇文档;不得沉默地连续堆叠「再找入口」式探索。
  2. 探索次数上限:在未向用户发出上述缺口说明前,禁止连续发起 4 次及以上仅以扩大搜索面为目的的 Grep / 无明确目标的 SemanticSearch。说明并获用户默许(或问题明确要求追到底)后,再有序下钻。
  3. 单点下钻优先:若仅需确认行为细节,应优先 Read 一个与问题最相关的实现文件并据此作答;禁止为同一子问题在无新假设的情况下链式深入第三方依赖目录中多文件,除非用户明确要求通读依赖。

Read the full file on GitHub · 73 lines

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 · 73 lines · 2,248 tokens per session scan A fbf219b2e511

Subscribe to this mod's changes

f2s-knowledge-preflight is a cursor rule published in the GitHub repository double-coding-lab/Flow2Spec (47 stars, last pushed 4d ago), licensed MIT. It adds 2,248 tokens to every session, about $0.0112 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.