All Days
Day 38

Context Engineering Mastery

30-Day Claude Code Series / Day 38

Context Engineering: Mastery

CLAUDE.md hierarchy, retrieval patterns, memory tiers, and prompts that compound — the full system for sessions that get smarter every time.

4
Weapons
1
System
Sessions
0
Re-Explaining

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.

“Prompt engineering is dead. Context engineering is the skill.”

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.

06Your Messagejust the tip
05Memorypersistent knowledge
04Hooksautomatic injection + safety
03Skills.claude/skills/ structured tasks
02System ContextCLAUDE.md — your instructions
01Model Capabilitiesbase — you cannot change this
Weapon 1

CLAUDE.md Architecture

The most underused and most powerful weapon. Not just “be helpful” — a full operating system for your Claude.

CLAUDE.md is read at the start of every session. It defines who you are, how Claude should behave, what systems exist, what you are building, and how to handle edge cases. It is the difference between a blank-slate assistant and a deeply-informed collaborator.
Hierarchy: Global → Project → Subfolder
~/.claude/CLAUDE.mdGlobal — applies to every project. Your identity, communication style, universal rules.
project/CLAUDE.mdProject-level — specific tech stack, team, project context. Inherits global.
project/src/CLAUDE.mdSubfolder-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.

# Your Name — Context File

## Identity & Business
[who you are, what you are building]

## How to Work With Me
[communication preferences, debugging style]

## Current Projects
[active work, priorities]

## Tools & Stack
[MCP servers, CLI tools, APIs available]

## Team Context
[engineers, clients, stakeholders]

## Rules & Constraints
[what not to do, when to ask, when to act]
Weapon 2

Skills Architecture

Skills are reusable, named workflows. Structure: SKILL.md (instructions) + any supporting files. Trigger by name or keywords.

What Skills Are
Stored in .claude/skills/. Each skill is a folder with a SKILL.md that contains instructions for a specific task. Think of them as saved procedures Claude can execute on demand.
Skills vs CLAUDE.md
CLAUDE.md = always active context (loaded every session)

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
Weapon 3

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.

Three Hook Types That Matter
PreToolUseFires BEFORE a tool runs. Add context: “this file is critical, be careful.” Block dangerous commands. Inject warnings.
PostToolUseFires AFTER a tool runs. Add context: “this ran, here is what to check next.” Log changes. Validate outputs.
UserPromptSubmitTransforms 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
Weapon 4

Memory as Persistent Context

Auto-memory system: ~/.claude/projects/[project]/memory/ — every session adds to memory. Next session starts smarter.

The Compound Effect
Every session adds facts, preferences, patterns, and corrections to memory files. The next session reads all of them. Over weeks and months, Claude builds a deep understanding of your project, your style, your team, and your constraints — without you repeating yourself.
Memory Types
User memory — your preferences and identity
Project memory — project-specific facts and state
Feedback memory — corrections and improvements
Reference memory — bookmarks and external resources
Storage Location
~/.claude/projects/[hash]/memory/MEMORY.md

One 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.

Session Starts
CLAUDE.md loaded (always active context)
Memory Files Loaded
Project context, user preferences, feedback history
User Types Message
Your prompt — the actual request
UserPromptSubmit Hook Fires
Enriches the message — appends year, injects memory, expands shorthand
Claude Processes With Full Context
CLAUDE.md + memory + enriched prompt = deeply informed response
PreToolUse Hook Fires
If a tool is called — safety checks, context injection, warnings
Tool Executes
File read, bash command, web search, etc.
PostToolUse Hook Fires
Log changes, validate output, add follow-up context
Response Generated
Informed by every layer of context
Stop Hook Fires
Save new learnings to memory for next session

Context Debt

What happens when you skip context engineering. The tax compounds daily.

Without Context Engineering
20 min/day re-explaining who you are
Inconsistent behavior across sessions
No compound improvement
Skills forgotten, patterns lost
Every session starts from zero
With Context Engineering
0 min re-explaining
Consistent, predictable behavior
Compound improvement over weeks
Skills and patterns persist
Every session starts smarter than the last
2-4h
Setup Time
20-30m/day
Time Saved
Week 1
Break-Even

The Interview Pattern

Instead of manually writing context, let Claude interview you and generate it. Fastest way to bootstrap a new project.

Instead of dumping context manually, say: “I have a new project. Interview me.”

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.

Tagged Memory
Structure your memory files with tags so Claude can retrieve specific facts without reading everything. Use #client, #decision, #constraint headers to create scannable context layers.
Prompt Templates
Store reusable prompt templates in skills. Instead of crafting a perfect prompt each time, invoke the skill and let it inject the optimal framing automatically.
# 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?

01What is the difference between prompt engineering and context engineering?
02What is the CLAUDE.md hierarchy order?
03Which hook enriches user messages before Claude sees them?
04What is the Interview Pattern used for?
05What is Context Debt?

don't miss what's next.

Playbooks, templates, and tools that save you hours. Straight to your inbox. No spam. Unsubscribe anytime.

Part of the 30-Day Claude Code Series — AY Automate © 2026