“Claude Code reported ‘Done,’ but when I ran it, there was an error.”
“The longer I use it, the more it stops following the rules I gave it at the start.”
Claude Code is a tool that can read and write files, run commands, and take on multi-step work. The wider the range of what you can hand over, the more the result depends on how you hand it over.
In Part 5, centered on the official Claude Code best practices (code.claude.com/docs/en/best-practices), we look at how to proceed, verification, CLAUDE.md, context management, the extension mechanisms, and permissions. We also add features you will want to know about once you start using it, such as how to protect secrets and how to work in parallel.
▶ This part is also available as a YouTube video (about 21 min) (it is also embedded at the end of this article).
- Explore → plan → implement → verify → commit
- Give it a way to verify
- CLAUDE.md
- Context management
- Extension mechanisms
- Permissions and auto mode
- Parallel work and automation
- The author’s real-world example: a project for building materials
- Think about it
- Summary
- Watch the video
- The Claude Fundamentals series (6 parts)
Explore → plan → implement → verify → commit
The core of the official best practices is: don’t have Claude write code right away.

- Explore: Have Claude read the relevant files and settings to understand the situation
- Plan: Have it produce a plan for how to change things, and review it yourself
- Implement: Have it make the changes following the plan
- Verify: Have it check the result with tests or check commands
- Commit: If there are no problems, commit
For large changes, use plan mode (in the CLI, Shift+Tab; in the Code tab, the menu opened with Ctrl+Shift+M). In plan mode, Claude only reads and proposes, and does not change files. You can open the plan in an editor with Ctrl+G and edit it directly. On the other hand, for small, well-defined fixes such as correcting a typo or renaming a variable, you can skip the plan and hand the task over directly. Choose according to the size of the work.
How to use plan mode, and how to tell which work can skip the plan and which needs one, are covered in detail in Part 2 of the follow-up series Claude Code in Practice.
Give it a way to verify
- Without a way to verify, Claude stops at “looks done.” This is the point the official guidance stresses most. It is the first of the two worries at the start of this article
- What you can give it to verify with: tests, builds, lint, check commands, screenshots, and examples of the expected output
- Examples in infrastructure:
ansible-playbook --check --diff,terraform plan,nginx -t,systemctl status, and health-check URLs - Include verification in the request: “After the change, confirm with
--checkthat there is no diff before you report” - A mechanism to stop it: With a hook (Stop), you can also set things up so that Claude cannot finish until verification passes
- Independent checking: Have a separate subagent do only the verification
The four levels for enforcing verification, checking by reading the diff rather than the summary, and the mechanism of stopping with hooks are explored in Part 7 of Claude Code in Practice.
CLAUDE.md
- What it is: A file for writing a project’s rules. It is loaded at the start of every session
- What to write: build and test procedures, working conventions, frequently used commands, and easy-to-get-wrong points
- What not to write: things Claude can read for itself (such as the directory structure), and information that changes often
- Keep it short: The official guideline is under 200 lines per file. A long file uses up context and is less likely to be followed. Rules that apply only to specific files go in
.claude/rules/(if you specifypaths, they are loaded only when Claude works with matching files). A CLAUDE.md larger than 4 MiB is not loaded - Import other files: Write
@docs/runbook.mdinside CLAUDE.md - How to start:
/initanalyzes the repository and creates a draft. You can also edit from/memory(the old#shortcut for appending has been removed. Ask Claude to “add this to CLAUDE.md”) - Where to put it: the project’s
CLAUDE.md(shared with the team),CLAUDE.local.md(just for you; add it to .gitignore), and~/.claude/CLAUDE.md(common to all projects). If there is no CLAUDE.md, it also readsAGENTS.md
# Working rules (example)
- Before running against the production inventory (inventory/prod), always show --check --diff first
- Put playbooks under roles/ and write variables in group_vars
- After making changes, run ansible-lint before reporting
How to choose where to put it, what to write and not write, how to write rules that get followed, and a template for sharing with the team are covered in Part 4 of Claude Code in Practice.
auto memory
Claude Code also has auto memory, in which Claude itself writes down things it learns during its work. It is on by default. It is stored in ~/.claude/projects/<project>/memory/, and the first 200 lines (or 25 KB) are loaded each time. You can check the contents and turn it on or off with /memory. Think of it this way: rules the team must follow go in CLAUDE.md, and things learned in your own work go in auto memory.
Update (October 18, 2026):
/memoryis a CLI command. In the Code tab of the desktop app, it shows “isn’t available in this environment.” In the Code tab, edit CLAUDE.md as a file directly or ask Claude to add to it, and turn auto memory on or off withautoMemoryEnabledin~/.claude/settings.json.
Context management
The official guidance says, “the biggest constraint is the context window.” The longer a conversation gets, the more easily Claude loses track of the first instructions, and the more usage it consumes. The second worry at the start of this article comes from this.
| Operation | What it does | When to use it |
|---|---|---|
/clear | Resets the conversation | When you move on to unrelated work |
/compact | Summarizes the conversation so far to free up context | When it is getting long (it also runs automatically) |
/rewind | Goes back to an earlier checkpoint (it also opens if you press Esc twice with an empty input box) | When you went in the wrong direction |
| Esc | Stops Claude’s work | When you want to correct course early |
| Subagents | Research in a separate context and return only the conclusion | When you don’t want research to fill the main conversation |
/context | Shows context usage | When you want to know what is taking up space |
/usage | Shows the remaining usage allowance and its breakdown | When you are concerned about limits (Part 3) |
- Checkpoints are created automatically each time you send a prompt (the latest 100 per session). You can choose “restore code and conversation,” “restore conversation only,” “restore code only,” and so on
- However, files changed through Bash commands and changes made outside Claude Code are not tracked. Changes made by commands, such as changing a server’s settings, are not undone by
/rewind. Think of it as restoring only the files Claude edited, and protect production changes with Git and the rollback in your procedure document
How the context is resent on every turn is covered in Part 1 of Claude Code in Practice, and steering with Esc, /compact, and /rewind is covered in detail in Part 3 of the same series.
Extension mechanisms
| Mechanism | What it is | When to use it |
|---|---|---|
| Skills | A folder (SKILL.md) bundling procedures, scripts, and materials. Loaded only for related tasks | Procedures for repeated tasks (for example, updating documents, how to build a playbook) |
| MCP | A mechanism for connecting to external services and tools | Integration with AWS, monitoring tools, and ticket management |
| Hooks | Processing that always runs at set points | Lint after edits, blocking dangerous commands (stronger than CLAUDE.md) |
| Subagents | Helper agents that run in a separate context | Research, verification, and parallel work |
| Plugins | A unit for distributing Skills, hooks, subagents, and MCP together | Distributing the same set of tools |
- The former “custom slash commands” (
.claude/commands/) have been merged into Skills. Both.claude/commands/deploy.mdand.claude/skills/deploy/SKILL.mdcan be called with/deploy. For new ones, Skills, which can hold supporting files, are recommended - Skills are placed in
~/.claude/skills/<name>/for personal use and.claude/skills/<name>/for a project. The list is shown with/skills - CLAUDE.md is a “request,” and hooks are a “mechanism that always runs.” Choose according to how important it is that something be followed
How to create and use Skills, subagents, and hooks is covered on this blog in the series Claude Code Skills Fundamentals and its sibling series on subagents and hooks.
Permissions and auto mode
Claude Code asks for permission before changing files or running commands. To reduce confirmations while staying safe, use permission rules.

- In
settings.json, write the operations to permit automatically (allow), the operations to always confirm (ask), and the operations never to run (deny). For example, permit reads and--check, confirm runs against production, and deny destructive commands - In auto mode, a separate classifier model checks whether an action goes beyond what was asked and whether it is being steered by content Claude has read, runs safe operations without confirmation, and stops dangerous ones. From v2.1.283, the terminal and VS Code start in auto mode by default (available on all plans)
- The official documentation states plainly that auto mode does not guarantee safety. The risk of following instructions buried in logs or web pages (prompt injection, Part 6) is not zero. Design things so that a human approves irreversible operations
Permission modes
| Mode | Behavior |
|---|---|
| default (shown as Manual) | Asks for confirmation on each operation |
| acceptEdits | Automatically permits file edits and some file operations |
| plan | Read only, no edits (plan mode) |
| auto | A classifier model decides, and safe operations are permitted automatically |
| dontAsk | Denies every operation that would need confirmation (for CI) |
| bypassPermissions | Skips all confirmations. Use it only inside a container or VM |
In the CLI, the first Shift+Tab in a session that started in auto switches to Manual (default), and after that it cycles Manual → acceptEdits → plan (modes you have enabled follow plan). In the Code tab of the desktop app, Shift+Tab does not switch modes; use the mode indicator below the input box or Ctrl+Shift+M (Cmd+Shift+M on a Mac). dontAsk is specified at startup with --permission-mode dontAsk, and bypassPermissions can be chosen only when you have enabled it with a startup option or a setting. Deny rules apply in every mode. Sources: https://code.claude.com/docs/en/permission-modes , https://code.claude.com/docs/en/desktop
The differences among the six modes, and what auto mode stops and what it lets through, are covered in Part 5 of Claude Code in Practice.
Keeping secrets unreadable
You can use deny rules to keep Claude from reading .env and credential files. The official example is as follows.
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Read(./config/credentials.json)"
]
}
}
- Matching files are denied for reading and editing, and this also applies to reads through commands such as
cat - However, it cannot block commands that read without naming files, such as
grep -r. To protect at the OS level, use the sandbox (enable it with/sandbox). Writes are limited to the working directory and a few other places, and connections to new destinations require approval - The sandbox works on macOS, Linux, and WSL2, and is not available in a native Windows environment
How to write allow, ask, and deny rules, the order in which they are evaluated, and the hierarchy of settings files are covered in Part 6 of Claude Code in Practice.
Parallel work and automation
- Parallel work with worktrees:
claude --worktree <name>(-w) creates a separate working tree (.claude/worktrees/<name>/) and branch and starts a session in it. You can run several tasks in parallel without fighting over files. Add.claude/worktrees/to .gitignore - Running without interaction:
claude -p "…"prints the result to standard output and exits. With--output-format json, you get the result as JSON. You can build it into scripts and scheduled runs. The Code tab of the desktop app is interactive only; non-interactive runs and Agent teams (a feature in which several Claudes divide the work as a team) are available only in the CLI - GitHub Actions: With
anthropics/claude-code-action, calling@claudein an issue or pull request gets a response. You can walk through the setup with/install-github-appin Claude Code
The more you automate, the more important it is to decide permission rules and deny rules first.
The author’s real-world example: a project for building materials
The author also builds the study-session materials that this series is based on with Claude Code.

- CLAUDE.md and a handoff document: Material formatting, naming, decided policies, and environment pitfalls (such as problems with PowerPoint automation) are kept in files, so the next session can start from the same assumptions
- Skills: Procedures for repeated tasks, such as finding and fixing errors in the materials and adding explanatory slides, are bundled
- Automatic generation from source md to pptx: Fix the md and rebuild with a script. Don’t edit the pptx directly
- Verification: Turn every page into an image and check for overflow and overlap
- Research: Research of official information is done in parallel with subagents and summarized with sources
The flow of explore → plan → implement → verify, the ways of giving it a way to verify, CLAUDE.md, and Skills work just as well for building materials.
Think about it
- For the work you ask Claude Code to do, have you given it a way to verify its own results? For infrastructure work, what could you give it?
- How many lines is your CLAUDE.md? If it is over 200, which parts could you move into
.claude/rules/or Skills? - After running a command that changes a production server’s settings, can you undo it with
/rewind?
Hint: Review the sections “Give it a way to verify” and “CLAUDE.md,” and the note about checkpoints in “Context management.”
Summary
- Explore → plan → implement → verify → commit. For large changes, review the plan first in plan mode
- Give it a way to verify. Without one, Claude stops at “looks done”
- Keep CLAUDE.md under 200 lines, and split out per-file rules into
.claude/rules/and repeated procedures into Skills - Reset the context at natural breaks in the work.
/rewinddoes not undo what was changed through Bash - Separate permissions into allow, ask, and deny, and protect secrets with deny rules and the sandbox. Even with auto mode, a human approves irreversible operations
Next time is the final part. We cover how to think about using Claude safely: handling of data, prompt injection and hallucination, the 4Ds of AI Fluency, and more.
Watch the video
This part is also explained in a YouTube video (about 21 min).
All parts of the series are in the Claude Fundamentals playlist on YouTube.
The Claude Fundamentals series (6 parts)
All 6 parts with a reading guide: Claude Fundamentals
- The Big Picture of Claude and Its Plans
- Choosing Between Chat, Cowork, and Code
- Model and Effort
- Prompting Basics and Example Instructions
- Claude Code Best Practices (this article)
- Using Claude Safely
This series is the English edition of 【Claude活用入門】, originally written in Japanese.


コメント