Getting More Out of Claude Code (1) — Memory, Skills, and Hooks

Getting More Out of Claude Code (1) — Memory, Skills, and Hooks


Introduction

Installing Claude Code and coding through basic conversation is quick to learn. But most users stop here — stuck at the “write this code,” “fix this bug” level.

Claude Code actually hides powerful features: project-specific memory, repeatable task automation, and external tool integration. Using them transforms Claude Code from a simple chatbot into your personalized coding partner.

This series covers how to get 200% out of Claude Code, across four parts:

Note: This post was checked against the latest Claude Code as of June 2026. Claude Code evolves fast, so for fast-growing lists like bundled skills or hook events, confirm with /help in your own environment.


TL;DR

  • Memory has two axes. The CLAUDE.md you write yourself (rules, guidance) and the auto-memory Claude writes during a session (learned habits, build commands). Both spare you from repeating the same explanations.
  • Skills teach new commands. A single markdown file (SKILL.md) defines “do this task this way.” Many bundled skills also ship ready to use — well over a dozen, no install needed.
  • Hooks run commands at specific moments. Auto-format after edits, block dangerous commands, notify you when input is needed, verify task completion — all attached to events.
  • Blocking and verification use defined signals. To block an action or keep Claude working, a hook returns an agreed exit code or JSON (permissionDecision, decision).
  • Combine all three for a tailored partner. Put rules in memory, repetitive work in skills, automation in hooks, and Claude Code becomes optimized for your project.

1. Memory — Making Claude Remember You

Claude Code starts each session with a fresh context window. It doesn’t remember yesterday’s conversation today. Memory solves this.

1.1 CLAUDE.md — Your Project Instruction Manual

CLAUDE.md is a markdown file Claude reads automatically at session start. Write your coding rules, build commands, and architecture there, and you won’t have to re-explain them every time.

Scope depends on where you put it

You can place it in several locations; all of them load and merge. A narrower scope (project) takes precedence over a wider one (user).

LocationScopeSharing
Managed policy (/Library/Application Support/ClaudeCode/CLAUDE.md, etc.)Org-wide, enforcedAdmin-deployed
./CLAUDE.md or ./.claude/CLAUDE.mdWhole projectShared with team (Git)
./CLAUDE.local.mdThis project, just meGitignore recommended
~/.claude/CLAUDE.mdAll my projectsJust me
.claude/rules/*.mdSpecific file typesShared with team

Quick start: /init

If it’s your first time, run /init in Claude Code. It analyzes your codebase and generates a CLAUDE.md automatically. (/init is a built-in command, not a skill.)

# Inside Claude Code
/init

Writing a good CLAUDE.md

# Project Rules

## Build & Test
- `pnpm dev` to run the dev server
- `pnpm test` to run tests; always run before committing

## Coding Rules
- 2-space indentation
- Use TypeScript strict mode
- Place API handlers in `src/api/handlers/`

## Architecture
- Frontend: React + Vite
- Backend: Express + Prisma
- DB: PostgreSQL

Key points:

  • Keep it under 200 lines. Longer files lower Claude’s compliance (the official guidance also targets “under 200 lines per file”).
  • Be specific. “Write good code” → “2-space indentation.”
  • Avoid contradictory rules. When two rules conflict, Claude picks arbitrarily.

Importing other files

When CLAUDE.md grows, reference external files with @path syntax (nesting up to 4 levels):

# Project Rules
@README.md
@docs/api-conventions.md

## Personal Settings
@~/.claude/my-preferences.md

Imported files are inlined into the context at session start. The first time you import a file outside your home directory, an approval dialog appears.

1.2 .claude/rules/ — File-Type Rules

Rules that don’t apply to every file belong in .claude/rules/. Use glob patterns in the paths frontmatter to apply them only to specific files:

---
paths:
  - "src/api/**/*.ts"
---

# API Development Rules
- Include input validation on every endpoint
- Use the standard error response format
- Include OpenAPI doc comments

Now this rule loads only when Claude works on TypeScript files under src/api/, saving context.

1.3 Auto-Memory — Claude Records on Its Own

Auto-memory is a system where Claude records things automatically without you doing anything. It learns and saves build commands, debugging tips, code-style preferences, etc. during a session.

Storage location

~/.claude/projects/<project>/memory/
├── MEMORY.md          # Index (loaded at every session start)
├── debugging.md       # Debugging patterns
├── api-conventions.md # API design decisions
└── ...

The MEMORY.md index loads at session start, up to whichever comes first of 200 lines / 25KB. The remaining files are referenced as needed.

Enable/disable

# Inside Claude Code
/memory  # Toggle auto-memory + show loaded memory/rules files
// settings.json
{
  "autoMemoryEnabled": false
}

You can also disable it with the CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 environment variable, or change the storage path with the autoMemoryDirectory key.

Telling it to remember

Say “remember this” to Claude and it saves to auto-memory:

Always use pnpm, not npm. Remember this.

The /memory command lets you review and edit what’s stored. They’re plain markdown files, so you can edit them directly.

1.4 CLAUDE.md vs Auto-Memory — When to Use Which

CLAUDE.mdAuto-Memory
Who writes itYou, directlyClaude, automatically
ContentRules, guidanceLearned patterns
ScopeProject/user/orgPer project
Use forCoding standards, workflowBuild commands, debugging tips, preferences

Summary: Put rules you share with the team in CLAUDE.md; use auto-memory to let Claude learn your habits.


2. Skills — Giving Claude New Abilities

A skill teaches Claude how to perform a specific task. A single SKILL.md file teaches Claude a new command.

2.1 Bundled Skills — Ready Without Installing

Claude Code ships with several built-in skills. Type a name after / and use them immediately, no install. The count grows with each version, so check your full list with /help. The major bundled skills as of June 2026, by purpose:

CategorySkillsPurpose
Code quality/code-review, /simplify, /reviewReview/simplify changes, review a PR
Security & verification/security-review, /verifyVulnerability scan, verify a change actually works
Large-scale work/batchParallel changes across the codebase
Run & debug/run, /debugRun/check the app, analyze session debug logs
Automation/loop, /scheduleRepeated execution, scheduled/remote agents
Analysis & config/insights, /statusline, /claude-apiSession analysis, status line, load API reference

A few worth highlighting:

  • /batch — handles large-scale codebase changes in parallel. It decomposes the work into independent units; once you approve, a separate agent per unit implements, tests, and opens a PR in an isolated git worktree. E.g. /batch replace all console.log with a structured logger.
  • /code-review — reviews the current diff for bugs and cleanups. You can set lowmax effort, and /code-review ultra scales it to a cloud multi-agent review (see Part 4).
  • /loop — runs a prompt or slash command on a fixed interval. E.g. /loop 5m check the deploy status.
  • /claude-api — loads the Claude API/SDK reference for your project’s language. It can auto-activate when you import anthropic in code.

Note: If you remember “there are 5 bundled skills,” that’s stale. With /code-review, /security-review, /run, /verify, /simplify and more added, there are now well over a dozen.

2.2 Creating Custom Skills

Beyond bundled skills, you can make your own. One SKILL.md file is enough.

Skill storage locations

LocationScope
~/.claude/skills/<name>/SKILL.mdAll my projects
.claude/skills/<name>/SKILL.mdThis project only

Example: blog post generation skill

---
name: blog-post
description: Generates a blog post draft. Creates Korean and English versions at once.
disable-model-invocation: true
---

Write a blog post:

1. Write a post about the $ARGUMENTS topic
2. Create the Korean version in `src/content/blog/`
3. Create the English version in `src/content/blog/en/`
4. Include the current time in pubDate (e.g. 2026-03-14T18:00:00+09:00)
5. Korean uses casual style; English uses a practical tone
6. heroImage path: Korean `../../assets/`, English `../../../assets/`

Usage:

/blog-post How to write Terraform modules

Frontmatter fields

Only name and description are required. Many fields have been added for fine-grained control:

FieldRole
name / descriptionName and description (required). The description drives auto-invocation
disable-model-invocation: trueUser-invocable only, no auto-invocation (deploy/commit side effects)
user-invocable: falseAuto-reference by Claude only, no direct user call (background knowledge)
allowed-tools / disallowed-toolsTools allowed/removed while the skill is active
modelhaiku / sonnet / opus / inherit
effortlow to max reasoning effort
context: forkRun in a separate sub-agent (avoid polluting the main conversation)
agentSub-agent type when context: fork
when_to_use / argument-hintExtra auto-invocation triggers / autocomplete hint

Controlling skill invocation

SettingUser callClaude auto-call
(default)OO
disable-model-invocation: trueOX
user-invocable: falseXO
  • disable-model-invocation: true: for side-effecting work like deploy or commit. You don’t want Claude auto-running “looks ready, I’ll deploy.”
  • user-invocable: false: for background knowledge like legacy-system context. You’d never call /legacy-context yourself, but it’s useful for Claude to auto-reference it.

2.3 Dynamic Context Injection

The !`command` syntax injects shell command output before the skill runs:

---
name: pr-summary
description: Summarize a PR
context: fork
agent: Explore
---

## PR Context
- PR diff: !`gh pr diff`
- PR comments: !`gh pr view --comments`
- Changed files: !`gh pr diff --name-only`

## Task
Summarize this PR...

How it works:

  1. Run /pr-summary
  2. Shell commands like !`gh pr diff` run first
  3. Each command’s output is substituted in place as text
  4. The fully substituted content is sent to Claude

!`command` behaves like a template variable. You can’t embed data directly in the skill file, so it means “insert this command’s result here at runtime.”

Frontmatter explained:

FieldRole
context: forkRun this skill in a separate sub-agent (prevents polluting the main conversation)
agent: ExploreSet the forked sub-agent’s type to Explore (read-only)

Without context: fork, it runs directly in the main conversation. For potentially long output like a PR diff, forking isolates it and saves the main conversation’s context.

What’s an agent type? Claude Code has specialized built-in agent types. Explore is read-only codebase exploration, Plan is for planning, and general-purpose is general (all tools). You can also build custom agents. Part 3 covers this in detail.


3. Hooks — Workflow Automation

A hook is a command that runs automatically at a specific moment in Claude Code. If a skill “teaches Claude how,” a hook “auto-runs code on a specific event.”

3.1 What’s a hook

Hooks can step in at several moments during a session. The common spots:

flowchart TB
    start["SessionStart<br/>start/resume/compact"]
    prompt["UserPromptSubmit<br/>prompt submitted"]
    pre["PreToolUse<br/>before a tool runs — can block"]
    post["PostToolUse<br/>after a tool runs — format/log"]
    stop["Stop<br/>response done — verify completion"]
    end_["SessionEnd<br/>session ends — cleanup"]

    start --> prompt --> pre --> post
    post -->|more tool calls| pre
    post --> stop --> end_
  • After editing a file → run Prettier automatically (PostToolUse)
  • Before a dangerous command → block it (PreToolUse)
  • When Claude waits for input → desktop notification (Notification)
  • At session start → load environment variables (SessionStart)

3.2 Your first hook

Get a desktop notification when Claude waits for input. Add to ~/.claude/settings.json:

{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
          }
        ]
      }
    ]
  }
}

On Linux, use notify-send 'Claude Code' 'Claude Code needs your attention'.

Type /hooks to see registered hooks.

3.3 Practical hook recipes

Auto-format after edits

.claude/settings.json (project level):

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
          }
        ]
      }
    ]
  }
}

Prettier runs only after the Edit or Write tool. It ignores other tools like Bash or Read.

Block edits to protected files

This hook blocks edits to sensitive files like .env, package-lock.json, .git/. The PreToolUse hook blocks the tool call with exit code 2, and the stderr message is shown to Claude.

.claude/hooks/protect-files.sh:

#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')

PROTECTED_PATTERNS=(".env" "package-lock.json" ".git/")

for pattern in "${PROTECTED_PATTERNS[@]}"; do
  if [[ "$FILE_PATH" == *"$pattern"* ]]; then
    echo "Blocked: $FILE_PATH matches protected pattern '$pattern'" >&2
    exit 2  # exit 2 = block the tool call; stderr is shown to Claude
  fi
done

exit 0
chmod +x .claude/hooks/protect-files.sh

.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-files.sh"
          }
        ]
      }
    ]
  }
}

Note: Instead of exit code 2, you can exit 0 and print the JSON below for the same block. Useful for delivering a structured reason.

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "deny",
    "permissionDecisionReason": "Protected files cannot be modified"
  }
}

Inject a reminder after compaction

After a long conversation, compaction (/compact) can drop important info. Auto-inject a reminder afterward:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "compact",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'Reminder: use pnpm, not npm. Run pnpm test before committing. Current sprint: auth refactor.'"
          }
        ]
      }
    ]
  }
}

Log Bash commands

Log every Bash command Claude runs to a file:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r '.tool_input.command' >> ~/.claude/command-log.txt"
          }
        ]
      }
    ]
  }
}

3.4 Prompt-based hooks — hooks that the AI judges

Beyond rule-based (exit code) hooks, there are hooks the AI judges. When Claude says it’s done but you want to confirm, use a type: prompt hook:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "prompt",
            "prompt": "Check whether all requested work is complete. If not, block so the work continues."
          }
        ]
      }
    ]
  }
}

If the Stop hook judges “not done yet,” it returns the JSON below to keep Claude working instead of stopping:

{
  "decision": "block",
  "reason": "Tests aren't passing yet. Fix the failing tests first."
}

Caution — common misconception: The {"ok": false, "reason": "..."} format seen in older material is not a hook return format. Hook block/continue signals use decision/reason (Stop/PostToolUse family) and hookSpecificOutput.permissionDecision (PreToolUse).

3.5 Hook events — where you can attach

Hook events keep growing with each version; there are now over 30. Use /hooks to see the full list your version supports. The most-used ones, categorized:

Session events

EventWhenUse for
SessionStartSession start, resume, compact, clearLoad env vars, inject context
SessionEndSession endsCleanup, release resources
PreCompact / PostCompactJust before/after context compactionBack up key info, inject reminders

Input & tool events

EventWhenUse for
UserPromptSubmitUser submits a promptInput validation, add context
PreToolUseJust before a tool runsBlock dangerous commands, protect files
PostToolUseJust after a tool runsAuto-format, logging, lint

Response, sub-agent & team events

EventWhenUse for
NotificationClaude sends a notificationDesktop notification
StopClaude finishes respondingVerify completion, catch missing work
SubagentStart / SubagentStopSub-agent start/finishPrep environment, log results
TeammateIdle / TaskCreated / TaskCompletedAgent team eventsDeliver feedback, quality gates
ElicitationAn MCP server requests user inputAuto-respond

3.6 Hook types — what runs

Hooks don’t only run shell commands. There are now five types:

TypeAction
commandRun a shell command (most common)
promptThe AI judges (§3.4)
agentSpawn a sub-agent
httpPOST to an HTTP endpoint
mcp_toolCall a tool on an MCP server

3.7 Hook settings locations

LocationScope
Managed policy (/Library/Application Support/ClaudeCode/, etc.)Org-wide, enforced
~/.claude/settings.jsonAll my projects
.claude/settings.jsonThis project (team shared)
.claude/settings.local.jsonThis project (just me)
Plugin hooks/hooks.json, skill/agent frontmatter hooks:When that plugin/skill is active

Recap

A summary of the three features covered here:

FeatureCoreTypical use
CLAUDE.mdRules you write (auto-loaded each session)Build commands, coding standards, architecture
Auto-memoryWhat Claude learns and recordsDebugging tips, tool preferences
SkillsTeach new commands (SKILL.md)Repetitive work, bundled skills
HooksAuto-run commands on eventsFormat, block, notify, verify completion

Memory, skills, and hooks are each powerful, but combined they show real force:

  1. Define project rules in CLAUDE.md
  2. Automate repetitive work (deploy, blogging, code review) with custom skills
  3. Set up file protection, auto-formatting, and notifications with hooks

Then Claude Code becomes not a simple AI chat but a development partner tailored to your project.

Part 2 covers plugins, MCP, and IDE integration. Install useful plugins from the marketplace, connect external services via MCP, and use Claude Code directly in VS Code and JetBrains.


Appendix

A. Glossary

TermDescription
CLAUDE.mdProject guide file auto-loaded at session start
Auto-memorySystem where Claude records what it learns during a session
SkillA task procedure you teach Claude via SKILL.md
Bundled skillA skill shipped with Claude Code, usable without install
HookA command/judgment auto-run at a specific event
matcherPattern filtering which tools/situations a hook reacts to (e.g. `Edit
context: forkSetting that runs a skill in a separate sub-agent to protect the main conversation

B. Command & config cheat sheet

# Memory
/init           # Auto-generate CLAUDE.md (built-in command)
/memory         # Toggle auto-memory + show loaded memory/rules

# Skills (bundled — grows per version, check with /help)
/code-review    # Review changes  (/code-review ultra = cloud multi-agent)
/security-review
/simplify /review /verify /run /debug /batch
/loop 5m <cmd>  # Repeated execution
/schedule       # Scheduled/remote agents
/claude-api     # Load API reference

# Hooks
/hooks          # Show registered hooks
// settings.json hook skeleton
{
  "hooks": {
    "<event>": [
      { "matcher": "<pattern>", "hooks": [ { "type": "command|prompt|agent|http|mcp_tool", "command": "..." } ] }
    ]
  }
}

C. References

Shop on Amazon

As an Amazon Associate, I earn from qualifying purchases.