feat: read path-scoped .claude/rules/*.md as review context - #183
Closed
roqmarcelo wants to merge 1 commit into
Closed
feat: read path-scoped .claude/rules/*.md as review context#183roqmarcelo wants to merge 1 commit into
roqmarcelo wants to merge 1 commit into
Conversation
Claude Code auto-loads convention files from .claude/rules/*.md (markdown with YAML frontmatter: `description` + `paths` globs). CodeCanary couldn't see them, forcing consumers to hand-duplicate every convention into review.yml, which drifts. - Add ReadClaudeRules (internal/review/rules.go): glob .claude/rules/*.md, parse leading `---` frontmatter, include a rule only when a changed file matches its `paths` globs (no `paths` = always included, matching Claude Code semantics). Own byte budget (8KB/file, 32KB total) separate from the CLAUDE.md caps, with a visible truncation warning. - Promote matchesIgnore -> shared matchesAnyGlob in new internal/review/glob.go so rules (and later features) reuse one glob helper; move the doublestar import out of the GitHub-flow file. - Merge discovered rules into the ProjectDocs map in prepareReview so they flow through writeProjectDocs with no prompt-builder changes. - Tests (docs_test.go): frontmatter parsing, scope in/out, no-frontmatter fallback, per-file and total byte budgets. - Add rules.go to the breaking-change manifest; update review-flow.md, configuration.md, README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Superseded — rebuilding against current main. PRs 2 & 3 from the original set are already implemented upstream (FilterRules / ancestor-scoped ReadProjectDocs); reopening a clean .claude/rules-only PR on a fresh base. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
Claude Code auto-loads convention files from
.claude/rules/*.md(markdown with YAML frontmatter:description+pathsglobs). CodeCanary couldn't see them, forcing consumers to hand-duplicate every convention into.codecanary/review.yml, which drifts.Changes
ReadClaudeRules(internal/review/rules.go): globs.claude/rules/*.md, parses leading---frontmatter, and includes a rule only when a changed file matches itspathsglobs. A rule with nopathsis always included (matches Claude Code semantics). Own byte budget (8KB/file, 32KB total) separate from the CLAUDE.md caps, with a visible truncation warning to stderr.matchesIgnore→ sharedmatchesAnyGlobin newinternal/review/glob.goso rules (and later features) reuse one glob helper; moved thedoublestarimport out of the GitHub-flow file.ProjectDocsmap inprepareReviewso they flow throughwriteProjectDocswith no prompt-builder changes.docs_test.go): frontmatter parsing, scope in/out, no-frontmatter fallback, per-file and total byte budgets.rules.goto the breaking-change manifest; updatedreview-flow.md,configuration.md,README.md.Follow-ups (this is 1 of 3)
Two dependent PRs will follow once this lands (both build on the new
glob.go):Rule.Paths/ExcludePathssoreview.ymlrules are injected only for matching files.apps/*/CLAUDE.mdetc. scoped to changed files.Verified:
go build,go vet ./...,go test ./...,golangci-lintall clean.🤖 Generated with Claude Code