← Home | Module 08 β€” Power User
0%
Module 08 Β· Final

Power User β€” Memory, Context & Expert Patterns

You've built the skills. Now optimize the system. This module covers how Claude's memory works across sessions, how to manage context like a pro, how to set up global custom instructions, and the expert patterns that separate fast Claude users from great ones.

⏱ ~40 min
πŸŽ“ Final module
⚑ Expert-level patterns

🧠 Understanding Claude's Memory System

Claude doesn't have persistent memory by default β€” each session starts fresh. But you have four layers to inject memory, each with different scope and persistence. Mastering these layers is what separates a power user from a casual one.

Global instructions
~/.claude/CLAUDE.md β€” applies to every session, every project
global
Project CLAUDE.md
./CLAUDE.md in your project root β€” loaded automatically each session
project
Session context
Files you @ mention, conversations in the current window
session
Inline instructions
What you tell Claude in the current message β€” overrides anything above
ephemeral

The priority order runs bottom-up: inline instructions override session context, which overrides project CLAUDE.md, which overrides global. Use each layer for what it's actually for:

  • Global CLAUDE.md: Your identity as an engineer. Stack preferences, languages you know, output format preferences, things Claude should never do.
  • Project CLAUDE.md: This project's architecture, stack, design decisions, file roles, known quirks. Updated as the project evolves.
  • Session context: Files relevant to today's task. Use @ mentions to pull in exactly what Claude needs, nothing more.
  • Inline: One-off overrides. "For this response only, reply in bullet points." or "Ignore the style guide just this once."
Power move: After every meaningful session, ask Claude: "Summarize what you learned about this project today and update CLAUDE.md." Over time your project CLAUDE.md becomes a complete mental model of your codebase β€” and every new session starts at full speed.

πŸ“Š Context Mastery β€” Work Within the Window

Every Claude session has a context window β€” a finite budget of tokens that covers everything: your instructions, the conversation history, and every file you reference. Hitting the limit degrades quality before it errors. Managing context is a skill.

What's consuming your context right now?

Typical mid-session breakdown ~60k tokens used
12%
35%
28%
25% free
System / CLAUDE.md (12%)
Conversation history (35%)
Referenced files (28%)
Remaining (25%)

The three context problems and how to fix them

Problem 1 β€” Context bloat from long conversation history
Fix: Use /compact. Claude summarizes the conversation so far into a compressed block β€” you keep the context of what happened without paying for every previous token. Do this whenever the session gets slow or verbose.
Problem 2 β€” Too many files referenced at once
Fix: Be selective with @ mentions. Only reference files directly relevant to the current task. If Claude needs to understand the whole project, CLAUDE.md should describe it β€” don't dump the whole codebase into context.
Problem 3 β€” CLAUDE.md growing too large
Fix: Keep CLAUDE.md under 2000 tokens. It loads every session β€” every token in there is always in use. Move deep architectural docs to a separate docs/ folder and @ mention them only when relevant.

Context hygiene rules

  • Start new sessions for new tasks. Don't drag unrelated context from a React debugging session into a Python scripting task.
  • /compact before long generation. If you're about to ask Claude to write a large file, compact first so the full context window is available for output.
  • Use /clear when pivoting completely. If you change direction mid-session, /clear wipes context and starts fresh β€” better than confusing Claude with contradictory history.
  • Reference only what Claude needs. Mentioning 10 files when only 2 are relevant wastes tokens and dilutes focus.
Power move: Open a second Claude window for large file reads. If you need Claude to read a massive file to answer a question, do it in a separate session so it doesn't pollute your main working context.

βš™οΈ Custom Instructions β€” Your Global CLAUDE.md

Global instructions live at ~/.claude/CLAUDE.md (on Mac/Linux) or %USERPROFILE%\.claude\CLAUDE.md (Windows). They load for every Claude session, regardless of which project you're in. Think of this as programming Claude's default behavior for you specifically.

What belongs in global instructions

  • Your tech identity: Languages you work in, frameworks you prefer, what you never want to use
  • Output format preferences: How verbose responses should be, whether to explain your reasoning, preferred code style
  • Hard limits: Things Claude should never do without asking β€” delete files, push to production, send messages
  • Your communication style: Terse and direct vs. explanatory, whether you want analogies, how much jargon is OK
~/.claude/CLAUDE.md β€” example global instructions
# Global Instructions β€” Rick

## Stack
Python 3.12+ (primary), TypeScript (secondary), vanilla HTML/CSS/JS for UIs.
Prefer: FastAPI, Pydantic, Anthropic SDK. Avoid: Django, jQuery, class components.

## Code style
- Concise over verbose. If it fits in 3 lines, don't write 10.
- Type hints always in Python.
- No docstrings unless the function is genuinely non-obvious.
- Functional patterns preferred over OOP for utilities.

## Response style
- Short answers by default. Expand only when I ask.
- No preamble ("Sure!", "Great question!") β€” start with the answer.
- When showing code, show only the changed part unless I ask for the full file.
- If something is ambiguous, ask one clarifying question before proceeding.

## Hard limits (always ask first)
- Never push to git remote without confirmation.
- Never send emails, Slack messages, or external API calls in production mode.
- Never delete files β€” move to .trash/ instead.

## Context
I'm a software developer who knows what I'm doing. Skip the basics.
Assume I understand trade-offs. Just give me the recommendation.
Global instructions are powerful β€” and fragile. If you add a "never write tests" rule globally, it applies to every project, including ones where tests matter. Be specific: "In utility scripts, skip tests unless asked. In API projects, always suggest a test."

Creating your global CLAUDE.md

terminal
# Create the .claude folder if it doesn't exist
mkdir -p ~/.claude

# Open in your editor
code ~/.claude/CLAUDE.md

# Or ask Claude to write it for you
claude "Write a global CLAUDE.md for me. Ask me 5 questions about my stack, style, and preferences first."

πŸ” Permission Tuning

Claude Code's permission system controls what Claude can do without asking. The defaults are cautious β€” Claude will ask before running shell commands, editing files outside your project, or installing packages. You can tune these per project in .claude/settings.json.

Permission levels

ModeWhat it meansWhen to use
default Ask before any shell command, file write outside project, or network call Unknown codebases, production systems, onboarding
--dangerously-skip-permissions No approval prompts β€” Claude acts immediately on everything Trusted local dev environments, CI pipelines, batch automation
allowedTools (per-tool) Pre-approve specific tools (Bash, Read, Write, etc.) without prompting Automated scripts where some tools are safe, others aren't

settings.json β€” per-project permission config

.claude/settings.json
{
  "permissions": {
    // Allow read without prompting β€” safe and fast
    "allow": [
      "Read",
      "Bash(git status)",
      "Bash(git diff*)",
      "Bash(npm run *)"
    ],
    // Always ask before these β€” high-risk actions
    "deny": [
      "Bash(rm *)",
      "Bash(git push*)",
      "Bash(curl *)"
    ]
  }
}
Glob patterns work in allow/deny. Bash(npm run *) allows any npm script. Bash(git *) allows all git commands. Be specific where risk is high, permissive where it's low. The goal is removing friction from safe operations β€” not bypassing security.

Hook-based permission patterns

Hooks (from Module 05) are the advanced permission layer. Instead of allow/deny, hooks let you intercept, log, approve, or block actions with custom logic.

~/.claude/settings.json β€” hook example
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{
        "type": "command",
        // Log every shell command Claude runs β€” audit trail
        "command": "echo \"[$(date)] $CLAUDE_TOOL_INPUT\" >> ~/.claude/audit.log"
      }]
    }]
  }
}

πŸ—‚ Multi-Project Setup

Once you're working on multiple projects β€” a SaaS product, a side project, client work β€” your Claude setup needs to scale with you. The key is a hierarchy where global instructions stay consistent and project-specific context stays isolated.

The expert file hierarchy

~/ (home directory)
.claude/
CLAUDE.md global β€” every session
settings.json  global permissions + hooks
audit.log     command history (optional)

Projects/
pulse-saas/
CLAUDE.md project β€” this repo only
.claude/settings.json  project-level permissions
brief.md  src/  docs/

client-alpha/
CLAUDE.md different stack, different rules
.claude/settings.json  stricter permissions for client work

scripts/
CLAUDE.md utility scripts context

Switching between projects

When you cd into a project and run claude, Claude automatically loads:

  1. Your global ~/.claude/CLAUDE.md first
  2. The project's ./CLAUDE.md second (overrides can be added here)
  3. Any .claude/settings.json in the project directory

This means walking into a new project is instant context β€” Claude knows the stack, the rules, and the history without you re-explaining anything.

Client work tip: For client projects, add a note in the project CLAUDE.md: "This is client work. Never commit credentials. Double-check all destructive operations. Prefer asking to assuming." This overrides your personal "move fast" global preferences when working on sensitive codebases.

⚑ Expert Patterns

These are the prompting and workflow patterns that experienced Claude Code users reach for automatically. Not clever tricks β€” durable techniques that appear across every project.

🎯

The Constraint Sandwich

Wrap your request between two constraint statements. First state what NOT to do, then the task, then re-state the key constraint at the end. Prevents drift on complex requests.

Don't touch the CSS.
Rewrite the nav JS to use event delegation.
CSS must remain unchanged.
πŸ”¬

Diagnose Before Fix

Ask Claude to explain the problem before suggesting a fix. You catch misunderstandings early and often discover the real issue is different from what you thought.

Before fixing this, explain in 2 sentences what you think the root cause is and why it fails only on mobile.
πŸ“‹

The Audit Prompt

Ask Claude to audit a file or codebase for a specific quality dimension before making changes. Gets problems surfaced all at once rather than discovering them one by one.

Audit @src/auth.js for: security issues, missing error handling, and any hard-coded values. List only β€” don't fix yet.
🧩

Decompose First

For large tasks, ask Claude to break the work into steps before doing any of it. Review the plan, reject wrong assumptions, then execute step by step.

Before writing any code, list the 5 steps needed to migrate the auth system from JWT to sessions. I'll approve each step.
πŸ”„

The Rubber Duck Review

After Claude writes something, ask it to critique its own work from a specific perspective. Gets a second pass without starting a new session.

Review what you just wrote from a security perspective. What's the weakest point and how would you fix it?
πŸ“

Example-Driven Generation

Show Claude one example of what you want, then ask it to generate more in the same pattern. Works for test data, copy variations, config files, anything repetitive.

This is one row of sample data: [example]. Generate 9 more in exactly this format, with realistic variation.
πŸ—ΊοΈ

Context Front-Loading

Put all relevant context at the start of a long prompt, not the end. Claude processes context before the instruction β€” front-loading improves comprehension and reduces hallucination.

Context: [file contents / situation / constraints]
Task: Given the above, [what you want].
🚦

The Confidence Check

Ask Claude to flag its uncertainty before committing. Surfaces hidden assumptions and prevents confident-sounding wrong answers from slipping through.

Before answering, rate your confidence 1–10 and tell me the one thing you're least sure about in this task.
Meta-pattern: The best Claude users treat it as a collaborator, not an autocomplete. Ask for opinions. Challenge outputs. Ask "what are you assuming here?" Disagreement produces better results than blind acceptance.
⚑ Live Sandbox β€” Expert Technique Practice interactive
Try the expert patterns in action
Claude Code Mastery β€” Power User sandbox
Practice expert patterns. Click a quick command or type your own.
 
expert $

🎯 Challenge

Cement the power user patterns with four targeted tasks β€” each one applies a different part of this module.

  • 1
    Build your global CLAUDE.md. Create ~/.claude/CLAUDE.md with at least four sections: stack preferences, code style rules, response style rules, and at least two hard limits. Ask Claude to help write it by answering 5 questions about yourself first.
  • 2
    Apply the Constraint Sandwich. Find any file in any project you've built during this course. Write a prompt to refactor one function using the constraint sandwich pattern β€” state what not to change, the task, and the constraint again at the end.
  • 3
    Use the Audit Prompt. Pick any file from your Module 06 SaaS dashboard project. Write an audit prompt targeting one quality dimension (accessibility, performance, or naming consistency). Review what Claude finds β€” then decide which issues to fix.
  • 4
    Configure project permissions. Create a .claude/settings.json in one of your projects. Allow at least 3 low-risk tools/commands without prompting. Deny at least 1 high-risk action. Test it by running claude and triggering each.

πŸ† Final Project β€” Your Personal Claude Setup

The capstone isn't a new build β€” it's optimizing your Claude environment end-to-end. You'll leave with a global CLAUDE.md, a global settings.json, and a CLAUDE.md template you can drop into any future project.

Step 1 β€” Write your global CLAUDE.md Create the file that defines how Claude works with you, forever.
Step 2 β€” Set up global permissions and hooks Create ~/.claude/settings.json with your personal permission rules and an audit log hook.
Step 3 β€” Create a project CLAUDE.md template Build a reusable template you'll drop into every new project.
Step 4 β€” Apply three expert patterns to an existing project Pick any project from this course and run the Audit, Decompose, and Constraint Sandwich patterns on it.
πŸŽ“
You've completed Claude Code Mastery.
Eight modules. Real projects. Expert-level patterns. You went from zero to power user β€” the hard way, which is the only way that sticks.
01 Β· Orientation 02 Β· Core Commands 03 Β· Skills 04 Β· Plugins 05 Β· Agents 06 Β· Build Real Things 07 Β· API & SDK 08 Β· Power User βœ“
← Back to Hub