Mastering Claude Code: Skills, Memory, Tokens & Power-User Secrets

Go beyond basics. Master CLAUDE.md context, auto memory, custom skills, hooks, subagents, token optimization, and the workflows that 10x your productivity with Claude Code.

22 min read
0 views
By Siraj AL Zahran
Claude CodeAICLIToken OptimizationProductivityDeveloper ToolsAdvanced
Mastering Claude Code: Skills, Memory, Tokens & Power-User Secrets

Why Most Developers Waste 80% of Their Claude Code Tokens

You installed Claude Code. You typed claude in your terminal. You asked it to build features and it delivered. But every session, it re-reads the same files. It forgets your conventions. Your context window fills up halfway through a complex task. You're burning tokens on work Claude already did five minutes ago.

Sound familiar?

This guide is not an introduction to Claude Code — if you need that, check out my intro deep dive. This is the advanced playbook. The techniques, configurations, and workflows that separate someone who uses Claude Code from someone who masters it.

We'll cover the full ecosystem: persistent context with CLAUDE.md, auto memory that learns across sessions, custom skills that extend Claude's capabilities, hooks that automate quality gates, subagents that parallelize work, and — most importantly — how to manage your context window so Claude stays sharp from the first prompt to the last.


The Context Window: Your Most Precious Resource

Everything in Claude Code revolves around one constraint: the context window. It's the amount of information Claude can "see" at any point in a conversation. Every file it reads, every command output, every message you send — it all takes space.

When the context fills up, bad things happen:

  • Claude "forgets" decisions made earlier in the conversation
  • Responses get slower and less accurate
  • Auto-compaction kicks in and might drop important details
  • You end up repeating yourself

The entire rest of this guide is about one thing: keeping your context window clean, focused, and efficient.

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Visualize how context fills up in a typical session
const contextBudget = 200000; // ~200K tokens
 
const typicalSession = [
{ action: "System prompt + CLAUDE.md", tokens: 8000 },
{ action: "Memory files loaded", tokens: 3000 },
{ action: "MCP tool definitions (5 servers)", tokens: 15000 },
{ action: "Read 3 source files", tokens: 12000 },
{ action: "Your prompt", tokens: 500 },
{ action: "Claude's response + thinking", tokens: 8000 },
{ action: "Read 5 more files", tokens: 20000 },
{ action: "Edit 3 files + verify", tokens: 15000 },
{ action: "Run tests (output)", tokens: 10000 },
{ action: "Fix errors + re-test", tokens: 18000 },
{ action: "More edits and reads", tokens: 25000 },
];
 
let running = 0;
console.log("Context Window Usage Throughout a Session:");
console.log("=".repeat(55));
typicalSession.forEach(({ action, tokens }) => {
running += tokens;
const pct = ((running / contextBudget) * 100).toFixed(1);
const bar = "█".repeat(Math.round(running / contextBudget * 30));
console.log(`${bar} ${pct}%`);
console.log(` +${tokens.toLocaleString()} tokens → ${action}`);
});
console.log("");
console.log(`Total: ${running.toLocaleString()} / ${contextBudget.toLocaleString()} tokens`);
console.log("That's " + ((running / contextBudget) * 100).toFixed(0) + "% used — and you're not even done yet.");
Terminal
Terminal Output
Click the Run button to execute the code...

The key insight: most of that usage is preventable. Let's fix it.


CLAUDE.md — The Foundation of Everything

You probably have a CLAUDE.md. But is it actually good? Most developers either leave it empty or stuff it with everything they can think of. Both approaches waste context.

Where CLAUDE.md Files Live

Claude uses a hierarchical discovery system. It doesn't just read one file — it reads several, depending on where you are:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const claudeMdHierarchy = [
{
path: "~/.claude/CLAUDE.md",
scope: "Global (all projects)",
loaded: "Always",
tip: "Your personal preferences — editor style, commit conventions"
},
{
path: "./CLAUDE.md",
scope: "Project root",
loaded: "Always",
tip: "Shared team context — commit to git"
},
{
path: "./.claude/CLAUDE.md",
scope: "Project (alternative)",
loaded: "Always",
tip: "Same as above, just tucked away"
},
{
path: "./CLAUDE.local.md",
scope: "Personal project overrides",
loaded: "Always",
tip: "Your machine-specific settings — auto-gitignored"
},
{
path: "./src/api/CLAUDE.md",
scope: "Subdirectory",
loaded: "On-demand",
tip: "Loaded when Claude reads files in that directory"
},
];
 
console.log("CLAUDE.md Discovery Hierarchy:");
console.log("=".repeat(55));
claudeMdHierarchy.forEach((entry, i) => {
console.log(`\n${i + 1}. ${entry.path}`);
console.log(` Scope: ${entry.scope}`);
console.log(` Loaded: ${entry.loaded}`);
console.log(` Tip: ${entry.tip}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

What Makes a Great CLAUDE.md

The goal is simple: prevent Claude from making mistakes that waste your time and tokens. Every line should earn its place.

markdown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Project: My Portfolio
 
Next.js 16 with App Router, TypeScript strict mode, Tailwind CSS v4.
 
# Commands
 
- Dev: `npm run dev`
- Build: `npm run build`
- Test: `npm test -- --watch`
- Lint: `npx eslint . --fix`
 
# Code Style
 
- ALWAYS use TypeScript — never plain JS
- 2-space indentation, no semicolons
- Use `clsx` for conditional classNames
- Server components by default, "use client" only when needed
- Import aliases: `@/` maps to project root
 
# Architecture
 
- `app/` — pages and layouts (App Router)
- `app/components/` — shared components
- `lib/` — utilities, configs, API clients
- `hooks/` — custom React hooks
 
# Conventions
 
- Commit messages: imperative mood ("Add feature" not "Added feature")
- Never push to main directly
- Always run build before committing

What NOT to Put in CLAUDE.md

This is just as important:

  • ✘ Standard language conventions Claude already knows
  • ✘ Entire API documentation (link to it instead)
  • ✘ File-by-file descriptions of your codebase
  • ✘ Anything that changes weekly
  • ✘ Long tutorials or explanations

Rule of thumb: If Claude would figure it out by reading your code anyway, don't put it in CLAUDE.md. Save those tokens for things it can't infer — your team's quirks, your preferred patterns, your non-obvious commands.

The Import System

For larger projects, CLAUDE.md supports imports:

markdown
1
2
3
4
5
# CLAUDE.md
 
@.claude/conventions.md
@.claude/api-guide.md
@.claude/testing-rules.md

This keeps your root file clean while still providing deep context when needed. Each imported file loads into the system prompt alongside the main CLAUDE.md.


Auto Memory — Claude That Learns Across Sessions

This is the feature most people don't know exists. Auto memory lets Claude write notes to itself that persist across conversations.

How It Works

Every project gets a memory directory at ~/.claude/projects/<project>/memory/. Inside, Claude maintains:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const memoryStructure = {
"MEMORY.md": {
description: "Main index file — first 200 lines loaded every session",
maxLines: 200,
autoLoaded: true,
},
"debugging.md": {
description: "Solutions to tricky problems encountered",
autoLoaded: false,
},
"patterns.md": {
description: "Code patterns and conventions discovered",
autoLoaded: false,
},
"api-notes.md": {
description: "API design decisions and quirks",
autoLoaded: false,
},
};
 
console.log("Auto Memory File Structure:");
console.log("=".repeat(50));
Object.entries(memoryStructure).forEach(([file, info]) => {
console.log(`\n📄 ${file}`);
console.log(` ${info.description}`);
console.log(` Auto-loaded: ${info.autoLoaded ? "✔ Yes (every session)" : "✘ No (on-demand)"}`);
if (info.maxLines) console.log(` Limit: First ${info.maxLines} lines`);
});
console.log("\n💡 Only MEMORY.md loads automatically.");
console.log(" Topic files are read when Claude needs them.");
Terminal
Terminal Output
Click the Run button to execute the code...

The Key Distinction

CLAUDE.mdAuto Memory
Who writes itYouClaude
What it containsInstructions and rulesLearned patterns and notes
When it loadsEvery sessionMEMORY.md every session, topic files on-demand
Committed to gitYes (shared with team)No (personal to your machine)
Best forProject conventionsDebugging insights, your preferences

Teaching Claude to Remember

You can explicitly ask Claude to remember things:

text
1
2
3
"Remember that we always use pnpm, never npm"
"Remember that the auth module uses JWT with RS256"
"Don't forget: the staging API is at api.staging.example.com"

Claude writes these to its memory files and loads them next session. This is incredibly powerful for things like:

  • Your preferred testing framework
  • Recurring debugging patterns
  • API endpoints and credentials locations
  • Your communication style preferences

Managing Memory

bash
1
/memory # Open the memory file selector

You can also edit memory files directly — they're just markdown files on disk. Delete outdated notes, reorganize topics, keep it lean.

Pro tip: Keep MEMORY.md under 200 lines. Move detailed notes to topic files like debugging.md or architecture.md. Only MEMORY.md auto-loads — everything else is read on-demand, saving you tokens.


Custom Skills — Extending Claude's Abilities

Skills are reusable instruction sets that Claude loads on-demand. Think of them as specialized modes you can activate.

Creating a Skill

Every skill lives in a directory with a SKILL.md file:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const skillStructure = {
location: ".claude/skills/my-skill/",
files: {
"SKILL.md": "Main instructions (required) — with frontmatter config",
"template.md": "Templates Claude fills in (optional)",
"examples/": "Example outputs for reference (optional)",
"scripts/": "Shell scripts Claude can execute (optional)",
},
scopes: {
"~/.claude/skills/": "Personal — available in all projects",
".claude/skills/": "Project — shared via git with team",
}
};
 
console.log("Skill Directory Structure:");
console.log("=".repeat(45));
console.log(`📁 ${skillStructure.location}`);
Object.entries(skillStructure.files).forEach(([file, desc]) => {
const icon = file.endsWith("/") ? "📁" : "📄";
console.log(` ${icon} ${file.padEnd(18)} ${desc}`);
});
console.log("\nSkill Scopes:");
Object.entries(skillStructure.scopes).forEach(([path, desc]) => {
console.log(` ${path}`);
console.log(` → ${desc}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Anatomy of a SKILL.md

markdown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
name: code-review
description: Reviews code for quality, security, and performance issues
user-invocable: true
allowed-tools: Read, Grep, Glob
argument-hint: "[file or directory]"
---
 
You are a senior code reviewer. When invoked:
 
1. Read the specified file(s)
2. Check for:
- Security vulnerabilities (injection, XSS, auth issues)
- Performance problems (N+1 queries, unnecessary re-renders)
- Code style violations
- Missing error handling
- Test coverage gaps
3. Output a structured review with severity levels
 
Use $ARGUMENTS to get the file path provided by the user.

Invoke it with /code-review src/api/auth.ts — Claude loads the skill instructions, follows them precisely, and only uses the tools you've allowed.

Why Skills Beat Stuffing Everything in CLAUDE.md

This is the critical insight for token optimization:

  • CLAUDE.md loads every single session, even when irrelevant
  • Skills load only when invoked or when Claude decides they're relevant

If you have 500 lines of coding conventions in CLAUDE.md, that's ~2,000 tokens consumed in every conversation. Move specialized workflows to skills, and they only cost tokens when actually needed.

Practical Skill Ideas

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const practicalSkills = [
{
name: "create-component",
trigger: "/create-component Button",
does: "Scaffolds a new React component with types, tests, and stories following your project patterns"
},
{
name: "db-migrate",
trigger: "/db-migrate add-user-preferences",
does: "Creates a new database migration with your ORM's conventions, adds types, updates schema"
},
{
name: "deploy-check",
trigger: "/deploy-check",
does: "Runs build, tests, lint, type-check, and reports any blocking issues before deployment"
},
{
name: "api-endpoint",
trigger: "/api-endpoint POST /users",
does: "Creates route handler, validation schema, types, and tests for a new API endpoint"
},
{
name: "perf-audit",
trigger: "/perf-audit",
does: "Analyzes bundle size, checks for unnecessary dependencies, finds performance bottlenecks"
}
];
 
console.log("Practical Skills You Should Create:");
console.log("=".repeat(50));
practicalSkills.forEach(skill => {
console.log(`\n⚡ ${skill.name}`);
console.log(` Invoke: ${skill.trigger}`);
console.log(` Does: ${skill.does}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Hooks — Deterministic Automation

Hooks are shell commands that fire at specific points in Claude Code's lifecycle. Unlike skills (which are instructions), hooks are guaranteed actions — they always run, no matter what.

Hook Events

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const hookEvents = [
{ event: "PreToolUse", when: "Before Claude executes any tool", power: "Block dangerous actions" },
{ event: "PostToolUse", when: "After a tool succeeds", power: "Auto-format, auto-lint" },
{ event: "UserPromptSubmit", when: "Before Claude processes your prompt", power: "Inject context, validate input" },
{ event: "PreCompact", when: "Before context compaction", power: "Re-inject critical context" },
{ event: "Notification", when: "Claude needs your attention", power: "Desktop alerts, sounds" },
{ event: "SessionStart", when: "When a session begins", power: "Setup, environment checks" },
];
 
console.log("Hook Events & Their Powers:");
console.log("=".repeat(55));
hookEvents.forEach(({ event, when, power }) => {
console.log(`\n🔗 ${event}`);
console.log(` Fires: ${when}`);
console.log(` Power: ${power}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Real-World Hook Examples

Auto-format after every edit:

json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$CLAUDE_FILE_PATH\""
}
]
}
]
}
}

Block edits to protected files:

bash
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
# .claude/hooks/protect-env.sh
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path')
 
if [[ "$FILE_PATH" == *".env"* ]] || [[ "$FILE_PATH" == *"credentials"* ]]; then
echo "BLOCKED: Cannot edit sensitive files" >&2
exit 2 # Exit code 2 = block the action
fi
exit 0 # Exit code 0 = allow

Re-inject context after compaction:

json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"hooks": {
"PreCompact": [
{
"hooks": [
{
"type": "command",
"command": "echo 'IMPORTANT: We use pnpm, not npm. Always use TypeScript strict mode.'"
}
]
}
]
}
}

This last one is a game-changer. When Claude compacts your conversation, it might forget important context. A PreCompact hook lets you re-inject the essentials every time.


Subagents — Parallel AI Workers

Subagents are specialized Claude instances that run in isolated context windows. This is the most powerful token optimization technique because subagent work doesn't pollute your main conversation.

Built-in Agent Types

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const agentTypes = [
{
name: "Explore",
model: "Fast (Haiku-class)",
tools: "Read-only (Glob, Grep, Read)",
bestFor: "Codebase research, finding files, understanding architecture",
tokenImpact: "Only the SUMMARY returns to your context"
},
{
name: "Plan",
model: "Full (Sonnet/Opus)",
tools: "Read-only + analysis",
bestFor: "Designing implementation strategies before coding",
tokenImpact: "Returns a structured plan, not raw file contents"
},
{
name: "Bash",
model: "Fast",
tools: "Command execution",
bestFor: "Running builds, tests, git operations",
tokenImpact: "Returns command output summary only"
},
{
name: "General-purpose",
model: "Full",
tools: "All tools",
bestFor: "Complex multi-step tasks, research",
tokenImpact: "Full agent with isolated context"
}
];
 
console.log("Subagent Types & When to Use Them:");
console.log("=".repeat(55));
agentTypes.forEach(agent => {
console.log(`\n🤖 ${agent.name}`);
console.log(` Model: ${agent.model}`);
console.log(` Tools: ${agent.tools}`);
console.log(` Best for: ${agent.bestFor}`);
console.log(` Context: ${agent.tokenImpact}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Why Subagents Save Tokens

Here's the mental model. Without subagents:

You: "Find all API endpoints and their auth requirements"
Claude: *reads 15 files, each adding to YOUR context window*
        *your context grows by ~30,000 tokens*

With subagents:

You: "Find all API endpoints and their auth requirements"
Claude: *spawns Explore subagent*
Subagent: *reads 15 files in ITS OWN context*
          *returns a 500-token summary to YOUR context*

That's a 60x reduction in context usage for the same result.

Creating Custom Subagents

You can define project-specific agents in .claude/agents/:

markdown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---
name: test-runner
description: Runs tests and reports failures only
tools: Bash, Read
model: haiku
maxTurns: 5
---
 
Run the test suite with `npm test`.
Only report failures — ignore passing tests.
Format output as:
 
- File: [path]
- Test: [name]
- Error: [message]

Parallel Execution

The real power comes from running multiple subagents simultaneously:

text
1
2
3
"Use subagents to investigate the auth module, the payment module,
and the notification module in parallel. Report back what each one
does and how they're connected."

Claude spawns three Explore agents that work simultaneously, each in its own context. Your main context only receives three summaries instead of 30+ file reads.


Token Optimization — The Complete Playbook

Now let's bring everything together into a systematic approach for minimizing token waste.

Strategy 1: Clear Between Tasks

bash
1
2
/clear # Nuclear option — fresh context
/compact # Soft option — compress and keep going

Rule: If your next task is unrelated to what you just did, use /clear. If it's a continuation, use /compact.

Name sessions before clearing so you can resume them:

bash
1
2
3
4
/rename auth-feature
/clear
# ... do other work ...
/resume # Pick up where you left off

Strategy 2: Custom Compact Instructions

Default /compact tries to preserve everything. That's wasteful. Tell it what matters:

text
1
/compact Keep only: 1) files I edited 2) current task requirements 3) errors not yet fixed

You can even set default compaction instructions in your CLAUDE.md:

markdown
1
2
3
4
5
6
7
8
# Compact Instructions
 
When compacting, prioritize:
 
- Current task requirements and acceptance criteria
- File paths and changes made
- Unresolved errors or test failures
Drop: exploration results, file contents already edited, resolved discussions

Strategy 3: Reduce MCP Tool Overhead

Each MCP server adds tool definitions to your context. Five servers with 10 tools each = ~15,000 tokens consumed before you even type a prompt.

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const mcpOptimization = {
problem: "5 MCP servers × ~3,000 tokens each = 15,000 tokens overhead",
solutions: [
{
technique: "Disable unused servers",
how: "Use /mcp to toggle servers off when not needed",
savings: "~3,000 tokens per disabled server"
},
{
technique: "Enable Tool Search",
how: "Set ENABLE_TOOL_SEARCH=auto:5",
savings: "85-95% reduction — tools load on-demand"
},
{
technique: "Prefer CLI tools",
how: "Use 'gh' instead of GitHub MCP, 'aws' instead of AWS MCP",
savings: "Eliminates tool definition overhead entirely"
},
{
technique: "Consolidate servers",
how: "Use one general server instead of many specialized ones",
savings: "Fewer tool definitions = less overhead"
}
]
};
 
console.log(`Problem: ${mcpOptimization.problem}`);
console.log("\nSolutions:");
console.log("=".repeat(50));
mcpOptimization.solutions.forEach((sol, i) => {
console.log(`\n${i + 1}. ${sol.technique}`);
console.log(` How: ${sol.how}`);
console.log(` Savings: ${sol.savings}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Strategy 4: Preprocess with Hooks

Don't let Claude read a 10,000-line test output. Filter it first:

json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo \"$CLAUDE_TOOL_OUTPUT\" | grep -A 3 'FAIL\\|ERROR' | head -100"
}
]
}
]
}
}

Strategy 5: Write Specific Prompts

The broader your prompt, the more Claude needs to explore:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const promptComparison = [
{
type: "✘ Broad (expensive)",
prompt: "Improve the codebase",
cost: "Claude reads everything, explores everywhere",
tokens: "~50,000+ tokens of exploration"
},
{
type: "✔ Specific (efficient)",
prompt: "Add input validation to the login form in app/auth/login.tsx using Zod",
cost: "Claude reads 2-3 targeted files",
tokens: "~5,000 tokens of focused work"
},
{
type: "✔ File-referenced (best)",
prompt: "Add rate limiting to @app/api/auth/route.ts — max 5 attempts per minute per IP",
cost: "Claude jumps straight to the file",
tokens: "~3,000 tokens — minimal exploration"
}
];
 
console.log("Prompt Specificity vs Token Cost:");
console.log("=".repeat(50));
promptComparison.forEach(p => {
console.log(`\n${p.type}`);
console.log(` Prompt: "${p.prompt}"`);
console.log(` Cost: ${p.cost}`);
console.log(` Impact: ${p.tokens}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Strategy 6: Monitor Your Usage

bash
1
2
/cost # See cumulative token usage and cost
/context # See what's consuming your context window

Check /cost periodically. If you're burning through tokens faster than expected, it's time to /compact or /clear.


Slash Commands — The Complete Reference

Beyond the basics, here are the commands that power users rely on:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const commands = {
"Context Management": {
"/compact [instructions]": "Compress context — add instructions to control what's kept",
"/clear": "Wipe conversation for a fresh start",
"/context": "See what's consuming your context window",
"/cost": "Display token usage and estimated cost",
},
"Session Management": {
"/rename [name]": "Name current session for later resumption",
"/resume": "Browse and resume a previous session",
"/rewind": "Undo recent changes and restore previous state",
},
"Configuration": {
"/init": "Generate a starter CLAUDE.md for your project",
"/memory": "Open and edit auto memory files",
"/mcp": "View and manage MCP server connections",
"/hooks": "Configure automation hooks",
"/permissions": "Manage tool access and security",
"/model": "Switch between Claude models mid-session",
},
"Workflow": {
"/doctor": "Diagnose Claude Code setup issues",
"/vim": "Toggle vim keybindings",
"/fast": "Toggle fast output mode (same model, faster)",
"/statusline": "Configure persistent status display",
}
};
 
Object.entries(commands).forEach(([category, cmds]) => {
console.log(`\n${category}:`);
console.log("─".repeat(50));
Object.entries(cmds).forEach(([cmd, desc]) => {
console.log(` ${cmd.padEnd(28)} ${desc}`);
});
});
Terminal
Terminal Output
Click the Run button to execute the code...

Keyboard Shortcuts That Save Minutes Per Hour

Once you've internalized these, you'll never touch the mouse:

ShortcutActionWhen to Use
EscapeStop Claude mid-actionWrong direction — stop early, redirect
Escape × 2Open rewind menuUndo changes Claude just made
Shift+EnterMulti-line inputWrite complex, structured prompts
Ctrl+CInterrupt current operationCancel a long-running command
Ctrl+RSearch command historyFind a prompt you used before
Shift+TabCycle permission modesSwitch between plan/default/accept modes

In VS Code

ShortcutAction
Cmd+Esc / Ctrl+EscToggle focus between editor and Claude
Alt+KInsert @-mention reference
Cmd+N / Ctrl+NNew conversation
Alt+V (Windows)Paste image/screenshot

The Power-User Workflow

Here's how everything fits together in a real workflow:

Phase 1: Setup (Once Per Project)

bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 1. Initialize CLAUDE.md
/init
 
# 2. Edit it with YOUR conventions (keep under 150 lines)
 
# 3. Create skills for repeated workflows
mkdir -p .claude/skills/create-component
# Write SKILL.md with your component scaffolding rules
 
# 4. Configure hooks for auto-formatting
# Add to .claude/settings.json
 
# 5. Set up MCP servers you actually need
claude mcp add github --transport http https://api.githubcopilot.com/mcp/

Phase 2: Daily Development

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const dailyWorkflow = [
{
step: "Start session",
action: "claude",
tip: "CLAUDE.md + MEMORY.md load automatically — Claude already knows your project"
},
{
step: "Complex task",
action: "Describe task specifically, reference files with @",
tip: "Use Plan mode first: 'Plan how to implement user preferences'"
},
{
step: "Research phase",
action: "Let Claude use subagents to explore",
tip: "Exploration happens in subagent context, not yours"
},
{
step: "Implementation",
action: "Switch to normal mode, follow the plan",
tip: "Provide verification: 'run tests after each change'"
},
{
step: "Mid-session cleanup",
action: "/compact Keep current task and test results only",
tip: "Frees 50-70% of context for more work"
},
{
step: "Task switch",
action: "/rename feature-auth && /clear",
tip: "Clean context for unrelated work — resume later with /resume"
},
{
step: "End of day",
action: "Ask Claude to update memory with today's learnings",
tip: "'Remember that the payment API requires idempotency keys'"
}
];
 
console.log("The Power-User Daily Workflow:");
console.log("=".repeat(50));
dailyWorkflow.forEach((item, i) => {
console.log(`\n${i + 1}. ${item.step}`);
console.log(` Action: ${item.action}`);
console.log(` 💡 ${item.tip}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Phase 3: Verification (Always)

The highest-leverage habit: always give Claude a way to verify its own work.

  • ✔ "Run the tests after implementing"
  • ✔ "Build the project and fix any TypeScript errors"
  • ✔ Paste a screenshot: "Make it look like this"
  • ✔ "The endpoint should return { status: 200, data: [...] }"

Without verification targets, Claude guesses whether it's done. With them, it knows.


Settings & Permissions — Lock It Down

Permission Rules

Control exactly what Claude can and cannot do:

json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"permissions": {
"allow": [
"Bash(npm run build *)",
"Bash(npm test *)",
"Bash(npx prettier *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git add *)",
"Bash(git commit *)"
],
"deny": [
"Bash(rm -rf *)",
"Bash(git push --force *)",
"Bash(npm publish *)",
"Read(.env)",
"Read(**/credentials*)"
]
}
}

Permission Modes

Switch modes depending on what you're doing:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const permissionModes = [
{
mode: "plan",
desc: "Read-only — Claude can explore but not modify anything",
useFor: "Research, architecture review, understanding codebases"
},
{
mode: "default",
desc: "Ask permission for each action",
useFor: "Normal development — review each change"
},
{
mode: "acceptEdits",
desc: "Auto-accept file edits, ask for commands",
useFor: "Trusted implementation where you've reviewed the plan"
},
{
mode: "bypassPermissions",
desc: "Auto-accept everything",
useFor: "CI/CD pipelines, automated workflows only"
}
];
 
console.log("Permission Modes:");
console.log("=".repeat(50));
permissionModes.forEach(({ mode, desc, useFor }) => {
console.log(`\n📋 ${mode}`);
console.log(` ${desc}`);
console.log(` Use for: ${useFor}`);
});
console.log("\nSwitch with: Shift+Tab or --permission-mode flag");
Terminal
Terminal Output
Click the Run button to execute the code...

Environment Variables for Power Users

bash
1
2
3
4
5
6
7
8
9
10
11
# Limit thinking tokens (saves output token cost)
MAX_THINKING_TOKENS=8000
 
# Auto-compact earlier (default triggers at ~95%)
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=80
 
# Enable tool search for MCP-heavy setups
ENABLE_TOOL_SEARCH=auto:5
 
# Disable auto memory if you manage it manually
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1

Common Anti-Patterns (And What to Do Instead)

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const antiPatterns = [
{
bad: "Kitchen-sink sessions — one conversation for 10 unrelated tasks",
fix: "Use /clear between unrelated tasks. Name sessions with /rename.",
impact: "Prevents context pollution, keeps Claude focused"
},
{
bad: "Correcting Claude 5 times in a row",
fix: "After 2 corrections, rewrite your prompt from scratch or /rewind",
impact: "Each correction adds confusion to context, making things worse"
},
{
bad: "Massive CLAUDE.md with 500+ lines of everything",
fix: "Keep CLAUDE.md under 150 lines. Move workflows to skills.",
impact: "Saves ~2,000+ tokens per session, loads skills on-demand"
},
{
bad: "Never using /compact until auto-compact kicks in",
fix: "Run /compact proactively with custom instructions",
impact: "YOU control what's preserved vs. auto-compact guessing"
},
{
bad: "Having 8 MCP servers always loaded",
fix: "Disable unused servers, enable TOOL_SEARCH, prefer CLI alternatives",
impact: "Saves 15,000-30,000 tokens of tool definitions"
},
{
bad: "Letting Claude explore your whole codebase for simple tasks",
fix: "Reference specific files: 'Edit @src/auth/login.tsx to add...'",
impact: "Eliminates exploration cost entirely"
}
];
 
console.log("Anti-Patterns vs. Best Practices:");
console.log("=".repeat(55));
antiPatterns.forEach((item, i) => {
console.log(`\n${i + 1}. ✘ ${item.bad}`);
console.log(` ✔ ${item.fix}`);
console.log(` 📊 ${item.impact}`);
});
Terminal
Terminal Output
Click the Run button to execute the code...

Conclusion

Mastering Claude Code isn't about knowing every feature — it's about managing context intentionally. Every token you save is a token available for actual work. Every piece of context you preload is a mistake Claude won't make.

The stack that makes you unstoppable:

  1. CLAUDE.md — lean, focused project context that prevents mistakes
  2. Auto Memory — Claude learns your patterns and preferences over time
  3. Skills — on-demand capabilities that don't waste baseline tokens
  4. Hooks — deterministic automation for formatting, linting, and safety
  5. Subagents — parallel workers that keep your context clean
  6. /compact + /clear — aggressive context hygiene between tasks
  7. Specific prompts — reference files, provide verification targets, be precise

The developers who get the most out of Claude Code aren't the ones who type the most prompts. They're the ones who set up their environment so Claude already knows what to do before they ask.

Pro Tip: Spend 30 minutes setting up your CLAUDE.md, creating 2-3 skills for your most common workflows, and configuring a PostToolUse hook for auto-formatting. That 30-minute investment will save you hours every week and cut your token usage in half.

Happy coding!

More Deep Dives

Claude Code: Agent Teams, MCP Servers & CI/CD Pipelines
20 min read

Claude Code: Agent Teams, MCP Servers & CI/CD Pipelines

Go multi-agent with Claude Code. Master agent teams, build custom MCP integrations, automate with GitHub Actions, and create CI/CD pipelines that code for you.

Claude CodeMCP+5
Feb 25, 2026
Read
Claude Code Remote Control: Continue Terminal Sessions From Your Phone
10 min read

Claude Code Remote Control: Continue Terminal Sessions From Your Phone

Learn how Remote Control lets you continue Claude Code sessions from your phone, tablet, or any browser — while everything runs locally on your machine.

Claude CodeRemote Control+5
Feb 25, 2026
Read
Code to Canvas: Turning Production Code into Editable Figma Designs
16 min read

Code to Canvas: Turning Production Code into Editable Figma Designs

Learn how Claude Code + Figma's MCP server turns your running UI into editable Figma layers — and back. The complete bidirectional design-code workflow.

FigmaClaude Code+5
Feb 25, 2026
Read
Claude Code: The Agentic Coding Tool That Lives in Your Terminal
14 min read

Claude Code: The Agentic Coding Tool That Lives in Your Terminal

Master Claude Code — Anthropic's AI coding agent. Learn setup, agentic workflows, MCP servers, hooks, CLAUDE.md, and how it compares to Cursor and Copilot.

Claude CodeAI+5
Feb 23, 2026
Read
JSX & Components — ReactJS Series Part 2
12 min read

JSX & Components — ReactJS Series Part 2

Learn how JSX works under the hood, how to create and nest React components, and the rules that make JSX different from HTML.

ReactJavaScript+4
Feb 21, 2026
Read
What is React? — ReactJS Series Part 1
10 min read

What is React? — ReactJS Series Part 1

A beginner-friendly introduction to React. Learn what React is, why it exists, how it differs from vanilla JavaScript, and build your first component.

ReactJavaScript+3
Feb 21, 2026
Read
View All Dives

Explore more content