Skip to content

feat(commands): add /context-budget optimizer command#554

Open
vazidmansuri005 wants to merge 9 commits intoaffaan-m:mainfrom
vazidmansuri005:feat/context-budget-optimizer-command
Open

feat(commands): add /context-budget optimizer command#554
vazidmansuri005 wants to merge 9 commits intoaffaan-m:mainfrom
vazidmansuri005:feat/context-budget-optimizer-command

Conversation

@vazidmansuri005
Copy link

@vazidmansuri005 vazidmansuri005 commented Mar 17, 2026

Summary

Adds a /context-budget command that audits context window token consumption and finds optimization opportunities.

Related to #434 — agent descriptions alone consume ~26k tokens, triggering performance warnings.

What It Does

  1. Measures token overhead across agents, skills, rules, MCP servers, and CLAUDE.md files
  2. Classifies components into always-needed / sometimes-needed / rarely-needed buckets
  3. Detects bloated agent descriptions, redundant components, MCP over-subscription, and CLAUDE.md bloat
  4. Reports specific token counts per component with prioritized optimization recommendations

Why This Is Useful

A typical ECC setup with 16 agents, 28 skills, and 10+ MCP servers can burn 30-50% of the context window on overhead before the user types anything. This command makes that invisible cost visible and actionable.

Key Design Decisions

  • Token estimation uses words × 1.3 approximation (good enough for prioritization)
  • Classifies MCP servers as "CLI-replaceable" when equivalent CLI tools exist (gh, vercel, supabase)
  • Supports --verbose flag for per-file breakdowns
  • Output format is ASCII table for terminal readability

Type

  • Skill
  • Agent
  • Hook
  • Command

Testing

  • Verified command format matches existing commands (harness-audit.md pattern)
  • Example output tested against realistic ECC installation numbers

Checklist

  • Follows format guidelines
  • Clear description in frontmatter
  • Practical examples included
  • No sensitive info

Summary by cubic

Adds a /context-budget command that audits context window usage across agents, skills, rules, MCP servers, and CLAUDE.md, then recommends targeted cuts to reduce overhead and prevent performance warnings. Addresses #434 by flagging bloated agent descriptions and other unnecessary load.

  • New Features

    • Measures token overhead per component (words × 1.3), estimates MCP tool schemas (~500 tokens/tool), computes effective available context; assumes a 200K window by default; supports --verbose via $ARGUMENTS for per-file details.
    • Classifies components into always/sometimes/rarely; detects heavy agents (>200 lines), bloated descriptions (>30 words), redundant rules/skills, and MCP over-subscription; outputs an ASCII report with prioritized savings.
  • Bug Fixes

    • Simplified agent accounting to a single full-file token metric; guidance aligns with heavy-agent actions (split/trim).
    • Corrected sample numbers and ordering; fixed MCP counts and savings; added a savings estimate to the heavy-agents action for consistency.
    • Skips duplicate skills in .agents/skills/ (Codex harness copies) to avoid double-counting overhead.

Written for commit b5b03b9. Summary will update on new commits.

Summary by CodeRabbit

  • Documentation
    • Added a Context Budget Optimizer guide with a step‑by‑step audit workflow to measure and classify context‑window usage.
    • Describes token estimation heuristics, three‑bucket classification, issue detection patterns (redundancy, oversized components), and an ASCII report format with Top‑3 optimizations and potential savings.
    • Includes verbose breakdowns, practical token‑reduction tips, usage guidelines, and maintenance recommendations.

Adds a command that audits context window token consumption across
agents, skills, rules, MCP servers, and CLAUDE.md files.

Detects bloated agent descriptions, redundant components, MCP
over-subscription, and CLAUDE.md bloat. Produces a prioritized
report with specific token savings per optimization.

Directly relevant to affaan-m#434 (agent descriptions too verbose, ~26k
tokens causing performance warnings).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new documentation guide commands/context-budget.md specifying the Context Budget Optimizer: CLI usage, a four-step audit workflow to measure token overhead across Agents/Skills/Rules/MCP/CLAUDE.md, three-bucket classification, issue detection heuristics, ASCII report formats, verbose output, and practical token-reduction tips. (39 words)

Changes

Cohort / File(s) Summary
Documentation
commands/context-budget.md
New guide introducing the Context Budget Optimizer: CLI usage and syntax, a four-step audit process to measure per-component token overhead, three-tier classification (Always / Sometimes / Rarely), issue detection rules (bloated descriptions, redundancies, MCP oversubscription, CLAUDE.md bloat), ASCII report format with Top-3 optimizations, verbose per-file outputs, token estimation heuristics, and practical maintenance tips.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibble through tokens, one by one with care,
Trimming fluff and duplicates from here and there,
I tuck frontmatter neat and split the bulky bits,
So context fits snug—hoppy audits, tiny wits,
A carrot for every saved token, bright and fair 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(commands): add /context-budget optimizer command' clearly and specifically describes the main change: introduction of a new /context-budget command for optimizing context-window usage. It is concise, directly related to the primary purpose of the PR, and uses proper conventional commit formatting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 17, 2026

Greptile Summary

This PR adds a /context-budget command that walks Claude through a four-step audit of an ECC installation's context-window consumption (agents, skills, rules, MCP servers, CLAUDE.md), classifies components by usage frequency, detects common bloat patterns, and outputs a prioritised ASCII report with token savings estimates. The command is a useful diagnostic addition to the repo.

The current revision has addressed most issues flagged in earlier rounds (token-per-tool formula aligned to 500/tool, $ARGUMENTS wiring present on line 18 and conditionally referenced in Step 4, Step 4 now has content, heavy-agent file threshold explicitly defined, sample numbers corrected). Two compound logic issues remain in the sample output:

  • Issues ordering: The sample "Issues Found" block lists HEAVY AGENTS (~3,200 tokens saved) as feat: Digimental özelleştirmeleri - #1 and MCP OVER-SUBSCRIPTION (~27,500 tokens saved) as #2 — ascending order — directly contradicting the Step 4 instruction to list in descending order of savings. The "Top 3 Optimizations" block immediately below correctly uses descending order, making the contradiction visible within the same output block.
  • Conflated heavy-agent savings: The three individual agent token estimates (1,840 + 1,780 + 1,760 = ~5,380) don't reconcile with the "save ~3,200 tokens" action line, and the same ~3,200 figure is reused in Top 3 for a structurally different action ("Compress agent descriptions"). Heavy file splitting and description compression are distinct optimizations; bundling them into one ambiguous savings number will mislead users trying to decide which change to make first.

Confidence Score: 3/5

  • Safe to merge with minor fixes — the command is documentation-only and causes no runtime harm, but the sample output contains ordering and arithmetic inconsistencies that will actively mislead users.
  • The file is a markdown command definition with no executable code, so there is no risk of runtime breakage. However, the sample output (the primary way users learn the command's behaviour) contains a descending-order violation and irreconcilable savings numbers that undermine the command's stated purpose of giving actionable, trustworthy token estimates. These are correctness issues in the instructional content itself.
  • commands/context-budget.md — specifically lines 140–157 (Issues Found ordering and heavy-agent savings arithmetic)

Important Files Changed

Filename Overview
commands/context-budget.md New /context-budget command that audits context-window token usage. The current revision has addressed most issues from prior review rounds (token-per-tool formula, $ARGUMENTS wiring, Step 4 content, heavy-agent thresholds), but still contains two compound logic errors: (1) the sample Issues Found section lists items in ascending savings order, contradicting the Step 4 "descending order" instruction; and (2) the heavy-agent savings figure (~3,200 tokens) is irreconcilable with the per-agent token sums (~5,380) and is conflated with the separate description-compression saving also quoted as ~3,200.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["/context-budget invoked"] --> B["Step 1: Measure token overhead"]
    B --> B1["Scan agents/*.md\n(words × 1.3, flag >200 lines,\nflag description >30 words)"]
    B --> B2["Scan skills/*/SKILL.md\n(flag >400 lines,\nskip .agents/skills/ duplicates)"]
    B --> B3["Scan rules/**/*.md\n(flag >100 lines,\nidentify overlaps)"]
    B --> B4["Read MCP config\n(~500 tokens/tool,\nflag >20 tools/server)"]
    B --> B5["Read CLAUDE.md chain\n(flag combined >300 lines)"]
    B1 & B2 & B3 & B4 & B5 --> C["Step 2: Classify components\n(Always / Sometimes / Rarely needed)"]
    C --> D["Step 3: Detect issues\n(bloat, redundancy, over-subscription)"]
    D --> E["Step 4: Generate Report\n(assume 200K window unless specified)"]
    E --> F{{"$ARGUMENTS contains --verbose?"}}
    F -- Yes --> G["Full per-file breakdown\n+ redundant lines\n+ per-tool MCP estimates"]
    F -- No --> H["Summary ASCII table\n+ Top 3 Optimizations\n+ Total savings %"]
Loading

Last reviewed commit: b5b03b9

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
commands/context-budget.md (1)

104-106: Adjust heading level for Output Format.

After “### Step 4,” Line 106 should likely be #### Output Format to preserve heading hierarchy.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commands/context-budget.md` around lines 104 - 106, Change the "Output
Format" heading from level 3 to level 4 to preserve hierarchy under "Step 4":
update the heading token for the line containing "Output Format" so it reads
"#### Output Format" instead of "### Output Format", ensuring it nests correctly
beneath "### Step 4" and maintains document structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@commands/context-budget.md`:
- Around line 165-166: The audit cadence is inconsistent: reconcile the two
statements by choosing one consistent cadence or defining a two-tier approach;
update the text referencing "/context-budget" and the "Audit quarterly" sentence
so they match (e.g., change "Audit quarterly" to "Audit monthly" or change "Run
`/context-budget` monthly" to "Run `/context-budget` quarterly"), or explicitly
document a dual cadence such as "Run `/context-budget` monthly for quick checks
and perform a quarterly deep audit" and ensure both references to CLAUDE.md and
the /context-budget command reflect that single reconciled policy.
- Around line 129-133: The frontmatter message "HEAVY AGENTS — 3 agents exceed
200 lines" is inconsistent with the example counts for planner.md (213),
architect.md (189), and security-reviewer.md (176); update the report so the
threshold and examples align by either raising the threshold to match the files
(e.g., "exceeds 175 lines") or changing the listed examples to all be >200
lines; find and edit the header text "HEAVY AGENTS — 3 agents exceed 200 lines"
and/or the example counts for planner.md, architect.md, and security-reviewer.md
so the summary accurately reflects the examples.
- Line 87: Update the inconsistent description-length thresholds so the guidance
is single and clear: choose one canonical threshold (e.g., 30 words or 50 words)
and update both occurrences — the line that currently reads "Flag agents where
the `description` frontmatter exceeds 50 words" and the later recommendation
that mentions "under 30 words" — to use the same threshold, or explicitly
document a warning vs target policy (e.g., "warning at >30 words, fail at >50
words") and apply that phrasing consistently in both places.

---

Nitpick comments:
In `@commands/context-budget.md`:
- Around line 104-106: Change the "Output Format" heading from level 3 to level
4 to preserve hierarchy under "Step 4": update the heading token for the line
containing "Output Format" so it reads "#### Output Format" instead of "###
Output Format", ensuring it nests correctly beneath "### Step 4" and maintains
document structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e5d3ae53-45f7-4872-8177-4809875aea24

📥 Commits

Reviewing files that changed from the base of the PR and between fce4513 and 56a1135.

📒 Files selected for processing (1)
  • commands/context-budget.md

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="commands/context-budget.md">

<violation number="1" location="commands/context-budget.md:31">
P2: Agent overhead calculation counts full agent files as session-start overhead, contradicting later guidance that only `description` is always loaded into Task routing context.</violation>

<violation number="2" location="commands/context-budget.md:123">
P2: Sample MCP token totals are internally inconsistent with the documented "~500 tokens per tool" heuristic, likely underreporting MCP overhead by ~10x.</violation>

<violation number="3" location="commands/context-budget.md:129">
P2: Sample output contradicts the documented `>200 lines` heavy-agent rule by including 189-line and 176-line agents as exceeding 200.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- Add $ARGUMENTS to enable --verbose flag passthrough
- Fix MCP token estimate: 45 tools × ~500 tokens = ~22,500 (was ~2,200)
- Fix heavy agents example: all 3 now exceed 200-line threshold
- Fix description threshold: warning at >30 words, fail at >50 words
- Add Step 4 instructions (was empty)
- Fix audit cadence: "quarterly" → "regularly" + "monthly" consistently
- Fix Output Format heading level under Step 4
- Replace "Antigravity" with generic "harness versions"
- Recalculate total overhead to match corrected MCP numbers
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="commands/context-budget.md">

<violation number="1" location="commands/context-budget.md:45">
P2: Skill overhead instructions can overcount harness-specific duplicate skill copies, inflating the reported context budget.</violation>

<violation number="2" location="commands/context-budget.md:120">
P2: The updated sample report is internally inconsistent (stale percentage and conflicting MCP tool counts), which can mislead output produced from this template.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- Fix MCP tool count: table now shows 87 tools matching the issues
  section (was 45 in table vs 87 in issues)
- Fix savings percentage: 5,100 / 66,400 = 7.7% (was 20.6%)
- Recalculate total overhead and effective context to match
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="commands/context-budget.md">

<violation number="1" location="commands/context-budget.md:120">
P2: Sample report arithmetic is inconsistent: total overhead and available-context values do not match the component breakdown sum.</violation>

<violation number="2" location="commands/context-budget.md:120">
P2: Total overhead is reported using full agent-file token counts, which conflicts with the command’s own rule that only agent `description` frontmatter is loaded every session.</violation>

<violation number="3" location="commands/context-budget.md:131">
P2: MCP savings example is internally inconsistent: it uses per-tool costing for totals but per-server costing for optimization, understating token savings.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- Fix total overhead: 66,400 → 66,100 to match component table sum
  (12,400 + 6,200 + 2,800 + 43,500 + 1,200 = 66,100)
- Fix MCP savings: ~1,500 → ~27,500 tokens (55 tools × 500 tokens/tool)
  to match the per-tool formula defined in Step 1
- Reorder optimizations by savings (MCP removal is now affaan-m#1)
- Fix total savings and percentage (31,100 / 66,100 = 47.0%)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="commands/context-budget.md">

<violation number="1" location="commands/context-budget.md:153">
P2: The document mixes full-file token accounting with description-only savings, making the reported agent compression savings methodologically inconsistent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Agent descriptions are always loaded into Task tool routing context,
but the full agent body is only loaded when invoked. The audit now
measures both: description-only tokens as always-on overhead and
full-file tokens as worst-case overhead. This resolves the
contradiction between Step 1 (counting full files) and Tip 1 (saying
only descriptions are loaded per session).
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
commands/context-budget.md (2)

143-145: Incomplete MCP breakdown in example.

The issue header claims "14 servers, 87 tools" but only details 3 servers (github, supabase, vercel) with 55 tools. The remaining 11 servers and 32 tools are unaccounted for, making the sample report feel incomplete. Either reduce the header counts to match the detailed examples (e.g., "3 CLI-replaceable servers, 55 tools") or add a note like "…and 11 other servers (32 tools) in use."

📊 Suggested fix for clarity
-2. MCP OVER-SUBSCRIPTION — 14 servers, 87 tools
-   → github (~30 tools), supabase (~15 tools), vercel (~10 tools) — replaceable with CLI: gh, supabase, vercel
+2. MCP OVER-SUBSCRIPTION — 14 servers, 87 tools (3 CLI-replaceable)
+   → CLI-replaceable: github (~30 tools), supabase (~15 tools), vercel (~10 tools)
+   → Remaining 11 servers (32 tools) in use
    Action: Replace 3 MCP servers with direct CLI calls, save ~27,500 tokens
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commands/context-budget.md` around lines 143 - 145, Update the MCP
over-subscription example so the header counts match the detailed breakdown:
either change the header "2. MCP OVER-SUBSCRIPTION — 14 servers, 87 tools" to
reflect the three listed servers and 55 tools (e.g., "3 CLI-replaceable servers,
55 tools"), or keep the original counts and add a clarifying sentence after the
listed items (referencing the line starting with "2. MCP OVER-SUBSCRIPTION — 14
servers, 87 tools" and the three bulletized entries "github (~30 tools),
supabase (~15 tools), vercel (~10 tools)") that indicates the remaining "…and 11
other servers (32 tools) in use" so the totals are reconciled.

87-89: Reconcile "lines" vs "words" metrics for agent descriptions.

Line 87 recommends "1-3 lines" while Line 89 defines thresholds at "30/50 words". A 3-line description could exceed 30 words (triggering a warning) or a 2-line description could fit within 30 words. Consolidate to one canonical metric—since word count appears in the warning/fail criteria and in Tips (Line 170), consider removing the "1-3 lines" guidance or explicitly noting it's a rough approximation.

📝 Suggested clarification
-Agent descriptions should be 1-3 lines for the Task tool
-Detailed instructions belong in the agent body, not the description
-Warning at >30 words in the `description` frontmatter; fail at >50 words
+Agent descriptions should be concise for the Task tool—detailed instructions belong in the agent body, not the description.
+Warning at >30 words in the `description` frontmatter; fail at >50 words (roughly 1-3 lines).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commands/context-budget.md` around lines 87 - 89, The doc is inconsistent: it
currently recommends "1-3 lines" for agent descriptions while enforcement and
tips use 30/50-word thresholds. Remove the "1-3 lines" guidance and replace it
with a single canonical metric based on words (e.g., "Keep descriptions under 30
words; >30 words warns, >50 words fails"), and update the related Tips section
(the existing Tips reference) to reflect the same word-based rule so both
guidance and enforcement match.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@commands/context-budget.md`:
- Around line 137-141: The review comment points out a mismatch between the
issue title "HEAVY AGENTS — 3 agents exceed 200 lines" and the Action which
targets only "Shorten description frontmatter"; update the Action to address
overall file size (e.g., "Refactor each heavy agent file (planner.md,
architect.md, security-reviewer.md): split responsibilities, extract reusable
sections into skills/includes, and move large examples/details to agent bodies
or separate modules") or alternatively rename the issue to "BLOATED
DESCRIPTIONS" if you truly intend to only shorten frontmatter; ensure you apply
this change to the issue's Action field and the issue title so they match.

---

Nitpick comments:
In `@commands/context-budget.md`:
- Around line 143-145: Update the MCP over-subscription example so the header
counts match the detailed breakdown: either change the header "2. MCP
OVER-SUBSCRIPTION — 14 servers, 87 tools" to reflect the three listed servers
and 55 tools (e.g., "3 CLI-replaceable servers, 55 tools"), or keep the original
counts and add a clarifying sentence after the listed items (referencing the
line starting with "2. MCP OVER-SUBSCRIPTION — 14 servers, 87 tools" and the
three bulletized entries "github (~30 tools), supabase (~15 tools), vercel (~10
tools)") that indicates the remaining "…and 11 other servers (32 tools) in use"
so the totals are reconciled.
- Around line 87-89: The doc is inconsistent: it currently recommends "1-3
lines" for agent descriptions while enforcement and tips use 30/50-word
thresholds. Remove the "1-3 lines" guidance and replace it with a single
canonical metric based on words (e.g., "Keep descriptions under 30 words; >30
words warns, >50 words fails"), and update the related Tips section (the
existing Tips reference) to reflect the same word-based rule so both guidance
and enforcement match.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e6fe77a6-0730-43de-82d6-ccb5d24aa054

📥 Commits

Reviewing files that changed from the base of the PR and between 98d9c61 and fb8a438.

📒 Files selected for processing (1)
  • commands/context-budget.md

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
commands/context-budget.md (1)

139-143: ⚠️ Potential issue | 🟡 Minor

Issue/action mismatch in the sample finding is still present (Line 139 vs Line 143).

“HEAVY AGENTS” is a file-size issue, but the action only targets description frontmatter. Align the action with file-size reduction (split/extract responsibilities), or rename the issue to description bloat.

Suggested fix
-1. HEAVY AGENTS — 3 agents exceed 200 lines
+1. HEAVY AGENTS — 3 agents exceed 200 lines
    → planner.md (213 lines, ~1,840 tokens)
    → architect.md (208 lines, ~1,780 tokens)
    → security-reviewer.md (205 lines, ~1,760 tokens)
-   Action: Shorten description frontmatter; move details to agent body
+   Action: Split responsibilities, extract reusable sections to skills, and trim oversized sections in agent bodies
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commands/context-budget.md` around lines 139 - 143, The report for "HEAVY
AGENTS" incorrectly ties a file-size issue to only shortening description
frontmatter; update the action so it matches the actual problem by either (A)
changing the action text to instruct splitting or extracting responsibilities
across the listed files (planner.md, architect.md, security-reviewer.md) to
reduce file length, or (B) rename the issue to "DESCRIPTION BLOAT" if the intent
is to only trim frontmatter; locate the "HEAVY AGENTS" entry and edit its action
line and/or title to reflect option A or B so the issue and action are aligned.
🧹 Nitpick comments (1)
commands/context-budget.md (1)

173-173: Clarify “zero context tokens” wording at Line 173.

This is clearer as “zero persistent context overhead” (vs absolute zero tokens in all situations).

Suggested wording tweak
-2. **Prefer CLI over MCP** — `gh pr create` costs zero context tokens. An MCP GitHub server with 30 tools costs ~15,000 tokens just for schemas.
+2. **Prefer CLI over MCP** — `gh pr create` adds zero persistent context overhead. An MCP GitHub server with 30 tools costs ~15,000 tokens just for schemas.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commands/context-budget.md` at line 173, Replace the phrase "zero context
tokens" with clearer wording such as "zero persistent context overhead" and
update the sentence that currently reads "Prefer CLI over MCP — `gh pr create`
costs zero context tokens." so it instead explains that using the CLI avoids
persistent context/schema overhead (e.g., "Prefer CLI over MCP — `gh pr create`
incurs zero persistent context overhead (it does not require sending large
persistent schemas to the model)"). Ensure the updated text preserves the
comparison to MCP and clarifies that this is about persistent overhead rather
than absolute token usage in every possible request.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@commands/context-budget.md`:
- Around line 139-143: The report for "HEAVY AGENTS" incorrectly ties a
file-size issue to only shortening description frontmatter; update the action so
it matches the actual problem by either (A) changing the action text to instruct
splitting or extracting responsibilities across the listed files (planner.md,
architect.md, security-reviewer.md) to reduce file length, or (B) rename the
issue to "DESCRIPTION BLOAT" if the intent is to only trim frontmatter; locate
the "HEAVY AGENTS" entry and edit its action line and/or title to reflect option
A or B so the issue and action are aligned.

---

Nitpick comments:
In `@commands/context-budget.md`:
- Line 173: Replace the phrase "zero context tokens" with clearer wording such
as "zero persistent context overhead" and update the sentence that currently
reads "Prefer CLI over MCP — `gh pr create` costs zero context tokens." so it
instead explains that using the CLI avoids persistent context/schema overhead
(e.g., "Prefer CLI over MCP — `gh pr create` incurs zero persistent context
overhead (it does not require sending large persistent schemas to the model)").
Ensure the updated text preserves the comparison to MCP and clarifies that this
is about persistent overhead rather than absolute token usage in every possible
request.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6d29e47-d41c-4801-9222-71b0187be471

📥 Commits

Reviewing files that changed from the base of the PR and between fb8a438 and 9572d05.

📒 Files selected for processing (1)
  • commands/context-budget.md

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="commands/context-budget.md">

<violation number="1" location="commands/context-budget.md:36">
P2: Add an explicit total-file line-count threshold for heavy agents. Right now the workflow only defines description word-count checks, so the `HEAVY AGENTS` report category cannot be derived consistently from the documented steps.</violation>

<violation number="2" location="commands/context-budget.md:38">
P2: The updated workflow requires both always-on and worst-case agent token totals, but the report schema still only supports a single agent/overhead metric, creating an ambiguous and inconsistent output contract.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- Revert to single agent overhead metric (full file tokens) — simpler
  and matches what the report actually displays
- Add back 200-line threshold for heavy agents in Step 1
- Fix heavy agents action to match issue type (split/trim, not
  description-only)
- Remove .agents/skills/ scan path (doesn't exist in ECC repo)
- Consolidate description threshold to single 30-word check
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="commands/context-budget.md">

<violation number="1" location="commands/context-budget.md:33">
P2: The updated agent audit instructions now count full agent files as always-on overhead, but the same document states only the `description` frontmatter is loaded per session. This inconsistency will inflate reported context overhead and misclassify long agent bodies as Task-tool bloat.</violation>

<violation number="2" location="commands/context-budget.md:40">
P2: The audit instructions now only include `skills/*/SKILL.md`, but `.agents/skills/*/SKILL.md` is still a supported skills location in this repo. Omitting it would undercount skill overhead for Codex-loaded skills.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- Step 4: assume 200K context window by default (Claude has no way to
  introspect its model at runtime)
- Step 4: add explicit instruction to check $ARGUMENTS for --verbose
  flag and include additional output when present
Skills scan now checks .agents/skills/ for Codex harness copies and
skips identical duplicates to avoid double-counting overhead.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="commands/context-budget.md">

<violation number="1" location="commands/context-budget.md:144">
P3: The added savings estimate for splitting heavy agents conflicts with the document’s own description that only agent *descriptions* are always loaded into context. This makes the “save ~3,200 tokens” claim misleading for baseline overhead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

→ planner.md (213 lines, ~1,840 tokens)
→ architect.md (208 lines, ~1,780 tokens)
→ security-reviewer.md (205 lines, ~1,760 tokens)
Action: Split into focused sub-agents or trim redundant sections, save ~3,200 tokens
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The added savings estimate for splitting heavy agents conflicts with the document’s own description that only agent descriptions are always loaded into context. This makes the “save ~3,200 tokens” claim misleading for baseline overhead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At commands/context-budget.md, line 144:

<comment>The added savings estimate for splitting heavy agents conflicts with the document’s own description that only agent *descriptions* are always loaded into context. This makes the “save ~3,200 tokens” claim misleading for baseline overhead.</comment>

<file context>
@@ -141,7 +141,7 @@ Component Breakdown:
    → architect.md (208 lines, ~1,780 tokens)
    → security-reviewer.md (205 lines, ~1,760 tokens)
-   Action: Split into focused sub-agents or trim redundant sections
+   Action: Split into focused sub-agents or trim redundant sections, save ~3,200 tokens
 
 2. MCP OVER-SUBSCRIPTION — 14 servers, 87 tools
</file context>
Suggested change
Action: Split into focused sub-agents or trim redundant sections, save ~3,200 tokens
Action: Split into focused sub-agents or trim redundant sections
Fix with Cubic

@vazidmansuri005
Copy link
Author

@affaan-m Ready for review — all bot feedback has been addressed.

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