Skip to main content

How I cut AI agent skill context bloat under 4,000 tokens across my stack

Updated 11 min readMarkdown
How I cut AI agent skill context bloat under 4,000 tokens across my stack

If you keep adding skills and AGENTS.md rules to your AI coding setup, you eventually hit a quiet tax: your assistant burns thousands of tokens before you even type your first prompt. In my own setup, auto-loading a 97-skill growth pack ate roughly 3,950 startup tokens on one assistant, and an 89-skill trading pack ate roughly 3,680 tokens on another.

Fixing that context bloat started with treating startup instructions like a menu instead of a full recipe book. Once that lightweight skill pattern worked across my 14 custom assistants, I rolled the same 20-skill library out to five external coding CLIs on my Windows ARM64 laptop, which triggered cross-tool hook leaks, a backup overwrite, and three Windows-specific snags that hit the exact same stack.

TL;DR

On Windows ARM64 (Nov 2026), treating startup skills like a menu (short descriptions + <=8 pinned core skills) kept 14 custom Raven agents at 1,269 to 3,731 active skill tokens (638 to 666 for 6 shared skills). Scaling our 20-skill catalog across 5 external coding CLIs with separate hook files hit zero hook leakage across 23 configs.

AGENTS.md vs. on-demand skills: the menu and recipe book pattern

Keep always-on instruction files (AGENTS.md, CLAUDE.md, copilot-instructions.md) thin with global rules and one startup pointer, and store deep workflows in on-demand skill folders. That split resolves the trade-off highlighted by Vercel's agent evals: putting every rule upfront guarantees visibility in short demos but bloats context at scale, while unindexed skill folders save tokens but get skipped unless a startup pointer tells the model when to check them.

The simplest mental model is the difference between a menu and a recipe book.

At startup, you hand the assistant a short menu: a thin startup pointer and a list of skill names with one-line descriptions. The full step-by-step recipes stay closed on the shelf until a task matches one of them.

You do not need custom tooling to use this pattern today. In Claude Code (Anthropic's terminal coding agent), OpenAI Codex (OpenAI's CLI coding agent), or GitHub Copilot CLI, keep your global instruction file concise, cap always-active skills at roughly 7 or 8 core workflows per domain, and leave deep reference guides inside your skills folder to load on demand.

Measuring skill context savings across 14 custom Raven agents

Switching oversized skills (over roughly 1,500 tokens) to description-only startup loading and pinning at most 8 core skills per bulk pack kept all 14 of my custom Raven specialist agents between 1,269 and 3,731 active skill tokens. Across all 14 specialists, the 6 shared behavioral skills (covering tone, verification, and careful patching) cost only 638 to 666 tokens per agent.

For context, alongside my five public coding CLIs, I run Raven (EverMind AI's open-source local multi-agent orchestrator) with 14 specialized assistants for writing, research, testing, design, and code review. To keep the measurement scope honest: the token table below measures those 14 custom Raven specialists, where I control the local Python skill loader (inject: description and a 20-skill startup cap are Raven registry features, not native flags in Claude Code or Codex). Per-CLI startup token totals for the five external coding tools were not tabulated in that same run.

Before trimming, auto-loading every skill in a bulk pack pushed startup skill context close to 4,000 tokens before counting system prompts or code context. Pinning 7 to 8 core skills per pack and marking the rest on demand cut the two heaviest packs by 43% to 50%:

Custom Raven specialist Before trimming (approx.) After trimming (active skill tokens) Full system prompt tokens What changed
Presentation (raven-ppt, lowest) n/a 1,269 2,978 Description-only slide skill + 6 shared skills
Trading (raven-trader) ~3,680 (89 skills) 1,857 4,584 8 core skills pinned, 81 moved on demand
Growth & SEO (raven-growth) ~3,950 (97 skills) 2,237 5,068 8 core skills pinned, 89 moved on demand
Design (raven-design) Full pack auto-loaded 2,266 4,415 7 core skills pinned, design engine on demand
Workspace (raven-assistant, highest) n/a 3,731 6,359 16 workspace skills + 6 shared skills

Measured across all 14 custom Raven specialist agents on Windows ARM64 using cl100k_base (Nov 23, 2026). All 14 specialists stayed under the 4,000-token active skills ceiling.

What broke when I rolled those skills out to 5 coding CLIs

Once the menu-and-recipe pattern cut startup bloat across my 14 Raven assistants, I wanted the same lightweight 20-skill catalog available across the five external coding CLIs I use daily: Claude Code, OpenAI Codex, GitHub Copilot CLI, Hermes Agent (Nous Research's open-source coding agent), and DeepSeek DSH (DeepSeek's open-source terminal harness). Rolling shared skills and hooks out to five tools on one Windows laptop immediately exposed a second problem: shared configs quietly leak across harnesses.

My first shortcut was pointing DeepSeek DSH (which supports Claude-style hooks) at ~/.claude/settings.json so I would not have to maintain two hook files. Immediately, every DSH tool call silently fired seven Claude-only optimization scripts from token-optimizer-mcp (an MCP server for token savings) and logged DSH's work under harness: "claude". Around the same time, an overly broad Claude PreToolUse rule started intercepting ordinary Windows terminal commands whenever paths mixed Windows and Unix formats.

The fix was giving every tool its own instruction file, its own skill folder, and a dedicated hook file that never points at another tool's settings. Each harness now loads one dedicated startup pointer for its native skill suite across both CLI and Agent Client Protocol (ACP) sessions, keeps its own copy of the 20 shared workflow and coding skills, and runs only its own hooks.

Architecture diagram showing 5 isolated coding agent harnesses (Claude Code, OpenAI Codex, GitHub Copilot, Hermes Agent, DeepSeek DSH) with dedicated hook files and a shared 20-skill catalog alongside 14 custom Raven specialist agents budgeted between 1,269 and 3,731 active skill tokens

Harness Instruction file Startup skill pointer Hook isolation
GitHub Copilot CLI (copilot) ~/.copilot/copilot-instructions.md Dedicated startup pointer for Superpowers (15 suite skills) Dedicated ~/.copilot/hooks/superpowers.json (sessionStart injects 3,405 chars in CLI and ACP)
OpenAI Codex (codex) ~/.codex/AGENTS.md Dedicated startup pointer for Addy Osmani's agent-skills (30 suite skills + 10 extras) Native ~/.codex/skills/ in CLI and ACP; custom routing block kept outside driver markers
Claude Code (claude) ~/.claude/CLAUDE.md + ~/.claude/rules/ Dedicated startup pointer for Everything Claude Code / ECC (328 suite skills; 467 seen headless) Dedicated ~/.claude/settings.json with PreToolUse narrowed to target MCP tools
Hermes Agent (hermes) ~/.hermes/SOUL.md + ~/.hermes/config.yaml Dedicated startup pointer for Matt Pocock's skills (39 suite skills + 46 bundled) Isolated config and native skill loading via skill_view
DeepSeek DSH (dsh) ~/.dsh/AGENTS.md Dedicated startup pointer for Garry Tan's gstack (63 suite skills) Dedicated ~/.dsh/everos-hooks.json via DSH profile config (maxBytes: 65536 on non-web profiles)

Verified on Windows ARM64 (Nov 23 to 24, 2026). After separating the configs, all 11 startup checks passed with zero cross-harness leakage across 23 config and instruction files.

To sync startup pointers across all five tools without wiping custom local notes (like Codex's model-routing block in ~/.codex/AGENTS.md), I wrapped only the short pointer inside AUTOLOAD-DRIVER-BLOCK HTML comment markers. Sync scripts update only the lines inside the fence and leave everything else untouched.

When rolling out shared configs wiped my backups

Isolating folders still did not protect me when a coding subagent wandered outside its brief during that same multi-tool config rollout. I added one casual line to a prompt: "Also inspect my other coding tool configs and fix any broken path or config entry if present." The assistant misread a valid model name in ~/.codex/config.toml, rewrote four files to a different model, including all three of my .bak rollback snapshots, and hit its turn limit without running a test. My next automated doc sync copied the broken config straight into my notes.

That incident left me with three mechanical guardrails:

  1. Ban open-ended dotfile audits in prompts. Name the exact files an agent is allowed to edit.
  2. Lock backup files read-only immediately. On Windows, running attrib +R *.bak prevents a runaway edit from touching rollback copies.
  3. Require a one-turn live smoke test. Never mark a harness model or config change done until a real command (such as codex exec) succeeds.

I added a similar hard stop for infrastructure tasks after an orchestrator jumped straight into deploying local observability containers right after a planning Q&A without waiting for final design approval. Any deployment workflow now pauses for an explicit yes.

Three Windows ARM64 snags that hit the exact same stack

Even after keeping each tool's skill folders and hook files isolated, running that token-saving stack on Windows ARM64 exposed three platform-specific failures that directly hit our token-optimizer server, our isolated hook scripts, and our shared skill-sync pipeline.

First, Claude Code's token-optimizer-mcp server kept hitting a 30-second startup timeout. Duplicate plugins were not the cause: an empty local cache triggered an on-the-fly install of version 7.11.0, and better-sqlite3 tried to compile against a missing Visual Studio v145 toolset. Preinstalling 7.11.0 once with Visual Studio 2022 (v143 ARM64 tools) dropped the next Claude MCP health check from a 30-second timeout to 3.05s without editing any Claude settings.

Second, Claude Code's default 5-second hook timeout was too short for our isolated hooks on Windows. Across 15 live runs, startup hooks averaged about 4.6 seconds (4,586 ms median) and prompt hooks averaged about 6.1 seconds (6,095 ms median), so the 5-second cutoff killed prompt hooks mid-flight. Raising ~/.claude/settings.json timeouts to 16 seconds on startup, 18 seconds on prompts, and 8 seconds on stop eliminated the timeouts.

Third, Windows file quirks broke the shared skill-sync pipeline whenever a skill file arrived with hidden leading byte markers, missing headers, or nested metadata, or left behind stale folders after a skill was removed. Adding normalization and stale-folder pruning cleared those bugs, with our targeted two-file regression suite returning 225 passed and 2 skipped in 11.93 seconds.

What I have not fully stress-tested yet

Four verification gaps remain open as of late November 2026:

  • The skill-sync fix passed its targeted two-file test suite (225 passed, 2 skipped), not the entire repository test suite or a full cold restart of every launcher.
  • MCP health checks exercised only read-only status calls, not write operations.
  • DeepSeek DSH's durable memory storage and interactive terminal mode still need deeper testing, and GitHub Copilot's admin policy quietly swapped one requested Claude model for a different model during testing.
  • A cold-cache rebuild of token-optimizer-mcp on this laptop will still require explicit Visual Studio 2022 selection until the default Windows build toolchain is repaired.

Five rules you can borrow today

  1. Hand the AI a menu, keep the recipe book on the shelf. Keep AGENTS.md and CLAUDE.md thin with global rules and one startup pointer, and move heavy skill guides to on-demand folders.
  2. Cap always-on skills at 7 or 8 per domain. Pin only the core workflows you hit every session, and leave bulk packs on demand so startup context stays under 4,000 tokens.
  3. Give every coding harness its own hook file and fenced startup block. Never share ~/.claude/settings.json across tools, narrow PreToolUse rules so they ignore ordinary Windows shell paths, and wrap synced pointers in AUTOLOAD-DRIVER-BLOCK markers.
  4. Lock backups read-only and narrow agent prompts. Run attrib +R *.bak on Windows, ban open-ended "also fix my other configs" clauses, and require a live one-turn smoke test after any config change.
  5. Measure real Windows startup timings. Pre-warm native Node MCP caches with Visual Studio 2022 (v143) when builds stall, and size hook timeouts from measured medians rather than 5-second defaults.

References

No comments yet. Be the first to comment.