ADVANCED GUIDE

Claude Code:
The Features You're Not Using

Most developers barely scratch the surface. This guide covers memory, context control, custom commands, and hooks — the tools that make Claude Code genuinely powerful.

8 min read
27 concepts
Claude Code Power User Series

🧠

Initialisation & Project Memory

Set up Claude to understand your codebase from day one

Start every project with /init

Running /init at the start of a new project lets Claude scan your entire codebase before you write a single prompt.

What /init does for you

CLAUDE.md — Your Project's Persistent Brain

Think of CLAUDE.md as a README written for Claude, not humans. It's included automatically in every request, meaning Claude always starts with full project context — no re-explaining needed.

Guides Claude on architecture, file structure & key commands
Stores Custom instructions and project-level preferences
Auto-loads Included in every conversation, zero manual effort
📁

CLAUDE.md

Project-level. Committed to your repo. Shared with the whole team.

🔒

CLAUDE.local.md

Personal preferences. Not committed. Not shared. Yours alone.

🌍

~/.claude/CLAUDE.md

Global rules. Applies to every project you open. Set once, always active.

Writing Custom Instructions with #

Prefix any message with # to enter memory mode. Claude writes it straight into CLAUDE.md.

# Enter memory mode
# Use comments sparingly.
# Only comment complex logic.

→ Claude auto-merges into CLAUDE.md

Referencing Files with @

Use @filename to pull a file into the conversation. Works inline in prompts or inside CLAUDE.md for persistent context.

# In a prompt
How does auth work? @auth.ts

# In CLAUDE.md (persistent)
@prisma/schema.prisma

🎮

Context Control

Stay focused. Stop runaway responses. Keep long sessions productive.

Esc — Interrupt & Redirect

Press Esc once to stop a response mid-stream. Redirect Claude immediately to where you actually want it to go. Prevents deep, off-track rabbit holes.

Esc Esc — Rewind the Conversation

Press Esc twice to strip away distracting history while keeping valuable context. Ideal when a conversation has gone sideways.

🗂 Context Management Quick Reference

Esc Interrupt the current response — redirect immediately
Esc Esc Rewind — remove distracting messages, keep useful context
/compact Summarise conversation — retains knowledge, reduces noise
/clear Full reset — removes all conversation history entirely

Best Use Cases for Context Controls


⚙️

Custom Commands

Turn your most-used prompts into reusable slash commands

Creating a Custom Command

  1. Create .claude/commands/ folder in your project
  2. Add a markdown file (e.g. audit.md)
  3. The filename becomes the command name (/audit)
  4. Restart Claude Code to activate

Commands with Arguments

Use $ARGUMENTS as a placeholder to accept dynamic input — file paths, text, flags. Makes commands reusable across any context.

# .claude/commands/review.md
Review the following file for
code quality issues:
$ARGUMENTS

# Usage:
/review src/auth.ts

🪝

Hooks

Automate actions before and after Claude does anything

What are Hooks?

Hooks let you intercept Claude's tool calls — automatically running your own commands before or after Claude acts. Format, test, validate, log, or block — all without lifting a finger.

🔀

PreToolUse vs PostToolUse

Hook When Can Block?
PreToolUse Before tool runs ✅ Yes
PostToolUse After tool runs ❌ No

Building a Hook — 4 Steps

  1. Choose Pre or Post hook timing
  2. Select which tool types to monitor
  3. Write the command to process the call
  4. Return feedback or block the operation

All Available Hook Types

PreToolUse Before tool execution — can block
PostToolUse After tool execution — cannot block
Notification When Claude sends a notification
Stop When Claude finishes responding
SubagentStop When a subagent task finishes
PreCompact Before /compact runs
UserPromptSubmit Before Claude processes your prompt
SessionStart / SessionEnd Session lifecycle events

Practical Hook Applications

Hook Configuration

Hooks are defined in .claude/settings.json. You can scope them globally, per-project, or locally.

// .claude/settings.json
{
  "PreToolUse": [...],
  "PostToolUse": [...]
}

Understanding Hook Payload

Hooks receive JSON via stdin. Structure varies by type — use a logging helper to inspect the real payload.

{
  "session_id": "...",
  "hook_event_name": "...",
  "tool_name": "...",
  "tool_input": {...},
  "tool_response": {...}
}

🔐 Security Best Practices

🐛 Debugging Hooks

Hook input structure can be unpredictable. Log the raw stdin payload first — it saves hours of guesswork.

# Helper hook to log payload
cat - | jq . > post-log.json

# Then inspect:
cat post-log.json