Skip to content

feat: read path-scoped .claude/rules/*.md as review context - #183

Closed
roqmarcelo wants to merge 1 commit into
alansikora:mainfrom
roqmarcelo:feat/claude-rules-context
Closed

feat: read path-scoped .claude/rules/*.md as review context#183
roqmarcelo wants to merge 1 commit into
alansikora:mainfrom
roqmarcelo:feat/claude-rules-context

Conversation

@roqmarcelo

Copy link
Copy Markdown
Contributor

Context

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 .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 its paths globs. A rule with no paths is 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.
  • Promote matchesIgnore → shared matchesAnyGlob in new internal/review/glob.go so rules (and later features) reuse one glob helper; moved 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.
  • Added rules.go to the breaking-change manifest; updated review-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):

  1. Consume Rule.Paths/ExcludePaths so review.yml rules are injected only for matching files.
  2. Raise CLAUDE.md caps and discover nested apps/*/CLAUDE.md etc. scoped to changed files.

Verified: go build, go vet ./..., go test ./..., golangci-lint all clean.

🤖 Generated with Claude Code

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>
@roqmarcelo

Copy link
Copy Markdown
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.

@roqmarcelo roqmarcelo closed this Jul 17, 2026
@roqmarcelo
roqmarcelo deleted the feat/claude-rules-context branch July 17, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant