$ man how-to/claude-code-power-features
CLI Toolsintermediate
Claude Code Power Features
Memory, hooks, custom skills, cost tracking, and worktrees
Beyond the Quickstart
The Claude Code quickstart gets you installed and running. This guide covers the features that make it stick. Memory that remembers what you taught it last Tuesday. Hooks that run shell commands when Claude touches specific tools. Custom slash commands that execute your workflows with a single keystroke. Cost tracking so you know where your tokens go. And worktrees for running parallel sessions without file conflicts. These are the features I use daily. Most of them I discovered by accident, weeks after I started using Claude Code. You should not have to wait weeks.
PATTERN
Memory: Your Agent Remembers
Claude Code has a persistent memory system. It writes notes to a directory at ~/.claude/projects//memory/ and reads them back at the start of every session. The index file is MEMORY.md. The first 200 lines load automatically into every session. Additional topic files (debugging.md, patterns.md, whatever you need) get created as the repo evolves.
What gets saved: stable patterns confirmed across multiple sessions, architectural decisions, important file paths, user preferences, solutions to recurring problems. What does not get saved: session-specific context, in-progress work, unverified guesses from a single file read.
You can also tell Claude to remember things explicitly. Say "always use bun instead of npm" and it writes that to memory. Say "forget about using bun" and it removes it. The memory compounds. After a few weeks, Claude starts a session already knowing your repo structure, your naming conventions, your preferred tools, and the mistakes it made before. That is the difference between a blank agent and a teammate.
CODE
Hooks: Automating Agent Behavior
Hooks are shell commands that fire on Claude Code lifecycle events. There are 14 hook events: PreToolUse, PostToolUse, SessionStart, Stop, and more. You configure them in .claude/settings.json (project level) or ~/.claude/settings.json (global).
The format:
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "./hooks/validate.sh",
"timeout": 600
}
]
}
]
}
Three hook types exist. Command hooks run shell scripts. Prompt hooks send context to Claude for a yes/no decision. Agent hooks spawn a subagent with read-only tools for complex verification.
Practical uses: block dangerous rm commands before they execute. Run a linter after every file write. Send a Slack notification when a session ends. Validate commit messages before they go through. The /hooks command gives you an interactive menu to manage them without editing JSON by hand.
PATTERN
Custom Skills and Slash Commands
Skills are markdown files in .claude/skills/ that define reusable workflows. Each skill folder contains a SKILL.md file with YAML frontmatter and step-by-step instructions. When you type /skill-name in a Claude Code session, the skill loads and Claude follows the instructions.
The frontmatter controls behavior. The basics: name (becomes the slash command), description (Claude uses this to auto-invoke when relevant), and allowed-tools (tools Claude can use without asking permission). The advanced fields: model (override which model runs this skill), context: fork (run in an isolated subagent context instead of the main conversation), disable-model-invocation: true (only the user can trigger it, useful for deploy and commit skills), and argument-hint (autocomplete hint like [issue-number]). You can also embed dynamic context with the !command syntax, which runs a shell command before the skill content is sent to Claude.
My repo has four custom skills: /handoff generates a context handoff document for the next session. /sync-main handles git divergence from automated machines. /update-github runs a pre-push safety scan before pushing to the public repo. /restart-openclaw diagnoses and restarts the OpenClaw gateway. Each one started simple and got more robust through actual use.
The skill file is plain English. You are not writing code. You are writing instructions that an AI agent follows step by step. Skills load on demand, so they do not consume context window space until invoked. That is the key difference between skills and CLAUDE.md. Put always-needed context in CLAUDE.md. Put workflow-specific instructions in skills. Skill descriptions are loaded into context at startup (capped at about 2% of your context window), so Claude knows which skills exist and can suggest them.
PRO TIP
Cost Tracking and Insights
Type /cost in a session to see your token spend. It shows total cost, API duration, wall duration, and code changes. Type /context to see what is consuming your context window. Type /model to switch models mid-session.
The power move is /insights. It generates an interactive HTML report at ~/.claude/usage-data/report.html that analyzes up to 50 recent sessions. The report includes a statistics dashboard (session counts, messages, duration, tokens, git commits, activity streaks, peak hours), daily activity charts, tool usage distribution, language breakdown, friction points with specific examples, and recommended CLAUDE.md additions. It runs your transcripts through Haiku for facet extraction and caches results so subsequent runs are fast. If you want to understand how you actually use Claude Code versus how you think you use it, /insights shows you the data.
The biggest cost lever is model selection. Sonnet handles most daily work. Opus is for complex architecture and judgment calls. Haiku works well for subagents doing mechanical tasks. Defaulting to Opus on everything is like hiring a senior architect to paint walls.
Other cost reducers: /clear between unrelated tasks starts a fresh context window. Move workflow instructions from CLAUDE.md to skills so they only load when invoked. Reference specific file paths instead of asking Claude to search. Short, focused sessions beat marathon conversations where context accumulates and old messages get compressed.
Average cost runs about $6 per developer per day. 90% of users stay under $12. If you are above that, check what is loading into every session and move it to on-demand skills.
CODE
Worktrees: Isolated Parallel Work
Worktrees let you run parallel Claude Code sessions without file conflicts. Each worktree gets its own branch and working directory while sharing the same git history.
Create one with: claude -w feature-name
This creates a worktree at .claude/worktrees/feature-name with a branch called worktree-feature-name. Start Claude in that directory and work on whatever you need. The main working tree stays untouched.
When you exit, Claude asks whether to keep or remove the worktree. If you had no changes, it cleans up automatically. The /resume command shows sessions from all worktrees in the same repo, so you can switch between parallel work easily.
Worktrees are good for isolated experiments and feature branches. For coordinated parallel work where agents need to talk to each other, Agent Teams are the better tool. Worktrees are solo lanes. Teams are a coordinated fleet.
knowledge guide
related guides