Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

The Context Window Is Full Before the First Prompt — When Project Rules in Claude Code Become a Fixed Cost of Every Session

Description and use

Project rules in Claude Code can consume a large portion of the context window before any user prompt, causing a "Prompt is too long" error. Reducing rule size by binding to file paths, moving inventories, and refactoring instructions dropped tokens from 454,900 to 64,700, resolving the issue.

Problem

Project rules in Claude Code repositories grow large enough to fill the context window before any user prompt, causing subagents to abort with a "Prompt is too long" error.

Outcome

Project rules can consume a fixed, large portion of the context window, but by scoping rules to file paths, separating inventories, and refactoring instructions, the token cost dropped from 454,900 to 64,700, eliminating the subagent abort.

Workflow

  • Measure context size with "/context" before changes.
  • Identify rule files that load at start and separate them from records.
  • Bind rules to file paths using the paths frontmatter so they load only when needed.
  • Move large inventory tables into a separate file that is not loaded at start.
  • Rewrite rule instructions to reference the inventory file instead of embedding it.
  • Re‑measure context size to confirm reduction.
  • Verify subagent no longer aborts on start.
  • Maintain guardrails in CI to prevent future growth.

Evidence

Project rules are a fixed cost of every session: Everything in the project's CLAUDE.md, its imports and the rule files without a file scope loads in Claude Code at start, before the first prompt arrives.

Source

After a good six months of maintenance, the largest rule file consisted to 84 percent of an inventory table with one row per test file.

Source

Three levers, measured before and after: Bind rules with a file scope to paths, move inventories into a neighboring file, and phrase instructions so that the agent looks things up instead of preloading everything. Afterwards the project instructions stood at 64,700 instead of 454,900 tokens.

Source

The subagent that had aborted before started again after the reduction.

Source

  • Record date: 2026-10-22T21:11:40.600Z