navigate · F fullscreen
~/agentic-coding-enablement01 / 17
$ claude --topic "context-management"
// AGENTIC CODING ENABLEMENT

Context Management
in Agentic Coding

Why the window is the whole game.
~20 min · for engineers who know agents, but haven't lived in them yet
~/the-symptom.log02 / 17
// you've probably watched this happen

The agent that slowly lost the plot

0:00SHARPreads the brief, writes a clean plan, edits land first try
0:20DRIFTINGstill mostly right, but re-reads files it already saw
0:40LOSTforgets the plan, re-introduces a bug it just fixed, loops

The model didn't get dumber. Its context did — and that you can manage.

stateless.md03 / 17
// ACT 1 — WHAT A CONTEXT WINDOW IS

The model is stateless

request #1 → [ system + tools + CLAUDE.md ] + you request #2 → [ system + tools + CLAUDE.md ] + you + reply + you request #3 → [ system + tools + CLAUDE.md ] + you + reply + you + reply + you └─ grows every turn ─────────────────────┘

This one fact explains the rest of the talk.

$ context-window --inspect04 / 17
// it's not just "your messages"

What's actually in the window

sys+tools skills CLAUDE.md history tool output file reads
System prompt + tool defs — fixed cost, every request
Skills — definitions loaded in
CLAUDE.md / AGENTS.md — your project rules
Message history — grows all session
Tool output — including file reads
MCP definitions — tool defs, descriptions, etc.
why-it-matters/01-context-rot05 / 17

It's a slope, not a cliff

quality context used → what you assume what happens limit rot starts
why-it-matters/02-cost06 / 17
// resent every turn = paid for every turn

Long sessions get slow & expensive

t1
t2
t3
t4
t5
t6
  • Bigger blob each turn → cost & latency climb
  • New tokens are cheap; cached prefix is reused
  • Churn early context → cache busts, you pay again
$ ls strategies/09 / 17
// ACT 3 — Management

What can we do about it?

Right context in. Junk out. Reset deliberately. Pull context just in time — search, don't dump.

strategies/ ├─ 01-monitor # see your budget ├─ 02-plan # think while the window is clean ├─ 03-subagents # isolate heavy work ├─ 04-compact/handoff # reset without losing the thread ├─ 05-session-toolbox # rewind · branch · clear · resume └─ 06-large-codebases # structure the repo so it stays lean
strategies/01-monitor10 / 17
// you can't manage what you can't see

1 · Monitor the budget

$ /context ⛁ 78,420 / 200,000 (39%) ├─ system + tools .. 11.2k ├─ messages ........ 52.0k ├─ file reads ...... 14.1k └─ free ........... 121.6k
  • Glance at usage like a memory profiler
  • Filling fast, little progress? reset or delegate
Claude Code/context + live meter in the status line Codextoken usage shown per turn
strategies/02-plan11 / 17
// think while the window is still clean

2 · Plan first, then build

A plan is a durable artifact — it survives a reset when messy build history doesn't.

KEEP context

  • Tightly-coupled follow-on work
  • Plan + recent edits still relevant
  • Mid-thread on one task

RESET context

  • Switching tasks
  • After a messy dead end
  • History is noise, not signal
Claude CodePlan mode (shift+tab) — read-only, proposes before editing Codexplan-style preamble before acting
strategies/03-subagents12 / 17
// borrow a fresh window, return only the answer

3 · Subagents isolate the mess

Main thread
stays lean — keeps the plan & the goal
spawn
Subagent
burns its own window: greps 40 files, reads, explores
summary
Main thread
gets a tight summary — not the raw dump

The noisy work happens elsewhere; your main context only sees the conclusion.

Claude CodeSubagents / Task tool — fan out into separate contexts Codexdelegated sub-tasks return condensed results
strategies/04-compact-handoff13 / 17
// when the window fills, two ways out

4 · Compaction vs Handoff

COMPACTION — condense in place

  • You run it; the agent summarizes
  • Lossy — it picks what to drop
  • Same session, smaller window

HANDOFF — intentional

  • You write state to a file
  • Fresh window + a brief you control
  • Nothing important drops silently

For anything important — hand off.

Claude Code/compact · /clear · write a memory/handoff file Codexsummarization + fresh session from notes
strategies/05-session-toolbox14 / 17
// Claude Code: reset, fork, recover

5 · The session toolbox

/compact
Condense the session into a summary — same thread, smaller window. You trigger it; the agent decides what to keep.
/rewind
Roll back to an earlier point — code, conversation, or both. Recover a clean state after a bad detour.
/clear
Empty the window for a new topic. Old session is saved — still resumable.
/branch
Fork the conversation into a new session; the original stays intact to return to.
/resume
Jump back into a saved session from the picker. Pair with /branch to explore safely.

Claude Code   Honorary mention: /btw — ask a side question without derailing the main thread.

strategies/06-large-codebases15 / 17
// configure the repo so context stays lean by default

6 · Wrangle large codebases

monorepo/ ├─ CLAUDE.md # root: shared rules ├─ .claude/settings.json └─ packages/ ├─ api/ │ ├─ CLAUDE.md # loads on-demand │ └─ .claude/skills/ # scoped to api/ └─ web/CLAUDE.md
// .claude/settings.json { "permissions": { "deny": [ "Read(./**/dist/**)", "Read(./**/build/**)", "Read(./**/*.generated.*)" ]}} # search already skips .gitignore paths
  • Nested CLAUDE.md — root for shared rules; per-package files load only when Claude opens that dir. Launch in the package you're working in.
  • Package-scoped skills — drop .claude/skills/ in a package, or add paths: to frontmatter.
  • Keep generated files out .gitignore covers search; deny Read() on dist / build / generated.

Codex   uses AGENTS.md the same nested way.

takeaways.md16 / 17
// the part to take to work tomorrow

The mental model

Context is a finite, decaying working memory. Manage it like a budget.

# three habits 1. watch it — know how full the window is 2. plan before you build — bank the thinking 3. reset deliberately — subagent · handoff · rewind · /clear

Do these three, and the agent stays sharp at minute 40.

~/thanks17 / 17
$ questions --open

Q&A