~/codigoagente
AI agents

Saving tokens and context with ECC: context-budget, timely compaction and model choice

To save tokens with ECC, measure first: /context gives you real session usage and /ecc:context-budget --audit estimates what your install takes (on the minimal profile, about 12,500 tokens in skill, agent and command descriptions alone). Then trim: remove agents for languages you do not use, compact at phase changes, and use Sonnet by default with Opus only for architecture.

This is part 7 of the complete ECC guide. Below: the real measurement we ran, the settings.json tweaks ECC recommends, when to compact and when not to, and how to stop MCP servers from eating your context window.

Why ECC can get expensive

Every installed skill, agent and command advertises its description to the model so it knows when to use it. One description is a few lines, but ECC ships hundreds. And the common rules load in full every session.

This is not only a money problem on API billing: on a Pro or Max subscription a full context means earlier compaction, worse answers in long sessions and quota burned faster.

Step 1: measure with /context and /ecc:context-budget

ECC does not invent its own live meter. Run /ecc:context-budget on its own and it tells you to use the native command:

snippettext
/context        # live breakdown of the context window
/context all    # expanded view

We checked: that was literally its answer (5 seconds, 0.12 USD). To estimate what your install weighs you must ask for the audit explicitly:

snippettext
/ecc:context-budget --audit

We ran it against the minimal profile installed in part 2 (prompt in Spanish, so the screenshot is in Spanish):

About 12,500 estimated tokens of descriptions on the minimal profile · codigoagente
WhatEstimated tokens
Descriptions of 54 skills~4,600
Descriptions of 72 agents~4,000
Descriptions of 99 commands~3,900
**Always-loaded subtotal****~12,500**
`AGENTS.md` (only if imported)~3,300
MCP catalog (only if enabled)~3,100

These are the skill's own estimates (bytes ÷ 4), not a model measurement. The audit took 39 seconds and cost 0.24 USD, and it caught something useful: our session had the full plugin and the manual profile loaded at once, so commands were duplicated with and without the ecc: prefix. That is the install mistake from part 2, seen from the context side.

Step 2: trim what you do not use

The three optimizations the audit proposed, which match what we would do:

  1. One source. Either the plugin or a manual install, never both.
  2. Remove agents for other languages. There are about 35 *-reviewer and *-build-resolver agents. On a JavaScript project, deleting the Go, Rust, C++, Swift, Kotlin, Flutter and other ones saves about 2,000 tokens.
  3. Sort what remains with /ecc:agent-sort or /ecc:config-gc: daily items stay, occasional ones move to a "library" that is not advertised to the model.

Step 3: the settings.json tweaks ECC recommends

The README suggests adding this to ~/.claude/settings.json:

snippetjson
{
  "model": "sonnet",
  "env": {
    "CLAUDE_CODE_EFFORT_LEVEL": "medium",
    "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "50",
    "CLAUDE_CODE_SUBAGENT_MODEL": "haiku"
  }
}
SettingDefaultECC recommendsEffect per ECC
`model`opussonnetAbout 60% lower cost; handles 80%+ of tasks
`CLAUDE_CODE_EFFORT_LEVEL`model-dependentmediumLess reasoning on simple tasks
`CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`9550Compacts earlier; better quality in long sessions
`CLAUDE_CODE_SUBAGENT_MODEL`—haikuCheaper subagents

The figures in that table come from ECC's README, not from our measurements. Two caveats: with CLAUDE_CODE_SUBAGENT_MODEL=haiku, agents whose frontmatter asks for sonnet or opus may perform worse, so test it with your reviewers; and on Bedrock, Vertex or Foundry the sonnet alias may point to a model without effort controls, as the README itself warns.

When you need real reasoning (architecture, a bug you do not understand), switch with /model opus and switch back afterwards.

Step 4: compact at the right moment

Compacting mid-task is the fastest way to make the agent forget variable names and paths. The strategic-compact skill suggests doing it at phase changes:

Compact:

  • After research, before implementation.
  • After finishing a milestone, before the next one.
  • After debugging, before going back to the feature.
  • After a failed approach, before trying another.

Do not compact: in the middle of an implementation.

With ECC's hooks on, one of them suggests /compact every ~50 tool calls. And if you are about to stop, prefer /save-session and a fresh session, as covered in part 6.

Step 5: watch your MCP servers

Every MCP tool advertises its description. ECC warns that with too many MCP servers enabled a 200,000-token window can shrink to about 70,000 usable tokens, and recommends:

  • Fewer than 10 MCP servers per project.
  • Fewer than 80 active tools in total.
  • Disabling unused ones with /mcp.

That is why ECC ships only one default connector (chrome-devtools) and turns the rest into skills that call a CLI or API when needed.

Other ways to spend less

  • /clear between unrelated tasks: free and instant.
  • /cost to watch session spend on API billing.
  • If ECC's cost warnings bother you on a subscription: ECC_CONTEXT_MONITOR_COST_WARNINGS=off.
  • For shorter model replies, see the Caveman skill, which tackles the other side: output tokens.

Conclusion

Saving with ECC means measuring before trimming: /context for the session, /ecc:context-budget --audit for the install, one install source and no agents for languages you never touch. Sonnet by default and compacting between phases do the rest. In part 8, the last one, we audit the security of this whole setup with AgentShield.

// source code

Repository in this article
The code this article covers is public: browse it, star it or clone it from here.

Help us grow

codigoagente is free, with no paywalls. If this article helped you, any of these keeps the blog going.

// newsletter

One email a week with the repos worth your time

The week's new articles, tested against real code. No spam; unsubscribe in one click.

rea-video is an Apache-2.0 skill that breaks a video down shot by shot: filmed, AI or code, voice, music, captions and how to remake it. Real test and costs.
  • Skills for your agents
  • Claude Code
read article
AI agents

guide · Marketing psychology guide for AI agents · #3

Part 3 of the guide: anchoring, decoy, paradox of choice, Hick's Law and activation energy applied to the pricing page, with examples from the codigoagente kit.
  • Skills for your agents
  • Claude Code
read article
AI agents

guide · Marketing psychology guide for AI agents · #2

Part 2 of the guide: authority, commitment, real scarcity and framing with the marketing-psychology skill, with real before/after fragments from codigoagente.
  • Skills for your agents
  • Claude Code
read article