Rule Tree — AI skill for Claude Code
Keep an AI coding project's requirements and rules in one tree.
How to install Rule Tree
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open penstic123-code/Rule-tree and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Rule Tree does
Keep an AI coding project's requirements and rules in one tree. Claude Code and Codex get only the rules for the files they touch, and a background recorder keeps the tree up to date. VS Code extension. 中文 / English.
Alternatives in AI
- PRD: Agent Builder — Create Your Own Sub-Agent — Your ecosystem, your rules 1.9k ★
- Nativeprompt — Rewrite your prompt into the native dialect of the model you're actually running (Claude Code / Codex) — by ea 113 ★
- Session Handoff — Date: 2026-03-29 14:45 Session: xmaster v1.3.2 hardening + v2.0 architecture from GPT-Pro deep review Context 109 ★
README
RuleTree 需求树
一套为 AI 编程设计的信息架构:规则、文档、代码地图各归其位,一直替你理好,AI 改哪个文件,就只读哪个文件的规则。
给 [Claude Code](https://claude.com/claude-code) 和 [OpenAI Codex](https://developers.openai.com/codex) 用的 VS Code 插件。[English](README.en.md) | 中文

用 AI 写一个项目写到第三周,你已经跟它说过几十条要求:注释用中文,金额一律用整数分,改完先跑一遍测试。这些话散在聊天记录、CLAUDE.md、AI 自己的记忆和设计文档里。新开一个对话,AI 就看不到聊天里说过的话;全写进 CLAUDE.md,它改一个标点也要先读完几万字;哪天你改了主意,旧说法还留在另外两处,AI 不知道该听哪一份。

作者自己的一个项目里,21 份写着规则的文档查出 237 处重复、矛盾和过时的说法。RuleTree 把这些要求收进项目里的一个文件,按"管哪些文件"分好,AI 改哪个文件,就只把管这个文件的几条交给它:

信息各归其位
项目里的信息不止规则:还有设计文档、代码本身、AI 的记忆、CLAUDE.md。每类信息放在哪、AI 什么时候读到哪些,这套安排就是信息架构。安排得不好,同一件事写在几处、AI 读一大堆用不上的;安排得好,每件事只写一处,AI 干活时手上正好是它要的。
RuleTree 的安排以一个文件为中心:项目里的 `需求树.md`。它把项目按功能分成一块块,每一块叫一个需求,大块下面还可以分小块。每个需求写明两件事:它管哪些文件,改这些文件时要守哪些规则。规则就是一句话能照着做的要求。拿一个网店举例:
# P 网店
- 注释用中文
## R1 支付
> 文件:src/payment/**
> 文档:docs/payment-design.md
- 金额一律用整数分
### R1.1 退款
> 文件:src/payment/refund.ts
- 退款前先查订单状态
- 决定:退款走消息队列,不直接调支付接口(失败了能重试)
`#` 的个数就是树的层数,P、R1、R1.1 是编号。`> 文件:` 写这个需求管哪些文件,`> 文档:` 写改这块之前该读的设计文档,`-` 开头的每一行是一条规则。以"决定:"开头的规则,是你在几种做法里拍板选定的,AI 想推翻它要先问你。
规则之外的信息,各有各的位置:
| 什么信息 | 放在哪 | AI 什么时候读 |
|---|---|---|
| 一句话能照着做的要求,如"金额一律用整数分" | 需求树里,挂在管相关文件的需求下 | 改到这些文件时自动收到 |
| 你拍板选定的做法和理由 | 同上,开头写"决定:" | 同上;想推翻要先问你 |
| 一句话说不清的:为什么这样设计、怎么做、例子 | 设计文档,需求树里用 > 文档: 指向它 |
改到这些文件时先收到文档的目录,只读用得上的几节 |
| 每块代码已有哪些文件、函数和类 | 代码地图,RuleTree 读代码自动生成 | AI 写新功能前想查就去读,免得重写一份 |
| 和项目无关的事,如你的电脑环境 | AI 自己的记忆 | Claude Code 自己管 |
| 项目是什么、东西放在哪 | CLAUDE.md | 每次都读,所以越短越好 |
AI 改文件时收到什么
AI 改 `src/payment/refund.ts` 时,管这个文件的有三层:整个网店、支付、退款。这三层的规则交给 AI,登录、商品页、优惠券的规则不送。

送规则靠的是 Claude Code 自带的一个功能:放在 `.claude/rules/` 里的规则文件可以写明"只在读写某些文件时加载"。RuleTree 把每个需求编成一份这样的文件,送规则就不靠 AI 的记性,新开对话、对话太长被压缩、派出子 agent,都照样送到。Codex 没有这个功能,RuleTree 改用一份目录加补送,见 [docs/code
Related Skills
Vibe Friend
Keep an AI coding project's requirements and rules in one tree. Claude Code and Codex get only the rules for t
JevGuard
Semantic policy engine for AI coding agents. Reviews every agent change against your repo's plain-Markdown rul
Nomore
Finds the corrections you keep repeating to Claude Code and turns them into evidence-backed CLAUDE.md rules. L
LLM Document Review Verifier
Let the LLM propose, let code judge: quote verification, number and date parsing, a rule evaluator, and a stab
PullDay
Never skip pull day. A macOS menu bar app that keeps your AI coding agents' skills, plugins and extensions up
Companion Vault
An Obsidian vault and setup kit that gives your AI assistant a lasting memory. It learns how you work and writ
Related Agents
Plumber
HQ plumber — keeps the agent team's machinery working: scripts, charters, skills, templates, permission rules,
Fleet Rule Auditor
Keeps the fleet's rules, role files, contracts and fleet definitions from turning into bureaucracy. Weighs eve
Rule Advisor
Selects optimal rulesets for tasks and performs metacognitive analysis. Use PROACTIVELY before implementation