Skip to content

docs: refactor CLAUDE.md Key Rules into a tiered rules index#710

Merged
mathrb merged 3 commits into
mainfrom
docs/refactor-claude-md-key-rules
Jun 25, 2026
Merged

docs: refactor CLAUDE.md Key Rules into a tiered rules index#710
mathrb merged 3 commits into
mainfrom
docs/refactor-claude-md-key-rules

Conversation

@mathrb

@mathrb mathrb commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Why

CLAUDE.md's ## Key Rules section had grown to 60 dense prose rules (~29.5 KB ≈ 70% of the file), all loaded into every session. That hurt on four axes: token cost (~7K tokens always-on), readability (60 unsorted paragraphs), reliability (past the ~150–200 instruction ceiling, adherence dilutes), and maintainability (no stated home/format for new rules).

Design doc: docs/plans/2026-06-25-claude-md-key-rules-refactor-design.md.

What

Tiered structure ("map, not territory" — progressive disclosure):

  • Workflow essentials stay inline — the ~11 rules that apply to every change (branch-first, PR titles, squash-merge, analyze-before-push, StatFormatter gate, …).
  • Rules Index table (mirrors the existing Spec Document Index) → 10 on-demand docs/rules/*.md domain files, with a ⚠️ tripwire column so the surprising/destructive gotchas still fire in-context.
  • Maintenance convention so the section stays lean (new rule → domain file; tripwire only when surprising; prune when a CI gate enforces it).

All 60 rules moved losslessly into docs/rules/{cricket,x01,game-engine,statistics,database,auto-scorer,ui-design,testing,git-ci-release,e2e}.md (substance-verified per rule).

Results

Before After
CLAUDE.md 363 lines / 42 KB 278 lines / 18 KB
Key Rules section 29.5 KB 5.4 KB inline
Extracted to on-demand files 28.5 KB / 10 files

Notes

  • Files live in docs/rules/ (tracked, alongside other spec docs) rather than .claude/rules/.claude/ is gitignored, so files there would never reach the repo/CI.
  • Docs-only change; no code, tests, or analyze impacted.

🤖 Generated with Claude Code

mathrb and others added 3 commits June 25, 2026 12:57
…index

Tiered approach (Option C): inline Workflow essentials + Rules Index table
+ tripwire headlines in CLAUDE.md, with rule bodies extracted to 10
referenced .claude/rules/*.md files loaded on demand. Includes the lossless
62-rule mapping and migration plan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the 60-rule / ~29.5 KB Key Rules wall with three lean parts:
- Workflow essentials (inline) — the rules that apply to every change
- a Rules Index table (mirrors the Spec Document Index) pointing to
  10 on-demand docs/rules/*.md domain files
- one-line tripwire headlines for the most surprising/destructive gotchas

All 60 rules moved losslessly into docs/rules/{cricket,x01,game-engine,
statistics,database,auto-scorer,ui-design,testing,git-ci-release,e2e}.md.
Adds a maintenance convention so the section stays lean.

CLAUDE.md 42 KB -> 18 KB; Key Rules section 29.5 KB -> 5.4 KB inline,
back under the ~200-line always-loaded guidance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Fix dangling "see Sentry note below" cross-reference in the Technology
  Decisions table (the Sentry rule moved to docs/rules/git-ci-release.md).
- Restore the exact `git checkout pubspec.lock .flutter-plugins-dependencies`
  command + "regenerate on every pub get/run/build_runner" rationale that the
  inline condensation had dropped.
- Add a GameConfig-dispatch tripwire (`maybeMap` not `maybeWhen`) and widen the
  game-engine index label so the rule is discoverable.
- Correct the design-doc rule-count mapping (statistics.md 9, git-ci-release.md
  7; clarify the 3 double-placed rules; 60 distinct rules, lossless).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mathrb mathrb merged commit 2bbda06 into main Jun 25, 2026
2 checks passed
@mathrb mathrb deleted the docs/refactor-claude-md-key-rules branch June 25, 2026 13:28
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