Vibe CodingPremiumMay 9, 20265 min read

The Context Window Discipline That Keeps Claude Sharp

Most builders blame Claude when it gets dumb mid-project. It's not Claude. It's your context hygiene. Here's the discipline that fixes it.

Every time someone tells me Claude got worse, I ask the same question. How long was your session? Nine times out of ten, they've been in the same conversation for four hours, pasted seventeen files, and watched it slowly lose the plot.

That's not a model problem. That's a context discipline problem. And it's the single biggest unlock for shipping with AI tools in 2026.

Here's exactly how we manage context at 47 Industries, what to dump, what to keep, and the rituals that keep Claude (and Cursor, and any coding agent) sharp for the entire project.

Why Context Rot Happens

LLMs don't have memory. They have a window. Everything in that window competes for attention. The more you stuff in, the more diluted the model's focus becomes on the thing you actually care about right now.

There's also a recency bias. Whatever you said most recently gets weighted heaviest. So if you spent an hour debugging an auth issue and then pivoted to writing a new feature, half the model's brain is still thinking about JWT tokens when you're asking about a payment flow.

Context rot looks like this:

  • Suggestions that contradict decisions you made earlier in the session
  • Inventing function names that don't exist
  • Forgetting your stack and suggesting libraries you explicitly ruled out
  • Going in circles on bugs it already debugged once
  • Getting weirdly verbose or weirdly terse

If you're seeing any of those, your context is cooked. Don't fight it. Reset.

The Three Buckets of Context

Before I touch a tool, I sort everything into three buckets. This is the mental model that makes the rest work.

Bucket 1: Permanent Context

Stuff that's true for the entire project. Stack, conventions, architecture decisions, naming patterns, business rules that never change. This lives in CLAUDE.md, cursor rules, or a system prompt. You never paste this manually because it's always loaded.

Bucket 2: Task Context

Stuff that's true for the current feature or bug. The specific files involved, the relevant schemas, the user story, the acceptance criteria. This gets loaded at the start of a task and dumped when the task is done.

Bucket 3: Conversation Context

The back and forth happening right now. Your last three messages, the code you're iterating on, the error you just hit. This is volatile. It builds up fast and is the first thing to flush.

The mistake most people make is treating all three buckets the same. They paste their entire codebase into chat because they don't know what's permanent versus task-level. Or they keep one conversation open for a week and never reset bucket three.

The Session Reset Ritual

Here's the rule I follow. One conversation equals one task. When the task is done, the conversation dies.

That means a typical day looks like four to eight separate conversations, not one long one. Each one starts fresh, loads exactly what's needed, executes, and gets archived.

The ritual at the start of each session:

  1. State the goal in one sentence. "Add Stripe webhook handling for subscription cancellations."
  2. Load the relevant files. Just the ones that matter. Not the whole repo.
  3. State the constraints. "Must match the existing webhook pattern in /api/webhooks/checkout.ts. No new dependencies."
  4. Define done. "Tests pass, types check, manual verification with Stripe CLI."

That's it. Four steps, takes ninety seconds. The model now has a clean window with exactly what it needs and nothing it doesn't.

What Belongs in CLAUDE.md (and What Doesn't)

I've watched people stuff their CLAUDE.md with three thousand lines of documentation. That's worse than having no CLAUDE.md at all. Every token in there is a token competing with your actual question.

What belongs:

  • Stack and versions (Next.js 15, Drizzle, Postgres, etc.)
  • Hard rules (never use any, always use server components by default)
  • File structure conventions
  • How to run tests, lint, typecheck
  • Auth and data access patterns
  • Anything you've corrected the model on more than twice

What doesn't belong:

  • Full API documentation (let it search the codebase)
  • Business logic explanations that don't affect code style
  • Anything that's only true for one feature
  • Aspirational rules you don't actually enforce

Mine is about 180 lines. Yours should probably be similar. If it's over 400 lines, you're doing too much.

The Mid-Session Compaction Move

Sometimes a task is genuinely big and you can't avoid a long session. When that happens, I use what I call compaction.

Every thirty to forty minutes, I stop and ask the model to summarize the state. Something like: "Summarize what we've done, what's left, and any decisions we made. I'm going to use this to start a fresh session."

It produces a clean handoff doc. Then I start a new conversation, paste that summary, load the current state of the files, and continue. The new session has zero rot and a sharp picture of where we are.

This sounds tedious. It takes maybe two minutes. The output quality difference is night and day.

Cursor and Claude Code Specifics

The principles are the same but the mechanics differ.

In Claude Code: Use the /clear command aggressively. Use /compact when you want to preserve context but reset the window. Keep CLAUDE.md files at the project root and in subdirectories for area-specific rules.

In Cursor: Don't rely on the codebase indexer to do your thinking. Manually @-mention the files you want considered. The indexer is fine for discovery but bad for focused work. Use .cursorrules for permanent context.

In ChatGPT or Claude web: New chat per task. Always. The temptation to keep one mega-thread is real and it will rot.

The Subagent Escape Valve

When a task genuinely needs a lot of context, don't try to cram it all into one window. Spawn subagents.

One agent reads the codebase and produces a summary. Another takes that summary and writes the code. A third reviews. Each one has a clean window focused on a single job.

This is how we handle anything non-trivial now. The main conversation orchestrates. The work happens in parallel sessions that report back. Each subagent is born, executes, and dies without polluting the main window.

The Discipline Itself

None of this is hard. The hard part is doing it consistently when you're in flow and don't want to stop.

The builders who ship the most with AI aren't the ones with the best prompts. They're the ones who treat context like a finite resource. They reset early. They keep windows small. They write everything important down somewhere persistent so the model doesn't have to remember.

If you take one thing from this post: one conversation, one task. Try it for a week. You'll stop blaming Claude.

Premium article

Unlock the full article

This article is part of the 47 Vibe Coding Playbook (lifetime, $147) and Inner Circle ($47/mo). Members get every premium article, every prompt, and every CLAUDE.md template.

Already a member? Sign in.

KZZY

Written by KZZY

47 Industries has been home since the beginning, from 3D printing operations to leading all software development across MotoRev, BookFade, and the 47 platform.

Ready to Build?

Get a quote on your project. We build websites, web apps, mobile apps, and SaaS products for businesses across Florida and the US.