Claude · Advanced

Context engineering

Choose what goes in front of Claude, put it in the right order, trim what doesn't change the answer, and carry state across sessions with a file.

Context engineering in Claude

The problem has changed

Older advice focused on fitting into the window. With a 1M-token window on current models, and compaction handling long sessions, running out of room is now rare. The problem now is quality. Anthropic's docs warn that accuracy and recall degrade as tokens grow, which they call context rot. So the question has moved from what fits to what deserves to be there.

Where context actually comes from

Much of it isn't what you typed. Project knowledge, memory, CLAUDE.md, tool definitions, tool results, earlier thinking and uploaded files can all be in play. Before tuning a prompt, work out what else Claude can already see. On the API, the usage field shows what each request consumed. In a chat, the simple test is to open a new one and see whether the answer improves.

Frequently asked
What is the difference between prompt engineering and context engineering?

Prompt engineering is about wording your instructions. Context engineering is about everything else the model sees, including files, history, memory and tools. Anthropic's engineering guide treats it as the next step beyond prompt engineering, especially for agents.

What happens when a Claude chat gets too long?

On paid plans, automatic context management summarizes earlier messages to make room, if code execution is on. Your full history is preserved, but longer chats use more of your usage limit. Starting a new chat with a short summary is often better.

Should I put my question before or after a long document?

After. Anthropic's guidance for inputs of about 20k tokens or more is to place long documents near the top and your query at the end, which it says can improve response quality by up to 30 percent in tests.

How do I make Claude remember things between sessions?

In the apps, use memory and project knowledge. In Claude Code, use CLAUDE.md for your instructions, and auto memory for Claude's own notes. For a long project, keep a short progress file that each session reads first and updates last.