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.
π§ 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.
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."
π 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?
The three context problems and how to fix them
/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.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,
/clearwipes 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.
βοΈ 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
# 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.
Creating your global CLAUDE.md
# 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
| Mode | What it means | When 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
{
"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 *)"
]
}
}
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.
{
"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
.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:
- Your global
~/.claude/CLAUDE.mdfirst - The project's
./CLAUDE.mdsecond (overrides can be added here) - Any
.claude/settings.jsonin 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.
β‘ 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.
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.
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.
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.
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.
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.
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.
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.
π― Challenge
Cement the power user patterns with four targeted tasks β each one applies a different part of this module.
-
1Build your global CLAUDE.md. Create
~/.claude/CLAUDE.mdwith 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. -
2Apply 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.
-
3Use 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.
-
4Configure project permissions. Create a
.claude/settings.jsonin one of your projects. Allow at least 3 low-risk tools/commands without prompting. Deny at least 1 high-risk action. Test it by runningclaudeand 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.