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/lawofall/agentcore/file-splittinggit clone --depth 1 https://github.com/Lawofall/AgentCoreWhat 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.00000 | $0.00542 |
| Opus 5 | $0.00000 | $0.00271 |
| Sonnet 5 | $0.00000 | $0.00108 |
| Haiku 4.5 | $0.00000 | $0.00054 |
Grade A, and why
file-splitting 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
大文件拆分准则
核心:按「职责 / 变更原因」拆,不按行数机械拆。一个 1200 行的单一内聚单元可以不动;一个 600 行混了多个关注点的就该拆。
触发判断(软阈值)
- ~800 行 = 软信号,~1200 行 = 必须自问。
- 关键一问:这文件是否有 >1 个变更原因 / >1 个独立类·关注点?
- 是 → 按职责拆成多文件。
- 否(单一内聚)→ 留着,别拆。
为什么本项目尤其要拆(AI 主导 + 多 Agent 并行)
常规「为人的可读性」理由变弱,但三条 AI 特有理由让拆分更值:
- 合并冲突面:多 Agent / 多 worktree 并行,人人都动的 god file = 冲突重灾区;拆成小文件让各 Agent 改不相交文件。
- StrReplace 可靠性:文件越大、重复模式越多,越易「锚点不唯一」改错位置,浪费轮次。
- 上下文成本:改一处却反复读上千行,每轮都在烧 token 和时间。
怎么拆
- 沿职责缝拆(按领域 / 聚合 / 关注点),让两个 Agent 能各改各的文件。
- 别把一次逻辑改动打散到多文件——那样更难 review、更易冲突。
- 拆分本身是「冲突炸弹」:做成小而快合并的独立改动,挑目标模块没人在动时做。
- 纯搬移、不改行为;改完跑测试验证。
不要拆
- 生成文件(如
api.generated.ts):重生成即可。 - 第三方 / vendored(
sidecar、site-packages、release)。 - 真正单一内聚的文件,即便上千行。
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 · 38 lines · 542 tokens per session scan A 67c0d7584c3f
file-splitting is a cursor rule published in the GitHub repository Lawofall/AgentCore (78 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 542 tokens. 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.
Other cursor rules, from other repositories
code-patterns
Python code style and recurring patterns (config, logging, errors, paths).
project-overview
Core project architecture, patterns, and conventions for the AI Documentation Generator.
cursorrules
You are an AI agent building the module: {{MODULENAME}} This module is part of the Mnemosyne Neural OS ecosystem by XPACEGEMS LLC.
backend-python
Python and FastAPI standards for the backend.
core-project-context
Canonical project context and ownership rules.
dashboard-typescript
React and TypeScript standards for the operator dashboard.