Context Engineering: Mastery
CLAUDE.md hierarchy, retrieval patterns, memory tiers, and prompts that compound — the full system for sessions that get smarter every time.
Prompt Engineering Is Dead
The difference: a prompt is what you say. Context is everything Claude knows before you say anything. Master context = master results.
A prompt is a single message. Context is the entire environment — your identity, your rules, your tools, your history, your constraints. Most people optimize the tip of the iceberg while ignoring the 90% below the surface.
Context Pyramid
Bottom layers are fixed. Top layers are what you control. The further down you build, the more leverage you get.
CLAUDE.md Architecture
The most underused and most powerful weapon. Not just “be helpful” — a full operating system for your Claude.
| ~/.claude/CLAUDE.md | Global — applies to every project. Your identity, communication style, universal rules. |
| project/CLAUDE.md | Project-level — specific tech stack, team, project context. Inherits global. |
| project/src/CLAUDE.md | Subfolder-level — narrow overrides for specific areas. Inherits project + global. |
Each level inherits from the one above and can override. Like CSS specificity for AI context.
Skills Architecture
Skills are reusable, named workflows. Structure: SKILL.md (instructions) + any supporting files. Trigger by name or keywords.
Skills = on-demand activated context (loaded when triggered)
Skills can be composable — skill A can call skill B.
# Skill folder structure .claude/skills/ meeting-processor/ SKILL.md # instructions template.md # output template client-report/ SKILL.md report-template.md proposal/ SKILL.md pricing-model.json
Hooks as Context Injectors
Hooks do not just protect — they inject context. They run at specific points in the Claude Code lifecycle and can transform what Claude sees.
| PreToolUse | Fires BEFORE a tool runs. Add context: “this file is critical, be careful.” Block dangerous commands. Inject warnings. |
| PostToolUse | Fires AFTER a tool runs. Add context: “this ran, here is what to check next.” Log changes. Validate outputs. |
| UserPromptSubmit | Transforms the user's message BEFORE Claude sees it. Auto-append current year to searches. Expand shorthand. Inject memory context. |
# Example: auto-append year to web searches # ~/.claude/hooks/search-year.sh #!/bin/bash query="$1" year=$(date +%Y) # If query does not contain a year, append current year if ! echo "$query" | grep -qE '20[0-9]{2}'; then echo "${query} ${year}" else echo "$query" fi
Memory as Persistent Context
Auto-memory system: ~/.claude/projects/[project]/memory/ — every session adds to memory. Next session starts smarter.
Project memory — project-specific facts and state
Feedback memory — corrections and improvements
Reference memory — bookmarks and external resources
~/.claude/projects/[hash]/memory/MEMORY.mdOne file per project. Automatically loaded at session start. Claude writes to it when it learns something new about your project.
All 4 Weapons Working Together
This is what happens in every Claude Code session. Each weapon activates at the right moment.
Context Debt
What happens when you skip context engineering. The tax compounds daily.
Inconsistent behavior across sessions
No compound improvement
Skills forgotten, patterns lost
Every session starts from zero
Consistent, predictable behavior
Compound improvement over weeks
Skills and patterns persist
Every session starts smarter than the last
The Interview Pattern
Instead of manually writing context, let Claude interview you and generate it. Fastest way to bootstrap a new project.
Claude asks 10 targeted questions. You answer. Claude generates a complete CLAUDE.md from your answers.
This is the fastest way to bootstrap context for any new project — 5 minutes of answers produces a CLAUDE.md that would take an hour to write manually.
# Start the interview User: I have a new project. Interview me to build a CLAUDE.md for it. Claude: I will ask you 10 questions. Answer each one and I will generate a complete context file. 1. What is this project? 2. Who is the target user? 3. What is the tech stack? 4. What are the current priorities? 5. What tools/MCP servers are available? 6. What are the hard constraints? 7. Who else is on the team? 8. What should I never do? 9. What is your communication style? 10. What does success look like? User: [answers each question] Claude: [generates complete CLAUDE.md]
Retrieval Patterns That Compound
Once you have memory and skills, the next level is structured retrieval — making context findable and compounding.
# Structured memory file example # ~/.claude/projects/[hash]/memory/MEMORY.md ## #client AcmeCorp - Stack: Next.js 15 + Supabase - Contact: Sarah (CTO) — prefers async - Deadline: Q3 2026 ## #decision Architecture - Chose edge functions over serverless (latency) - Decision date: 2026-03-12 ## #constraint Never Do - No inline SQL — always use ORM - No direct prod DB writes without migration
Context Engineering Quiz
5 questions. How deep is your understanding?