← Back to list

How to Prompt Claude Without Wasting Your Context Window

The thing nobody tells you when you start using AI tools daily.

Coey in Coffee☕ And Code💚 · 2026-04-08 06:51 · 10 claps · 5.2 min read
#artificial-intelligence #software-engineering #programming-tips #claude-ai #techtrends-digest
Open on Medium ↗
Wiki topics: LLM · Large Language Models AI · AI · General 💻 · Programming

How to Prompt Claude Without Wasting Your Context Window

The thing nobody tells you when you start using AI tools daily.

You paste a 300-line controller, ask a specific question about a race condition, and get a surprisingly shallow answer. You provide more context. Still not quite right. By message ten, Claude feels like it’s forgotten the architecture decisions you made twenty minutes ago.

It has.

This is the Context Window problem. Once you treat Claude’s memory like managed RAM instead of an infinite notebook, your output quality will double. Here is how to stop wasting your tokens.

What Are Tokens, Actually?

Before the tips, a quick mental model worth having.

Claude doesn’t read your messages the way you do. It processes everything… your questions, its own answers, your code, your follow-ups… as tokens. Think of tokens as chunks of text, roughly three to four characters each. A line of code is a few tokens. A full service file might be hundreds.

Every conversation has a limit on how many tokens Claude can hold in its “working memory” at once. That’s the context window.

Image generated by Gemini / AI-assisted visual for token explanation.

Image generated by Gemini / AI-assisted visual for token explanation.

Here’s why this matters: Claude doesn’t just read your latest message. It re-reads the entire conversation history every single time it responds. The longer your conversation, the more tokens get consumed just to maintain context, and the less room there is for useful reasoning about your actual problem.

When you hit the limit, early messages silently fall off. Claude starts losing track of decisions made earlier in the chat. Responses get generic. It starts contradicting itself.

The fix isn’t a bigger window. It’s learning to use the window you have efficiently.

Tip 1: Don’t Describe Code… Paste It

This wastes tokens and degrades answer quality at the same time.

“I have a service that handles user authentication. It checks the JWT, validates the role, and returns the user profile if everything passes…”

That description is always incomplete. You’ll leave out the one detail causing the bug. It will fill in the gaps with assumptions that don’t match your actual code.

Paste the actual code. Claude is trained on code, it reads it faster and more accurately than your English summary of it. You get a better answer in fewer exchanges, which means fewer tokens spent on clarification rounds.

The one caveat: paste the relevant code, not everything. Which brings us to the next tip.

Tip 2: Trim Before You Paste

Pasting a 400-line file when the issue is in a 30-line method is one of the most common ways developers burn through context unnecessarily.

Before pasting, ask yourself: what’s the smallest piece of code that contains the problem?

Strip out:

  • Unrelated methods in the same file
  • Import statements Claude doesn’t need to reason about the logic
  • Commented-out dead code
  • Boilerplate that’s identical to standard patterns (Claude already knows what a NestJS module declaration looks like)

Trimmed code = fewer tokens consumed + Claude focuses on what actually matters.

If you need to share multiple files, share them one at a time and only when each is directly relevant to the current question.

Tip 3: Structure Your Prompt Upfront

Vague prompts lead to vague answers, which leads to follow-up questions, which burns tokens on clarification instead of problem-solving.

A structured prompt gets you to the right answer in one shot:

Role: [Who Claude should act as]
Stack: [Your actual tech stack]
Context: [What you're building and where you are in the process]
Task: [Exactly what you want]
Constraint: [What Claude should NOT do — e.g., don't suggest new libraries]

In practice it looks like this:

“You’re a senior NestJS developer. I’m building a trading platform using NestJS + Prisma (MySQL) + Redis. I’m halfway through a revamp and can’t change the overall architecture. Review this queue processor for production reliability issues, don’t suggest switching to a different queue library.”

[paste relevant code]

One prompt. One focused answer. Zero clarification rounds.

The constraints part is underrated. Telling Claude what NOT to do saves you from getting back a perfectly correct answer to a slightly different question than the one you asked.

Tip 4: New Problem, New Chat

Most developers keep one chat alive for the entire day — debugging a Redis connection, then pivoting to CSS layout, then asking about Docker networking.

By the hour mark, Claude is spending 60% of its brainpower re-reading your Redis logs just to answer a Docker question. That is “Context Pollution.”

The Rule: Fresh chats are free; context pollution is expensive. If the topic shifts, hit “New Chat.” You’ll notice an immediate jump in Claude’s “intelligence” because its reasoning isn’t being weighted down by irrelevant history.

Tip 5: Chain Prompts Like Functions

Complex tasks done in one massive prompt usually produce mediocre results. Claude is better when you break work into steps — like composing middleware.

Instead of: “Design my entire authentication system with JWT, refresh tokens, Redis session blacklisting, and role-based access control for a NestJS app.”

Do this:

Prompt 1: “Design the JWT access + refresh token flow for a NestJS app. Just the auth logic, no implementation yet.”

Prompt 2: “Now add Redis session blacklisting to that design. Here’s what we decided in the previous step: [paste the relevant output]”

Prompt 3: “Now implement the NestJS guard based on this design: [paste design]”

Each prompt is focused. Each answer is high quality. You carry forward only the relevant output from the previous step — not the entire conversation history.

This also gives you natural checkpoints to course-correct before Claude builds ten more things on top of a wrong assumption.

Tip 6: Know When to Start Fresh

There’s a point in every long conversation where Claude’s answers start feeling slightly off. A bit generic. A bit inconsistent with earlier decisions. Slightly contradicting itself.

That’s your signal. The context window is getting crowded.

Don’t try to fix it by adding more context in the same chat — that makes it worse. Start a new chat, bring in only what’s essential, and you’ll immediately notice the quality jump back up.

A useful habit: at natural breakpoints in your work (finished one feature, moving to the next), just start a new chat. You lose nothing — Claude has no persistent memory between sessions anyway. You gain a clean slate with full context capacity.

Tip 7: Summarise Don’t Repeat

When you genuinely need Claude to carry context across a long task — say, you’re iterating on the same piece of code across multiple prompts — don’t re-paste the full history.

Summarise what was decided, and paste only the current state: “We’ve established: JWT auth with 15-minute access tokens, Redis blacklist for logout, and role-based guards using a custom decorator. Here’s the current state of the guard, let’s add the refresh token rotation logic now.”

That summary costs maybe 40 tokens. Re-pasting the full conversation history of how you got there might cost 600. Same context for Claude, fraction of the token cost.

The Underlying Principle: Treat It Like RAM

Every token spent on irrelevant imports, dead code, or tangential conversation is a token not spent on reasoning about your bug.

You wouldn’t fill your server’s RAM with zombie processes and then complain about latency. Don’t do it to your LLM. Apply engineering discipline to your prompts: trim the fat, isolate the logic, and clear the cache often.

This is part of a two-post series on using Claude effectively as a developer. If you haven’t read it yet, the second post covers prompting strategies, verification habits, and where Claude actually fits in your workflow.

And if you want to understand why AI tools aren’t a magic wand for real engineering work, check out my earlier post on why you can’t just AI-revamp a full-stack website.

Note: While Claude ‘Projects’ allow for persistent documentation, the active chat window still follows these token limits.


메타데이터
post_id
e076e6aa81a2
slug
how-to-prompt-claude-without-wasting-your-context-window-e076e6aa81a2
url
https://medium.com/techtrends-digest/how-to-prompt-claude-without-wasting-your-context-window-e076e6aa81a2
canonical_url
https://medium.com/techtrends-digest/how-to-prompt-claude-without-wasting-your-context-window-e076e6aa81a2
author_url
https://medium.com/@coeylow
status
ok
fetched_at
2026-06-13 07:35:29