Skip to content

fix: eliminate 72k token context exhaustion via paths frontmatter#8

Open
riaworks wants to merge 1 commit intomainfrom
fix/context-exhaustion
Open

fix: eliminate 72k token context exhaustion via paths frontmatter#8
riaworks wants to merge 1 commit intomainfrom
fix/context-exhaustion

Conversation

@riaworks
Copy link
Owner

@riaworks riaworks commented Mar 2, 2026

Summary

  • Added paths: frontmatter to all 14 rule files in .claude/rules/ that were missing it
  • All 16 rule files now use Claude Code's native lazy-loading mechanism
  • Rules load on-demand only when matching files are in conversation context

Impact

Metric Before After
Always-loaded tokens ~72,392 0
Context recovered ~34% of 200k window
Rules affected 14 of 16 16 of 16 scoped

Approach

Claude Code's paths: frontmatter mechanism scopes rule loading:

  • Rules without paths: → loaded eagerly (always)
  • Rules with paths: → loaded only when matching files are in context

This is the native, zero-risk approach — no files moved, no content changed, no architecture modified.

Files Changed (14)

All edits are identical in pattern: prepend YAML frontmatter with relevant glob patterns.

Security Mapping

  • OWASP LLM10 — Unbounded Consumption
  • MITRE ATLAS AML.T0054 — LLM Resource Exhaustion

Fixes

Fixes thiagofinch#2

🤖 Generated with Claude Code

All 16 rule files in .claude/rules/ now have paths: frontmatter,
making them load on-demand instead of eagerly. This eliminates
~72k tokens (~34% of 200k context) from every session startup.

Before: 72,392 tokens loaded unconditionally on session start
After: 0 tokens always-loaded (rules load only when matching files
are in conversation context)

Fixes: thiagofinch#2 (Context Window Exhaustion)

Security mapping:
- OWASP LLM10 (Unbounded Consumption)
- MITRE ATLAS AML.T0054 (LLM Resource Exhaustion)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

[PERF] .claude/rules/ consumes 34% of context window on session start (68k/200k tokens)

1 participant