Software Engineering 2026

Context management

Context Management Best Practices

Context is the agent's working memory, and quality drops as it fills with noise. The staff-level decision is where durable context lives: in files (plans, ADRs, CLAUDE.md, memory), not in chat history that disappears on /clear.

Avoid compaction

Quality drops after compaction. Keep sessions focused.

  • Separate sessions for research and implementation
  • Use subagents to search without filling the main context
  • /clear between tasks

Best practices

  • Write precise prompts. Extra words are noise
  • Research in one session. Execute in a fresh one with the plan file
  • Have different agents cross-check plans
  • Use Markdown instead of plain text for structure

A standard handoff format lets any engineer or agent resume any task: a plan file with goal, decisions, status, and next step. The same file works as onboarding material.

Structured prompts for multi-part tasks:

[TASK] JWT auth for Express API
[CONTEXT] PostgreSQL, existing users table
[CONSTRAINTS] Use src/auth/ patterns, no new deps

Use structure only for multi-part tasks. Simple prompts don't need it. For compact structured data in prompts, see TOON: https://github.com/toon-format/toon

Example prompts:

Starting fresh:
"New session. Read AUTH_REFACTOR_PLAN.md and pick up at the next unchecked step."

Handing off:
"Update AUTH_REFACTOR_PLAN.md with what's done, what's decided, and what's next."

Delegating:
"Have a subagent investigate the caching issue and write findings to CACHE_DEBUG.md."

Restart for a reason. If a session is working, don't restart it on a schedule. Modern models handle long sessions well when the task is coherent. Restart when the task changes, not when a timer says so.

On this page