Adding Context
Why Context Management Matters
Context management is the single most impactful factor in Claude Code's effectiveness. The model can only work with information it has access to -- and providing too much irrelevant information degrades performance just as much as providing too little. The goal is precise, targeted context.
The Context Principle
More context is not always better. Claude performs best when given just enough relevant information to complete the task. Flooding the context with unrelated files forces the model to filter signal from noise, reducing accuracy and increasing latency.
Performance peaks with the right amount of relevant context
The /init Command and Claude.md
The /init command is your first step when introducing Claude Code to a new project. It analyzes the entire codebase and generates a Claude.md file containing a structured summary of your project's architecture, key files, conventions, and patterns. This file is automatically included in every request, giving Claude persistent project awareness.
# Run in your project root
claude
> /init
# Claude analyzes your codebase and creates:
# - CLAUDE.md (project-level, committed to git)
# Contains: project summary, tech stack, key files,
# architecture patterns, testing conventions| Claude.md Level | Location | Scope | Committed? |
|---|---|---|---|
| Project | CLAUDE.md in project root | Shared with entire team | Yes -- committed to git |
| Local | .claude/settings.local.json | Personal instructions only | No -- gitignored |
| Machine | ~/.config/claude/CLAUDE.md | Global across all projects | No -- local to machine |
Three levels of Claude.md configuration
Pro Tip
Reference critical files in your Claude.md that Claude should always be aware of. For example: 'Always check src/db/schema.prisma before modifying database-related code.' This ensures Claude has the right context without you having to specify it every time.
Context Shortcuts: # and @
Claude Code provides two powerful shortcuts for managing context during conversations. The # symbol enters memory mode for editing Claude.md files, and the @ symbol lets you reference specific files to include in your request.
# Memory mode: update Claude.md with natural language
> # Always use TypeScript strict mode in this project
> # The auth system uses Supabase, check src/lib/supabase/
# File references: include specific files as context
> @src/db/schema.prisma Fix the user table migration
> @src/auth/middleware.ts @src/auth/types.ts Update the auth flowWhen to Use Each
Use # when you want Claude to remember something permanently across all future conversations in this project. Use @ when you want Claude to have specific file context for the current task without searching for it.
- •# (Memory) -- Edits Claude.md files with natural language; changes persist across sessions
- •@ (File Reference) -- Includes specific files as context; more efficient than letting Claude search
- •Best practice: Use @ for targeted tasks, # for conventions and rules that always apply
Key Takeaways
- ✓Context management is the #1 factor in Claude Code effectiveness -- aim for just enough relevant information
- ✓Use /init to bootstrap project awareness; it creates a Claude.md with your codebase summary
- ✓Three Claude.md levels: project (team-shared, committed), local (personal), machine (global)
- ✓# enters memory mode for persistent project instructions; @ references specific files for current context
- ✓Reference critical files like database schemas in Claude.md so Claude always has key context available
Check Your Understanding
Test what you learned in this lesson.
Q1.What is the relationship between context amount and Claude Code performance?
Q2.What does the # shortcut do in Claude Code?
Q3.You want Claude to understand your database schema for a specific task but don't need it available in every session. Which approach should you use?
Q4.Which Claude.md level is shared with the entire team?