Skip to main content
Second Foreman LLC · Oklahoma City, OK SAM.gov UEI: U4BYU2ELNVW1 OK SOS: #3513997463 OK Tax Permit: #796020736 Veteran-Owned Small Business
hello@secondforeman.com
AGENT TOKEN ECONOMICS ยท ZERO-INSTALL CLI & MCP GUIDE

How to Stop AI Coding Context-Compaction Loops & 5x Prompt-Cache Burn

Why a 35 KB project instruction file triggers compaction every 12 tool calls, invalidates prompt caches, and how a <5 KB START.md boot card cuts input burn by 60%-80%.

Key Rules & Field Checklist

  • When boot instructions + tool schemas consume 45,000+ tokens upfront, multi-file reads push the session over the compaction threshold within minutes.
  • Every compaction rewrites the prefix, breaking cached-prefix discounts and forcing full-price re-tokenization of summarized state.
  • Fix: keep START.md <= 5,000 bytes on every boot and load deep runbooks or historical logs strictly on demand.
  • Enforce it in CI with --max-boot-tokens 6000 so bloated changelogs never merge back into your boot file.

Run in terminal: npx --allow-git=all --yes github:oneandroid-max/contextguard-mcp audit .

Related Study & Engineering Guides

The <5 KB START.md Boot-Card Pattern for AGENTS.md & .cursorrules Repositories · Auditing MCP Server Tool-Schema Token Overhead Before Tool Call #1 · Preventing package-lock.json, pnpm-lock.yaml & Build Artifacts from Leaking into Agent Context · Connect Second Foreman Remote Streamable HTTP MCP Server