Your agent is not stuck, it is looping — and loops have signatures. Learn the four loop patterns, what causes each one, and the intervention that actually breaks it.
For projects that run for weeks: a context-budget system covering what to persist in memory files, how to write a session handoff, and what to deliberately let compaction take.
Cut Claude Code costs through habits, not settings: prompt shape, file scoping, session timing and model discipline — a daily checklist for cheaper finished work.
Memory patterns for coding agents that actually work: the file-based patterns for facts, decisions and handoffs, what to persist, and why forgetting is a feature.
Run CLAUDE.md with a small team without the merge conflicts and rule wars: what belongs in the shared file, what stays personal, and a review workflow that keeps it trustworthy.
Skip the 200-line template. Write a minimal CLAUDE.md in 20 minutes that stops Claude Code guessing — then grow it only when you catch a repeat mistake.
Control Claude Code spend at the settings level: route models by task, keep context lean, and build the /clear habit — practical levers, honestly framed.
Subagents fail on vague briefs, not weak models. Use this brief template — context, constraints, done-definition — to get delegated work you can actually merge.
Write an AGENTS.md that Codex, Cursor and other agents actually follow: what ports from CLAUDE.md, what does not, and an annotated template to start from.
11 min read
It decides both halves of agent work that matter — output quality and cost — because a model can only reason over what is in the window, and you pay for everything in the window on every request. This page collects the budgets, audits and file-design guides that make that control deliberate.
Start with a context budget audit
You cannot budget what you have not measured. The context budget audit walks a real setup and prices every always-loaded element — a large CLAUDE.md can run to roughly 2,500 tokens per request, while a skill description costs around 33 tokens until the skill fires — so the waste shows up as arithmetic, not vibes. Run it once and most builders find the same three leaks: instructions duplicated across CLAUDE.md and AGENTS.md, task procedures stored as always-on rules instead of skills, and sessions kept alive long past the point where their history helps. The free context-budget worksheet turns the audit into a sheet you rerun monthly.
CLAUDE.md and instruction files
CLAUDE.md and AGENTS.md look like documentation and behave like configuration. The guides here treat them that way: what belongs in the always-loaded layer (facts, commands, hard rules), what belongs in skills (procedures for specific jobs), what belongs in subagent briefs (one task, one context), and what belongs nowhere near the window (history the agent can re-derive from the repo). Teams get their own layer — nested files, personal overrides, shared conventions — because a file that works for one builder becomes a tax on five. The Claude Code page applies all of this inside one tool; this page keeps the principles portable.
Context management for long projects
A weekend project forgives sloppy context. A three-month build does not: memory patterns decide what survives between sessions, handoff summaries decide whether a fresh agent continues or restarts, and debugging agent loops — the same wrong fix attempted five times — is usually a context failure wearing a model failure's clothes. The long-projects guide sequences budgets, compaction and handoffs into one operating pattern, and the memory-patterns piece separates what should persist (decisions, constraints, state) from what should be re-read fresh (code, data, anything that changes).