Claude Code: context, compact, clear and session hygiene
Claude Code in depth: dump zone, compact vs clear, permissions, skills, plan mode, MCP (build/design), autonomy plugins, subagents and tokens. Team method to keep quality.

Claude Code: the bottleneck is context
Before model or plugin talk, look at the context window. With Claude Code every message, file read, tool log and answer piles up. The model rereads that past to predict the next token. As the session grows, cost rises and quality can drop before you feel “done”.
Windows are large (hundreds of thousands to a million tokens depending on model and plan). Large is not unlimited quality. In practice you get a “smart” zone where answers stay solid, then a zone where relevance falls. Often called the dump zone: past a share of the window, reasoning is not the same.
Useful rule of thumb for teams: several field reports point to clear degradation near half to 60% of the useful window, especially with long tool loops. Not a fixed physical law. It is an alarm to compact or split the session before “one more push”.
Claude Code often warns early: near the end of the useful window, it pushes you to compact. The daily token war is less noise, shorter sessions, intentional summaries, bounded tools.
Compact vs clear: two commands, two jobs
Compact: you ask (or the tool pushes you) to summarize useful history. The model compresses back-and-forth, file searches, edit attempts, flow understanding. You continue the same thread with a smaller summary. Note: the summary itself costs tokens; compact is not free.
Clear: you change thread. You leave the current chat context. Compact = compress to continue. Clear = reset chat for another goal.
What survives after you leave Claude Code depends on what you wrote elsewhere. A session-only summary can vanish on close. A repo file note (CLAUDE.md, memory, skill, handoff) survives. Rule: what must last day to day lives in the repo.
Intentional, frequent compaction: on monorepos or long features, do not wait for the dump zone. Compact after a step (research, plan, sub-goal implementation). Write a short handoff: goal, decisions, files touched, next. Less magic, more control.
Dump zone: signals and countermeasures
LLMs lean on the start and end of context. The middle erodes. With too many MCP tools, files, and logs, you enter the zone where answers go generic, contradict themselves, or “forget” a constraint from 40 messages ago.
Signals: the agent rereads files for no reason, proposes out-of-scope diffs, ignores the definition of done, loops on tools, or says you are “completely right” in a sycophantic mode just before derailing. That last reflex is a good marker to reset or hand off.
Countermeasures: one goal per session; compact after each step; clear when the topic changes; limit active MCP tools; deny destructive permissions (e.g. rm -rf); slice the monorepo (subtree, package, local CLAUDE.md); subagents to isolate heavy research.
More commits from a saturated session does not mean more value. We look at incidents and review time after merge.
Permissions, sandbox, yolo
Every shell command or MCP tool can request a permission. Grant what is needed (tests, build) and deny destructive by default. Team settings can pre-allow an allowlist and block the rest.
Yolo / skip permissions: tempting in a throwaway sandbox. Dangerous on a dev machine with secrets and prod access. Rule: isolated sandbox or no yolo.
Without the third brick (control: permissions, HITL, allowlist), you just have a POC / demo, even with the best coding agent.
Init, CLAUDE.md, skills and plan mode
Slash init and repo instruction files give permanent context: stack, test commands, forbidden zones, conventions. Version them. A root CLAUDE.md plus one per hot package beats a 40-message monologue.
Skills: reusable competencies (create plan, migration, design tokens, test scenario). Better than a throwaway prompt. As a team, one plan skill avoids every eng producing a different plan format and an impossible review.
Create plan is not one-shot: the agent researches, asks trade-off questions, writes the plan, iterates. If you switch mode or tool mid-way without materializing the plan in a file, you lose the thread. Keep the plan in the repo.
When you do the same thing twice, extract a skill or command. Mature teams accumulate dozens of skills and thousands of versioned context lines: that is an internal product, not a chat gadget.
Hooks: extension points to enforce steps (lint, tests, checks) at points in the cycle. Useful for determinism around the agent.
Subagents, scripts and “free” tokens
A subagent has its own context window. The orchestrator does not swallow the full research history. You keep focused context and often go faster on isolable tasks (exploration, docs, local audit).
A deterministic script (lint, format, transform) does not burn LLM tokens. When a step is purely mechanical, a skill that calls a script beats an agent reinventing the wheel in prose.
Reducing tooling noise (monster command output, file trees) is also IDE-side context engineering. “Token killer” style tools compress what enters the model: the key idea is token efficiency, not only unit model price.
MCP: build, design, outside world
MCP is a common standard to wire tools to the agent (often described as USB-C for agents). Claude Code can orchestrate several servers: build and simulator (e.g. Xcode ecosystem), design (Figma: tokens, hierarchy, screenshot), tickets, docs.
MCP brings outside-world context; Claude orchestrates. A prompt without that context yields generic throwaway code. A design-system skill plus a design MCP reduces mock/code gap.
Cost: more MCP servers + more skills = more input tokens before a single line of code. Day one: few tools, read first, writes behind confirmation. Disable what the session does not need.
MCP architecture detail (allowlist, security, computer use) is in the Model Context Protocol article. Here: impact on the Claude Code session.
Autonomy plugins: plan first, exit after
Autonomy loop plugins (style “persist until done”) promise an agent that iterates alone. Without parameters you burn tokens: no max turns, no exit condition, no plan.
Healthy pattern: 1) build the plan with a human (real leverage), 2) generate a versioned implementation plan file, 3) loop tasks while updating the plan (done / left), 4) explicit exit conditions per goal.
Structural limit: context saturation in a long loop. The agent derails in the same thread. Solutions: compact, split sessions, or replay the batch pattern outside the plugin with file handoffs (same logic, more control).
Yolo plus plugin without sandbox = incident. Spec first, bounded autonomy second.
Debug, ADE, cloud coding agents
Giving the agent a debugger (or debug CLI) changes the loop: repro → hypothesis → patch → retest, instead of guessing in the void. Same context discipline: bounded logs, no unfiltered monster dumps.
We move from “sidebar chat” IDEs to agentic environments (ADE) and cloud/CI agents. Useful for headless jobs. Team policy (permissions, secrets, review) stays the same whatever the client.
Craft guardrails: AI is easy to adopt; protections (tests, review, file segmentation, short precise prompts) less so. One precise prompt beats three fuzzy ones and saves tokens.
Team routine (checklist)
1) One goal per session. 2) Spec or plan file before large generation. 3) Compact after each major step (or before ~50-60% if the tool signals it). 4) Clear when the topic changes. 5) File handoff if the session exceeds 30-40 useful minutes. 6) MCP and permissions listed for the session. 7) Deterministic scripts for mechanical work. 8) Human review on auth, payments, migrations, PII.
Enablement: 1-day workshop, max 8 people, real repo. Force compact/clear and versioned plans, not a feature tour.
If you want to scope Claude Code and team conventions on a real process, we can do it in 20-40 minutes.
FAQ
- What is the difference between compact and clear?
- Compact summarizes to continue the same thread with fewer tokens. Clear resets the thread for another goal. What must survive outside the session is written in the repo (CLAUDE.md, skill, handoff).
- What is the dump zone?
- The part of the window where quality drops sharply (often cited near half to 60% fill under heavy use). Signals: out-of-scope, forgotten constraints, tool loops. Countermeasure: compact earlier, shorter sessions, fewer active tools.
- Should you compact every message?
- No. Compact after a step (end of research, plan, sub-goal) or on tool warning. Too many compacts cost tokens and can drop useful detail.
- How many MCP servers at once?
- The minimum for the current session. Each server and skill inflates input context. Disable the rest.
- Are autonomy plugins safe?
- Only with a plan file, exit conditions, max turns, bounded permissions and preferably a sandbox. Otherwise you burn tokens and risk out-of-scope actions.
- Link to production context engineering?
- Same context physics, different perimeter. Here: Claude Code session hygiene. The context engineering article covers corpus, tools and metrics for a replayable business agent.
- How to train the team?
- 1-day workshop, max 8 people, real repo: feature + bugfix with compact/clear, versioned plan, MCP policy. At 30 days: incidents, review time, % of PRs with a plan.
- Why a script instead of an agent for some tasks?
- A script is deterministic and does not burn LLM tokens. Reserve the agent for judgment; script the mechanical work.
Scope your first AI agent
20 minutes to review your tools, data and the first useful case. No jargon, no commitment.