Context engineering fundamentals: getting superior output from Claude Code
Context engineering is the art of optimizing what you feed the model so what comes back is worth keeping. It’s what turns Claude from a tool into a collaborative developer partner: consistent output across interactions, fewer iteration cycles, less context switching. (This started as a talk: slides here, and as a LinkedIn post.)
Here are the techniques that earned their place in my workflow.
Compaction
Fitting more context without losing clarity:
- Concise names: variable names and abbreviations the model understands
- Reference documents: compressed project knowledge libraries
- Context libraries: reusable prompt components
- Strip verbosity: essential patterns only
The result: 60–70% token reduction while maintaining the full specification.
The advanced version is a consistent abbreviation language the model can
decode. Architecture specs become
API:REST | Auth:JWT | DB:Postgres | Cache:Redis:60s. Code patterns become
ErrorHandling:try-catch-log-rethrow, Validation:zod-schemas. Dependencies
become Core:Next14,TS5,Tailwind. Dense for humans, perfectly legible to the
model.
Structured note-taking
Organize project context the way the model consumes it best:
- Architecture: MVC with service layer, state management patterns
- Conventions: TypeScript strict mode, component patterns, error handling
- File structure: API endpoints, shared utilities, atomic components
- Critical rules: no direct DB access, loading states, input validation
And layer it general-to-specific to prevent information overload: foundation (project type, stack, design pattern) → technical details (API design, auth, data layer) → task context (current work, dependencies, constraints).
Sub-agent architectures
Break complex tasks into specialized expert prompts: an architect agent for design and structure, an implementation agent for code generation, a review agent for quality and security, a documentation agent, and specialist agents for performance, security, and DevOps. Each persona focuses on its expertise, and output quality jumps compared to one context doing everything.
Keeping conventions from drifting
The consistency challenge across AI sessions is solvable:
- Convention anchoring: define error formats, API response shapes, and naming patterns explicitly in durable context
- Reference reinforcement: link to existing code examples instead of re-describing them
- Drift prevention: include examples, reference files, and periodic style checks
Best practices
- Front-load critical information: most important context first
- Use consistent terminology: build a project glossary
- Prefer examples over explanations: show, don’t tell
- Layer complexity gradually: start simple, add detail as needed
The habit that ties it together: keep a context-engineering.md in each
project with compacted contexts, successful prompts, and learned patterns.
Treat it as living documentation. It compounds.
The bigger point
Context engineering isn’t just prompt writing. It’s a systematic approach to AI collaboration that scales with project complexity. The developers getting the most out of these tools aren’t writing better prompts. They’re building better context.