Repository navigation
feat(repo): repo budget counts .claude/rules #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
napetrov
wants to merge
15
commits into
intel:main
Choose a base branch
from
napetrov:feat/budget-claude-rules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+598
−28
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ab3f5fb
feat(repo): repo budget counts .claude/rules
napetrov d4d63e8
fix(repo): rules: paths that names no pattern starts, warn on a linke…
napetrov 1b7ccad
fix(repo): warn on a rules link out of the tree; read paths as YAML f…
napetrov 82fd9bf
fix(repo): a rule frontmatter too deep for YAML no longer crashes budget
napetrov f1718b7
fix(repo): budget counts a rule linked to guidance once, at its loadi…
napetrov 21e287c
Merge branch 'main' of https://github.com/intel/dokimi into pq-326-fix
napetrov cc17f0d
fix(repo): budget reads rule frontmatter, links and promoted files as…
napetrov f2da52f
fix(repo): budget reads a paths key on its own, keeps rules out of th…
napetrov 6cc0717
fix(repo): rule exclusions follow the harness flag; an open flow list…
napetrov b1f2624
Docs: a rule a root guidance file imports is start whatever its paths
antonwolfy cd427e9
fix(budget): comments and alias links do not change how a rule's path…
napetrov adbfd73
fix(budget): an indented field of another key ends the paths block
napetrov 6d372ac
fix(budget): a scoped rule does not cover a cut import at start
napetrov b484dc8
Recognise a quoted key after empty paths as another field
antonwolfy b852254
Merge remote-tracking branch 'intel/main' into pr326-land1031
napetrov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
dokimi/changelog.d/20261030_180000_napetrov_budget-claude-rules.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ### Added | ||
|
|
||
| - **`repo budget` counts `.claude/rules`** — a `.claude/rules/**/*.md` file is a `rule` entry. | ||
| A rule in the root `.claude/rules/` whose `paths` frontmatter names no pattern is `start`; one | ||
| whose `paths` does, and every rule of a subdirectory's `.claude/rules/`, is `lazy`, unless a root `CLAUDE.md` or `AGENTS.md` imports it: then it is `start` whatever its `paths`. The | ||
| frontmatter is not counted, since Claude Code removes it before loading the rule, and an `@` | ||
| path in a rule is not followed as an import. A link to a directory under `.claude/rules` is a | ||
| warning: the rules behind it are not counted. A link under `.claude/rules` that does not resolve in | ||
| the tree is named too, whatever its suffix, since the tree cannot tell a dangling file from a directory; a | ||
| `CLAUDE.md` under `.claude/rules` is a rule, not guidance. Measured on Claude Code 2.1.304: a root rule | ||
| raised the first prompt by its size, `paths: []` included; a scoped or nested one loaded only | ||
| once the agent read a file it covers; a rule's `@extra.md` was not expanded. `start` was too | ||
| low by every root rule before; `repo_budget.v1` widens `kind` with `rule`. Rules are counted | ||
| for a harness profile with the new optional `guidance.claude_rules: true` (`claude-code` | ||
| only); the Codex and Copilot profiles leave it unset. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must-fix: these rules omit the case where guidance imports a rule. For example, with
CLAUDE.mdcontaining@.claude/rules/api.mdandapi.mdcontainingpaths: src/**frontmatter,repo budgetreports the rule asstart, notlazy(also asserted bytest_a_rule_a_root_claude_md_imports_is_one_start_entry). If that rule contains@extra.md,_importsalso follows it transitively. Qualify these statements to distinguish automatic rule discovery from guidance imports, or adjust the implementation if the unconditional no-import behavior is intended. The same missing start-classification exception appears indocs/architecture.mdand the changelog; the changelog also repeats the unconditional no-import claim.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on a decision before I change this: is the harness's
@expansion inside a rule that a root CLAUDE.md imports part of the behaviour we document? Context: the code follows those@paths transitively, as it does for any imported file, and counts them as start imports; the docs say an@path in a rule is not followed, without the imported-rule case. Options: (a) keep the current behaviour and state it in the docs, with the start classification of imported rules; (b) stop expansion at an imported rule. My recommendation: measure it on Claude Code withrepo reachbefore choosing; I can make the doc change in the next round once it is answered. The thread stays open until then.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the question in this thread: I would keep the current code (option a) and fix the docs. Claude Code's memory docs say an imported file can import more files, up to four hops; a file a CLAUDE.md
@-imports is loaded as an import, whatever directory it is in. What 2.1.304 measured is a rule loaded as a rule (@extra.mdnot expanded), and that does not cover a rule a CLAUDE.md imports. With the PR code,CLAUDE.md=@.claude/rules/api.md,api.mdwithpaths: src/**andsee @../../extra.mdgivesapi.mdstart andextra.mda start import, which matches the docs. So the docs should say: "an@path in a rule is not followed, unless a CLAUDE.md imports the rule: then the rule loads at start and its imports are followed" (here, in architecture.md and in the changelog fragment). One thing this does not settle: when imported, the rule's frontmatter is probably not removed, but it is not counted now.repo reachon a probe repo would measure both (a few haiku calls, cents).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on a decision before I change this, still open. The reviewer's comment is one reading (keep following
@paths, and state it), not the author's decision.Options: (a) keep following them, transitively and hop-limited, and state that in these docs, architecture.md and the changelog, as the comment proposes; (b) stop expansion at an imported rule.
My recommendation: (a), with the wording from the comment, after
repo reachmeasures the imported-rule case on Claude Code. The comment also raises a new question for that measurement: whether an imported rule keeps its frontmatter. The count strips it on this route, as on the rule route, and that is not measured yet. The thread stays open until then.