Add a char-based CML finding that mirrors Claude Code's own startup warning
("Large CLAUDE.md will impact performance (X chars > 40.0k)"). CC 2.1.169 scales
that threshold with the model's context window, so the finding anchors on the
conservative 200k window (we cannot observe the user's window; the anchor fires
earliest) and discloses the relaxed ~200,000-char figure at 1M context. MEDIUM
severity (token cost, not an adherence cliff — consistent with the v5.2.0 reframe).
Keyed on chars, not lines, so it is complementary to the existing 200/500-line
checks (which stay untouched): a file can be long by lines yet under budget (short
lines, e.g. large-cascade at 37k chars / 1024 lines), or short by lines yet over it.
Extract the shared 200k/1M context-window constants to scanners/lib/context-window.mjs
(single source of truth; skill-listing-budget.mjs now imports + re-exports them).
40.0k figure and context-window scaling verified against the CC changelog (2.1.169,
2026-06-08) and the live startup-warning text. +6 tests, new fixture large-claude-chars
(48,531 chars / 100 lines). Suite 918/918, self-audit PASS configGrade A 97.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ter3E2JSi1Khgmuf2kady8
28 lines
1.3 KiB
JavaScript
28 lines
1.3 KiB
JavaScript
/**
|
|
* Context-window constants — single source of truth.
|
|
*
|
|
* Several Claude Code budgets scale with the model's context window:
|
|
* - the skill listing is allotted ~2% of context (CC 2.1.32, changelog L2860);
|
|
* - the "CLAUDE.md is too long" warning threshold scales with it (CC 2.1.169).
|
|
*
|
|
* We cannot observe the user's actual context window, so scanners anchor on a
|
|
* conservative 200k window (the smallest common size — it fires earliest, the
|
|
* safe default when the window is unknown) and disclose the relaxed 1M figure.
|
|
*
|
|
* Zero external dependencies.
|
|
*/
|
|
|
|
// Conservative anchor: the smallest common context window. Budgets anchored
|
|
// here fire earliest, which is the safe default when the window is unknown.
|
|
export const CONTEXT_WINDOW_ANCHOR = 200_000;
|
|
|
|
// Large context window (Opus/Sonnet 1M tier). Used to disclose how a budget
|
|
// relaxes on large-context models.
|
|
export const LARGE_CONTEXT_WINDOW = 1_000_000;
|
|
|
|
// How much larger the 1M window is than the 200k anchor (= 5). A budget that
|
|
// scales linearly with the window relaxes by this factor at 1M.
|
|
export const LARGE_CONTEXT_SCALE = LARGE_CONTEXT_WINDOW / CONTEXT_WINDOW_ANCHOR;
|
|
|
|
// Dependency-free thousands separator (repo invariant: zero external deps).
|
|
export const withCommas = (n) => String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|