CC-301m · Module 2
Context Injection Patterns
3 min read
Every Claude Code session starts fresh. The agent does not remember the previous session, does not know what changed yesterday, and cannot infer the current state of the project from CLAUDE.md alone. What the agent knows is what you inject into context — through CLAUDE.md, through the task prompt, and through explicit context-providing instructions.
- Project state context Use CLAUDE.md to inject stable project state: which branch is the main branch, what the current deployment state is, what the testing infrastructure expects. For dynamic state — 'we are in the middle of a refactor of the auth system, do not touch it without asking' — inject it in the task prompt or a session-start instruction.
- Constraint context Context that changes behavior belongs near the instruction it affects. 'We use Vitest, not Jest' belongs near instructions about testing. 'TypeScript strict mode is enforced' belongs near instructions about type changes. Co-location makes CLAUDE.md easier to maintain and reduces the chance that the agent misses relevant context.
- Decision context When a past decision affects how the agent should behave now — 'we chose X over Y because of Z' — include the reasoning, not just the decision. The decision alone tells the agent what was chosen. The reasoning tells it when exceptions might be appropriate and when they are not.
- Session-specific context in the prompt Not all context belongs in CLAUDE.md. Context specific to the current task — recent changes, current focus areas, known issues to avoid — belongs in the task prompt. CLAUDE.md is the standing instruction. The task prompt is the mission brief.
Context for this session:
- We merged a large CRM refactor yesterday — the CRM files are unstable, do not touch them
- The staging environment is down — do not run deployment commands
- We are using the new design token system in tokens.ts — do not use hardcoded hex values
Task: Add the user avatar component to the nav bar...