One concept per page. Learn by turning pages like a book — no endless scrolling. Built from hands-on, verified material.
A hands-on guide to Claude Code, Anthropic's official CLI coding agent, for first-time users — all 30 chapters. From install and your first conversation to permissions, Git, models, Hooks, MCP, Subagents, and team operations.
Claude Code is not just a chat window. It's an agent-based CLI tool that can read code, execute commands, and modify files from within your project folder.
How Claude Code differs from typical AI chat:
CLI is short for Command Line Interface. In other words, it's a program you use by typing commands in a terminal.
Claude Code is usually run like this:
cd ~/my-project
claudeThen Claude Code runs inside your current project folder.
In other words, Claude Code is not a tool you access from a website. It's a tool that works alongside you in the terminal and project folder where you actually develop.
Beginners don't need to learn all features at once. At first, understanding these 5 things is enough.
The important thing is that Claude Code can work with real files and terminal commands. That makes it powerful, but it also means you need to use it carefully.
Claude Code is easier to understand when divided into 3 main layers.
Extension Layer
- MCP
- Hooks
- Skills
- Plugins
Delegation Layer
- Subagents
Core Layer
- Basic conversation
- Read files
- Modify files
- Execute commandsThis is the basic conversational space. Here, you ask Claude questions.
Explain the structure of this project to me.Claude reads files, organizes relevant content, and responds.
This layer divides large tasks into smaller ones. For example, it's useful in situations like this.
Search the entire codebase for authentication-related files,
and summarize any security risks.This kind of task has a wide scope. Claude Code can delegate exploration or analysis to separate subagents as needed.
Beginners don't need to understand this deeply right now. You can learn about it later when working on larger projects.
This layer connects Claude Code to external tools or automates tasks. Key features include:
Beginners don't need to set up MCP, hooks, or plugins from the start. It's better to first learn the basics: conversation, reading files, and the approval workflow for edits.
The most basic workflow for Claude Code looks like this:
In the terminal, you typically start like this:
cd ~/my-project
claudeInside Claude Code, you can make requests like this:
Explain the overall structure of this project in a way beginners can understand.
Start by organizing the important folders and files.
Don't modify any files yet.The request above is a good first question for beginners.
When starting with Claude Code, it's good to repeat this cycle:
For example, if you want to fix a bug, you'd say:
There's a login error.
Find the related files first and explain the cause.
Don't modify the code yet—just propose a fix plan.Once you like the plan, you'd say:
Okay, go ahead with the plan you just proposed.
After making changes, summarize which files you modified.After modifications, always verify like this:
Summarize the changes based on git diff.
Check for any risky or unintended changes too.Assume you're a developer seeing this project for the first time.
1. Project purpose
2. Main folder structure
3. Commands that seem to run it
4. Files to read first
Organize in this order.
Don't modify any files yet.Find where the login feature is handled.
Organize the related files and function names.
Just explain the structure—don't modify anything yet.I want to add signup input validation.
First check the current structure,
then just create a plan for which files to modify and how.
Don't modify files until I approve.Review what you just modified.
Based on git diff, summarize the modified files, reasons, and any risks.
Also let me know what tests to run if needed.Bad example:
Login doesn't work. Fix it.Saying this makes Claude guess a very broad scope.
Good example:
There's a login error.
Find the related files first and explain the cause.
Don't modify anything yet—just propose a fix plan.You must always verify after Claude modifies files.
git status
git diffInside Claude Code, you can request this:
Summarize the changes based on git diff.
Check for any unintended changes too.Be careful with these files:
.env
.env.local
credentials.json
private-key.pem
id_rsa
config/secrets.ymlIt's a good habit to tell Claude like this:
Don't read sensitive files.
If needed, just describe what values are required.Bad example:
Refactor the entire project and fix all tests.Good example:
Find parts that need refactoring first.
Then organize priorities,
and just propose a stage 1 work plan.Claude Code is powerful, but large tasks are safer when divided into stages.
When using Claude Code for the first time, check these items:
Claude Code is not just a question-and-answer tool. It's a development agent that can read, modify, and execute commands on code within your project.
Beginners don't need to learn advanced features right away. Just start with this cycle:
Following this cycle makes Claude Code much safer to use.
Unit 2. Checking prerequisites before installation
Before installing Claude Code, there are 5 things you should check first.
Claude Code is not like a regular app where you "install and click to run." You typically use it like this:
That's why checking your environment before installation is critical—skipping it can cause problems.
.env, API keys, private keysInstallation itself is not difficult. However, insufficient pre-installation preparation can make your first experience more complicated.
According to official documentation, Claude Code runs on the following environments.
This information is current as of writing. Before actual installation, also check the official documentation and run claude --version and claude doctor.
On macOS, open your terminal and run the following commands.
sw_vers
uname -mExpected output looks something like this:
ProductVersion: 14.x.x
arm64If ProductVersion is 13.0 or higher, you meet the basic requirement. arm64 indicates Apple Silicon; x86_64 indicates an Intel Mac.
On Windows, open PowerShell and run the following commands.
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
$PSVersionTable.PSVersionOn Windows, you can use either PowerShell or CMD. Official documentation provides separate installation methods for PowerShell and CMD. For native Windows, it's recommended to install Git for Windows so Claude Code can use Bash tools.
On Linux or WSL, run the following commands.
cat /etc/os-release
uname -mOn Ubuntu, you'll see output like this:
NAME="Ubuntu"
VERSION_ID="22.04"Ubuntu 20.04 or later satisfies the basic requirement. Windows users can also choose to use WSL and follow Linux installation instructions.
Claude Code runs from your terminal by default. Common terminals include:
Claude Code works with most terminals by default without special configuration. Beginners don't need to set up anything complex at first.
As a beginner, you only need these 3 basic commands.
cdlspwdOn Windows PowerShell, ls and cd work the same way.
Using Claude Code requires authentication. Common authentication methods are:
For beginners, individual users typically use Claude Pro or Max; team users use their company-provided Team or Enterprise account; developers or organizational users use Claude Console.
Claude Code can incur costs or usage limit impacts depending on how you use it. The following activities can increase usage significantly:
Beginners don't need to understand cost optimization deeply at first. Instead, develop these habits:
/cost or /usage commands.Claude Code usually runs from your project root folder. For example, if your project structure looks like this:
my-project/
├── src/
├── tests/
├── package.json
├── README.md
└── .git/You run it from inside that folder:
cd ~/my-project
claudegit status and git diff are availableBefore installation, you can try running pwd, ls, and git status in your project folder. If git status doesn't work, your folder might not be a Git repository.
Claude Code can read your project files. Before installation, check for sensitive files. Be especially careful with these:
.env
.env.local
.env.production
credentials.json
service-account.json
private-key.pem
id_rsa
id_rsa.pub
*.key
*.pemBefore installation, you can check your project using ls -a.
If you have sensitive files, develop this habit when using Claude Code:
Don't read .env, API keys, private keys, or credentials files.
If needed, just describe what environment variables are required by name.Claude Code starts with read-only permissions by default and asks for your approval when file editing or command execution is needed. You are responsible for reviewing proposed code and commands before approval.
Good Git habits are important for using Claude Code properly. Before installation, verify these commands work:
git --version
git statusIf it's not a Git repository, you might see this message:
fatal: not a git repositoryIf your project is already managed by Git, that's great. If not, it's safer to back up important files or initialize a Git repository before using Claude Code.
The safest workflow for beginners is:
Check the items below, then proceed to the next unit for installation.
cd, ls, pwdgit status.env, API keys, and credentials files are locatedBad example:
cd ~
claudeRunning from your home folder makes it hard for Claude to understand your project context.
Good example:
cd ~/my-project
claudeAlways run from your project root folder.
Bad request:
Read my .env file and fix the settings.Good request:
Don't read the .env file.
Just estimate and describe what environment variables this project needs by name.Bad approach:
Clean up this entire project for me.Good approach: First, in your terminal:
git statusThen, in Claude Code:
Check if there are any pending changes.
Then suggest a modification plan.
Don't modify files yet.Bad example:
Read the entire project and fix all problems.Good example:
Just understand the project structure briefly.
Pick out and explain the 5 most important files.
Don't modify anything yet.Break large tasks into smaller requests.
Before installing Claude Code, check these 5 things first:
More important than installation itself is preparing to use it safely.
Run from project root · Protect sensitive info · Plan before modifying · Verify after modifying
In this section, you will install Claude Code for real.
Beginners should follow the steps below in order.
1. Choose an install command for your OS.
2. Paste the install command into your terminal.
3. Check the installation with claude --version.
4. Verify your environment with claude doctor.
5. Run claude and log in.The official Claude Code documentation recommends installation via Native Install, Homebrew, or WinGet.
This information is current at time of writing. Installation commands, supported operating systems, and update methods may change, so consult the official documentation before installing.
Claude Code runs in the terminal. If you skip verification, you may run into problems in the next steps.
command not found: claudeSo after installing, don't jump straight into coding. First verify the version → environment → login status.
curl or brewcurlcurl inside WSL terminalirmcurl + install.cmdwingetThe official documentation recommends Native Install as the preferred method. Native Install supports automatic updates, while Homebrew and WinGet installations need manual upgrades.
On macOS, you can use Native Install.
curl -fsSL https://claude.ai/install.sh | bashThis command downloads and runs the official install script. Before pasting, verify it matches the command in the official documentation.
Homebrew users should use the stable channel.
brew install --cask claude-codeHomebrew offers a stable channel claude-code and a latest channel claude-code@latest. The stable channel is usually slightly behind the latest, which updates faster. For the latest channel:
brew install --cask claude-code@latestBeginners typically benefit from the stable channel.
Linux and WSL use the same Native Install command as macOS.
curl -fsSL https://claude.ai/install.sh | bashIf you're using WSL, install and run inside the WSL terminal, not PowerShell.
After installing, open a new terminal or restart your shell to refresh PATH.
exec "$SHELL"Then verify:
claude --versionOn Windows PowerShell, use this command:
irm https://claude.ai/install.ps1 | iexThe PowerShell prompt typically looks like this:
PS C:\Users\YourName>If the irm command is not recognized, you may have pasted a PowerShell command into CMD. After installing, open a new PowerShell and verify:
claude --versionOn CMD, use this command:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmdThe CMD prompt typically looks like this:
C:\Users\YourName>Mixing PowerShell and CMD commands can cause installation errors. For beginners, it's easier to open PowerShell from Windows Terminal and use PowerShell commands.
Not required, but recommended.
The official documentation recommends Git for Windows in native Windows environments. With Git for Windows, Claude Code can use Git Bash as its Bash tool; without it, it uses PowerShell. WSL users don't need Git for Windows.
After installation, first check the version.
claude --versionIn PowerShell, it's the same:
claude --versionIf installed correctly, you'll see the version number:
2.x.xThe official documentation recommends running claude doctor for detailed installation and configuration checks.
After checking the version, run the diagnostic command:
claude doctorIn Windows PowerShell, it's the same:
claude doctorclaude doctor checks installation status, environment configuration, and potential issues. Beginners benefit from running it right after installation.
If there are no issues, move to the next step:
claudeWhen you first run Claude Code, it will prompt you to log in.
claudeIf you need to log in again within Claude Code, use this command:
/loginThe official documentation notes that you can log in with a Claude subscription, Claude Console account, or supported cloud provider.
To check authentication status from the terminal, use:
claude auth statusAfter installation and login, navigate to your project folder:
cd /path/to/your/project
claudeFor example, on macOS or Linux:
cd ~/my-project
claudeOn Windows PowerShell:
cd C:\Users\YourName\my-project
claudeStart your first question safely:
Explain the structure of this project.
Summarize the important folders and files first.
Don't modify any files yet.If you installed via Native Install, Claude Code supports automatic updates. Homebrew and WinGet installations require manual upgrade commands.
For manual updates, use:
claude updateIf you installed via Homebrew stable channel:
brew upgrade claude-codeIf you installed via Homebrew latest channel:
brew upgrade claude-code@latestIf you installed via WinGet:
winget upgrade Anthropic.ClaudeCodeBeginners typically benefit from using stable or the stable channel.
With Native Install, you can specify the stable channel:
curl -fsSL https://claude.ai/install.sh | bash -s stableOn Windows PowerShell:
& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) stableSometimes teams need a specific version to match.
For example, to install a specific version:
curl -fsSL https://claude.ai/install.sh | bash -s 2.1.89On Windows PowerShell:
& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) 2.1.89However, beginners should avoid pinning to a specific version unless there's a good reason. In team projects, follow your team lead or documentation instructions.
claude: command not foundAfter installation, your terminal may not have reflected PATH yet.
On macOS / Linux / WSL, open a new terminal or run:
exec "$SHELL"Then verify again:
claude --versionIn PowerShell:
irm https://claude.ai/install.ps1 | iexIn CMD:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmdIf irm is unrecognized, you put a PowerShell command in CMD. If you see && errors, you may have put a CMD command in PowerShell.
In native Windows environments, consider installing Git for Windows. With Git Bash, Claude Code can use Bash tools.
If Claude Code can't find Git Bash, you can specify the path in your settings file later:
{
"env": {
"CLAUDE_CODE_GIT_BASH_PATH": "C:\\Program Files\\Git\\bin\\bash.exe"
}
}Uninstall commands actually delete files. Only run them if you need to undo installation or reinstall.
To remove Native Install on macOS, Linux, or WSL:
rm -f ~/.local/bin/claude
rm -rf ~/.local/share/claudeOn Windows PowerShell:
Remove-Item -Path "$env:USERPROFILE\.local\bin\claude.exe" -Force
Remove-Item -Path "$env:USERPROFILE\.local\share\claude" -Recurse -ForceIf you installed via Homebrew:
brew uninstall --cask claude-codeIf you installed via WinGet:
winget uninstall Anthropic.ClaudeCodecurl -fsSL https://claude.ai/install.sh | bash
claude --version
claude doctor
cd ~/my-project
claudeInside Claude Code:
Explain this project's structure.
Don't modify any files yet.irm https://claude.ai/install.ps1 | iex
claude --version
claude doctor
cd C:\Users\YourName\my-project
claudecurl -fsSL https://claude.ai/install.sh | bash
claude --version
claude doctor
cd ~/my-project
claudeIn WSL, you can work in Windows paths like /mnt/c/..., but if you use many Linux tools, it's simpler to work under /home/....
Bad: Analyze the whole project and fix all the bugs.
Good: Explain just the project structure first. Don't modify any files yet.
Always verify after installing: claude --version. If problems arise, run claude doctor.
If the prompt shows PS, it's PowerShell (PS C:UsersYourName>). Without PS, it's likely CMD (C:UsersYourName>).
Bad:
cd ~
claudeGood:
cd ~/my-project
claudeClaude Code understands your project from the current folder. Always run from your project root.
These commands permanently delete files: rm -rf ~/.claude. They can remove settings, session history, and permissions. Beginners should avoid running them without official documentation or team guidance.
claude --versionclaude doctorclaude and logged inAfter installing Claude Code, don't ask it to code right away. Follow this order to verify:
The safest first question for beginners:
Section 4. Start Your First Session
In this section, you'll learn how to run Claude Code for the first time and ask your initial questions safely.
The goal of your first session is not to immediately modify code. The goal is to help Claude Code understand your project first.
Claude Code understands your project based on the current folder. If you start your first session in the wrong location, Claude may not properly understand your project structure.
Bad start:
cd ~
claudeGood start:
cd ~/my-project
claudeWhen you run from your project directory, Claude Code can directly read your project files and understand the structure.
Before running Claude Code, execute these commands from your project folder first.
pwd
ls
git statusWhat each command does:
If git status shows many already-modified files, it's good to review what those changes are before starting Claude Code.
git diffFollow this principle especially in your first session:
From your project folder, run this command:
claudeIf it works correctly, the Claude Code interface will open. If this is your first time, you may see a login prompt.
If you need to log in directly within Claude Code:
/loginNever start your first question with "Fix this". Instead, ask questions that help Claude understand your project first.
Explain what this project does.
Organize the important folders and files first.
Don't modify any files yet.Treat this like you're seeing this project for the first time and explain it.
1. What is the project for
2. Main folder structure
3. Key files
4. Commands that look like they run or test the project
5. Files I should read first
Organize it in this order.
Don't modify any files yet.In your first session, Claude hasn't fully understood your project yet. These requests are too ambitious:
First understand the project structure.
If you see areas that need fixing,
just list them as candidates—don't fix yet.After Claude explains your project structure, don't immediately ask for fixes. First, verify the explanation.
You can ask follow-up questions like:
In your explanation, separate what you guessed
from what you verified by looking at actual files.Pick just 5 key files and explain
what role each one plays.
Don't modify them yet.What commands do you see for running or testing this project?
List the candidates—don't run them yet.This prevents Claude from moving too fast into fixes or execution.
Claude Code can run tests, builds, and lint commands. But in your first session, don't let it run commands immediately—first review the candidates.
Find the command for running tests in this project.
List the candidates—don't run them yet.Good. Run npm test.
Summarize the results, and if tests fail, list possible causes.
Don't modify any files yet.Run tests and fix everything that fails.Be extra careful with install, delete, deploy, and database migration commands.
It's best not to make big changes in your first session. If you need to edit something, start very small.
I want to add one paragraph to README.md about how to run the project.
First show me a plan of what to add.
Don't modify it yet.Good. Only modify README.md.
Don't touch any other files.
Summarize the changes after you're done.For beginners, this workflow of checking each change individually is safest.
If Claude modified files, always review them.
git status
git diffExplain the changes you just made based on git diff.
1. Files changed
2. Why they changed
3. Possible unintended changes
4. Whether testing is needed
Organize it in this order.Within Claude Code, you can type / to see available commands. Here are the ones beginners should know on day one:
/help/usage/resumeWhen you're done, exit Claude Code.
Ctrl+CBefore exiting, it helps to ask this:
Summarize what you found and what you changed in this session.
Also organize what I should do first when I continue next time.If you modified files, always check before closing:
git status
git diffClaude Code saves sessions, so you can continue previous conversations.
claude -cOr use the long option:
claude --continueclaude --resume/resumeYou can reopen your previous conversation.
cd ~/my-project
pwd
ls
git statusclaudeTreat this like you're seeing this project for the first time and explain it.
1. What is the project for
2. Main folder structure
3. Key files
4. Run or test command candidates
5. Files I should read first
Organize it in this order.
Don't modify any files yet.
Don't run any commands yet.Pick just 5 key files and explain each one's role.
Only read them—don't modify them.Show me candidate commands for running or testing this project.
Don't run them yet, and explain which files you based that on.Summarize what you found in this session.
Recommend 3 things I could do in the next session.git statusYour first session shouldn't have any changes since you didn't modify files.
Bad example:
Find all problems in this project and fix them.Good example:
First explain the structure and key files of this project.
Don't modify anything yet.Bad example:
Run all the setup commands you need.Good example:
First list candidate install, run, and test commands.
Don't run them yet.If you modified files, always check before closing:
git status
git diffAlso ask Claude to summarize:
Organize the files you changed and why.If you work on different tasks in one session, context gets mixed. It's better to use separate sessions for these:
When you switch tasks, start a new session or consider /clear.
pwd, ls, and git statusclaude commandgit status and git diffclaude -c, claude --resume, and /resumeThe goal of your first session is understanding, not editing. It's important to make sure Claude Code understands your project well before you start changing code.
The safest first question is:
Always remember the basic flow of your first session:
Section 5. How to Talk to Claude Code Safely
The difference between people who use Claude Code well and those who don't comes down to how you ask questions.
Beginners usually make requests like this:
Fix this.But people who use Claude Code well make requests like this:
First, find the relevant files and explain the root cause.
Don't modify anything yet—just propose a fix plan.
Once I approve, then make the minimal changes.Claude Code is not just a question-answering tool—it's an agent-based CLI that can read your codebase, execute commands, and modify files. To use it effectively, you need to understand systems like settings, permissions, hooks, MCP, and subagents, and apply them to your real development workflow.
In this lesson, you'll learn 7 best practices that beginners can use immediately to get results.
Using Claude Code is convenient. But using it correctly changes the results.
Claude Code's power is not in giving it a big task all at once, but in breaking work into small pieces and directing Claude step by step.
The most fundamental formula is this:
What you ask Claude to do at each stage differs.
Using this flow reduces the chances of Claude making unexpected large edits or touching wrong files.
The most common mistake beginners make is asking Claude to fix things right away.
Fix the login error.There's a login error.
First, find only the login-related files and functions.
Don't modify the code yet.
List possible root causes with evidence.This way, Claude first reads and understands your project. Then you ask for a fix plan.
Good.
Based on the most likely root cause,
write only a plan for which files to modify and how.
Don't modify anything yet.Good. Make the changes as planned.
Limit changes to related files only.
After modifications, summarize the changes.Assigning Claude a role improves answer quality.
Look at this code.Review this code as a senior backend engineer would.
Find issues from security, error handling, and maintainability perspectives.
Just review—don't modify yet.Example roles by situation:
Act as a test engineer.
First, list the test cases needed for this feature.
Don't write test files yet.Specifying output format makes results easier to use immediately.
Explain the project.Explain this project in the format below.
1. Project purpose
2. Main folder structure
3. Top 5 core files
4. Possible run commands
5. Possible test commands
6. The order newcomers should read things
Don't modify files yet.Review the code from git diff.
Organize it in the table format below.
| File | Issue | Severity | Reason | Fix Suggestion |Analyze the error log.
Answer in the format below.
1. Most likely root cause
2. Evidence
3. Files to check
4. Commands to try
5. Precautions before fixingSpecifying output format makes Claude's answers less scattered.
Assigning a large task all at once increases failure risk.
Add payment functionality.I want to add payment functionality.
First, break this into 5 or fewer small work packages.
For each task, note which files change, risk level, and test methods.
Don't modify anything yet.Claude might break it down like this:
Then proceed one by one:
Do task 1 only.
Find relevant files and explain the structure only.
Don't modify anything yet.Benefits of this approach:
A good habit is to always demand evidence when Claude gives answers.
Where should I fix it?Tell me where to fix.
Explain the evidence for each judgment: file names, function names, code flow.This is especially important for codebase analysis:
Explain the authentication flow in this project.
Don't guess—explain based on files and functions you actually checked.
Mark uncertain parts as "not confirmed."This reduces Claude's tendency to assert vague assumptions.
Claude Code maintains conversation context within a session. But too many tasks in one session mixes context.
Dividing sessions by task improves Claude's focus.
claude -cclaude --resume/resumeIt's also good to clean up context when moving to a new task:
/clearTo use Claude Code well, you need to use Git together.
git statusgit diffInside Claude Code, request like this:
Review changes based on git diff.
1. Files changed
2. Why changed
3. Unintended change possibility
4. Bug possibility
5. Additional test needs
Organize in that order.You can also ask Claude to write commit messages:
Write a commit message based on the current git diff.
Use Conventional Commits format.
Include the reason for change briefly in the body.fix(auth): handle missing access token
Modified to handle cases where access token is missing from login response.
Returns a clear error message on authentication failure.Save frequently used requests as templates.
Analyze the following bug.
Symptom: [enter symptom here]
Conditions:
- Find relevant files first.
- Don't modify anything yet.
- Organize possible root causes in order of likelihood.
- For each cause, note evidence files and how to verify.
- End with a fix plan suggestion.Code review the current changes.
Criteria:
1. Bug possibility
2. Security issues
3. Exception handling
4. Performance issues
5. Maintainability
Output format: | File | Issue | Severity | Reason | Fix Suggestion |
Don't modify files yet.I want to add the following feature.
Feature description: [enter feature here]
First, organize the following.
1. Relevant files
2. Current structure
3. Implementation plan
4. Modification scope
5. Test method
6. Risk factors
Don't modify anything yet.I want to write tests for this feature.
First, write only a list of test cases.
For each test case, organize purpose, inputs, and expected results.
Don't create test files yet.Situation: Clicking the login button produces an error.
I'm getting an error when clicking the login button.
First, find files related to the login flow.
Don't modify anything yet.
Just organize relevant files and function roles.Good.
Now organize possible root causes for login failure in order of likelihood.
For each cause, note evidence files, how to verify, and expected modification scope.Based on the most likely root cause, write a fix plan.
Include which files to modify, what to change, and test method.
Don't modify anything yet.Good.
Make the changes as just planned.
Minimize the modification scope,
and don't touch other files.Review changes based on git diff.
Organize unintended changes, bug possibility, and test needs.What tests should I run to verify this change?
Show candidates only—don't run commands yet.Good. Run the proposed test commands.
If they fail, analyze the cause only—don't make additional fixes yet.Using this workflow lets you use Claude Code not as a simple auto-fix tool, but as an analyst + developer + reviewer + test assistant.
Bad example:
Restructure it well yourself.Good example:
First, propose only 3 improvement options.
For each option, explain pros, cons, and risk level.
Don't modify anything yet.Bad example:
Refactor the entire project.Good example:
Find refactoring candidates.
Choose only the 3 highest-priority files,
and explain why each needs refactoring.
Don't modify anything yet.Bad example:
Review it.Good example:
Review in the table format below.
| File | Issue | Severity | Fix Suggestion |After modifications, you must always check:
git status
git diffAlso ask Claude:
Summarize changes based on git diff,
and check for risky modifications.It's best not to read or paste these files:
.env.env.localcredentials.jsonprivate-key.pemid_rsaservice-account.jsonGood request:
Don't read the .env file.
Infer needed environment variable names and explain.Verify you're using Claude Code correctly.
The core of using Claude Code 300% better comes down to one line:
The most powerful baseline prompt is:
First, find relevant files.
Don't modify anything yet.
Explain the root cause,
and propose a fix plan only.
Once I approve, make minimal changes.
After modifications, review changes based on git diff.Once you master this workflow, Claude Code becomes not just an auto-completion tool, but a development partner that helps with project analysis, bug fixes, refactoring, tests, and code review.
Section 6. How to Read Files and Make Claude Understand Your Codebase
To use Claude Code well, reading many files is less important than reading the right files accurately.
Beginners usually request like this:
Analyze the entire project for me.But a good request starts like this:
First, find only files related to this feature.
Don't modify anything yet,
and explain which files you read and why.The goal of this unit is to teach Claude to understand your codebase this way.
As your codebase grows, asking Claude to read every file at once becomes inefficient.
Beginners don't need to memorize all internal tool names. But knowing these concepts is helpful:
package.json, README.md)auth, login, user)loginUser, JWT, TODO)CLAUDE.md creation)At first, you can make requests like this:
First, get a light understanding of the project structure.
Explain which files you read and why.
Don't modify files yet.With an unfamiliar project, rather than asking immediately about features or bugs, you should create a project map first.
Imagine you're a developer seeing this project for the first time and explain its structure.
Organize it in this order:
1. Project purpose
2. Main folder structure
3. Key configuration files
4. Files that appear to be execution entry points
5. Test-related files
6. Top 5 files to read first
Don't modify files yet.
Don't run any commands.If you already know which files you want to read, directly specifying them is best.
Read README.md and package.json,
and explain how to run this project and its main dependencies.
Don't modify files yet.You can also specify multiple specific files:
Read the following files and compare their roles.
- src/app.ts
- src/server.ts
- src/routes/auth.ts
Organize in a table which responsibility each file has.
Don't modify yet.It's even better to specify the output format:
Organize it in the following table format.
| File | Role | Important functions | Relationships with other files | Points to watch |When you don't know the filename, Claude should search for it first.
Find where the login feature is implemented.
Conditions:
- Find candidate files first.
- Don't modify files.
- Explain what role each file plays in the login flow.
- Distinguish between guessed and actually confirmed parts.Find where payment-related code is located.
Search based on these keywords:
- payment
- billing
- checkout
- invoice
- subscription
After finding related files,
explain each file's role and the overall payment flow.
Don't modify yet.Find where this error message is generated.
"Invalid access token"
Organize related files, functions, and call flow.
Don't modify yet.This approach makes Claude narrow down from related parts using keywords instead of blindly reading entire files.
When having Claude explain your codebase, always request evidence.
Explain the authentication structure.Explain the authentication structure.
Base the explanation on actual filenames and function names you confirmed.
For parts you're unsure about, mark them "needs confirmation" instead of guessing.Organize the authentication structure in this format.
1. Overall flow
2. Related files
3. Key functions
4. Data flow
5. Evidence from actual files confirmed
6. Parts still needing confirmation
Don't modify files yet.This way Claude's answers become more verifiable.
For mid-sized or larger projects, creating a "codebase map" first is helpful.
Create a codebase map for this project.
Organize it in this format.
1. App entry point
2. Routing structure
3. State management approach
4. API communication structure
5. Authentication structure
6. Database or storage access structure
7. Test structure
8. Build and deployment related files
9. Order of files for beginners to read first
Don't modify files yet.
Don't run commands.Good output format looks like this:
src/main.ts — app startup (high)src/routes/* — request handling by URL (high)src/auth/* — login, token handling (high)tests/* — test code (medium)package.json, .env.example — runtime environment (high)Once you have this map, future work becomes much faster.
When reviewing a codebase, order matters. Rather than blindly reading all of src, this order usually works well:
README.md
↓
package.json / pyproject.toml / go.mod etc.
↓
Environment example file
↓
App entry point
↓
Routing or main module
↓
Core domain code
↓
Test codeYou can request from Claude like this:
Recommend a file reading order for understanding this project.
Conditions:
- Choose only up to 10 files.
- Explain why each file should be read first.
- Base it only on files that actually exist.
- Don't modify files yet.This request is especially useful for beginners who don't know which files to start with.
If you don't want to repeat the same explanation every time, you can create CLAUDE.md in the project root.
CLAUDE.md is a Markdown file added to the project root, and Claude Code reads it at the start of each session and uses it as guidance for coding standards, architecture decisions, preferred libraries, review checklists, and so on.
Example CLAUDE.md for beginners:
# Project Guide
## Project Overview
This project is a web application that provides user login, signup, and payment features.
## Key Commands
- Run dev server: npm run dev
- Run tests: npm test
- Run linter: npm run lint
## Key Folders
- src/routes: routing
- src/components: UI components
- src/lib: common utilities
- tests: test code
## Work Rules
- Explain modification plans before modifying files.
- Don't read .env files.
- Break large refactoring into small steps.
- Summarize changes based on git diff after modification.After writing it, you can tell Claude:
Refer to CLAUDE.md and explain the structure of this project.
If there's any missing content, only offer suggestions to supplement.
Don't modify yet.However, CLAUDE.md is not a mandatory security measure. To block certain tasks, you need to use separate mechanisms like permissions or hooks.
While Claude Code being able to read files is convenient, be careful with sensitive information.
.env
.env.local
.env.production
credentials.json
service-account.json
private-key.pem
id_rsa
*.key
*.pemIt's good practice to always tell Claude like this:
Don't read .env, credentials, or private key files.
If needed, infer and explain only the environment variable names.To block even more securely, you can deny read permissions in settings. You can block sensitive file access by putting rules in permissions.deny of .claude/settings.json.
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Read(./config/credentials.json)"
]
}
}Beginners don't need to set up all complex permission rules from the start. But developing the habit of never pasting sensitive files to Claude is essential.
Using an IDE together lets you point specific files or code ranges to Claude more precisely.
When you have selected code in VS Code, Claude can see the highlighted code. On Mac use Option+K, on Windows/Linux use Alt+K to insert a mention that includes the file path and line numbers.
Explain @app.ts#20-45.
Organize what inputs this function takes and what outputs it returns.
Don't modify yet.If you don't use an IDE, you can write the filename and function name directly:
Explain the loginUser function in src/auth/login.ts file.
Also organize other functions this function calls.Rather than analyzing large files all at once, you need to set a purpose.
Explain the entire file.In this file, explain only the parts related to authentication.
Organize based on this criteria.
1. Related functions
2. Input values
3. Return values
4. External dependencies
5. Exceptional situations to watchOr you can request like this:
Don't summarize the entire file;
first scan the structure and tell me each section's role.
Then explain only the sections I choose in detail.Step-by-step approach to large files reduces context waste.
To understand a specific feature, "flow explanation" is more important than "file explanation".
Trace the flow from when a login request comes in until a response is returned.
Organize in this format.
1. Starting point
2. Function call order
3. What each function does
4. Database or external API calls
5. Points where errors can occur
6. Actually confirmed files and functions
Don't modify yet.Trace the flow of the user info lookup API.
If there are route, controller, service, and repository layers, explain them in order.
Organize based on actual filenames and function names.Trace what code runs when the login button is clicked.
Explain in order: component, state change, API call, error handling.
Don't modify yet.Test files are excellent material for understanding features.
Find test files related to this feature.
Based on what the tests describe, organize the feature requirements.
Don't modify the tests yet.Reading tests teaches you:
Request to understand features based on tests:
Read the test files for the payment feature,
and reverse-engineer the current payment feature requirements.
Write in this format.
| Test name | Verified behavior | Input | Expected result | Potential gap |README or documentation might differ from actual code. When that happens, have Claude compare the two.
Compare the execution method in README.md with the actual scripts in package.json.
If there are differences, organize in a table.
Don't modify files yet.Or:
Check if the API paths in the documentation match the actual routes in the route file.
If there are mismatches, organize with source files.
Don't modify yet.When documentation and code differ, it's better to organize the differences first rather than fix immediately.
Explain the entire structure of this project.
Conditions:
- Cover only important folders and files.
- Explain based on files you actually confirmed.
- Don't modify files yet.
- At the end recommend a file reading order for beginners.Find where [feature name] is implemented.
Conditions:
- First organize related file candidates.
- Explain each file's role.
- Include actual confirmed function names.
- Don't modify yet.Find where this error occurs.
Error message:
[error message input]
Conditions:
- Search for the error string.
- Distinguish direct occurrence from call flow.
- Don't modify; only organize problem candidates.Trace how [feature name] executes.
Organize in this format.
1. Starting point
2. Call order
3. Key functions
4. Data flow
5. Error handling
6. Confirmed files and functionsRecommend a file reading order for understanding this project.
Choose only up to 10 files.
Explain why each file should be read.
Don't modify yet.Check if the description in README.md matches the actual code.
If there are mismatches, organize in a table with source files.
Don't modify yet.Situation: You need to modify the login feature, but don't know where it is.
Find where the login feature is implemented.
Search keywords:
- login
- auth
- token
- session
- password
Find related files,
and explain what role each plays in the login flow.
Don't modify yet.Trace the flow from login request to response.
Organize in this format.
1. Request starting point
2. Function call order
3. Token generation or session handling location
4. Error handling location
5. Actually confirmed files and functionsFind places in the login flow prone to bugs.
Criteria:
- Input validation
- Password validation
- Token generation
- Session saving
- Error messages
- Exception handling
Don't modify yet;
only organize problem candidates and evidence.Choose the highest-priority problem and write a modification plan.
Include:
1. Files to modify
2. Why to modify
3. How to modify
4. How to test
5. Risk factors
Don't modify files yet.Following this flow lets Claude sufficiently understand the codebase before modifying.
Bad example:
Read all files and explain.Good example:
First understand the project structure,
then recommend the reading order for only the top 10 core files.
Don't modify yet.Bad example:
Explain authentication structure.Good example:
Explain authentication structure.
Include actual confirmed filenames and function names as evidence.
Mark uncertain parts as "needs confirmation".Bad example:
Find payment feature.Good example:
Find the payment feature.
Search using these keywords: payment, billing, checkout, invoice, subscription.Bad example:
Read .env file and explain the settings.Good example:
Don't read .env file.
Instead, base on .env.example or README and explain only the needed environment variable names.Bad example:
Explain login structure and fix any problems you find.Good example:
Explain only the login structure first.
If problems appear, don't fix them; organize only candidates.When starting Claude Code for the first time, check the items below:
CLAUDE.mdThe key to making Claude understand your codebase is this:
The most frequently used basic prompt is as follows:
First, find files related to this feature.
Don't modify yet.
Explain each file's role and the evidence you actually confirmed.
Mark uncertain parts as "needs confirmation".
Then, if modification is needed, propose only the plan.Developing this habit helps Claude understand your project more accurately, reduces unnecessary file reading, and minimizes risky modifications.
Unit 7. Creating a plan first before modifying with Plan Mode
Plan Mode is a feature that tells Claude Code to investigate and create a plan first, rather than immediately making changes.
Flow difference between normal mode and Plan Mode:
In Plan Mode, Claude investigates and creates a plan before proposing changes, and does not edit files until approval. File reading for exploration and shell commands can be executed through permission prompts.
Claude Code can modify files and execute commands. So assigning large tasks directly is risky.
Bad request:
Refactor the entire authentication structure for me.Good request:
Use Plan Mode to create a refactoring plan for the authentication structure first.
Investigate the related files,
and organize the files to modify, reasons for changes, potential risks, and testing methods.
Don't make any changes yet.Situations where Plan Mode is necessary:
You can switch modes by pressing Shift+Tab while Claude Code is running.
Basic mode cycle:
default → acceptEdits → planThree modes cycle:
You can also use Plan Mode for a single request.
Add /plan before a specific request in Claude Code:
/plan Create a plan for refactoring the login feature.
Investigate the related files and write only the modification plan.This method is useful when you mostly work in normal mode but want to use plan mode at specific moments.
You can also start with Plan Mode from the terminal from the beginning.
claude --permission-mode planOr:
claude -p planRunning this way starts the Claude Code session in Plan Mode from the beginning, so all requests are handled in Plan Mode.
The basic flow in Plan Mode is as follows:
Beginners should ensure Claude includes the following in Plan Mode:
Example of a good Plan Mode request:
/plan I want to add input validation to signup.
1. Related files / 2. Current behavior / 3. Files to modify
4. Modification content / 5. Files not to modify
6. Potential risks / 7. Testing methods
Don't modify files yet.When Claude creates a plan, don't approve immediately. You must review it by these criteria.
If the plan is insufficient, request this way:
The plan is still too broad.
Narrow the modification scope.
1. Files that must be modified
2. Files not to modify
3. Smallest change unit
4. How to revert if it failsWhen a plan is ready in Plan Mode, Claude Code asks how to proceed. Possible options:
You can also directly edit the proposed plan in a text editor with Ctrl+G.
Recommended for beginners: Approve and review each edit manually
Situation: Invalid access token error occurs at login.
Step 1. Request cause investigation in Plan Mode:
/plan I'm getting an "Invalid access token" error at login.
1. Where the error message is raised
2. Related files and functions
3. Possible causes
4. Most likely cause
5. Files to modify / 6. How to modify
7. Testing method / 8. Potential risks
Don't modify files yet.Step 2. Narrow the plan:
Good.
Make the modification scope smaller.
Based on the most likely cause only
rewrite the minimal modification plan.Step 3. Approve:
Good.
Proceed with the plan as proposed.
Limit modification to only files mentioned in the plan.
Let me review each edit.Step 4. Review changes:
Review the changes based on git diff.
1. Modified files
2. Reasons for changes
3. Bug possibility
4. Possibility of unintended changes
5. Tests to runSituation: I want to add a password confirmation field to the signup form.
/plan I want to add a password confirmation field to the signup form.
1. Current signup UI structure
2. Current validation structure
3. Components to modify
4. Validation logic to modify
5. Tests to add or modify
6. Error messages to show users
7. Potential risks / 8. Modification scope
Don't modify files yet.After the plan comes out, request in a more beginner-friendly way:
Explain the plan in a more beginner-friendly way.
For each modified file, explain why it's needed,
and let me know if there are alternatives that don't require modification.Then proceed in steps:
Good.
Proceed with only step 1 UI modification first.
Don't modify validation and tests yet.
After modification, summarize based on git diff.For large features, don't approve all at once. Break the plan into steps and execute.
Refactoring is where Plan Mode is most needed.
Bad request:
Clean up this code structure with refactoring.Good request:
/plan I want to refactor the auth module.
Goals:
- Don't change behavior.
- Reduce duplicate code.
- Make function names clearer.
- Keep tests from breaking.Include the following in the plan:
1. Current auth module structure
2. Duplicate or complex parts
3. Refactoring candidates
4. Priorities
5. Smallest first task
6. Files to modify
7. Files not to modify
8. Testing method
Don't modify files yet.Make sure to break refactoring plans into small steps:
Don't refactor everything at once,
pick only the safest first step.
Choose only tasks with no behavior changes.Plan Mode is not a "slower way to use Claude". Rather, on large tasks it's a feature that reduces failures and overall time.
Just because you use Plan Mode doesn't mean all risks disappear. In Plan Mode too, permission prompts apply the same as in normal mode, and file reading or shell command execution may occur during exploration.
Beginners should follow this:
Example request for sensitive information:
Investigate in Plan Mode, but
don't read .env, credentials, or private key files.
If needed, just describe environment variable names.Example for command execution restrictions:
If commands are needed during exploration, don't run them immediately.
First tell me the command candidates and reasons.When the plan is too broad:
The plan is too broad.
Break it down into the smallest safe change unit.
Write the first step at an executable level.When potential risks are insufficient:
Risks are insufficient.
Features that could break with this change,
affected tests,
and revert methods—add these.When test plan is insufficient:
Make the test plan more concrete.
Command candidates to run,
manual verification methods,
test cases to add—organize these separately.When evidence is insufficient:
Mark the file names and function names that support each modification proposal.
Distinguish assumed parts with "needs verification".For bug fixes:
/plan I want to fix the following bug.
Symptom: [enter symptom here]
Conditions:
- Investigate related files first.
- Don't modify files yet.
- List possible causes in order of likelihood.
- Propose the smallest modification plan.
- Distinguish files to modify from files not to modify.For feature additions:
/plan I want to add the following feature.
Feature: [describe feature here]
Content to include in plan:
1. Related files / 2. Current structure / 3. Files to modify
4. New files to create / 5. Testing methods
6. Potential risks / 7. Step-by-step execution order
Don't modify yet.For refactoring:
/plan I want to refactor the following area.
Target: [target module or file]
Principles:
- Don't change behavior.
- Keep change scope small.
- Tests must not break.
- First write only step 1 plan.
Don't modify yet.It's good to check Git status before and after using Plan Mode.
Before work:
git statusAfter work:
git diffWhen comparing plan and actual changes in Claude Code:
Compare the plan proposed in Plan Mode and the actual git diff.
1. Parts modified as planned
2. Parts that differ from the plan
3. Additionally modified files
4. Possibility of risky changes
5. Parts to revertThis question is very important. Because planned and actual modifications can differ.
If you use Plan Mode frequently, you can set it as the project default mode.
Example .claude/settings.json:
{
"permissions": {
"defaultMode": "plan"
}
}Recommendation criteria:
Mistake 1. Approve the plan immediately after seeing it
You must review the plan:
Check if there are parts of this plan where the modification scope is too broad.
Point out the most risky changes first.Mistake 2. Giving too large a goal in Plan Mode
Bad example: /plan Improve the entire project structure.
Good example:
/plan Create only step 1 plan for reducing duplicate code in the auth module.
Write it in a direction that doesn't change behavior.Mistake 3. Approve without a test plan
Add testing methods to verify this plan.
Separate automated tests and manual verification methods.Mistake 4. Not restricting sensitive files
Don't read .env, credentials, or private key files.
If needed, just describe required environment variable names.Mistake 5. Not checking diff after approval
Verify whether the plan and actual changes match based on git diff.The essence of Plan Mode is:
Most commonly used basic prompt:
/plan Before doing this task, investigate related files and create a plan.
Include the following in the plan.
1. Related files / 2. Current structure / 3. Files to modify
4. Files not to modify / 5. Reasons for changes
6. Potential risks / 7. Testing methods
8. Smallest step 1 task
Don't modify files yet.Plan Mode is a safety mechanism for using Claude Code securely, and at the same time a tool that elevates result quality. The larger the task, the more you should follow the order of Plan Mode → Review → Small approval → diff verification instead of executing immediately.
Lesson 8. Safely handle file modifications and command execution
The key to using Claude Code well is not blocking all tasks. The key is controlling the scope of modifications and command execution to be small while iterating quickly.
A formula beginners should remember:
Make small changes
↓
Verify immediately
↓
Execute only necessary commands
↓
Review the result and move to the next modificationA bad approach is "fix the entire project", a good approach is "modify only the src/auth/login.ts file and review with git diff".
Claude Code is fast. But because it's fast, without control you might end up modifying files you didn't intend to.
Efficient users don't give all permissions to Claude at once. Instead, they create small approval units.
Claude Code tasks can be divided into four main categories.
The most dangerous flow is modify → run command → fail → auto re-modify → repeat. Beginners must always separate reading, modifying, and execution.
File modification requests must include four things.
Bad example: Fix the login bug.
Good example:
Fix the login bug.
Conditions:
- Modify only the src/auth/login.ts file.
- Do not modify any other files.
- Summarize changes based on git diff after modification.If you only tell Claude "what to do", the scope can expand. You must also say "what not to do".
Advantages of this approach:
If you need to modify multiple files, don't approve all at once.
Bad example: Complete the signup feature. You can modify all necessary files.
Good example: First divide the work into 3 phases, then for each phase list the files to modify, what to change, how to test, and potential risks. Then execute one phase at a time.
A good flow for multi-file modifications is:
Don't run commands immediately; get candidates first.
Bad example: Run tests and fix if they fail.
Good example: Ask for test command candidates to verify this change, have them explain what each command checks, then approve only one.
Command execution sequence:
Request command candidates
↓
Confirm command purpose
↓
Approve only one
↓
Summarize execution results
↓
Analyze failure cause
↓
Request fix planNot all commands have the same risk level.
After modifying files, the most frequently used commands should be Git verification commands.
git status
git diffIn Claude Code, request it like this:
For commit messages: Ask Claude to write a commit message in Conventional Commits format based on git diff.
If you find it tedious to approve the same safe commands repeatedly, you can allow certain tools or commands.
Example of specifying permissions in project settings:
{
"permissions": {
"allow": [
"Read",
"Bash(git status)",
"Bash(git diff *)",
"Bash(npm test)",
"Bash(npm run lint)"
],
"deny": [
"Read(./.env)",
"Bash(rm -rf *)",
"Bash(sudo *)",
"Bash(git push *)"
]
}
}For beginners, the recommended approach is to start with small allowed scope. Efficiency comes from "allowing only frequently used safe tasks and continuing to control dangerous ones".
The CLI has a --dangerously-skip-permissions option to skip permission prompts.
Bad example:
claude --dangerously-skip-permissionsThis option seems convenient, but it allows Claude to proceed with file modifications and command execution too easily.
A better approach for beginners:
claude --permission-mode planOr in Claude Code, use /plan first to ask for a modification plan.
After file modification, in the terminal:
git status
git diffRun tests if necessary.
Ask Claude to review the modifications in the following format:
Pay special attention to the following items.
When tests fail, don't immediately say "fix it". First, you need to isolate the cause.
Bad example: Tests failed. Fix it yourself.
Good example: Ask to analyze the test failure cause, but don't modify files yet. Ask to list the failed test names, explain failure causes in order of likelihood, and distinguish between code problems and test expectation problems.
Test failure response flow:
Summarize failure log → List cause candidates → Distinguish code/test problems
→ Fix plan → Minimal modification → Re-testSituation: The app crashes when there's no access token during login.
Find related files and ask to write a modification plan only. Don't modify files yet. Ask to distinguish between files to modify and files not to modify.
Modify only the src/auth/login.ts file to return a clear error when access token is missing. Don't modify other files.
Check git diff and ask to summarize changes.
Get test command candidates to validate this change, but don't run yet.
Run only 1 test command with the narrowest scope. If it fails, ask to analyze only the cause.
Situation: There are multiple lint errors.
Bad request: Fix all lint errors.
Good request:
Situation: The build fails.
Package installation can change lock files and dependency structure. Don't approve immediately.
Beginners should ask whether to use existing code first before adding new packages if possible.
Mistake 1. Modifying too many files at once
Bad example: Fix all type errors in the entire project.
Good example: Categorize type errors by file, and ask to make a modification plan for only 1 file with the smallest impact scope first.
Mistake 2. Running commands immediately
Bad example: Run all necessary commands.
Good example: Ask for command candidates first, have them explain the purpose and risk level of each command. Don't run yet.
Mistake 3. Creating auto-fix loops after test failure
Bad example: Keep fixing until tests pass.
Good example: Analyze test failure causes and propose only the smallest fix plan. Don't modify until I approve.
Mistake 4. Not checking git diff
After modification, always check git status and git diff, and ask Claude to review changes.
Mistake 5. Approving dangerous commands
Commands like rm -rf, sudo, git reset --hard, npm publish, prisma migrate deploy should not be immediately approved by beginners. Ask for explanations first.
When modifying a single file:
Modify only [file path].
Goal: [modification goal]
Constraints: - Don't modify other files.
- Summarize based on git diff after modification.When getting only command candidates:
Tell me command candidates to verify this task.
- Don't run yet.
- Explain the purpose of each command.
- Mark high-risk commands.When analyzing execution results:
Analyze the just-executed command results. Organize in the following format.
1. Success or failure 2. Key message 3. Failure cause candidates
4. Files to check next 5. Whether modification is needed
Don't modify files yet.When getting plan only after test failure:
Analyze test failure cause.
- Don't fix yet.
- List failed tests.
- Distinguish between code and test problems.
- Propose minimal fix plan only.When requesting diff review:
Review current git diff.
Criteria: Goal alignment, unintended changes, bug potential,
Test sufficiency, parts to revertThe core of handling file modifications and command execution well is this:
The basic prompts you'll use most frequently are:
People who use Claude Code efficiently don't automate everything. They quickly allow frequently repeated safe tasks and control dangerous ones by breaking them down into smaller pieces.
Unit 9. Teach project rules with CLAUDE.md
CLAUDE.md is a file that tells Claude Code the rules and context it should always know about in this project. In simple terms, it's a project guide for Claude Code.
CLAUDE.md contains content like the following.
Project structure
Build commands
Test commands
Coding rules
Verification procedures before making changes
Warnings about sensitive files
Team workflowIt is a persistent guideline file that Claude Code reads at the start of each session. Since each session starts with a fresh context, CLAUDE.md and auto memory are used to transfer project knowledge across sessions.
Without CLAUDE.md, you would need to repeat the same explanation every session. For example, you might have to say these things every time.
This project uses pnpm.
Run tests with pnpm test.
Don't read the .env file.
Show me the plan first before making changes.
Check git diff before committing.Benefits of having CLAUDE.md:
Beginners don't need to write it perfectly from the start. Adding these 7 items is enough.
1. Project overview
2. Main folder structure
3. Run commands
4. Test commands
5. Coding rules
6. Work procedures
7. Prohibitions or warningsEven this much makes a difference in Claude Code's work quality.
The most basic location is the project root. You can also place it inside the .claude folder.
Here's how location, purpose, and sharing differ:
Beginners can start with one CLAUDE.md at the project root.
If it's hard to write from scratch, you can have Claude Code generate a draft. Running the /init command inside Claude Code analyzes your codebase and generates a starter CLAUDE.md that includes build commands, test instructions, and project rules. If CLAUDE.md already exists, it suggests improvements rather than overwriting it.
This is the recommended workflow for beginners.
Good CLAUDE.md is not long. It is clear, specific, and contains only frequently used information. Aim for under 200 lines per file.
Good rules:
- This project uses pnpm.
- Run tests with pnpm test.
- Authentication code is in src/features/auth.
- Explain the modification plan first before making file changes.Bad rules:
- Write code well.
- Organize it nicely.
- Test appropriately.
- Be secure on your own.pnpm test candidates.env, credentials, or *.pem filesCLAUDE.md is a file that provides project context to Claude. It's better to write it fact-focused rather than as overly strong commands.
Good example:
## Project Information
- This repository uses pnpm.
- The default test command is pnpm test.
- Auth code is in src/features/auth.
- API client is in src/lib/api.ts.Less good example:
You must always and absolutely only use pnpm.
Never make a mistake.
Follow my instructions unconditionally.CLAUDE.md is not a mandatory security mechanism. CLAUDE.md and auto memory are context passed to Claude, not forced settings. To block certain behavior, you need to use permissions or hooks.
# CLAUDE.md
## Project Overview
This project is an application for [project purpose].
## Tech Stack
- Language: [example: TypeScript]
- Framework: [example: Next.js]
- Package Manager: [example: pnpm]
- Testing Tool: [example: Vitest, Jest, Playwright]
## Main Commands
- Dev server: [example: pnpm dev]
- Test: [example: pnpm test]
- Lint: [example: pnpm lint]
- Build: [example: pnpm build]
## Main Folders
- src: application source code
- src/components: UI components
- src/features: feature-based code
- src/lib: common utilities
- tests: test code
## Work Rules
- Explain the modification plan first before editing files.
- Break large tasks into small steps.
- Distinguish between files to modify and files not to touch.
- Summarize changes based on git diff after edits.
- Explain test command candidates and reasons before running.
## Code Style
- Follow existing code style first.
- Don't do unnecessary large-scale refactoring.
- Separate functionality changes from formatting changes when possible.
- Before adding new packages, check if existing dependencies can solve it.
## Warnings
- Don't read .env, .env.local, credentials, or private key files.
- Don't output sensitive information like API keys, tokens, or passwords.
- Always explain deletion, deployment, or DB migration commands before running.
- Explain the reason before changing package.json or lock files.After writing, ask Claude to review it.
This is an example for a web frontend project.
# CLAUDE.md
## Project Overview
This project is a React-based frontend application.
## Main Commands
- Dev server: pnpm dev
- Test: pnpm test
- Lint: pnpm lint
- Build: pnpm build
## Main Folders
- src/components: shared UI components
- src/pages or src/app: routing
- src/features: feature-based code
- src/lib: API client and utilities
- tests: test code
## Work Rules
- Find related components and usage locations first before UI changes.
- Separate style changes from logic changes when possible.
- Explain changes that may affect accessibility.
- After edits, suggest test command candidates if needed.
## Warnings
- Don't read .env files.
- Before adding new UI libraries, check if possible with existing components.This is an example for a backend API project.
# CLAUDE.md
## Project Overview
This project is a REST API server.
## Main Commands
- Dev server: pnpm dev
- Test: pnpm test
- Lint: pnpm lint
- Build: pnpm build
## Main Folders
- src/routes: API routes
- src/controllers: request handling
- src/services: business logic
- src/repositories: data access
- tests: test code
## Work Rules
- Check routes, services, and tests together before API changes.
- If response format changes, check affected tests.
- Don't run DB migrations right away; explain the plan first.
- Follow existing error handling patterns.
## Warnings
- Don't read credentials, private key, or .env files.
- Don't run commands that may affect production databases.This is an example for a library project.
# CLAUDE.md
## Project Overview
This project is a reusable library package.
## Main Commands
- Test: pnpm test
- Type check: pnpm typecheck
- Build: pnpm build
- Release validation: pnpm lint && pnpm test && pnpm build
## Main Folders
- src: library source code
- examples: usage examples
- tests: test code
- docs: documentation
## Work Rules
- Explain whether public API changes are breaking changes.
- When changing type definitions, check usage examples and tests together.
- Always explain the reason before modifying release-related files.
- Verify that documentation matches code examples.
## Warnings
- Don't run npm publish commands.
- Don't change package.json version before approval.In team projects, you should separate rules everyone needs to follow from personal preferences.
Team common rules go in CLAUDE.md.
## Team Common Rules
- Use pnpm as the package manager.
- Run pnpm lint and pnpm test before PR.
- Put auth-related code in src/features/auth.Personal preferences go in CLAUDE.local.md.
## Personal Work Preferences
- Receive explanations in English.
- Always request step-by-step plans before making changes.
- Approve test commands before running them.It's good to add CLAUDE.local.md to .gitignore so it's not shared.
Putting everything in CLAUDE.md can actually lower quality.
Bad example:
## Secret Information
- DATABASE_URL=postgres://...
- API_KEY=sk-...Good example:
## Environment Variables
- Refer to .env.example for needed environment variable names.
- Don't read the actual .env file.
- Don't output API key, token, or password values.CLAUDE.md is a document you tell Claude about. Permission settings limit what Claude can do. This matters.
"Read(./.env)"It's good to write this in CLAUDE.md.
- Don't read .env files.But to block it more reliably, set permissions in .claude/settings.json.
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Read(./config/credentials.json)"
]
}
}Inside Claude Code, you can check the CLAUDE.md, CLAUDE.local.md, and rules files loaded in the current session using the /memory command.
If Claude doesn't seem to be following CLAUDE.md, check it this way.
/memoryThen you can ask Claude.
Based on the CLAUDE.md content loaded in the current session,
summarize the work rules for this project.If there's a problem, check the following.
At first, one CLAUDE.md is enough. But as projects grow, you can split rules.
my-project/
├── CLAUDE.md
├── frontend/
│ └── CLAUDE.md
├── backend/
│ └── CLAUDE.md
└── infra/
└── CLAUDE.mdFor beginners, start this way.
Small project → one root CLAUDE.md
Large project → add CLAUDE.md by large areas like frontend/backend
Team project → separate common and personal rulesOne thing to watch for is rule conflicts. If there are conflicts like these, Claude can get confused, so it's good to regularly clean up outdated or conflicting guidelines.
Instead of putting all content directly in CLAUDE.md, you can import other files. You can import other files using @path/to/import syntax, and both relative and absolute paths work.
Example:
# CLAUDE.md
## Project Rules
This repository uses pnpm.
Explain the plan first before making changes.
## Additional Documents
@docs/architecture.md
@docs/testing.mdThe recommended approach for beginners is this:
Put only core rules in CLAUDE.md.
Put long documents in the docs/ folder.
Import only needed documents with @.However, too many imports can increase context size, so it's better to start with one short CLAUDE.md.
In a team, CLAUDE.md should be managed as an AI work guide, not just personal notes.
Team operation principles:
1. Put only common team rules in CLAUDE.md.
2. Put personal preferences in CLAUDE.local.md.
3. Update CLAUDE.md when commands change.
4. Review CLAUDE.md changes in PR.
5. Never put sensitive information in it.Good things to put in team CLAUDE.md:
If you leave the CLAUDE.md you created unchanged, it becomes outdated documentation. Update it in these cases.
npm test → pnpm testsrc/pages → src/appWhen Claude repeats the same mistake for the second time, or when code review finds something Claude should know, or when you repeat the same explanation every session, it's good to add it to CLAUDE.md.
Bad example: 500 lines of full architecture docs, all meeting notes, all API specs, old TODO lists
Good example: Core rules, package manager, test commands, plan-first rule, don't read .env
Bad example: "Write good code", "test well"
Good example: "When adding features, first suggest related test candidates", "Summarize changes based on git diff after edits"
Bad example: "Always explain in English", "Always be very detailed"
If it's not a rule all team members need, put it in CLAUDE.local.md.
Bad example: "The real API key is sk-...", "DB password is ..."
Good example: "Don't read the actual .env file", "Check needed environment variable names based on .env.example"
Writing something in CLAUDE.md doesn't mean 100% enforcement. Use permission settings together if you want to enforce something.
CLAUDE.md is a file that stores content you'd otherwise explain to Claude Code repeatedly.
Here's the core idea.
Beginners only need to remember these basic items.
A well-made CLAUDE.md means you don't have to educate Claude Code from scratch every time. As projects grow, the value of CLAUDE.md grows too.
Section 10. Understanding Configuration File Structure
Claude Code's settings are divided into user-wide settings, project-shared settings, project-personal settings, and enterprise-managed settings.
Beginners can understand it this way:
~/.claude/settings.json.claude/settings.json.claude/settings.local.jsonIf you don't understand the configuration file structure, several problems arise.
.envUnderstanding the configuration structure lets you control Claude Code more efficiently.
The three most important configuration files are:
~/.claude/settings.json.claude/settings.json.claude/settings.local.jsonWhether each file is included in Git:
Configuration files in your project are organized like this:
my-project/
├── .claude/
│ ├── settings.json
│ └── settings.local.json
├── CLAUDE.md
├── package.json
└── src/User-wide settings live outside the project.
~/.claude/settings.jsonOn Windows, ~/.claude is typically interpreted like this:
%USERPROFILE%.claudeClaude Code settings follow a priority order when the same item exists in multiple places.
.claude/settings.local.json (only for me on this project).claude/settings.json (all team members on this project)~/.claude/settings.json (default for all my projects)Even if user settings look like this:
{
"permissions": {
"defaultMode": "acceptEdits"
}
}If project settings look like this:
{
"permissions": {
"defaultMode": "plan"
}
}On that project, the project settings take priority.
~/.claude/settings.jsonPut your personal settings you want applied across all projects here.
{
"outputStyle": "Explanatory",
"permissions": {
"defaultMode": "plan"
}
}.claude/settings.jsonPut settings your entire team must follow here.
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Bash(rm -rf *)",
"Bash(git push *)"
],
"allow": [
"Bash(git status)",
"Bash(git diff *)",
"Bash(pnpm test)",
"Bash(pnpm lint)"
],
"defaultMode": "plan"
}
}.claude/settings.local.jsonPut settings that only you use on this project here.
{
"outputStyle": "Explanatory",
"env": {
"DEBUG": "app:*"
}
}You don't need complex configuration from the start. As a beginner, creating just one .claude/settings.json file in your project is enough.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"defaultMode": "plan",
"allow": [
"Bash(git status)",
"Bash(git diff *)",
"Bash(pnpm test)",
"Bash(pnpm lint)",
"Bash(pnpm build)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Read(./config/credentials.json)",
"Bash(rm -rf *)",
"Bash(sudo *)",
"Bash(git push *)",
"Bash(npm publish *)"
]
}
}The above configuration does three things:
defaultMode: "plan"allowdenyBeginners don't need to create complex configurations all at once. Starting with just sensitive file blocking, dangerous command blocking, and Plan Mode defaults is enough.
$schemaAdding $schema at the top of your configuration file lets your editor help with autocomplete and validation.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json"
}With $schema, editors like VS Code and Cursor that support JSON Schema can provide autocomplete and inline validation.
Beginners should include $schema when creating configuration files.
The most commonly used setting is permissions. Its basic structure is:
{
"permissions": {
"allow": [],
"deny": [],
"ask": [],
"defaultMode": "plan"
}
}allowdenyaskdefaultMode{
"permissions": {
"allow": [
"Bash(git status)",
"Bash(git diff *)",
"Bash(pnpm test)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Bash(rm -rf *)",
"Bash(git push *)"
],
"ask": [
"Bash(pnpm install *)",
"Bash(docker *)"
],
"defaultMode": "plan"
}
}With this setup, git status, git diff, and pnpm test run quickly, while .env reads and dangerous commands are blocked.
defaultMode determines which permission mode Claude Code starts in.
defaultplanacceptEditsbypassPermissionsIf you want to run Plan Mode just once from the terminal:
claude --permission-mode planClaude Code detects configuration file changes and reloads most settings even in running sessions.
/model or restart to confirm/clear or restart to confirmAfter changing settings, confirm in Claude Code like this:
/status/statusTo confirm settings are applying correctly, use /status in Claude Code.
~/.claude/settings.json is loaded.claude/settings.json is loaded.claude/settings.local.json is loadedsettings.json is a JSON file. Watch out for commas, quotes, and comments.
Bad example (trailing comma):
{
"permissions": {
"defaultMode": "plan",
}
}Good example:
{
"permissions": {
"defaultMode": "plan"
}
}JSON doesn't support comments either. If there are issues after editing settings, check errors with /status.
On team projects, split configurations like this:
.claude/settings.json.claude/settings.local.json~/.claude/settings.jsonClear roles for each file reduce configuration conflicts among team members.
CLAUDE.md and settings.jsonThis is what confuses beginners most.
You can put env in Claude Code settings.
{
"env": {
"NODE_ENV": "development",
"DEBUG": "app:*"
}
}But be careful. Don't put real API keys or passwords in env.
Manage sensitive information in .env or secret management tools, and block Claude from reading them.
If you want to change your response style, you can set outputStyle.
{
"outputStyle": "Explanatory"
}To open the settings menu in Claude Code:
/configBeginners should put output style in personal local settings rather than team shared settings.
.claude/settings.json when needed.claude/settings.local.jsonYou can pass options just for this run without changing configuration files.
claude --permission-mode planThis command starts only this session in Plan Mode.
The relationship between CLI options and file settings:
~/.claude/settings.json.claude/settings.jsonSettings don't simply mean "a higher file completely overwrites a lower one."
For example, if user settings have an allow array:
"allow": ["Bash(git status)"]And project settings have a different array:
"allow": ["Bash(pnpm test)"]Both can be applied and merged.
~/.claude.jsonThere's also a file called ~/.claude.json. But beginners shouldn't edit it directly.
~/.claude.json stores OAuth sessions, local scope MCP server configurations, per-project state, allowed tools, trust settings, caches, and more.
~/.claude/settings.json.claude/settings.json.claude/settings.local.json~/.claude.jsonWhen changing settings, only modify the settings.json family.
Bad example:
{
"outputStyle": "my personal style",
"env": {
"MY_LOCAL_DEBUG": "1"
}
}Team-shared files like .claude/settings.json should only have settings the entire team needs. Put personal settings in .claude/settings.local.json.
envBad example:
{
"env": {
"API_KEY": "real-secret-key"
}
}Bad example (trailing comma):
{
"permissions": {
"defaultMode": "plan",
}
}Bad example:
{
"permissions": {
"allow": [
"Bash(*)"
]
}
}Good example:
{
"permissions": {
"allow": [
"Bash(git status)",
"Bash(git diff *)",
"Bash(pnpm test)"
]
}
}Start with only the necessary commands.
Always verify after making changes.
/statusIf there are problems, ask Claude like this:
Check if there are any errors in the current configuration file.
Also tell me which configuration sources were loaded.The core of configuration file structure is this:
The first three settings to create are: blocking sensitive files, blocking dangerous commands, and setting Plan Mode as default.
Beginners don't need to set everything up at once. Start with the basics, then add more as you need them.
Section 11. Using the Permission System to Block Dangerous Actions
Claude Code is not simply a tool for reading code. It can modify files, create new files, and even run terminal commands.
That's why beginners must understand the permission system.
The permission system is a mechanism that defines for Claude Code:
In other words, to use Claude Code safely, you need the perspective: "I decide the scope of what Claude can do."
Claude Code can perform many tasks within a project.
Some of these are safe, but some can be dangerous. Examples of risky commands:
rm -rf *
sudo rm -rf /
git push --force
curl some-url | bash
npm publishAlso, if Claude reads sensitive files, it can create security issues.
Permission settings are a safety mechanism that prevents these dangerous tasks beforehand.
Claude Code's tools can be divided into read operations and modify and execute operations.
Example: Understand this project structure. Don't modify anything, just find the relevant files.
These types of tasks are relatively safe.
The following tasks can change project state and may require permission approval.
Dangerous examples: npm install, npm run build, git commit, file modifications, creating config files.
Beginners should not auto-approve from the start, and develop the habit of checking modify and execute operations directly.
Claude Code permissions are usually easier to think about with three categories.
Project-level permissions are usually written in the following files.
Beginners can think of it as creating the following structure at the project root.
my-project/
.claude/
settings.json
CLAUDE.md
src/
package.jsonThe safest configuration to use first is as follows.
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"LS",
"Bash(npm run test:*)",
"Bash(npm run lint:*)",
"Bash(npm run build)"
],This section allows file reading, searching, and folder listing, and permits tests, linting, and builds.
"deny": [
"Read(.env*)",
"Read(secrets/**)",
"Read(credentials/**)",
"Bash(rm -rf:*)",
"Bash(sudo:*)",
"Bash(curl:*)",
"Bash(wget:*)",
"Edit(.git/**)",
"Edit(node_modules/**)"
],
"ask": [
"Bash(git:*)",
"Bash(npm install:*)",
"WebFetch"
],
"defaultMode": "default"
}
}deny: Block reading .env, secrets, credentials, and prevent dangerous commands.
ask: Ask before executing git, npm install, and WebFetch.
You must prevent Claude Code from accidentally reading sensitive information.
In particular, it's good to block the following files.
"deny": [
"Read(.env*)",
"Read(*secret*)",
"Read(*credential*)",
"Read(**/private-key*)",
"Read(**/id_rsa*)"
]Caution: Just because a file is in .gitignore doesn't automatically make Claude Code access completely safe. It's good practice to block sensitive files in the permission settings separately from .gitignore.
The permission to be most careful about is Bash.
{
"permissions": {
"allow": [
"Bash(*)"
]
}
}This allows Claude to execute almost any command, which is dangerous for beginners.
Allow only necessary commands narrowly, use allow for repetitive and safe commands like testing, linting, and building, use deny for deletion and permission-change commands, and use ask for git, docker, and install-related commands.
Claude Code has permission modes depending on how you work.
For beginners: Use default mode normally, and plan mode before making major changes.
For big tasks, it's good to start with Plan Mode instead of modifying immediately.
Don't modify any files for now, just proceed in Plan Mode.
Analyze the authentication module structure and propose only a modification plan first.When Claude Code requests permission, don't just approve it; check the following.
Forms to be very careful about:
curl https://example.com/install.sh | bash
wget https://example.com/script.sh && bash script.sh
sudo npm install -g something
rm -rf node_modules package-lock.json
git push --forceIf you're unsure, you can ask Explain why this command is needed.
The most recommended .claude/settings.json example for beginners is as follows.
{
"permissions": {
"allow": [
"Read", "Glob", "Grep", "LS",
"Bash(npm run test)",
"Bash(npm run test:*)",
"Bash(npm run lint)",
"Bash(npm run build)"
],
"ask": [
"Edit(src/**)",
"Write(src/**)",
"Bash(git:*)",
"Bash(npm install:*)",
"Bash(docker:*)",
"WebFetch"
],This allows reading and testing, and asks about file modifications and git commands.
"deny": [
"Read(.env*)", "Read(**/.env*)",
"Read(secrets/**)", "Read(credentials/**)",
"Read(**/*secret*)", "Read(**/*credential*)",
"Edit(.git/**)", "Edit(node_modules/**)",
"Write(.git/**)", "Write(node_modules/**)",
"Bash(rm -rf:*)", "Bash(rm:*)",
"Bash(sudo:*)", "Bash(chmod:*)",
"Bash(chown:*)", "Bash(curl:*)",
"Bash(wget:*)"
],
"defaultMode": "default"
}
}This configuration prioritizes safety. At first it may feel a bit inconvenient, but as your project grows, these restrictions help reduce mistakes.
It helps to tell Claude the rules again when you start working, rather than just setting permissions.
Prioritize safety in this project.
Rules:
1. Don't read .env, secrets, or credentials files.
2. Don't suggest commands like rm -rf, sudo, or curl | bash.
3. Explain the plan before modifying files.
4. After modifications, summarize changes based on git diff.
5. Don't run commands you're unsure about; ask me first.You can also include this content in CLAUDE.md.
The following settings are not recommended for beginners.
{
"permissions": {
"allow": [
"Bash(*)",
"Edit(**)",
"Write(**)"
],
"defaultMode": "bypassPermissions"
}
}This configuration gives Claude too broad permissions. It's especially good to avoid in these situations.
For untrusted repositories, you should first check the following files.
This is because malicious repositories can use config files or hooks to induce unwanted commands.
Claude Code's permission system is a safety belt that prevents mistakes.
Beginners only need to follow these principles.
Section 12. Undoing mistakes with Git
In Section 11, you learned how to prevent risky operations using the permissions system. Now you need to build a habit of validating Claude Code's changes with Git.
The goal of this section is to help you confirm these five things on your own after Claude Code modifies code.
Git is not just a tool for saving changes all at once. Instead, think of it as a safety mechanism for reviewing modified files and selecting only the changes you want to commit.
After Claude Code modifies a file, always start by requesting this.
Run git status and give me a summary of the currently changed files.
Distinguish between modified files, newly created files, and deleted files.You can also check directly in the terminal.
git statusgit status shows the differences between your current working directory and the staging area, as well as files that Git is not yet tracking.
As a beginner, you only need to watch for these three states when viewing git status output.
One important thing to note: git status alone doesn't show you what changed. git status shows you "which files changed," while git diff (covered next) shows you "what changed within the files."
Once you've confirmed the list of changed files, next review the differences.
git diffHere's how to ask Claude for help.
Review git diff and explain the changes in a way a beginner can understand.
For each file, describe what was added, what was deleted, and why this change is needed.As a beginner, you only need to understand these symbols in the diff first.
- deleted line
+ added lineFor example, if you see this diff:
- const timeout = 3000;
+ const timeout = 10000;This means the timeout value was increased from 3 seconds to 10 seconds. At this point, you can ask Claude:
In this diff, pick out only the parts where behavior changes.
Distinguish between simple formatting changes and actual logic changes.This question is important because when Claude modifies multiple files, functional changes and formatting changes can get mixed together.
In Git, "changes in progress" and "changes to include in the commit" are separate.
The diff you see before running git add:
git diffAfter staging, to see what will actually go into the commit:
git diff --stagedThe recommended workflow for beginners is:
git status
git diff
git add <filename>
git diff --staged
git commitRequest it from Claude like this:
Don't git add yet; review git diff first.
If everything looks good, suggest which files I should stage.After staging, verify again:
Review git diff --staged and summarize what will go into this commit.
Also check if any unnecessary files got included.Claude Code is directly connected to Git and can help with commit messages and PR creation. However, as a beginner, you should ask Claude to separate review from execution rather than asking to commit immediately.
A sample prompt to request review before committing:
Review the current changes before committing.
1. Check the list of changed files with git status.
2. Check the actual changes with git diff.
3. Look for unintended changes, risky changes, or possible sensitive data exposure.
4. Tell me which parts need testing.
5. Suggest a commit message, but don't commit yet.The key is the last sentence.
Once you've determined the changes are safe, request a commit message.
Propose 3 commit messages for this change.
First check if the project uses conventional commits,
and format them accordingly if it does.Conventional commit examples:
fix: handle empty user profile response
feat: add validation for signup form
refactor: simplify auth token parsingIf you want to let Claude handle the commit directly, say:
Check git status and git diff --staged again,
and if everything is fine, commit with the suggested message.
Show me the list of files to be included before committing.Reverting in Git can be risky, so beginners should first distinguish between different situations.
If you want to discard changes to a specific file:
git restore <filename>Request it from Claude like this:
Check if there are any uncommitted changes that are safe to revert.
Suggest the revert command but don't execute it yet.To keep file modifications but unstage them:
git restore --staged <filename>This command removes files from the commit candidates, but does not delete the file contents.
Adjusting the commit itself requires extra caution. For beginners, follow this principle.
Never reset commits that have been pushed to the remote repository on your own. First explain the situation to Claude and have them compare whether revert or reset is better.
Safe question example (if you haven't pushed yet):
I want to revert the commit I just made.
I haven't pushed it yet.
Explain which of reset, revert, or amend is safest,
and don't execute the command until I approve.If you've already pushed:
I want to revert a commit that's already been pushed to the remote repository.
Prioritize safe methods that don't rewrite history.This section links to Section 11's permissions system. Claude Code starts with read-only permissions by default, and requests explicit approval for additional tasks like file editing, test execution, or command execution.
Also, the .git directory is included in protected paths, so dangerous Git commands are not auto-approved. The recommended principle for beginners is:
This configuration is for beginner learning. In real projects, adjust it to match your team's policies and branching strategy.
Claude Code can help create PRs too. Here's the beginner-friendly prompt for reviewing before creating a PR.
Review the current changes before creating a PR.
1. Check git status
2. Check git diff --staged
3. Verify if testing is needed
4. Suggest a PR title
5. Draft PR description
6. Summarize risks the reviewer should watch for
Don't create the PR yet.A good PR description follows this structure.
## Summary of changes
-
## Testing
-
## Points for reviewer to verify
-
## Risk factors
-After Claude Code modifies code, repeat this routine.
git status
git diffThen ask Claude:
Review the current changes.
Separate intended changes from unintended ones and explain.If everything looks good, stage the files.
git add <filename>Verify again after staging.
git diff --stagedFinally, commit.
git commit -m "message"The most important habit for a beginner is this one sentence.
git status is the command to check which files changed.
git diff is the command to check what changed within files.
git diff --staged is the command to check what changes will actually go into the commit.
Even if you let Claude Code handle commits, you must always verify the list of changed files and a diff summary before committing.
Revert commands have different risk levels depending on the situation, so it's safest not to auto-approve reset --hard, clean -fd, and push --force at the beginner stage.
Section 13. Making model selection easy to understand
Choosing a model in Claude Code can seem complicated at first. You encounter names like opus, sonnet, haiku, default, opusplan, sonnet[1m].
But as a beginner, you can understand it like this:
sonnet is an alias for the latest Sonnet for everyday coding work, opus is an alias for the latest Opus for complex reasoning tasks, and haiku is an alias for a fast and efficient Haiku for simple work. opusplan is a special mode that uses Opus during plan mode and switches to Sonnet during execution.
As of the writing date, the official model comparison highlights Claude Opus 4.8, Claude Sonnet 4.6, and Claude Haiku 4.5 as the latest comparison models. Opus 4.8 is the strongest for complex reasoning and agentic coding, Sonnet 4.6 balances speed and intelligence, and Haiku 4.5 is the fastest.
For beginners, think of it this way:
Model pricing also differs. Opus 4.8 costs $5 per 1M input tokens and $25 per 1M output tokens, Sonnet 4.6 is $3 input and $15 output, and Haiku 4.5 is $1 input and $5 output. Since prices change, this reflects the writing date only. In actual teaching, checking the official pricing table should become a habit.
As a beginner, you don't need to change models frequently from the start. Claude Code has a default option, which is the recommended base model for your account type or environment.
According to official documentation:
For beginners, this principle is the safest.
You can ask Claude like this:
Determine which model would be best for my current task.
Among fast, balanced, and high-performance models,
explain which would be good to use and why.To check or change your model in Claude Code, use this command in your session:
/modelIf you want to switch to a specific model immediately, type:
/model sonnet
/model opus
/model haikuWhen starting a session from the terminal, type:
claude --model sonnetYou can also set it via environment variable:
ANTHROPIC_MODEL=opusHowever, when you change models, the new model will re-read your existing conversation history for the next response. In long sessions, this can increase cost and time, so it's best to switch models only when necessary.
Haiku is a fast and cost-efficient model. In official model comparisons, Haiku 4.5 is classified as the fastest model.
Haiku is suitable for:
However, if you ask Haiku to make too complex a judgment, the quality of results may suffer. For example, with authentication structure changes, database migrations, or large refactoring plans—tasks where mistakes are costly—Sonnet or Opus is better than Haiku.
Sonnet is the most well-balanced choice for everyday use in Claude Code. Official documentation describes the sonnet alias as the latest Sonnet model for routine coding work.
Sonnet is suitable for:
Most beginners can think of Sonnet as their default development model.
Signs that Sonnet isn't enough:
In these cases, upgrading to Opus or using opusplan with plan mode is good.
Opus is suited for complex reasoning and long-horizon tasks. The official model overview describes Opus 4.8 as the strongest for complex reasoning, long-horizon agentic coding, and tasks requiring high autonomy.
Opus is needed for:
Typical situations where Opus is good:
However, Opus may have higher costs. Especially with the latest Opus and Sonnet models, adjusting effort can be a better control tool than switching models.
opusplan is a very useful option for beginners. In plan mode, it uses Opus for complex reasoning and architecture decisions, then switches to Sonnet in execution phase for implementation.
In other words, here's the idea:
How to use:
claude --model opusplanOr during a session:
/model opusplanRecommended situations:
For beginners, opusplan is a good compromise between "always using expensive models" and "struggling with lightweight models from the start".
Models like sonnet[1m] and opus[1m] with [1m] are used for long sessions or large codebases. Opus 4.6+ and Sonnet 4.6 support a 1 million token context window, and availability depends on model and plan.
As a beginner, you can judge like this:
Just because 1M context is available doesn't mean it's always better. Including more content means the model must read more, and costs and time can grow. It's safer to first have the model read only necessary files, and consider 1M context only if that's insufficient.
In the latest Claude Code, both model and effort matter. Effort level controls adaptive reasoning—low effort is fast and cheap for simple tasks, and high effort provides deeper reasoning for complex problems.
Opus 4.8 and Opus 4.7 support low, medium, high, xhigh, max, and Opus 4.6 and Sonnet 4.6 support low, medium, high, max.
By beginner standard:
Configure like this:
/effort
/effort highTo set it when starting:
claude --model opus --effort xhighThe key point is this:
Claude Code documentation mentions ultrathink as a way to request deeper reasoning in a single turn. Including ultrathink in your prompt requests deeper reasoning for that turn, but it doesn't change the effort level passed to the API.
Usage example:
ultrathink.
Analyze this bug's cause deeply based on logs and code flow.
Don't fix yet—list possible root causes by priority.However, using ultrathink every time increases cost and time, and causes excessive reasoning for simple tasks. The principle to remember is:
Model names change frequently. Official documentation explains that aliases point to provider-recommended versions and can be updated over time. To fix a specific version, use the full model name or set an environment variable.
For example, at Anthropic API, opus currently resolves to Opus 4.8 and sonnet to Sonnet 4.6, but on Bedrock, Vertex, and Foundry, aliases may resolve to different versions.
So it's safer to write in educational guides like this:
Model names in this guide are based on the writing date.
Before actual use, verify with /model screen and official documentation.For team documentation, it's better to write like this than hardcoding specific model names:
Writing this way means guides age less quickly when model versions change.
As a beginner, you can get by with just these rules:
Real-world prompt example:
Recommend a Claude Code model best for this task.
Task details:
- May need to modify multiple files
- Must first understand existing structure
- Must add tests too
Among haiku, sonnet, opus, opusplan, which fits best?
Compare from cost, speed, and accuracy perspectives.
Don't change models yet—just recommend./model haiku
Summarize what src/auth/session.ts does
in a way even a beginner can understand.
Don't make any changes./model sonnet
Investigate the issue where login error messages don't show.
First explain the cause, then propose a fix plan.
If I approve, go ahead and fix it./model opusplan
Use Plan mode to create an auth module refactoring plan.
Read related files and map impact scope and risk factors.
Don't modify files yet./model opus
/effort xhigh
ultrathink.
Since the recent deployment, payment completion callbacks fail intermittently.
Look at logs, router, and payment service code together
and analyze possible causes by priority.
Don't fix yet.Model selection in Claude Code isn't about "choosing the single best model." It's about choosing the right model for your task's difficulty.
haiku is suited for fast exploration and summarization.
sonnet is suited for general coding work.
opus is suited for complex reasoning, design, and difficult bugs.
opusplan is a compromise that uses a high-performance model for planning and executes efficiently.
Use /model to check and change your current model.
/effort is an auxiliary tool to adjust reasoning strength within a model.
Model names and defaults can change, so always check official documentation and the /model screen.
In the next Section 14, we cover how to track costs and reduce waste.
Claude Code costs are fundamentally based on token usage. Tokens are the units Claude uses to calculate input it reads, output it generates, information exchanged during tool use, and long conversation context.
For beginners, think of it this way:
To check costs and usage within a Claude Code session, use this command:
/usageThree items matter for beginners:
Important: the dollar amount from /usage is a local estimate. For actual billing, check the usage page in Claude Console.
Here's how to understand example output:
Total cost: $0.55
Total duration (API): 6m 19.7s
Total duration (wall): 6h 33m 10.2s
Total code changes: 0 lines added, 0 lines removedA beginner-friendly follow-up prompt:
Looking at my current /usage results, explain
what caused cost growth in a way I can understand.
Among model, context, tool use, and long output,
which had the most impact?Older guides or documentation may call cost checking /cost. However, the latest Claude Code cost management docs use /usage as the standard command.
In this guide, we standardize as follows:
In current Claude Code, check costs and usage
with /usage.
If older resources mention /cost,
check /usage first.For educational documentation, write:
Check usage: /usage
Check or set credit limits: /usage-creditsA common beginner request:
Analyze this whole project for me.This seems convenient but makes Claude read many files, increasing costs.
A better request:
Find files related to login first.
Don't modify code, just list the top 5
likely candidates with reasons.Or narrow it down:
Don't read the whole project.
Check only package.json, README, and src/auth
first.As Claude Code sessions grow, previous messages, file contents, and tool results build up in context. When switching to unrelated work, use /clear to start fresh.
When switching tasks, do this:
/clearBut if you want to find the session later, name it first:
/rename auth-bugfixThe beginner rule is simple:
Pasting entire test failure logs to Claude increases costs.
Bad example:
Analyze this entire test log for me.Better request:
Analyze only the first failure cause in this log.
Skip duplicate stack traces and focus on
the actual error message and relevant files.Build this habit early:
Don't read the entire log.
Just check lines containing ERROR, FAIL,
or Exception and their surroundings.Opus and similar high-performance models excel at complex design and tough bugs, but not all tasks need them.
A beginner's sense of model costs:
Revisiting Section 13's model selection through a cost lens:
simple tasks = haiku
general development = sonnet
hard judgments = opus
deep planning, efficient execution = opusplanTo switch models mid-session, use:
/model sonnet/model haikuA cost-conscious practical prompt:
I want to do this task cost-efficiently.
First, check if haiku or sonnet is enough.
Only explain why Opus is needed if it truly is.Beyond changing models, /effort matters for cost management. medium works well for cost-sensitive tasks by reducing token use, high balances most coding work well, and xhigh and max accept more tokens in exchange for deeper reasoning.
Set it with:
/effort medium/effort highWhen cutting costs, ask:
I want to save cost on this task.
Try medium effort, and if accuracy
drops, we'll bump it to high.The most powerful way to cut costs is reducing what Claude reads.
Look at the whole codebase and find issues.Investigate only the login failure issue.
First find related file candidates, then
read the top 3 and estimate the cause.Read only src/auth/login.ts and
src/auth/session.ts first.
If you don't find the cause, suggest
what to read next.Claude Code automatically summarizes conversation history when approaching context limits to optimize costs.
To summarize manually:
/compactYou can specify what to keep during summarization:
/compact keep only decisions so far, files
modified, and test results.The difference:
MCP is powerful, but more connections mean more tools Claude must consider. Disable MCP servers you aren't actively using via /mcp.
The beginner rule:
Don't connect many MCPs upfront.
Connect only what you need, and
turn off unused servers.Check with:
/context/mcpCLAUDE.md is great for telling Claude project rules each session, but too long and it consumes context every time. Since CLAUDE.md loads into context at session start, excessive guidelines consume tokens even in unrelated work.
A beginner's CLAUDE.md principle:
Put only always-needed rules in CLAUDE.md.
Move task-specific long instructions to
skills later.A good CLAUDE.md needs only this much:
# Project Rules
## Commands
- Test: npm test
- Lint: npm run lint
- Build: npm run build
## Coding Rules
- Maintain TypeScript strict mode.
- Follow existing code style.
- Check related tests before modifying.
## Safety
- Never read or modify .env files.
- Summarize git diff before committing.To monitor costs frequently, configure the status line. Claude Code's status line appears at the bottom and can continuously show context usage, cost, git status, and more.
Start setup like this:
/statusline show model name, context percentage,
cost, and git branchFour items beginners should display:
Individual users often need only /usage and model selection, but teams need spend limits and usage reports.
Good team documentation includes:
Claude Code may use tokens on background features even when you're not typing. Generally under $0.04 per session, but these habits help:
Clean up sessions when work finishes.
Don't hold onto old sessions unnecessarily.
Use /clear when moving to new work.Before starting big work in Claude Code, request:
Let's do this work cost-efficiently.
Rules:
1. Don't blindly read the whole project.
2. First find related file candidates.
3. Propose a plan before editing.
4. For long logs, focus on error summaries.
5. Use sonnet as the baseline for general work.
6. Explain why Opus is needed if you suggest it.Check usage mid-work:
/usageDuring work, check like this:
Find cost factors in the current session.
Tell me what's costly: long context,
reading too many files, model choice,
or tool use?If work gets long, compress:
/compact keep only goals, decisions,
modified files, and test results.If tasks change, restart:
/clearDon't read the whole project.
First find files related to login.
Give me just 5 candidates with reasons.Don't explain the entire git diff.
Summarize only behavior changes
and risky edits.
Separate formatting changes.Focus on the first failure cause only.
Skip duplicate stack traces and extract
just the error message and relevant paths.I want to save cost.
If haiku or sonnet works, recommend it.
Only explain why opus is necessary
if it truly is.Summarize what I'll need going forward
from our conversation.
Keep only goals, files modified,
remaining tasks, and warnings.
Then write a summary to put in /compact.Claude Code costs depend mainly on token usage. Check session usage with /usage, but remember it's a local estimate—verify actual billing in Claude Console.
Costs spike from reading large files, long sessions, long logs, high-performance models, and overusing MCP or subagents. Use Sonnet for general development, Haiku for quick exploration, and Opus for complex design and tough bugs.
Section 15. How to manage context and use sessions longer
Context is the working memory space that Claude can refer to when generating your current answer. It contains your requests, Claude's responses, file contents that have been read, tool execution results, error logs, and previous decisions.
Here's how beginners can think about it.
When the workspace has well-organized information, Claude gives good answers. Conversely, when old logs, completed tasks, and unrelated file contents keep accumulating, Claude starts to get confused.
When you maintain a Claude Code session for a long time, the following issues can emerge.
The core point is this.
To see context usage, use the following command.
/contextThen ask Claude like this.
Explain which elements take up the most space in the current context.
Let me know separately which of these is largest: files read, long logs, MCP, CLAUDE.md, or conversation history.If context has grown too large, don't fix it immediately—first diagnose.
Determine whether I should continue this session.
Recommend whether to continue, run /compact, or start fresh with /clear./compact is a command to summarize long conversations so you can continue the session. Use it when you want to keep the work going but reduce unnecessary detailed exchanges and old output, keeping only the essentials.
/compactFor beginners, the recommended approach is not just to use /compact alone, but to clearly state what to keep.
/compact Preserve only the goals so far, decisions, modified files, test results, and remaining work.If you're fixing a bug, write it this way; if you're refactoring, you might write it differently. /compact is best when continuing the same work.
/clear clears the current conversation context and starts anew. Use /clear when switching to unrelated work. Old context can waste tokens in all subsequent messages.
/clearBeginners should use /clear in the following situations.
Before switching tasks, it's good practice to name your session.
/rename auth-bugfixThen move on to your new work.
You may not finish work in a day. Claude Code can resume previous conversations.
To resume the most recent session, use the following command.
claude -cThis command resumes the most recent conversation in the current directory.
If you want to pick from the session list and resume, use the following.
claude --resumeIf you want to pick a session from within Claude Code, use this.
/resumeThe recommended session management approach for beginners is to name your session first, then use claude --resume or claude -c (for the most recent) when resuming later.
To sustain long sessions, don't just ask Claude to "remember," but structure your work status periodically.
A good request looks like this.
Summarize the work status so far.
1. Goal
2. Files checked
3. Files modified
4. Problems not yet solved
5. Next tasks
6. Risk factors to watchThen compact based on this summary.
Test failure logs, build logs, and server logs can become very lengthy. If you paste entire long logs or keep having Claude read them, context grows rapidly.
A bad request looks like this.
Read all of this log and find the problem.A better request looks like this.
Only look at the first failure cause in this log.
Ignore duplicate stack traces and summarize only the actual error message and relevant file paths.Or filter it at the terminal first.
npm test 2>&1 | grep -E "FAIL|ERROR|Exception|Cannot|Expected"Then ask Claude like this.
Don't read the entire long log.
Analyze based only on lines related to the failure cause.
If you need more logs, tell me what part you need first.The key to saving context is not "giving more," but "giving only what's needed."
Beginners often ask Claude like this.
Analyze the entire project for me.This request can bloat context. A safer approach is incremental exploration.
Don't read the entire project.
First find only the candidate files related to the login feature.
Tell me the top 5 files and why.Then read only the necessary files.
Read only src/auth/login.ts and src/auth/session.ts first.
If you can't find the cause, suggest which files to read next.When exploring large codebases, using a subagent is also a good approach. Large codebase exploration can fill your main context with file reading, so delegating the investigation to a subagent lets the subagent read files in a separate context and return just a summary.
Use a subagent to investigate the token refresh flow in the authentication system.
Return to the main conversation only key files, a flow summary, and risk factors.Some models and plans support a 1M context window. Opus 4.6+ and Sonnet 4.6 support a one-million-token context window for long sessions and large codebases.
/model opus[1m]/model sonnet[1m]But having 1M context doesn't mean you should read every file indiscriminately. A larger context is not always better, and as token count increases, accuracy and recall performance can degrade.
If you want to check context usage frequently, you can set a status line. Claude Code's status line is a custom bar displayed at the bottom of the screen and can show context window usage, cost, git status, and more.
To set it up simply, make a request like this.
/statusline show model name, context percentage, cost, and git branchHere are the recommended status line items for beginners.
Sustaining a session indefinitely isn't always best. In these situations, a fresh session is safer.
For beginners, remember just one thing.
When starting work:
This session's goal is to analyze the login failure cause.
Don't read the entire project—just find candidate files first.Narrowing down relevant files:
Suggest only the top 5 relevant files.
Explain in one line why each file should be reviewed.
Don't modify files yet.Midway check-in:
Summarize what you've confirmed so far, files modified, and remaining questions.
Tell me if there's content unnecessarily taking up context.When the session has grown long:
/compact Preserve goal, decisions, modified files, test results, and remaining work only.When moving to different work:
/rename auth-login-debug/clearWhen resuming the next day:
claude --resumeDetermine if this session's context has grown too large.
Recommend whether to continue, /compact, or /clear, with reasons.Organize what needs to be preserved before /compact.
Keep only goal, decisions, modified files, test results, remaining work, and cautions./compact Preserve only the essential content just discussed.
Especially keep the files modified, failed tests, and next steps.Before ending this session, create a work summary so I can resume later.
Write it so I can paste it directly as the first prompt in the next session.Re-orient to the current state based on the previous session summary.
First check git status, then propose remaining tasks in order.Context is the working memory Claude currently references. As sessions lengthen, conversations, file contents, logs, and tool results accumulate. When context grows, costs increase and answer quality can suffer. When continuing the same work, use /compact to keep only essentials; when moving to different work, use /clear to start fresh. For work you'll return to later, use /rename to name it, then clean up. Resume previous work with claude -c, claude --resume, or /resume. For large codebase exploration, read necessary files incrementally or delegate to subagents. The 1M context helps with large work, but it doesn't mean you should include unnecessary information. Setting a status line lets you continuously check context percentage, cost, model, and git branch.
Unit 16. When to use extended reasoning and effort
Ultra Think is a practical prompt pattern that tells Claude Code to analyze this request in greater depth.
Basic usage is simple.
ultrathink.
Analyze this problem deeply.
Don't fix it yet, just organize the possible causes and check order first.Simply put, Ultra Think is:
You must understand Ultra Think's three characteristics precisely.
ultrathinkIn other words, ultrathink is not a command that changes session settings like /effort xhigh. It's a request to examine one specific question more deeply.
Use Ultra Think not for simple tasks, but for tasks where mistakes are costly.
For beginners, remember it this way:
It might seem good to add Ultra Think to everything, but it's not. Official documentation explains that effort and reasoning have trade-offs between token usage, speed, and capability.
Tasks that don't need Ultra Think:
Ultra Think is not a magic spell you add every time. It's a high-performance tool for critical moments.
To use Ultra Think well, don't just throw ultrathink at it. Provide situation, goals, constraints, and output format together.
The basic formula is:
ultrathink.
Situation:
-
Goal:
-
Constraints:
- Don't modify files yet.
- Don't run commands until I approve.
- Organize possible causes by priority.
Do first:
1. Summarize how you understand the problem.
2. Break down possible causes.
3. List files to check, by priority.
4. Warn about risky fix directions.
5. Suggest safe next steps.The core of this formula is the last part. Ultra Think is a tool for thinking deeply, not for executing immediately. Use it in an Analyze → Plan → Approve → Execute flow.
Ultra Think is especially useful for bugs where the cause is hard to spot.
ultrathink.
Analyze the cause of this bug deeply.
Symptoms:
- Login says it succeeded but session doesn't persist
- Refresh redirects back to login page
Recent changes:
- Modified auth middleware
- Changed cookie options
- Changed HTTPS settings in deployment
Constraints:
- Don't modify files yet.
- First organize possible causes by priority.
- Also show how to check each cause.
- Suggest just the top 3 files to read first.The core principle when using Ultra Think for bugs is preventing immediate fixes.
Bad request:
ultrathink. Fix this bug.Good request:
ultrathink.
Analyze the cause of this bug first.
Don't fix it, just suggest possible causes and check order.It's even better to specify a good output format:
Output format:
1. Most likely cause
2. Evidence to check
3. Files to read
4. Commands to try
5. Cautions before fixingRefactoring might look like "just changing code structure," but it can actually touch hidden dependencies. Especially when refactoring auth, state management, DB access, or API layers, it's safer to use Ultra Think to plan first.
ultrathink.
Analyze whether refactoring the auth module is safe.
Goals:
- Separate auth logic into service layer
- Remove token handling from controller
- Keep existing API response format
Check:
1. Files affected
2. Hidden dependencies
3. Parts that need testing
4. Changes that are hard to roll back
5. Step-by-step execution order
Constraints:
- Don't modify files yet.
- Just present the plan first.
- Mark high-risk changes separately.For Ultra Think used in refactoring, prevent "changing everything at once."
It's good to add this request:
Don't refactor all at once.
Break it into small commit-sized chunks.
Plan so we can check each step with git diff.Security, permission, and payment logic are riskier than simple feature implementation. Even if something seems to work, permission bypasses, sensitive data exposure, duplicate charges, or wrong refunds can happen.
For these tasks, use Ultra Think strongly:
ultrathink.
This change touches permission/security logic.
Accuracy matters more than speed.
Review the following first:
1. Permission bypass possibility
2. Sensitive data exposure possibility
3. Risks existing tests don't catch
4. Outage scope if fixed wrong
5. Safe fix order
6. Tests that must be added
Constraints:
- Don't modify files until I approve.
- Don't run risky commands.
- Mark low-confidence areas as guesses.For payment logic, use it like this:
ultrathink.
Review the payment completion webhook handling logic.
Focus on:
1. Whether duplicate charges happen on duplicate webhooks
2. Whether payment success/failure state transitions are safe
3. Whether signature verification might be skipped
4. Whether DB transactions are needed anywhere
5. Edge cases to test
Don't fix yet, just analyze and suggest a fix plan.The principle here is clear:
Outage analysis is different from simple bug fixes. You might need to look at logs, deployment history, environment variables, config, recent commits, and external service status all together.
ultrathink.
API response time spiked sharply after the recent deploy.
Analyze the outage cause deeply.
Current symptoms:
- Only a specific API is slow
- Can't reproduce locally
- Started right after deploy
- No errors, just timeout increase
Do first:
1. Break down possible causes by layer.
2. Organize logs and files to check first.
3. Warn about risky quick fixes.
4. Separate temporary fix from root cause fix.For outage analysis, it's risky to pinpoint one single cause.
A good request looks like this:
Don't pinpoint a single cause.
Organize likely candidates by priority.
For each candidate, show both how to confirm and how to disprove it.Ultra Think enables deep judgment, and Plan Mode provides a safety check before editing. The official common workflows doc also recommends setting a plan before editing, to review changes before they touch disk, and delegating large codebase exploration to subagents to keep your main context clean.
The safest combination is:
ultrathink.
Start with Plan Mode.
Investigate related files, organize the fix plan and risks.
Don't modify files until I approve.The core of this combination:
For large tasks, make it more concrete:
ultrathink.
Use Plan Mode to organize an auth module refactoring plan.
Include in the plan:
1. Current structure summary
2. Files to change
3. Fix order
4. Risk level of each step
5. Required tests
6. How to rollback
7. Criteria for splitting commits
Don't modify files yet.Using both together means: instead of "think deeply then fix immediately," you think deeply, show the plan, and get approval before executing.
You can use Ultra Think even after Claude Code modifies files. It's especially useful for deeply reviewing the current diff for safety before committing.
ultrathink.
Review the current git diff deeply.
Distinguish:
1. Intentional changes
2. Unintentional changes
3. Logic changes that alter behavior
4. Pure formatting changes
5. Changes that need testing
6. Risk factors before deploy
7. Files that shouldn't be in the commit
Don't git add, commit, or push yet.After staging, request like this:
ultrathink.
Review what's going into this commit based on git diff --staged.
Suggest a commit message, but don't commit yet.Good cases to use Ultra Think for Git review:
Ultra Think quality varies greatly with prompt structure.
The real Ultra Think power is not "think more deeply," but specifying what criteria to think deeply about.
Overusing Ultra Think creates these problems:
For simple tasks, it's better to say:
Don't analyze deeply, just answer the essentials briefly.Now let's connect effort to understand both:
ultrathink / /effort high, /effort xhigh, etc.Simply put:
To change effort within a session:
/effortYou can also specify directly:
/effort low
/effort medium
/effort high
/effort xhigh
/effort maxTo set it at startup, run in the terminal:
claude --effort high
claude --model opus --effort xhighOfficial docs explain effort as a balance between token usage and capability. For beginners, the standard is:
Ultra Think and effort aren't separate tools—they can combine:
/effort high
Analyze this bug and suggest a fix plan./effort high
ultrathink.
Review whether this fix direction is safe.
Focus on hidden side effects and missing tests./effort xhigh
ultrathink.
Use Plan Mode to organize a refactoring plan.
Include impact scope, risks, test strategy, and commit split criteria.
Don't modify yet./effort xhigh
ultrathink.
Review whether this payment webhook change is safe.
Check deduplication, signature verification, state transitions, transactions, and rollback.
Don't modify files yet.The practical sense is:
max can provide the deepest reasoning possible, but it's not always the best choice. Official docs also note that max can improve performance on demanding tasks but has unbounded token spending, and diminishing returns and overthinking can occur, so test before applying widely.
For beginners, it's better to ask first before using max:
Does this problem need max effort first, judge for me.
If needed, explain why, expected cost increase, and why xhigh isn't enough.
Don't switch to max yet.Situations worth considering max:
You might also see ultracode in the /effort menu. But ultracode is not a model effort level.
According to official docs, ultracode is a Claude Code setting that sends xhigh to the model and orchestrates dynamic workflow for substantive tasks. It's also a session-only setting and not part of effortLevel, --effort, or CLAUDE_CODE_EFFORT_LEVEL.
The distinction is:
Beginners don't need to use ultracode by default from the start. It's enough to master ultrathink and /effort high, /effort xhigh first.
ultrathink.
Analyze this bug cause deeply.
Symptom: (enter symptom)
Recent changes: (enter changes)
Constraints:
- No file edits yet
- Organize cause candidates by priority
- Include how to confirm and disprove each
- Suggest just top 3 files to readultrathink.
Organize this refactoring plan.
Goal: (enter refactoring goal)
Include:
1. Impact scope
2. Hidden dependencies
3. Step-by-step fix order
4. Test strategy
5. How to rollback
6. Commit split criteria
Don't modify files yet.ultrathink.
Review whether this change is secure.
Focus:
1. Permission bypass possibility
2. Sensitive data exposure possibility
3. Auth/authz boundary
4. Values that shouldn't log
5. Missing tests
6. Safe fix order
Don't fix, just review.ultrathink.
Review payment handling logic deeply.
Check:
1. Duplicate payment possibility
2. Webhook retry handling
3. Signature verification
4. DB transaction
5. Failure state handling
6. Refund/cancel edge case
Just suggest plan before file edits.ultrathink.
Review current git diff deeply.
Distinguish:
1. Intentional changes
2. Unintentional changes
3. Actual behavior changes
4. Pure formatting
5. Needs test items
6. Exclude from commit
7. Risk before deploy
Don't git add, commit, or push yet.Does this problem need max effort?
Compare: is xhigh enough, is max needed, is there cost-benefit?
Don't change effort yet.The actual prompt keyword for Ultra Think is ultrathink. ultrathink is a keyword that makes Claude Code analyze one specific request more deeply, and it doesn't change the session-wide effort setting.
Use Ultra Think for tasks where judgment matters—unclear bugs, large refactoring, security, permission, payment, outage analysis. Don't use it for simple summaries, file location searches, or short diff explanations.
When using Ultra Think, include situation, goal, constraint, output format, and execution block together. Using it with Plan Mode lets you analyze deeply, review the plan first, before actually fixing it.
/effort controls your session's reasoning strength. low, medium, high, xhigh, max each balance cost, speed, and reasoning depth differently, and max isn't always the best choice—it can cause over-analysis and cost spikes.
Section 17. Creating a Bug Fix Workflow
When fixing bugs with Claude Code, we use a 10-step process as the foundation.
Then the next steps:
The most common mistake beginners make is skipping these steps and requesting like this.
Fix this bug.With this kind of request, Claude might guess too broad a scope.
A much better request looks like this.
There's a bug where the page redirects to the login page again after logging in and refreshing.
First, analyze the root cause.
Don't fix it yet,
organize the reproduction steps, related files, possible causes, and verification order.For Claude to fix a bug well, it needs to understand exactly "what went wrong."
Login seems broken.When I enter the correct email and password in the login form,
the server responds with 200,
but on the frontend the login state doesn't persist.
After refresh, it redirects to /login again.A good bug description should include these items.
When sending organized bug information to Claude, use this template.
After reviewing the bug description below,
first ask if there's any missing information.
Don't fix it right away, organize the information needed for root cause analysis in a list.
Symptoms:
- (description)
Expected behavior:
- (description)
Actual behavior:
- (description)
Recent changes:
- (description)
Error messages:
- (description)The most important thing in bug fixing is reproduction. If you can't reproduce it, it's hard to verify the fix is correct.
A good request looks like this.
First, organize the procedure to reproduce this bug.
If there's missing information in the symptoms I provided, ask.
Reduce it to the minimum reproducible steps.1. Start local server: npm run dev
2. Go to /login in browser
3. Log in with test account
4. Confirm navigation to /dashboard
5. Refresh
6. Confirm it redirects to /login againReproduction command:
npm test -- auth
Failure log:
...This bug doesn't always happen, it's intermittent.
Assume it's intermittent,
and suggest possible causes and where to add logs.
Don't modify files yet.Error logs are important, but very long ones waste context. Provide the key parts.
Look at all this log and fix it.Analyze the first failure cause from this log.
Ignore duplicate stack traces,
focus on the actual error message, related files, and the failing test.When providing logs to Claude, it helps to include these.
When analyzing test failure logs, this template is efficient.
Analyze this test failure.
Run command:
npm test -- auth
First failure:
...
Stack trace:
...
Request:
1. Explain the most likely root cause.
2. Suggest only 3 related file candidates.
3. Organize what needs to be verified before fixing.
4. Don't modify files yet.Beginners tend to read the entire project when a bug appears.
Look at the entire project and find the bug.This approach greatly increases context and cost. A better request narrows the scope.
Don't read the entire project,
just find file candidates likely related to this bug.
Conditions:
- Files related to maintaining login state
- Files related to session, cookie, auth middleware
- If there are test files, suggest them too
Output:
1. File paths
2. Why they seem related
3. Priority order for readingAfter Claude suggests candidate files, don't read all of them at once, proceed step by step.
First, read only the top 1-3 priority files from your suggestions.
If you can't find the cause there, suggest the next files.This approach has these advantages.
A dangerous attitude in bug fixing is deciding too quickly "this must be the cause."
Always ask Claude to divide possible causes into multiple candidates with evidence and verification methods.
Organize possible causes by priority.
For each cause, include:
1. Why the possibility is high
2. Files to check
3. Code location to check
4. How to disprove it
5. Expected change scope if fixed
Don't fix it yet.For difficult bugs, use Ultra Think from Unit 16 together.
ultrathink.
Analyze this bug's root cause deeply.
Don't pinpoint one cause,
organize high-probability candidates by priority.
For each candidate, present verification and disproof methods.secure setting issue — only happens in productionOnce you've confirmed root cause candidates, don't fix immediately. Get a fix plan first.
Example request:
Suggest a fix plan first.
Include:
1. Files to modify
2. Function or code location to change
3. Why the change is needed
4. Expected side effects
5. Tests to add or modify
6. How to revert
Don't modify files yet.Plan Mode lets Claude read files and propose a plan, but won't edit until approved.
Use Plan Mode.
Verify the bug root cause and write a fix plan.
Don't modify files until I approve.claude --permission-mode planThis gives you time to review before file modifications.
Bug fixes should be as small as possible. If you mix refactoring, formatting, or naming changes while fixing a bug, review becomes hard.
Instruct Claude like this.
This fix should be minimal changes to solve the root cause.
Don't refactor, change formatting, or rename.
Only modify where behavior change is needed.When delegating to Claude, break it into steps.
From the plan just suggested, apply only step 1.
Fix with minimal changes,
and summarize which files you modified after fixing.Advantages of this approach:
The best test for a bug fix is one that fails before the fix and passes after the fix.
First, add a test that reproduces this bug.
Review the existing test style,
and write a test that should fail before the fix.
Don't modify implementation code yet.Add a regression test so this bug doesn't happen again.
Follow the existing test pattern,
and separate success and failure cases.Test focus points differ by bug type.
If it's hard to add tests immediately, at least request this.
What tests should be added for this bug?
Also let me know if unit, integration, or E2E tests are appropriate.After fixing, run tests.
npm testnpm test -- authRequest Claude like this.
Run related tests first.
If it fails, analyze only the first failure cause,
and suggest a revised fix plan.Good requests when tests fail:
Analyze only the first failure from the test failure log.
Ignore cascading failures,
and suggest the root cause and fix scope first.With long failure logs, don't read all of it, just provide the key parts.
Don't read the entire log,
analyze based only on the first FAIL block and related stack trace.
If more logs are needed, tell me what part you need.This approach:
Even if tests pass, it's not done. You must check changes with Git.
git status
git diffReview the current git diff.
Check:
1. Is the change directly related to the bug fix?
2. Are there unnecessary formatting changes?
3. Were unintended files modified?
4. Were tests added?
5. Are there risky behavior changes?
6. What to check before commit?For important bugs, attach Ultra Think for deeper review.
ultrathink.
Deeply review the current git diff.
Does this change actually solve the root cause,
or just mask symptoms?
Are tests sufficient?
Don't commit yet.The most dangerous thing in bug fixing is fixes that only hide symptoms.
For example, if you swallow all errors with try/catch, the screen quiets but actual data problems remain.
Request Claude like this.
Does this fix solve the root cause,
or is it just a workaround that hides symptoms?
Evidence:
1. What code path changed
2. How the failure condition is resolved
3. Conditions where this problem could recur
4. Additional tests neededIntermittent bugs are harder because they don't always reproduce.
Example intermittent bug analysis request:
This bug happens intermittently.
ultrathink.
Analyze based on:
1. race condition possibility
2. cache or session issues
3. environment variable differences
4. timezone/timing problems
5. external API delays
6. test flakiness possibility
Don't fix right away,
first suggest what logs or tests to add for observability.With intermittent bugs, increasing observability often comes before fixing.
When finding bug roots in large codebases, your main context can be filled with file reading. Delegating to a subagent lets it read files in separate context and return only a summary, keeping your main context clean.
Use debugger subagent to investigate this bug.
Goals:
- Analyze error message and stack trace
- Verify reproduction steps
- Isolate failure location
- Organize possible cause candidates
- Suggest minimal fix plan
Return only key summary to main conversation.
Don't modify files yet.After analyzing with debugger subagent,
if fix is needed, suggest only minimal changes.
Don't execute Edit until I approve.Often-repeated bug fix rules work well written briefly in CLAUDE.md.
# Bug Fix Workflow
- Always verify reproduction steps before fixing a bug.
- Don't pinpoint one cause; provide possible candidates and evidence.
- Show a fix plan before modifying files.
- Keep fixes minimal.
- Run related tests first, add regression tests if possible.
- Summarize git status and git diff before commit.
- Analyze security, permission, payment bugs with ultrathink first.Keep it short and include only rules that always apply.
Bug fixing shouldn't end at "the error is gone." You must create completion criteria.
Can we consider this bug fix complete?
Criteria:
1. Was it reproducible?
2. Was root cause confirmed?
3. Is it a minimal fix?
4. Are tests sufficient?
5. Is there unnecessary change in diff?
6. Are there remaining risks?Once the bug fix is complete, request this final check before committing.
Final review before commit.
Execute:
1. Check git status
2. Check git diff
3. Summarize list of modified files
4. Summarize bug cause and fix content
5. Summarize test run results
6. Confirm regression test addition or reasons
7. Confirm risks and remaining TODOs
8. Suggest 3 commit messages
Don't commit yet.Good commit message examples:
fix: preserve session after login refreshfix(auth): handle secure cookie settings in productiontest(auth): add regression coverage for session persistenceIf review shows no issues,
commit using the first suggested message.
Show the file list again right before commit.This template can be pasted as-is when a bug occurs.
Use the bug fix workflow.
Symptoms:
-
Expected behavior:
-
Actual behavior:
-
Reproduction steps:
1.
2.
3.
Run command:
-
Error log:
-
Recent changes:
-
Process rules:
1. Don't fix immediately.
2. First organize cause candidates by priority.
3. Suggest no more than 5 related file candidates.
4. Provide verification and disproof methods.
5. Present fix plan first.
6. Apply only minimal changes after my approval.
7. Add regression tests if possible.
8. Run tests and review git diff after fixing.ultrathink.Use Plan Mode.You can also combine these two options.
ultrathink.
Use Plan Mode.There's an issue where after logging in and refreshing, the user is logged out.
First, analyze the root cause.
Organize possible causes by priority based on
cookie, session, auth middleware, and frontend auth state.
Don't fix yet.Auth tests fail when running npm test.
Analyze only the first failure cause.
Ignore cascading failures,
find the failing assertion and related code location.
Suggest a fix plan first.This bug can't be reproduced locally, only happens in production.
ultrathink.
Organize possible causes based on
environment variables, cookie secure settings, proxy, HTTPS, and DB connection differences.
Don't fix yet, suggest verification order first.There's a permission bug where regular users can access admin pages.
ultrathink.
Analyze focusing on permission bypass possibilities.
Check if authentication and authorization are separated,
and if server-side validation is missing anywhere.
Don't fix yet.There's an issue where duplicate payment webhooks cause order state problems.
ultrathink.
Analyze based on duplicate webhooks, idempotency, DB transaction, and state transition order.
Suggest test cases and safe fix order before fixing.Check this checklist whenever fixing a bug.
Bug fixing follows this order: reproduction → root cause analysis → plan → minimal fix → testing → diff review.
You must describe symptoms, expected behavior, actual behavior, reproduction steps, error logs, and recent changes specifically. Don't ask Claude to fix immediately; first request cause candidates and verification methods.
Read related files step by step by priority, not the entire project. Get a plan before fixing and use Plan Mode for risky work.
Keep fixes minimal and don't mix refactoring or formatting changes. Add regression tests that fail before the fix and pass after whenever possible.
In large codebases, use debugger subagent to delegate cause investigation. Add repeated bug fix rules briefly to CLAUDE.md.
Section 18. Creating a Feature Addition Workflow
Implementing new features safely by following an established process.
Feature additions follow this basic sequence.
1. Describe the feature you want to build in concrete terms.
2. Clarify the behavior users expect.
3. Find the scope of changes first.
4. Investigate related files and existing patterns.
5. Get an implementation plan.
6. Review and approve the plan.
7. Implement in small stages.
8. Add or modify tests.
9. Check if documentation or README updates are needed.
10. Review final changes with git diff.Bad example:
Add a notification feature.Good example:
I want to add a feature that shows notifications in a notification list when users receive comments.
Don't implement right away. First clarify requirements and find related files.
Then propose an implementation plan.Vague requirements lead to shaky results. Before assigning implementation to Claude, organize requirements first.
Before implementing the feature request below, organize it into requirements.
Feature:
- Show a notification in the notification list when a user receives a comment.
Organize:
1. User perspective behavior
2. Required screen changes
3. Required API changes
4. Data persistence requirements
5. Permission or security considerations
6. Test cases to verify
Don't modify files yet.User scenario:
1. User A comments on User B's post.
2. User B sees the new comment notification in the notification list.
3. When B clicks the notification, they go to that post.
4. Read notifications are excluded from the unread count.If Claude makes arbitrary decisions during feature implementation, fixes can become larger later. Therefore, unclear requirements should prompt questions first.
Before implementing this feature, ask about unclear requirements.
Don't guess; organize decisions needed as a list.Once requirements are clarified, find related files. Don't read the entire project aimlessly; identify only likely candidate files for this feature.
Don't read the entire project aimlessly.
Find only candidate files likely related to this feature.
Features:
- Create notification when comment is added
- Query notification list
- Display unread count
Output:
1. File paths
2. Why they seem related
3. Priority for reading first
4. Whether modifications are likelyRead priority 1-5 files first.
Find existing patterns in them,
and explain where naturally adding the new feature fits.
Don't modify files yet.New features must match the project's existing style. If API routers, service layers, test structures, and naming conventions already exist, Claude should follow those patterns.
Before implementing the new feature, investigate existing patterns.
Check:
1. Whether similar functionality already exists
2. API route structure
3. Service or repository layer structure
4. Test file location and writing style
5. Error handling approach
6. Naming conventions
Don't implement yet; only summarize patterns.# Feature Development Rules
- New features follow existing folder structure and naming conventions.
- Maintain existing API response format and error handling approach.
- Investigate related files and existing similar features before implementation.
- Present implementation plan before modifying files.
- Check if related tests and documentation updates are needed when adding features.Once related files and existing patterns are confirmed, don't implement immediately. Get a plan first.
Create an implementation plan for this feature.
Include:
1. Files to modify
2. New files to create
3. Data model changes
4. API changes
5. UI changes
6. Testing plan
7. Documentation update requirements
8. Risk factors
9. Step-by-step implementation order
Don't modify files yet.Create a feature addition plan in Plan Mode.
Investigate related files and organize implementation stages and risk factors.
Don't modify files until I approve.Or when starting from the terminal:
claude --permission-mode planFeature addition is risky when trying to complete everything at once. Modifying DB, API, UI, tests, and documentation simultaneously creates large diffs and difficult reviews.
Divide this feature into small implementation stages.
Requirements:
- Each stage must be reviewable with git diff
- Don't modify too many files in one stage
- Divide into testable units
- Include completion criteria for each stageImplement stage 1 first.
After completing, show modified files and git diff summary.Be extra careful when feature additions require database schema or data model changes.
Determine whether this feature requires data model changes first.
Check:
1. Whether existing models are sufficient
2. Whether new tables/collections are needed
3. Whether migration is required
4. Whether compatible with existing data
5. Whether rollback is possible
6. Whether test data is needed
Don't create migration files yet.ultrathink.
Review whether this feature's data model changes are safe.
Organize existing data compatibility, migration order, rollback strategy,
and test cases. Don't modify files yet.Features that add or modify APIs affect both client and server together.
Design the API changes needed for this feature.
Include:
1. endpoint
2. request format
3. response format
4. error response
5. authentication/permission requirements
6. compatibility with existing APIs
7. test cases
Don't implement yet.GET /api/notifications
Response:
{
"items": [...],
"unreadCount": 3
}Who should be able to call this API?
Check if server-side permission verification is needed to ensure only personal data is queried.If the API requires permissions, add Ultra Think.
ultrathink.
Review whether this API design is safe in terms of permissions.
Check for any bypass paths allowing query or modification of other users' notifications.UI features must consider screen behavior, state management, error handling, and loading states.
Create a UI implementation plan for this feature.
Check:
1. Components to modify
2. State values needed
3. Loading state
4. Error state
5. Empty state
6. Accessibility considerations
7. Existing design patterns
8. Testing method
Don't modify files yet.Check existing UI component patterns first,
and create a plan to implement notification UI following that pattern.
Reuse existing components; don't create a new design system.Feature additions must be accompanied by tests. Check existing test files and write tests matching the project's testing style, framework, and assertion patterns.
Create a test plan for this feature.
Categories:
1. Unit tests
2. Integration tests
3. E2E tests
4. Permission tests
5. Failure/error cases
6. Edge cases
Check existing test style first,
and propose what tests should be added.Write tests for this feature first.
Follow existing test style,
and write tests that can fail before implementation.
Don't modify implementation code yet.Once the plan is approved, implement stage by stage. Review changes after each stage.
Implement only stage 1 of the plan.
Rules:
- Implement with minimal changes
- Don't refactor unrelated code
- Don't separate formatting-only changes
- Summarize modified files after changes
- Notify before running tests if neededSummarize the git diff of what was just changed.
Distinguish between intended and unintended changes.Now proceed to stage 2.
Maintain the structure set in stage 1,
and explain first if new design changes are needed.During feature implementation, facts may emerge that differ from the original plan. Claude must not change direction arbitrarily.
If you discover facts differing from the existing plan during implementation,
don't fix immediately. Stop and notify me.
Report:
1. What was unexpected
2. Impact on the existing plan
3. Available alternatives
4. Recommendation
5. What I need to decideIf there's existing notification-related code, don't create a new structure.
First review whether existing structure can be reused.Feature additions may require documentation changes. After implementing the feature, check if documentation updates are needed.
Check if this feature addition requires documentation updates.
Documents to check:
1. README
2. API documentation
3. .env.example
4. Developer guide
5. changelog
6. User help
If needed, propose which documents to change and how.
Don't modify yet.Code changes are complete, so handle documentation updates as a separate stage.
Propose which documents to change before modifying.New features can create security problems. Features related to user data, payments, permissions, admin functions, and file uploads must be carefully reviewed.
Review whether this feature addition is secure.
Check:
1. Whether the API requires authentication
2. Whether only personal data is accessible
3. Whether admin permission verification is needed
4. Whether sensitive information is exposed in responses or logs
5. Whether input validation is needed
6. Whether rate limiting is needed
7. Whether tests are sufficient
Don't make additional modifications yet. Only report review results.ultrathink.
This feature involves user permissions and personal information.
Deeply review possibilities of permission bypass, data exposure, and missing input validation.
Don't modify yet.Large features may have many related files. Reading all files in the main conversation expands context. Delegating to subagent keeps the main context clean by reading files in a separate context and returning only summaries.
Use subagent to investigate the impact scope of this feature.
Feature:
- Comment notification feature
Investigate:
1. Comment creation flow
2. Existing code related to user notifications
3. Authentication/permission handling
4. Test file locations
5. UI display locations
Return to main conversation with only key file list and implementation candidates summarized.
Don't modify files yet.Ignore vendor folders during investigation,
and if existing notification structure exists, don't create a new structure.
First check for reuse possibilities.Feature addition doesn't end at "showing on screen". Completion criteria must be created first.
Create completion criteria for this feature.
Include:
1. Whether user scenarios are met
2. Whether API or UI behavior is verified
3. Whether permission conditions are maintained
4. Whether tests are added
5. Whether documentation updates are needed
6. Whether git diff contains no unnecessary changes
7. Whether remaining risk factors are organizedAfter implementation, run tests. Run related tests first and analyze failure causes.
npm testYou can also run only related tests first.
npm test -- notificationsRun related tests first.
If they fail, analyze only the first failure cause,
and distinguish cascading failures.Based on test results, review whether this feature meets completion criteria.
Notify if there are insufficient tests or edge cases.After features work and tests pass, check changes with Git.
git status
git diffReview current git diff.
Check:
1. Whether changes are directly related to feature addition
2. Whether unintended files were modified
3. Whether formatting changes are mixed in
4. Whether enough tests are added
5. Whether documentation updates are needed but missing
6. Whether security or permission risks exist
7. Whether commits should be splitDivide this change into commits.
Propose whether separation by model/API/UI/test/docs is possible.
Don't git add or commit yet.Feature additions are typically reviewed via PR. Before creating a PR, draft a description that clarifies key points for reviewers.
Before creating a PR, draft a description.
Include:
1. Change summary
2. User-visible changes
3. Implementation details
4. Test results
5. Key areas for reviewers
6. Remaining risk factors
7. Related issues## Change Summary
-
## User-Visible Changes
-
## Implementation Details
-
## Testing
-
## Reviewer Checklist
-
## Risk Factors / Remaining TODOs
-If feature addition rules repeat, write them briefly in CLAUDE.md. However, since CLAUDE.md occupies context in every session, write concisely.
# Feature Development Workflow
- Organize requirements for new features before implementation.
- Investigate related files and existing similar features first.
- Present implementation plan before modifying files.
- Implement large features in small stages.
- Don't mix unrelated refactoring or formatting changes.
- Include permission checks for new APIs.
- Check whether related tests and documentation updates are needed when adding features.
- Summarize git status and git diff before commits.The template below can be used directly when adding new features.
Proceed with the feature addition workflow.
Feature description:
-
User scenarios:
1.
2.
3.
Expected behavior:
-
Constraints:
- Maintain existing API response format if possible
- Follow existing code style and folder structure
- Don't refactor unrelated code
- Present plan before modifying files
Progress sequence:
1. Organize requirements.
2. Ask about unclear points.
3. Find related file candidates.
4. Investigate existing similar features and patterns.
5. Propose staged implementation plan.
6. Create test plan.
7. Once I approve, implement stage 1 with minimal changes.
8. After each stage, summarize git diff.
9. At the end, check whether tests and documentation updates are needed.
Don't modify files yet.For complex features, add on the first line.
ultrathink.To use Plan Mode together, start this way.
ultrathink.
Create a feature addition plan in Plan Mode.
Don't modify files until I approve.I want to add a feature where post authors get notifications when comments are added.
First organize requirements,
and find the comment creation flow, user model, and any existing notification-related code.
Don't implement yet; only propose a plan.I want to add a post search feature.
Requirements:
- Search in title and body
- Handle empty search term
- Maintain pagination
- Compatible with existing list API
First investigate related API and query structure,
then propose implementation plan and test cases.I want to add a feature where admins can deactivate users.
ultrathink.
Organize requirements and risk factors focusing on permission verification.
Need to ensure regular users can't bypass this feature.
Don't modify files yet.I want to add a profile image upload feature.
First design:
1. Allowed file types
2. Maximum file size
3. Storage location
4. Security validation
5. Failure handling
6. Test cases
Proceed with implementation after my approval.I want to add a subscription payment feature.
ultrathink.
Organize requirements and implementation plan based on payment success, failure, webhook, duplicate requests, refunds, permissions, and DB consistency.
Don't modify files yet.Confirm the checklist below each time you add a feature.
Feature addition isn't "just build it" but requirements clarification → related file exploration → plan approval → staged implementation → testing → documentation → diff review.
git status, git diff for unintended changes.Unit 19. Refactoring and Requesting Code Review
Refactoring is not about creating new features. It is improving code structure, removing duplication, clarifying names, separating concerns, and enhancing testability while preserving existing behavior.
Bad request:
Clean up this code for me.Good request:
I want to refactor this code.
Goal: preserve existing behavior
Remove duplicate validation logic
Separate function responsibilities
Existing tests should still pass
First propose a refactoring plan without making changes.Refactoring scope can easily grow larger. So it is safer to start with Plan Mode first. The official common workflows documentation also recommends "Plan before editing," suggesting Plan Mode if you want to review changes before they touch disk. Also, exploring large codebases can be delegated to subagents to keep the main context clean.
Request example:
Create a refactoring plan using Plan Mode.
Target: src/auth folder
Goal: separate token parsing logic
Remove session validation duplication
Preserve existing API response format
Include in the plan:
1. Current structure summary
2. Files to refactor
3. Behavior that must not change
4. Step-by-step modification order
5. Testing method for each step
6. Risk factors
7. Rollback method
Don't modify files until I approve.To start in plan mode from the beginning:
claude --permission-mode planRefactoring often leads to situations where you intended to clean up a little but ended up changing the whole project. That is why scope must be clearly limited.
Bad request:
Refactor the entire codebase.Good request:
Refactor only src/auth/session.ts file.
Constraints: don't change public function names
Preserve API response format
If tests break, stop and explain the reason
Don't make unrelated formatting changes.src/auth/session.tssrc/auth/**When you don't know what to refactor, start by finding candidates.
Request example:
Find refactoring candidates for me.
Criteria:
1. Duplicate code
2. Functions that are too long
3. Files with too many responsibilities
4. Functions with vague names
5. Error handling that repeats
6. Structures that are hard to test
Output: file path, problem description, refactoring difficulty, risk level, order
Don't modify files yet.session.ts — token validation duplication, medium riskauthMiddleware.ts — too many responsibilities, high riskvalidators.ts — vague function names, low riskBeginners should start with low-risk items first.
The most important thing in refactoring is "preserving existing behavior". You must clearly communicate this condition to Claude.
Refactoring conditions:
- Preserve existing public API
- Don't change function inputs and outputs
- Preserve error message format
- All existing tests must pass
- Performance characteristics must not degrade
- Don't modify unrelated filesEspecially for API or library code, be stricter:
This module is code that other modules import and use.
Don't change exported function names, types, or return values.
Only clean up the internal implementation.For UI components:
Don't change UI behavior or visual results.
Only improve component separation and state management structure.Large refactoring all at once is hard to review. You should proceed in small, testable units.
Request to divide into steps:
Break this refactoring into small steps.
Conditions:
- Each step must be reviewable with git diff
- Don't modify too many files in one step
- Each step should be testable
- Don't mix behavior changes with structure changesStep examples:
Step 1: Combine duplicate validation functions into one
Step 2: Separate token parsing function into its own file
Step 3: Change auth middleware to call session service
Step 4: Run existing tests
Step 5: Add necessary regression testsRequest one step at a time:
Apply only step 1 from the plan.
Make minimal changes,
and after completion show me the modified files and git diff summary.Testing is important in refactoring since you must not change behavior.
Finding test commands before refactoring:
Find relevant test commands before refactoring.
After confirming the test commands,
suggest which tests to run after modification.Testing after modification:
Run relevant tests for me.
If they fail, analyze only the first failure reason,
and check if refactoring changed the behavior.Claude can observe existing test files and match project test style, frameworks, and assertion patterns, and can suggest edge cases.
If tests are insufficient:
Check if there are insufficient tests for safe refactoring.
If regression tests following existing test style are needed, suggest them.
Don't modify test files yet.After refactoring, always check Git diff.
git status
git diffRequest Claude like this:
Review the current git diff for me.
Check for:
1. Whether behavior changes are mixed in
2. Whether files outside refactoring scope were modified
3. Whether unnecessary formatting changes are mixed in
4. Whether public API changed
5. Whether there are parts that need testing
6. Whether commits need to be split
Don't run git add or commit yet.For large refactoring, use Ultra Think:
ultrathink.
Review the current git diff deeply.
Analyze whether this change is pure refactoring,
whether behavior changes are mixed in,
and whether there are unconfirmed risks by tests.Code review is not just something done at the end of work. You can request it at these moments.
Basic request:
Review my current changes for code review.
Review from security, performance, maintainability, and test coverage perspectives.
Don't make modifications yet, just provide review feedback.Getting results by priority:
Organize review results in this format.
1. Critical: issues that must be fixed
2. Warning: issues that should be fixed
3. Suggestion: improvements to consider
4. Question: design questions needing clarification/code-reviewClaude Code provides bundled skills like /code-review, /debug, /batch, /loop, and /claude-api in every session, callable directly in /skill-name format. /code-review is not a fixed-logic command but a prompt-based skill where Claude orchestrates tools to accomplish the work.
Basic usage:
/code-reviewRequest more specifically:
/code-review Review based on the current git diff.
Prioritize security, error handling, missing tests, and performance issues.For beginners, read-only review is recommended as default:
/code-review
Just review.
Don't modify files.Auto-fix is considered only under these conditions:
Safe request:
Show me code review results first.
Don't auto-fix.
Once I approve each item, fix them one at a time.You can also request review without using /code-review.
Review my current changes from a senior engineer perspective.
Scope: based on git diff, focus on modified files, include new tests
Focus on:
1. Bug potential
2. Security issues
3. Missing permission validation
4. Error handling
5. Performance issues
6. Duplicate code
7. Missing tests
8. Maintainability
Format: Critical / Warning / Suggestion / Praise / Final judgmentMore strictly:
Find only review-blocking-level issues first.
Put style preferences and minor naming aside for later.More gently:
Review as if explaining to a beginner.
Explain not just problems but why they are problems and how to fix them.If the code includes permissions, authentication, payments, personal information, file uploads, or admin features, request a separate security review.
Review code from a security perspective.
Check:
1. Whether APIs requiring authentication have auth checks
2. Whether users can only access their own data
3. Whether admin permission bypass is possible
4. Whether input validation is sufficient
5. Whether sensitive information is exposed in logs or responses
6. Whether secrets, API keys, or tokens are included in code
7. Whether error messages expose internal information
8. Whether rate limit or abuse prevention is needed
Don't make modifications yet, just show review results.For critical changes, add Ultra Think:
ultrathink.
This change is related to permission logic.
Review deeply focusing on permission bypass potential.
Don't make modifications yet.Refactoring can also degrade performance. Especially when loops, DB queries, API calls, or rendering are involved, request performance review.
Review code from a performance perspective.
Check:
1. Unnecessary loops
2. N+1 query potential
3. Duplicate API calls
4. Parts that need caching
5. Async handling issues
6. Code that slows with large data
7. React re-render potential
8. Memory usage increase potential
Don't make modifications yet,
but report risk level and rationale.Performance review should not end in speculation:
For suspected performance issues,
also suggest measurement methods or logs/tests to check.The core goal of refactoring is improving maintainability.
Review code from a maintainability perspective.
Check:
1. Whether functions have too many responsibilities
2. Whether names clearly express intent
3. Whether there is duplicate logic
4. Whether abstraction is excessive or insufficient
5. Whether structure is easy to test
6. Whether new developers can easily understand it
7. Whether error handling patterns are consistent
8. Whether it matches existing project styleDon't immediately apply review results; examine them first:
Organize maintainability improvements by risk level.
Distinguish whether each suggestion has real value
or is just a style preference.If you do code reviews repeatedly, you can create a code-reviewer subagent. Design it as a read-only code reviewer.
Save location: .claude/agents/code-reviewer.md
Example file:
---
name: code-reviewer
description: Read-only code reviewer that examines code quality, security, and maintainability. Use immediately after code changes.
tools: Read, Grep, Glob, Bash
model: inherit
---
You are a senior code reviewer.
Review procedure:
1. Run git diff to check recent changes.
2. Focus on modified files.
3. Do not modify code.
4. Provide review results only.
Review checklist:
- Is code clear and easy to read?
- Are function and variable names appropriate?
- Is there duplicate code?
- Is error handling adequate?
- Are there no exposed secrets, API keys, or tokens?
- Is input validation sufficient?
- Is test coverage sufficient?
- Are there performance issues?
Output format:
- Critical: issues that must be fixed
- Warning: issues worth fixing
- Suggestion: worthwhile improvements
- Good: things done wellUsage example:
Review my current changes with the code-reviewer subagent.
Just show review results without modifying.Code reviewers should fundamentally not have modify permissions. If reviewers detect and fix simultaneously, changes can get mixed in before users review.
Good tool setup:
tools: Read, Grep, Glob, BashSetup to avoid:
tools: Read, Grep, Glob, Bash, Edit, WriteSeparate review from modification:
After receiving review, don't immediately fix everything; prioritize first.
Choose only issues from review that absolutely need fixing.
Separate Critical from Warning,
and tell me each item's fix difficulty and risk level.Then fix one at a time:
Fix only Critical item 1.
Don't touch other review items yet.
After fixing, summarize the git diff.Verify after applying review:
Check whether the fix just made resolves the review item.
Also check if new issues appeared.Bad request to auto-fix everything:
Fix all the review issues.Safer request:
Organize review items by priority.
Fix only the items I approve, one at a time.Before creating a PR, review changes from a reviewer perspective.
Request example:
Before creating a PR, review changes from a reviewer perspective.
Check:
1. Whether PR purpose is clear
2. Whether scope is not too large
3. Whether test results are sufficient
4. What files reviewers should focus on
5. Risky changes
6. Whether commits need splitting
7. Content for PR descriptionPR description template:
## Change Summary
-
## Refactoring Goal
-
## Behavior Changes
- None / Yes
## Testing
-
## What Reviewers Should Focus On
-
## Risk Factors
-At team scale, you can automate Claude Code review with GitHub Actions. For the beginner guide, learning the local workflow first before automation is better.
Recommended order:
Even when adopting auto-review, people must make final judgments:
Keep repeated rules short in CLAUDE.md.
# Refactoring Rules
- Refactoring must preserve existing behavior.
- Don't change public API, response format, or error messages without explicit approval.
- Large refactoring should present plan in Plan Mode first.
- Divide changes into small steps and test after each step.
- Don't mix unrelated formatting or naming changes.
- Review git status and git diff before commit.
# Code Review Rules
- Reviews are based on git diff.
- Prioritize into Critical, Warning, and Suggestion.
- Prioritize reviewing security, permissions, error handling, and missing tests.
- Keep reviewer subagents read-only by default.
- Apply only user-approved review items.Follow refactoring workflow.
Target:
- Goal:
- Behavior to preserve:
- What must not change:
- Public API
- Response format
- Error messages
- Existing test expectations
Workflow rules:
1. Don't modify immediately.
2. First summarize current structure.
3. Organize refactoring candidates and risk levels.
4. Create plan in small steps.
5. Once I approve, modify only step 1.
6. Run relevant tests after each step.
7. Review git diff to check for behavior changes.
8. Suggest commit split criteria.For complex refactoring:
ultrathink.
Create refactoring plan in Plan Mode first.
Don't modify files until I approve.Follow code review workflow.
Target: current git diff
Review perspectives:
1. correctness
2. security
3. permission/auth
4. error handling
5. performance
6. maintainability
7. test coverage
8. documentation needed
Output format:
- Critical: must fix
- Warning: should fix
- Suggestion: improvement idea
- Question: needs clarification
- Good: things done well
Rules:
- Don't modify files.
- Just provide review results.
- Include rationale and file location for each item.
- Make fix suggestions specific, but only apply after I approve.I want to refactor duplicate validation logic.
First find duplicate locations,
and analyze whether behavior is preserved when separating into a common function.
Don't modify files yet.This function is too long.
Create a plan to divide responsibilities while preserving behavior.
Also tell me test cases to run after function separation.I want to reduce any type usage.
First find where any is used,
and suggest type improvement plan ordered by risk level.
Don't change behavior.I want to make error handling patterns consistent.
First investigate existing error handling methods,
and create an improvement plan matching existing patterns, not creating new ones.I want to improve this code's performance.
First analyze possible bottlenecks,
and suggest measurement methods.
Be careful not to change behavior under the guise of performance improvement.Beginner refactoring and code review checklist:
Refactoring is work that improves internal structure while preserving existing behavior. It is safer to create a plan in Plan Mode before refactoring.
Limit change scope by file, folder, public API, and test criteria. Divide large refactoring into small, testable steps.
After modification, always run related tests and review git diff. Code review can be requested not just before commit, but also at the planning stage, mid-stage, and before PR.
/code-review is a bundled skill in Claude Code available in every session, and beginners should use read-only review by default rather than auto-fix review.
Security, permissions, payments, and personal information changes require separate security review and Ultra Think. Repeated reviews can be separated into a code-reviewer subagent, and it is good to keep reviewer subagents read-only.
Section 20. Running tests, linting, and builds with Claude
The goal of this section is to safely delegate the following tasks to Claude Code.
1. Find the project's test, lint, and build commands.
2. Run only the relevant tests first.
3. Analyze the root cause from the failure log.
4. Fix lint errors safely.
5. Narrow down build failure causes step by step.
6. Get a plan before automatic fixes.
7. Run tests, lint, and build again after fixes.
8. Finally, review changes with git diff.For Claude to run tests, it needs to know what commands your project uses. The best approach is to document the commands in CLAUDE.md.
# Project Commands
## Test
- Full test: npm test
- Auth test: npm test -- auth
## Lint
- npm run lint
## Build
- npm run build
## Type Check
- npm run typecheckIf you don't know the commands already, have Claude find them first.
Find the test, lint, and build commands for this project.
Files to check:
- package.json
- README
- Makefile
- pyproject.toml
- composer.json
- Cargo.toml
- docs folder
Don't run commands yet.
Just organize the candidate commands and their rationale.After finding the commands, check safety before running.
Distinguish which commands are safe to run now.
Categorize tests, lint, build, and commands with deployment/deletion/external call potential separately.
Don't run them yet.Beginners often run the full test suite right after fixing a feature. However, on large projects this takes time and produces long logs. Running related tests first is better.
npm test -- auth
pytest tests/test_auth.py
go test ./internal/authRun only tests related to this change first.
If full tests are needed, explain why,
and tell me which command you'll run before executing.If the scope is small, restrict it further.
Find and run only tests directly related to the files you modified.
If no tests exist, suggest what tests should be added first.When tests fail, don't blindly ask Claude to fix everything.
Tests failed. Fix everything.Analyze only the first failure cause from the test failure log.
Distinguish cascading failures separately,
and propose the root cause and fix plan first.
Don't modify files yet.This format is useful when analyzing test failure logs.
Analyze the test failure.
Run command:
- npm test -- auth
First failure:
- (failure message)
Related stack trace:
- (stack trace)
Request:
1. Explain what the failed test is validating.
2. Estimate the actual root cause.
3. Suggest up to 3 related file candidates.
4. Present a fix plan first.
5. Don't modify files yet.If the log is long, limit like this.
Don't read the entire log.
Analyze based only on the first FAIL block and its surrounding stack trace.
Tell me what additional log sections you need, if any.Follow this sequence when fixing test failures.
git diff.Before fixing this test failure,
determine first whether the test expectation is correct or the implementation is wrong.
If a fix is needed, present a minimal change plan.The test itself may be wrong, so don't immediately change the implementation.
Compare cases where the test should be fixed vs. cases where the implementation should be fixed.
Explain which is more justified with reasoning.
Don't modify anything yet.When you fix a bug, it's good to add a regression test so the same problem doesn't happen again.
Add a regression test so this bug doesn't happen again.
Conditions:
- Follow existing test style
- Should fail before the fix and pass after
- Test name should describe the bug scenario
- Propose the test plan first,
and modify the test file after my approval.If the project lacks tests, ask like this.
This project seems to lack test structure.
Suggest the smallest test method to validate this change.
Tell me whether unit tests, integration tests, or manual verification is appropriate.Lint is a tool that catches code style, potential errors, and rule violations.
npm run lint
pnpm lint
ruff check .
eslint .First, confirm the command.
Confirm this project's lint command.
Find evidence in package.json or README,
and tell me only the command candidates without running yet.Then run it.
Run the lint command.
If it fails, categorize errors by type,
and distinguish what can be auto-fixed from what requires human judgment.Lint errors usually fall into these categories.
unused variable — delete or verify usageno-explicit-any — requires design judgmentsort-imports — can be auto-fixedno-floating-promises — requires human reviewMany projects have auto-fix commands.
npm run lint -- --fix
eslint . --fix
ruff check . --fixHowever, auto-fix can change more files than expected. So always get a plan first.
Before running lint auto-fix,
explain which command you'll run and which files might be affected.
Don't run --fix yet.After running, always review the diff.
After running lint --fix, review git diff.
Distinguish formatting changes, actual logic changes, and unintended changes.--fix is convenient, but always confirm with git diff after running.Build is a process to verify that code is in a deployable state.
npm run build
pnpm build
cargo build
go build ./...Find this project's build command.
Show command candidates and evidence first,
and run after my approval.If build fails:
Analyze the build failure log.
Explain the root cause based on the first actual error,
and distinguish type errors, import errors, environment variable errors, and config errors.
Don't modify files yet.Build failures usually fall into these categories.
.env.example and configIn projects using TypeScript, Python, Rust, Go, etc., it helps to run type checking separately before build.
npm run typecheck
tsc --noEmit
mypy .
cargo checkCheck if this project has a typecheck command.
If it does, suggest a workflow that runs typecheck before build.Type errors can be more directly connected to actual behavior than lint errors.
Analyze type errors.
Don't mask them with simple type casting,
but verify first that actual data structures and function return values are correct.Change to any and pass.Don't mask type errors with any,
but infer the correct type and propose a fix plan.Builds, full tests, E2E tests, and dev servers can take time. Claude Code supports background bash commands, allowing Claude to receive a task ID immediately and continue processing other requests.
Full tests might take a while, so run them in the background.
While they're running, review related files,
and when done, read the result log and analyze only the first failure.You can also run directly in shell mode by prefixing with !, which executes the shell command without Claude.
! npm testHowever, long output consumes context, so for long tests, run only necessary ranges or request a summary.
A safe general verification order is usually this.
But it can vary by project. Have Claude decide the order.
Suggest the command execution order to validate this change.
Consider:
1. Fastest verification first
2. Order that makes failure causes easy to narrow down
3. Long commands last
4. Full tests last if needed
5. Expected purpose of each command
Don't run yet.When tests, lint, and build all fail, it's easy to panic. Don't try to fix everything at once.
Even if there are multiple failures, don't fix them all at once.
First categorize failures by type,
and choose only the one with the most likely root cause.Categorize failure logs by type.
Organize by likelihood of root cause,
and propose a fix plan for only the first cause.
Don't modify files yet.When Claude tries to fix test or lint failures, always get a plan before auto-fixing.
Show the plan before auto-fixing.
Include:
1. Which failure you'll fix
2. Rationale for the root cause
3. Files to modify
4. How to fix
5. Expected side effects
6. Commands to run after the fix
7. How to revert
Don't modify files until I approve.Even after approval, limit the scope.
Modify only item 1 from the plan.
Don't touch other failures yet.
Run only related tests after the fix.In frontend projects, snapshot tests can fail. Auto-updating snapshots can cause you to miss actual UI changes.
Update snapshot and make it pass.Analyze the snapshot failure cause first.
Distinguish whether it's an intended UI change, a bug, or a broken test.
If snapshot update is needed, explain why,
and don't update until I approve.Build failures can be due to environment variable issues rather than code problems.
Missing required environment variable: DATABASE_URLReading or modifying .env is risky. Sensitive files must be protected.
Check if build failure is due to environment variables.
Don't read the .env file,
but estimate needed variable names from .env.example, README, and config schema.Don't modify the .env file.
If needed, propose a plan to add only missing variable names and descriptions to .env.example.While fixing tests or build, lockfiles like package-lock.json, pnpm-lock.yaml, yarn.lock can change.
Lockfile changes can be intentional, but dependency installs or version changes might be mixed in.
Check if the lockfile changed.
If it did, explain why,
and whether the change is necessary for this task.
Don't commit yet.If dependency installation is needed:
Verify that installing a new dependency is really necessary.
Check if existing dependencies can solve it,
and if installation is needed, explain the reason and impact scope.Tests, lint, and formatting are repetitive. Hooks can automate recurring verifications.
Hooks are custom shell commands that run at specific points in the Claude Code lifecycle. For example, you can automate formatting after editing files, blocking commands before execution, or validating on completion.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}Beginners should start with simpler hooks rather than complex ones.
Hooks are powerful but can ruin your workflow if configured wrong.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npm test"
}
]
}
]
}
}Running full tests on every file edit would be too slow.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npm run lint -- --quiet"
}
]
}
]
}
}Or establish team rules like this.
Document recurring test, lint, and build rules in CLAUDE.md.
# Verification Workflow
## Commands
- Test related files first: npm test --
- Full test: npm test
- Lint: npm run lint
- Type check: npm run typecheck
- Build: npm run build
## Rules
- Run related tests first after modifications.
- Run full tests after related tests pass.
- Get user approval before running lint --fix.
- Explain snapshot updates and get approval before running.
- Start from the first actual error when analyzing build failures.
- Don't read or modify the .env file.
- Summarize git status and git diff before committing.You can use this template directly after implementing features or fixing bugs.
Run the verification workflow.
This change:
- (modification description)
Progress order:
1. Find related test commands.
2. Run related tests first.
3. If failing, analyze only the first failure cause.
4. Confirm and run the lint command.
5. Divide lint failures into auto-fix/needs-judgment.
6. Run typecheck if available.
7. Confirm and run the build command.
8. Determine if full tests are needed.
9. Finally, review git status and git diff.
Rules:
- Tell me which command you'll run before executing.
- Don't auto-fix until I approve.
- Don't run lint --fix, snapshot update, or dependency install without approval.
- Don't read or modify .env.Finally, here's Section 20's essentials as a checklist.
Tests, lint, and build are core verification routines that validate Claude Code's changes. Start by documenting your project's test, lint, and build commands in CLAUDE.md.
If you don't know the commands, have Claude check package.json, README, Makefile, etc., and get candidates and reasoning before running. Always run related tests first before full tests, analyze from the first actual failure, and distinguish cascading failures from root causes.
Categorize lint errors into auto-fixable and judgment-required types, and never run lint --fix, snapshot updates, or dependency installs without approval. Analyze build failures by categorizing into type, import, environment variable, dependency, and bundler configuration issues.
git status and git diff to catch unintended changes.Section 21. Speeding Up Work with Slash Commands and Keyboard Shortcuts
When people use Claude Code for the first time, they try to request everything using sentences.
The conversation seems to have gotten really long. Can you clean it up and keep only the important content?But Claude Code has commands that accomplish the same goal much faster.
/compactIn other words, slash commands are shortcuts — they're like buttons that execute repeated operations quickly.
/modelBeginners don't need to memorize every command. Just learning /help, /usage, /model, /status, /context, /compact, /clear, /diff, /permissions, and /config is enough.
/usage is the central command that shows session costs, plan usage, and activity statistics. /cost and /stats are aliases for /usage that feel familiar to existing users.
Claude Code works in "work sessions" rather than single chats. You need to know commands for continuing sessions, starting new ones, or rewinding.
/clear auth-fix-before-refactor/resume/rename payment-bug-fix/branch alternate-approach/rewind/export session-notes.md/exitFor beginners, the most important are /clear and /resume. Use /clear to empty context when starting new work, and /resume when you need to go back to previous work.
/rename login-bug-investigation
/context
/compact focus on login bug root cause and files already inspected
/clear payment-refactor-startAs Claude Code sessions grow longer, context and costs can increase. You should use cost, model, and reasoning depth commands frequently.
/usage alias | Use if you prefer this termSimple question → Keep current model as-is
Small edit → Current model + low effort
Complex bug → Better model + high effort
Large refactor → /plan first, then adjust model/effort if needed
Long session → Check /context then /compact or /clear/model opens a model selector or switches to a specified model, while /effort is used to choose reasoning depth like low, medium, high, xhigh, max, or auto.
Claude Code can read, modify, and execute commands on files. That's why "safe work" matters more than "fast work".
/config alias | Use to open settings/permissions alias | Use when managing allowed toolsStarting new project → /status
Too many permission prompts → /permissions
Terminal input feels awkward → /terminal-setup
Installation or auth issues → /doctorThese connect with the testing, linting, building, and review workflows you learned earlier.
/init
/plan add validation to signup form
/diff
/code-review high
/usage/, !, @In Claude Code, / isn't the only important prefix. There are prefixes you use frequently at the start or middle of input.
/context! git status@src/auth.tsIf you want to include and check Git status in the Claude conversation:
! git statusTo ask a question while pointing to a specific file:
@src/auth.ts Explain the authentication flow in this file in a way beginners can understand.Shortcuts exist to reduce interruptions in your workflow, not just to type faster.
Shortcuts vary by platform and terminal. On macOS, you may need to configure Option as Meta in your terminal for Option/Alt shortcuts to work properly.
When writing long prompts, shortcuts for moving the cursor, deleting parts, and pasting are useful.
On Windows, Ctrl+Backspace also works for deleting the previous word.
In Claude Code, Enter submits messages by default. To write multi-line prompts, you need alternative input methods.
Shift+Enter works on most modern terminals, but on VS Code, Cursor, Windsurf, Alacritty, and Zed you may need to run /terminal-setup first.
Priority 1: Shift+Enter
If that doesn't work: Ctrl+J
If still confused: \ + Enter/keybindingsIf default shortcuts don't fit your hands or conflict with your terminal, use /keybindings.
/keybindingsCustom keyboard shortcuts are available in Claude Code v2.1.18 and later. Running /keybindings lets you create or open ~/.claude/keybindings.json. Changes to this file are auto-detected and applied without restarting Claude Code.
As a beginner, it's better not to change many shortcuts at first. Get comfortable with the defaults first, and only customize shortcuts that truly conflict — this builds efficient finger memory.
Older materials often explain custom slash commands by creating them in .claude/commands/. In the latest official docs, custom commands have been unified with skills.
Both .claude/commands/deploy.md and .claude/skills/deploy/SKILL.md create /deploy, and existing .claude/commands/ files still work. However, when creating new ones, the skills approach is more extensible.
Slash commands are best for explicit tasks the user invokes directly, skills are for expert knowledge Claude applies automatically based on context, and subagents are for work to be handled in separate contexts.
/help → Search in the list/status → If odd, run /doctor/usage → If high, run /compact or /clear/context → If needed, run /compact/clear → Name and save previous work/plan → Approve plan then execute/diff → Request review if issues arise/code-review → Use --fix if needed/security-review → Use when changing auth, permissions, input/config → Model, theme, output style/permissions → Adjust allow, ask, deny rules/terminal-setup → Configure Shift+Enter etc./keybindings → Modify only conflicting keys/status
/usage
/contextCheck current status, costs, and context.
/plan implement password reset flowGet the plan first and review the scope of file changes.
@src/auth.ts Check only the parts related to password reset flow.
! npm testReference only the files you need and include test results in the conversation.
/diff
/code-review highReview changes and request a review.
/usage
/compact focus on final implementation summary and remaining risksCheck costs and leave key takeaways for the next session.
Slash commands are the command system for controlling Claude Code quickly. You don't need to memorize every command — start with the ones you use most often.
Shortcuts speed up work, but their real purpose is keeping your flow uninterrupted. Once you're comfortable with defaults, only customize the ones you truly need.
By current standards, cost checking centers on /usage, and /cost is presented as an alias. Custom slash commands are understood in connection with skills rather than as independent features, which aligns with the current official documentation.
Section 22. Prompt Engineering Fundamentals — The Art of Asking Good Questions
You can tell Claude something like this:
Always run prettier after modifying a file.But this is a prompt. Claude must remember and execute it within the conversation flow. If sessions get long or context gets compressed, it might slip.
Hooks are different. Claude automatically runs prettier after editing a file. It's not about Claude "remembering to execute"—rather, Claude Code always runs it at a defined event.
The rule is simple.
Beginners can start by learning command hooks that work with shell commands.
Hooks attach to specific Claude Code events. Beginners need to know just these 6 first.
The official hook reference offers more events. For example, PostToolUseFailure, PostToolBatch, SubagentStart, SubagentStop, ConfigChange, CwdChanged, FileChanged, PreCompact, PostCompact, SessionEnd, and more. But for a beginner's guide, it's best to focus learning around PreToolUse and PostToolUse.
Hooks for a project usually go in .claude/settings.json at the project root.
my-project/
├── .claude/
│ ├── settings.json
│ └── hooks/
│ └── protect-files.sh
├── src/
└── package.jsonHere's the basic configuration structure.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "echo 'file edited'"
}
]
}
]
}
}You can view currently registered hooks read-only with the /hooks command. Make edits in the settings JSON file.
Let's interpret the following configuration line by line.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}The matcher is a filter that narrows down which hooks execute. Bash matches only the Bash tool, Edit|Write matches only file-edit tools, and mcp__github__.* matches only GitHub MCP tools. MCP tool names follow the format mcp__<server>__<tool>.
The easiest hook is "automatically run a formatter when Claude edits a file."
Add the following to .claude/settings.json.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}This hook extracts the modified file path after Claude edits it and passes it to prettier --write. Note that jq is required. On macOS, install with brew install jq; on Ubuntu/Debian, use apt-get install jq.
For beginners, it's better to split the command into a separate script file rather than write it too long.
First, create the file.
mkdir -p .claude/hooks
touch .claude/hooks/format-edited-file.sh
chmod +x .claude/hooks/format-edited-file.sh.claude/hooks/format-edited-file.sh
#!/usr/bin/env bash
set -euo pipefail
input="$(cat)"
file_path="$(echo "$input" | jq -r '.tool_input.file_path // empty')"
if [ -z "$file_path" ]; then
exit 0
fi
case "$file_path" in
*.js|*.jsx|*.ts|*.tsx|*.json|*.md|*.css)
npx prettier --write "$file_path"
;;
esacThen link it in .claude/settings.json.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format-edited-file.sh",
"args": []
}
]
}
]
}
}To reliably reference hook scripts relative to the project, use ${CLAUDE_PROJECT_DIR}.
Hooks aren't just for automation; they're also safety guards. For example, you can prevent Claude from modifying files like .env, .git, or package-lock.json.
.claude/hooks/protect-files.sh
#!/usr/bin/env bash
set -euo pipefail
input="$(cat)"
file_path="$(echo "$input" | jq -r '.tool_input.file_path // empty')"
if [ -z "$file_path" ]; then
exit 0
fi
case "$file_path" in
*.env|*.env.*|.env|.git/*|package-lock.json|pnpm-lock.yaml|yarn.lock|*.pem|*.key)
echo "Blocked by project hook: protected file cannot be edited: $file_path" >&2
exit 2
;;
esac
exit 0Give it execute permission.
chmod +x .claude/hooks/protect-files.shThen link it in .claude/settings.json.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/protect-files.sh",
"args": []
}
]
}
]
}
}Here we use PreToolUse because we need to check before modification happens, not after.
Command hooks signal results to Claude Code via exit code.
However, not all events block the same way. Exit code 2 in PreToolUse can block because it happens before tool execution. PostToolUse, on the other hand, runs after the tool has already executed, so you can't revert it the same way.
Here's how beginners can remember it:
Formatting can auto-fix, but linting or typechecking can take time. Start with lightweight checks.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npm run lint -- --quiet"
}
]
}
]
}
}But this config can be slow because full lint runs every time you edit a file.
By default, hooks block Claude's execution until they complete. Long-running tasks like tests or external API calls can slow down your workflow.
That's when you use async: true.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/run-tests-async.sh",
"args": [],
"async": true,
"timeout": 300
}
]
}
]
}
}Async hooks don't block Claude and run in the background. However, since the work already happened by the time it completes, you can't use them to block tool calls or return permission decisions.
You can set up hooks to send notifications when Claude is waiting for permission or input.
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification "Claude Code needs your attention" with title "Claude Code"'"
}
]
}
]
}
}{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "notify-send 'Claude Code' 'Claude Code needs your attention'"
}
]
}
]
}
}If you leave Notification hook's matcher empty, it reacts to all notification types. For specific cases, you can use matchers like permission_prompt, idle_prompt, or auth_success.
As sessions grow, conversations get summarized via /compact or automatic compaction. Important project rules can weaken in the process.
For example, you can reinjection important content after each compression.
{
"hooks": {
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{
"type": "command",
"command": "echo 'Reminder: use Bun, not npm. Run bun test before committing. Current sprint: auth refactor.'"
}
]
}
]
}
}Adding a compact matcher to SessionStart hooks lets you reinject critical context after compression. However, static project rules are better kept in CLAUDE.md than in hooks.
Hook scripts receive JSON from Claude Code on stdin.
For example, a Bash pre-execution hook might receive input like this:
{
"session_id": "abc123",
"transcript_path": "/home/user/.claude/projects/.../transcript.jsonl",
"cwd": "/home/user/my-project",
"permission_mode": "default",
"hook_event_name": "PreToolUse",
"tool_name": "Bash",
"tool_input": {
"command": "npm test"
}
}That's why shell scripts usually start like this:
input="$(cat)"
tool_name="$(echo "$input" | jq -r '.tool_name // empty')"
command="$(echo "$input" | jq -r '.tool_input.command // empty')"
file_path="$(echo "$input" | jq -r '.tool_input.file_path // empty')"Here's a hook that blocks dangerous commands like rm -rf.
.claude/hooks/block-dangerous-bash.sh
#!/usr/bin/env bash
set -euo pipefail
input="$(cat)"
command="$(echo "$input" | jq -r '.tool_input.command // empty')"
if echo "$command" | grep -Eq 'rm[[:space:]]+-rf|sudo|chmod[[:space:]]+777|curl .* | sh|wget .* | sh'; then
echo "Blocked by hook: dangerous bash command: $command" >&2
exit 2
fi
exit 0Link it in .claude/settings.json as a PreToolUse.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-dangerous-bash.sh",
"args": []
}
]
}
]
}
}The official reference also shows a structured JSON approach where PreToolUse hooks inspect Bash commands and return permissionDecision: "deny". For beginners, the exit code 2 approach is easier to understand; you can graduate to JSON output later when finer control is needed.
Hooks don't replace the permission system. Permissions manage "which tools Claude can use," while hooks manage "what runs automatically or blocks in specific situations."
Even with hooks in place, permission settings remain important.
Most beginners only need command hooks. But some automation is hard to judge with simple shell conditions.
For example, "Claude said the work is done, but did they really finish everything requested?" is hard to judge with just grep. That's when prompt or agent hooks come in handy.
Agent hooks are experimental; prioritize command hooks in production workflows.
Hooks are powerful but risky. Command hooks especially run shell commands with your account privileges. Review and test before adding to settings.
The official security guidelines emphasize input validation, shell variable quoting, path traversal protection, absolute paths, and avoiding sensitive files.
If a hook isn't working, first check registration with /hooks.
/hooksThen enable debug logging.
claude --debug-file /tmp/claude.logIn another terminal, watch the log.
tail -f /tmp/claude.logHook execution details, matched hooks, exit codes, stdout, and stderr all appear in the debug log. Here's the debugging checklist:
Don't build complex automation from the start. Add hooks in this order:
{
"hooks": {
"Notification": [
{ "matcher": "", "hooks": [{ "type": "command", "command": "echo 'Claude Code needs attention' >&2" }] }
]
}
}{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format-edited-file.sh",
"args": []
}
]
}
]
}
}{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/protect-files.sh",
"args": []
}
]
}
]
}
}{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-dangerous-bash.sh",
"args": []
}
]
}
]
}
}These four cover most automation beginners need.
Add email format validation and error message to the signup form.
Find related files first, explain your plan, then proceed.After Claude edits files, you manually run formatting, linting, tests, and check diffs.
npx prettier --write src/...
npm run lint
npm test
git diffIf Claude tries to edit a protected file, the hook blocks it.
This is hooks' core power: automate routine work, block dangerous operations before they happen.
Hooks are Claude Code's automation layer. Prompts ask Claude to "do this", while hooks set rules that "always execute on specific events".
Beginners should start with PostToolUse to auto-format after edits, then PreToolUse to block sensitive file changes and dangerous Bash commands.
Hooks can become your automation layer when used well, aligning Claude Code with team rules. But since shell commands run with your privileges, start small and safe. Use /hooks to verify registration and claude --debug-file to troubleshoot.
MCP stands for Model Context Protocol. It's a protocol that standardizes how AI models connect to external tools, data, and APIs.
Without MCP, using only basic features:
Claude Code basic features
→ Read project files
→ Modify code
→ Run Bash commandsWith MCP connected:
Claude Code with MCP connected
→ Read GitHub PRs
→ Check Sentry errors
→ Query PostgreSQL schemas
→ Check Jira tickets
→ Reference Figma design info
→ Call internal APIsMCP servers provide three main capabilities.
Real development work doesn't end with just reading code. Without MCP, you repeatedly copy and paste external information.
With MCP connected, Claude can fetch this information directly and integrate it into your workflow.
1. User goes to Sentry.
2. Copies the error message.
3. Pastes it into Claude Code.
4. Claude infers the cause.
5. User goes back to Sentry to find more info.
6. Pastes again.1. Ask Claude: "Check auth service errors from the last 24 hours"
2. Claude uses the Sentry MCP tool
3. Analyzes errors, stack traces, and deployment info together
4. Proposes a code fix planMCP transforms Claude Code from a "code editing tool" into a "task agent connected to a development tool chain."
Beginners shouldn't think of MCP as "every cool external connection." Connect only when needed.
Practical rule: If you repeatedly copy and paste external info, consider MCP
Beginners should start with read-only MCP servers.
Connection decision criteria:
You repeatedly copy and paste external info → Consider MCP
Claude querying directly saves work time → Consider MCP
Read-only permission is sufficient → Good time to start MCP
Write permission needed → Design permissions carefully before connectingTo connect external tools with MCP, you need an MCP server. Here, "server" doesn't necessarily mean a cloud server.
Claude Code
↓
MCP server
↓
GitHub / Sentry / DB / Jira / Internal APIsThe MCP server tells Claude Code "here's the list of tools I can provide." Claude sees the user's request and chooses the appropriate tool to call.
Claude Code has several MCP server connection methods. Beginners only need to understand HTTP and stdio first.
Official docs recommend HTTP for remote MCP server connections.
This is the basic format for adding a remote HTTP MCP server.
claude mcp add --transport http <name> <url>Real example:
claude mcp add --transport http sentry https://mcp.sentry.dev/mcpAfter connecting, verify status inside Claude Code.
/mcpMCP servers are managed with terminal commands and the /mcp command inside Claude Code.
When adding an MCP server, you decide "where it applies."
Beginner guide:
First test → local
Whole team needs it → project
Personal tool for all projects → user
Contains API keys or personal tokens → Don't put directly in project scopeIf the whole team needs to use the same MCP server, use project scope.
claude mcp add --transport http github --scope project https://api.githubcopilot.com/mcp/This creates or updates .mcp.json at project root.
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
}
}
}Approval is required before using a project-scoped server.
Never put API keys or tokens directly in .mcp.json. Use environment variables instead.
{
"mcpServers": {
"internal-api": {
"type": "http",
"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": {
"Authorization": "Bearer ${INTERNAL_API_KEY}"
}
}
}
}This way, .mcp.json shares only the structure, and each person adds their own token via environment variables.
export INTERNAL_API_KEY="your-token"Connecting GitHub MCP lets you handle PRs, issues, and review workflows inside Claude Code.
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
--header "Authorization: Bearer YOUR_GITHUB_PAT"After connecting, you can request:
Review PR #456 and suggest improvements.
Create a new issue for the bug we just found.
Show me all open PRs assigned to me.It's better not to give write permissions from the start. Start with read-only or minimal-permission tokens.
Sentry MCP is useful for analyzing production errors.
claude mcp add --transport http sentry https://mcp.sentry.dev/mcpAuthenticate inside Claude Code.
/mcpThen make requests like:
What are the most common errors in the last 24 hours?
Show me the stack trace for error ID abc123.
Which deployment introduced these new errors?Databases are powerful but risky. Beginners must use read-only accounts.
claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
--dsn "postgresql://readonly:[email protected]:5432/analytics"After connecting, you can make requests like:
Show me the schema for the orders table.
Find customers who haven't made a purchase in 90 days.
What's our total revenue this month?Always apply these principles to production databases.
Some remote MCP servers require OAuth authentication. After adding the server, run /mcp inside Claude Code to complete the browser authentication flow.
/mcpBeginners should remember:
Need auth after adding server → /mcp
Browser opens → Log in
Claude Code manages the token
If stuck, check status with claude mcp get <name>MCP servers provide resources that Claude can read. You can reference them like files with @.
Can you analyze @github:issue://123 and suggest a fix?
Please review @docs:file://api/authentication.
Compare @postgres:schema://users with @docs:file://database/user-model.When you type @, connected MCP server resources may appear in autocomplete alongside files.
If an MCP server provides prompts, you can use them like slash commands in Claude Code.
/mcp__github__list_prs
/mcp__github__pr_review 456
/mcp__jira__create_issue "Bug in login flow" highRegular slash commands are Claude Code's own, while MCP prompt commands are provided by connected external servers.
Since MCP fetches external data, output can grow large. Default max output is 25,000 tokens.
export MAX_MCP_OUTPUT_TOKENS=50000
claudeBut beginners shouldn't raise limits blindly.
Good request: Show me the top 5 errors in the auth service from the last 24 hours.
Bad request: Get me all Sentry logs.
Good request: Show me the columns and indexes of the orders table.
Bad request: Get me the entire database schema.
When you connect many MCP servers, Claude has many tools to learn about. Claude Code uses Tool Search to manage this.
Tool Search loads only tool names at session start, then fetches relevant tool definitions when Claude actually needs them. It's enabled by default.
export ENABLE_TOOL_SEARCH=auto:5 claudeOr disable it completely:
export ENABLE_TOOL_SEARCH=false claudeIf you need a specific server's tools to always be preloaded, you can use alwaysLoad.
{
"mcpServers": {
"core-tools": {
"type": "http",
"url": "https://mcp.example.com/mcp",
"alwaysLoad": true
}
}
}alwaysLoad: true loads all that server's tools at session start. Use it only for a small set of frequently-needed tools.
MCP isn't a "more connected = better" feature. Wrong connections create cost, security, and confusion issues.
Beginner principle: Connect one at a time, start read-only.
Part 6 features have different roles.
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp/mcpCheck the top 5 errors in the auth service from the last 24 hours.Find which files these errors relate to and propose a fix plan./diff
/code-review highclaude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
--header "Authorization: Bearer ${GITHUB_TOKEN}"/mcpRead PR #456 and review from bugs, security, testing, and maintainability perspectives.Prioritize only the items that actually need fixing.claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
--dsn "${DATABASE_READONLY_URL}"Based on @postgres:schema://users and @postgres:schema://orders,
suggest the API response structure needed for the order history screen.Find related files in the current codebase and create a fix plan./plan implement order history API based on current DB schemaIf MCP isn't working, check in this order:
Don't connect many MCPs from the start. Add them in this order:
The safest first practice is to start "read-only focused" like Sentry or GitHub.
MCP is a standard protocol that connects Claude Code to external tools. Connecting tools like GitHub, Sentry, PostgreSQL, Jira, Figma, and internal APIs means Claude doesn't just see code—it can also consider the context of your actual development environment.
Beginners should remember this one principle:
MCP is powerful, but more connections aren't always better. The best approach is to start by connecting one safe server read-only to build a small success experience, then add only tools that match your team's workflow.
Section 24. Managing Large Projects: Running Multiple Agents Simultaneously
Subagents are a feature in Claude Code that breaks down large tasks into smaller, specialized subtasks. If the previous section's MCP was a bridge to connect external tools, subagents are a way to delegate work to a separate Claude instance.
By official documentation, a subagent is a specialized AI assistant that handles specific types of work. Each subagent runs in its own context window, can have custom system prompts, specific tool access permissions, and independent permission settings.
As you use Claude Code longer, too much information accumulates in a single session. For example, here's asking everything at once.
Read the authentication code,
read the DB model,
read the API routes,
run the tests,
analyze the error logs,
make a fix plan,
and finally change the code.When you do this, the context in the main conversation grows quickly. All the files you read, search results, test logs, and intermediate decisions pile up in the same chat window.
With subagents, you can split like this.
Main conversation:
- Manage the overall goal.
- Make final decisions.
- Judge whether to approve changes.
Subagent 1: Find authentication-related files only.
Subagent 2: Analyze DB models only.
Subagent 3: Analyze API routes only.
Main conversation: Combine summaries from the three subagents.Subagents start with a clean context, work with designated tools and models, and return only results to the main conversation, preventing context overflow.
Beginners typically ask Claude to read all files and fix them immediately. But in real development, it's safer to separate exploration from decision-making.
Exploration consumes lots of context by reading many files and logs. Decision-making, meanwhile, only needs key summaries. Subagents are ideal for separating the two.
Not every task needs subagents. The criterion is: Does bulk information appear that has no value in the main conversation?
The main conversation suits frequent back-and-forth, iterative refinement, and quick small changes. Subagents suit tasks where detailed output isn't needed in the main context, tools must be restricted, or work can finish independently and return a summary.
Claude Code comes with built-in subagents you can use. Beginners just need to understand these three.
Explore is a fast read-only agent optimized for codebase search and analysis. Plan is for context collection during plan mode. General-purpose is for work that needs both exploration and modification, or multiple dependent steps.
You don't need to create custom subagents at first. Just tell the prompt explicitly to use a subagent.
Use an explore agent to find all authentication-related files.
Do not modify anything. Return only the important files and why they matter.You can also be more explicit about which subagent to use.
Use the Explore subagent to find authentication-related files.
Don't modify them—just summarize each important file and its role.When automatic delegation isn't enough, you can specify a name in natural language, use @ mention to guarantee a specific subagent runs, or use the --agent flag to run the entire session with a specific agent.
If you want to use a specific subagent, use @ mention.
@"code-reviewer (agent)" look at the auth changes.Or, typed out in full:
@agent-code-reviewer Review the recent auth changes.@ mention fixes which subagent to run. But the specific task prompt delivered to the subagent is still written by Claude based on your current request.
Foreground subagents block the main conversation until completion and forward permission prompts to the user. Background subagents run in parallel, work with already-granted permissions, and auto-deny tools they don't have. Running tasks can be sent to background with Ctrl+B.
Run a thorough security review in the background while I continue working on the frontend.The biggest advantage of subagents is being able to divide independent exploration into parallel work.
Investigate the following three domains in separate subagents in parallel.
1. Authentication flow
2. Payment model
3. API routes
Each subagent should not modify files,
and return only a summary of related files, core flow, and risky areas.
Finally, combine the three results and propose a fix plan.Independent investigation works best when multiple subagents investigate in parallel and Claude combines the results. It works best when research paths don't depend on each other. For beginners, it's safer to include the condition don't modify.
Not all work suits parallel execution. Some tasks have the previous step's output become the next step's input.
1. Use the code-analyzer subagent to find performance issues.
2. Based on that result, have the optimizer subagent create a fix plan.
3. Before fixing, get my approval.In multi-step workflows, use subagents sequentially so Claude receives the first result and passes it as context to the next subagent. For beginners, remember the chain like this.
Explore → Plan → ImplementSubagents can save context, but cost doesn't automatically decrease. Each subagent also uses a model and consumes tokens. Subagents help in these cases.
A subagent's model field can use sonnet, opus, haiku, a full model ID, or inherit. If not specified, the default is inherit.
If you repeatedly delegate the same role, it's good to create a custom subagent.
Every time you say "look at it from a security perspective"
Every time you say "find the cause of test failures"
Every time you say "check DB query performance"
Every time you say "review only the changed code"Custom subagents are Markdown files with YAML frontmatter, created via the /agents command or by adding files directly. The /agents interface provides view, create, edit, delete, and duplicate-check functionality.
If the same name exists in multiple scopes, the location with higher priority applies. Project subagents are suitable for sharing with your team via version control.
The most important safeguard when creating a subagent is tool restriction. This way you can read and search files but can't modify them.
tools: Read, Grep, GlobIf you allow Bash, you can run tests or git diff. But Bash is powerful, so only add it when needed.
tools: Read, Grep, Glob, BashYou can also remove just write tools from inherited tools.
disallowedTools: Write, EditSubagents inherit tools from the main conversation by default, but you can restrict them using tools as an allowlist or disallowedTools as a denylist. If both are used, disallowedTools applies first, then tools resolves from the remaining pool.
It's safer to keep a security reviewer read-focused. Create file .claude/agents/security-reviewer.md like this.
---
name: security-reviewer
description: Expert security reviewer. Use proactively after changes to auth, data handling, payments, or API boundaries.
tools: Read, Grep, Glob, Bash
model: inherit
permissionMode: plan
---
You are a senior security engineer. Review only. Do not edit files.
Check for: hardcoded secrets, missing authorization, SQL injection, unsafe file handling, overbroad permissions.
Output: Severity / File / Risk / Evidence / Recommended fix.This agent finds security issues but doesn't modify files. For beginners, it's safer to separate finding from fixing.
Test logs consume lots of context. So running tests and summarizing failures is ideal to delegate to a subagent. Create .claude/agents/test-runner.md.
---
name: test-runner
description: Runs project tests and summarizes only failing tests and likely root causes.
tools: Read, Grep, Glob, Bash
permissionMode: default
maxTurns: 8
---
Identify the test command, run the smallest relevant test first.
If tests fail, summarize only: test name, exact error, likely cause, related files.
Avoid pasting huge logs. Keep output concise.This way, long logs don't enter the main conversation entirely, and only failure summaries return.
If you connected a DB via MCP in section 23, you can create a separate DB subagent. Here's .claude/agents/db-analyst.md.
---
name: db-analyst
description: Analyzes database schema, query patterns, and migration risks.
tools: Read, Grep, Glob
mcpServers:
- postgres
model: inherit
permissionMode: plan
---
Inspect schema via MCP. Identify mismatch, missing indexes, unsafe migrations.
Never modify data. Never run destructive SQL.The mcpServers field limits which MCP servers the subagent can use. This is useful when you want to hide MCP tool descriptions from the main conversation and only give tools to a specific subagent.
As covered in detail in section 25, subagents can be used with skills.
---
name: api-developer
description: Implements API endpoints following team conventions.
tools: Read, Edit, Grep, Glob, Bash
skills:
- api-conventions
- error-handling-patterns
model: inherit
---The skills field injects specific skill content into the subagent's context at startup. Rather than expecting it to find and load during execution, this way injects needed domain knowledge from the start. If you haven't created skills yet, beginners can leave this field empty.
Subagents are managed with /agents. The Running tab shows currently-running subagents and lets you open or stop them. The Library tab shows built-in, user, project, and plugin subagents and lets you view, create, edit, delete, and check for duplicates.
For quick tests or automation, you can define a subagent at session start via the --agents flag without creating a file.
claude --agents '{
"code-reviewer": {
"description": "Expert code reviewer. Use proactively after code changes.",
"prompt": "You are a senior code reviewer. Focus on quality and security.",
"tools": ["Read", "Grep", "Glob", "Bash"],
"model": "sonnet"
}
}'--agents accepts JSON with the same frontmatter fields as file-based subagents. Subagents defined this way exist only for that session and are not saved to disk. For beginners, file-based definitions are easier to understand.
Beginners can remember it this way. Small work uses Main REPL, isolated exploration uses Subagents, long-running work uses Background, multi-worker collaboration uses Agent teams, and large-scale repetition uses Workflow.
When delegating to a subagent, narrow the scope. Here's file exploration.
Use an Explore subagent to find files related to payment functionality.
- Do not modify files
- Extract only highly relevant files
- Explain each file's role in one line
- Separate uncertain files as "uncertain"Here's bug cause investigation.
Use a subagent to investigate the cause of this test failure.
- Do not paste the entire test log
- Summarize only: test name, error, related files, cause candidates
- Do not make fixesHere's how to use parallel exploration and code review.
Use three subagents in parallel for investigation.
1. Authentication code 2. DB model 3. API routes
Each: related files / core flow / risky areas / next steps to check only.
Finally combine and propose only a fix plan.Use the code-reviewer subagent to review recent changes.
- Prioritize changed files by git diff
- Categorize as Critical / Warning / Suggestion
- Focus on actual bugs·security·missing tests, don't modify filesDon't trust subagent results directly and fix immediately. You must review again in the main conversation.
When multiple subagents return detailed results, their results can again consume lots of main conversation context. It's important to request short, structured summaries.
The situation: login redirect sometimes fails. Bad request is too broad.
Fix the login redirect bug.Good request splits exploration into parallel work and stops at fixing.
Investigate login redirect failures that happen intermittently.
Use three subagents in parallel:
1. Authentication flow 2. Routing/redirect 3. Session/cookie handling
Each: don't modify files, return related files·core flow·cause candidates.
After receiving results, propose only a fix plan in the main conversation.Before refactoring the auth module into a new structure, use subagents to explore the separation.
I want to prepare for auth module refactoring. Use subagents to explore separation.
1. Current auth entry points and major flows
2. Token issue/verify/refresh logic
3. Permission checks and route protection approach
4. Related test structure
Each: return summaries only, no fixes. Finally propose risk level and step-by-step plan.Later, connecting to Plan Mode lets subagents handle exploration while Plan Mode reviews the actual refactor plan.
/plan refactor auth module based on the subagent findingsA review subagent only finds, then the main Claude fixes only approved items — this is safer.
Use code-reviewer subagent to review recent changes.
Don't modify files, review strictly by git diff.When review results arrive, decide in the main conversation.
Convert only Critical items to actual fix plans.
Exclude Warning and Suggestion from this PR scope.Fix only the 2 Critical items in minimal scope and explain by /diff.Subagents are a feature to break down large work into separate specialized workers. The biggest advantage is separating work that consumes lots of context like exploration and log analysis from the main conversation, and using only the summary for final decision.
Beginners just need to remember this principle. Use Explore for finding related files, Plan for pre-implementation investigation, test-runner for analyzing long logs, read-only custom subagents for security·review, parallel subagents for independent domains, chains when one step inputs the next, and get main conversation approval before actual fix.
Section 25. When to use Skills and Plugins
First, let's distinguish their roles simply.
Skill = A unit that teaches Claude domain-specific knowledge or procedures
Plugin = A package that bundles and deploys skills, agents, hooks, MCP, etc.In other words, skill is closer to "knowledge and procedure," and plugin is closer to "deployment unit."
According to the official documentation, in Claude Code's Extension Layer, MCP connects external services, hooks provide automation, skills provide domain expertise, and plugins package all of these into deployable form.
Skill is a file separation of "task knowledge" that you repeatedly communicate to Claude.
For example, if you keep saying things like this, it's a skill candidate.
Our API always validates input values with Zod,
error responses use the { code, message } format,
and don't put business logic in controllers—put it in the service layer.Writing this to every prompt is tedious, and putting too much in CLAUDE.md consumes context in every session. With a Skill, Claude loads it only for relevant tasks.
The official documentation also explains that skill content is only loaded when used, so long reference materials cost almost nothing until actually needed.
The official documentation also recommends creating a skill if domain expertise should be automatically activated, multiple team members need the same knowledge, or you're repeatedly explaining the same patterns and rules. Conversely, if you want to control explicit invocation, use slash commands; if separate context is needed, use subagents; if it's one-time use, just input it directly.
CLAUDE.md is a file that tells Claude the basic rules of a project. Skill is a file that loads domain-specific procedures or knowledge only when needed for specific tasks.
The criterion is simple.
Always need to know short rules → CLAUDE.md
Procedures needed only in specific situations → SkillThe following is suitable for CLAUDE.md.
## Project commands
- Test: npm test
- Lint: npm run lint
- Build: npm run build
## Rules
- Do not edit .env files.
- Use TypeScript strict mode.On the other hand, the following is suitable for skill.
## How to add a new API endpoint
1. Create route file.
2. Add request validation.
3. Add service method.
4. Add test cases.
5. Update OpenAPI docs.According to the official documentation, custom commands have been integrated into skills. Both .claude/commands/deploy.md and .claude/skills/deploy/SKILL.md create /deploy, and existing .claude/commands/ files continue to work. For new creation, the skill approach offers better extensibility.
For beginners, you can distinguish like this.
In other words, in the current workflow, "creating a custom slash command" should be understood as "creating a skill and invoking it with /skill-name."
Let's create a "summarize changes skill" as an example.
mkdir -p .claude/skills/summarize-changes.claude/skills/summarize-changes/SKILL.md
---
description: Summarizes uncommitted git changes and flags risky parts. Use when the user asks what changed, wants a commit summary, or asks to review the current diff.
---
## Current changes
!`git diff HEAD`
## Instructions
Summarize the changes in 2-3 bullet points.
Then list risks, if any:
- missing tests
- hardcoded values
- error handling gaps
- security-sensitive changes
- files that should be reviewed manually
If there are no uncommitted changes, say so clearly.There are two ways to use it.
What did I change?Or invoke it directly.
/summarize-changesThe official documentation's first skill example also explains that SKILL.md consists of YAML frontmatter and Markdown instructions, the directory name becomes the command the user types, and description is the criterion Claude uses to decide whether to auto-load the skill.
The simplest skill needs only one SKILL.md file.
.claude/
└── skills/
└── api-conventions/
└── SKILL.mdWhen it grows a bit, add supporting files.
.claude/
└── skills/
└── api-conventions/
├── SKILL.md
├── reference.md
├── examples.md
└── checklists/
└── endpoint-review.mdAccording to the official documentation, a skill can include multiple files, SKILL.md should contain only core overview and navigation, and long API docs or examples should be in separate files. The official documentation recommends keeping SKILL.md under 500 lines and moving detailed materials to supporting files.
The scope of a skill's application varies depending on where it's stored.
According to the official documentation, project skills apply only to the current project, and personal skills apply to all projects. If names collide, priority is applied in order: enterprise, personal, project. Plugin skills use plugin-name:skill-name namespace to avoid conflicts.
For beginners, the guideline is as follows.
My personal habits → ~/.claude/skills/
Current project rules → .claude/skills/
Feature bundle to deploy to team → pluginThe area at the top of a Skill between --- is called frontmatter.
---
name: api-conventions
description: API design patterns for this codebase. Use when creating or modifying API endpoints.
disable-model-invocation: false
allowed-tools: Read Grep
---
Skill instructions here.The most important field is description. It's the criterion Claude uses to decide when to use this skill.
The official documentation explains that all frontmatter fields are optional, but recommends description so Claude knows when to apply the skill. Also, description and when_to_use text are truncated to a certain length in listing to reduce context usage.
A skill can be executed in two ways.
Auto-invocation:
Claude reads the conversation and auto-loads related skills.
Direct invocation:
User directly executes with /skill-name.For example, an API rules skill works well with auto-invocation.
---
description: API design conventions for this codebase. Use when creating or modifying API routes, request validation, response formats, or service-layer code.
---On the other hand, a deployment skill is safer for direct invocation only.
---
description: Deploy the application to production.
disable-model-invocation: true
---The official documentation also explains that specific actions like deployment, commits, and code generation are appropriate for direct /skill-name invocation, and you can use disable-model-invocation: true to prevent Claude from auto-executing.
You can inject shell command results into a skill.
## Current branch
!`git branch --show-current`
## Current diff
!`git diff HEAD`This way, when Claude views the skill, the command output is already included.
For example, a commit summary skill can be created like this.
---
description: Creates a commit summary from the current git diff. Use when the user asks for a commit message or change summary.
---
## Current branch
!`git branch --show-current`
## Current diff
!`git diff HEAD`
## Instructions
Create a concise commit summary.
Use this format:
- Type:
- Scope:
- Summary:
- Risk:
- Tests needed:The official documentation also explains that with dynamic context injection in the form of !`git diff HEAD`, Claude Code executes the command, inserts the output into the skill content, and passes it to Claude.
One caution is sensitive data. Don't include commands that output env, secrets, tokens, or production data in skills.
.claude/skills/api-conventions/SKILL.md
---
description: API design and implementation conventions for this codebase. Use when creating or modifying API endpoints, validation, service methods, or response formats.
---
# API conventions
When creating or modifying API endpoints:
1. Validate all request input before using it.
2. Keep business logic in the service layer.
3. Return errors in this format:
- code
- message
- details, only when safe
4. Do not leak internal exception messages to API clients.
5. Add or update tests for success and failure cases.
## File patterns
- Routes: src/routes/**
- Services: src/services/**
- Validation schemas: src/schemas/**
- Tests: tests/api/**
## Output expectation
When you propose an API change, include:
- files to edit
- validation changes
- service changes
- tests to add
- security risks.claude/skills/review-checklist/SKILL.md
---
description: Project-specific code review checklist. Use when reviewing diffs, pull requests, or completed feature changes.
---
# Review checklist
Review changes for:
## Correctness
- edge cases
- null or undefined handling
- async error handling
- regression risks
## Security
- missing authorization
- unsafe input usage
- hardcoded secrets
- sensitive data exposure
## Tests
- success path
- failure path
- boundary cases
- integration impact
## Maintainability
- duplicated logic
- unclear naming
- excessive file scope
- inconsistent patterns
Return findings by severity:
- Critical
- Warning
- Suggestion.claude/skills/deploy-checklist/SKILL.md
---
description: Deployment checklist for this project. Use only when the user explicitly asks to prepare or review a deployment.
disable-model-invocation: true
---
# Deployment checklist
Before deployment:
1. Confirm target environment.
2. Run tests.
3. Run lint.
4. Run build.
5. Check migration status.
6. Review environment variables.
7. Summarize rollback plan.
Do not run deployment commands unless the user explicitly approves.For risky operations like deployment, it's good to prevent auto-invocation and maintain an explicit approval flow.
When a skill gets long, don't put everything in SKILL.md—split into supporting files.
.claude/skills/security-review/
├── SKILL.md
├── SECURITY_PATTERNS.md
├── AUTH_CHECKLIST.md
└── EXAMPLES.mdSKILL.md
---
description: Security review guidance for authentication, authorization, data handling, and API boundary changes.
---
# Security review skill
Use this skill when reviewing security-sensitive changes.
For detailed vulnerability patterns, see [SECURITY_PATTERNS.md](SECURITY_PATTERNS.md).
For authentication and authorization review steps, see [AUTH_CHECKLIST.md](AUTH_CHECKLIST.md).
For examples of good and bad findings, see [EXAMPLES.md](EXAMPLES.md).
Return only actionable findings with file paths and severity.This way, Claude doesn't read all the long documents from the start but can reference related files only when needed.
Skill is knowledge, and subagent is a worker. Using them together is powerful.
For example, you can pre-load the security-review skill in the security-reviewer subagent created in unit 24.
.claude/agents/security-reviewer.md
---
name: security-reviewer
description: Reviews authentication, authorization, API, and data-handling changes for security issues.
tools: Read, Grep, Glob, Bash
skills:
- security-review
permissionMode: plan
---
You are a senior security reviewer.
Use the loaded security-review skill as your checklist.
Do not edit files.
Return only actionable findings.The official subagent documentation explains that you can inject specific skills into a subagent context at startup through the skills field in the subagent frontmatter. The latest version also clarifies that subagents inherit the entire skill graph available in the parent session.
A plugin bundles skills, agents, hooks, MCP servers, etc. into one installable package.
According to the official documentation, plugins extend Claude Code with skills, agents, hooks, MCP servers and allow sharing between projects and teams. It's recommended to start with .claude/ standalone configuration for quick experiments or personal setup, and transition to plugins when team sharing or version management is needed.
The official documentation also summarizes plugins as Claude Code extension features for deployment that can include custom commands, subagents, skills, hooks, and MCP servers.
The official documentation also explains that standalone is suitable for personal workflows, per-project customization, quick experiments, and short skill names, while plugins are suitable for team and community sharing, multi-project reuse, versioned releases, and marketplace deployment.
For beginners, the guideline is as follows.
Step 1: Create one skill in .claude/skills/
Step 2: Try using with .claude/agents/
Step 3: Need it repeatedly across team
Step 4: Package as pluginA plugin roughly has this structure.
my-plugin/
├── .claude-plugin/
│ └── plugin.json
├── skills/
│ └── api-conventions/
│ └── SKILL.md
├── agents/
│ └── code-reviewer.md
├── hooks/
│ └── hooks.json
├── commands/
│ └── legacy-command.md
└── .mcp.jsonThe official documentation's plugin structure similarly includes .claude-plugin/plugin.json, commands/, agents/, skills/, hooks/, and .mcp.json.
The official plugins reference also explains that plugin manifest can declare skills, commands, agents, hooks, MCP servers, output styles, LSP servers, dependencies, etc.
my-plugin/.claude-plugin/plugin.json
{
"name": "team-dev-kit",
"description": "Team development conventions, review agents, and automation for Claude Code.",
"version": "1.0.0",
"author": {
"name": "Your Team"
}
}According to the official documentation, plugin manifest defines plugin identity, description, and version, and Claude Code displays this metadata in the plugin manager. The name is a unique identifier and is used as the skill namespace to create names like /my-first-plugin:hello.
Plugin structure:
team-dev-kit/
├── .claude-plugin/
│ └── plugin.json
└── skills/
└── api-conventions/
└── SKILL.mdskills/api-conventions/SKILL.md
---
description: Team API conventions. Use when creating or modifying API endpoints.
---
# Team API conventions
- Validate inputs.
- Keep business logic in services.
- Return consistent error responses.
- Add tests for success and failure cases.When the plugin is active, this skill is invoked with a namespace.
/team-dev-kit:api-conventionsPlugin namespace reduces name conflicts. Multiple teams can use common names like deploy, review, and api-conventions, and conflicts are reduced by prefixing the plugin name.
A plugin can include just one skill, but for teams, it often bundles multiple components.
team-dev-kit/
├── .claude-plugin/
│ └── plugin.json
├── skills/
│ ├── api-conventions/
│ │ └── SKILL.md
│ └── security-review/
│ └── SKILL.md
├── agents/
│ ├── code-reviewer.md
│ └── security-reviewer.md
└── hooks/
└── hooks.jsonFor example, a team plugin can provide:
The official plugin discovery documentation also explains that plugins extend Claude Code with skills, agents, hooks, and MCP servers.
Plugins are managed with /plugin.
/pluginFrequently used commands are as follows.
According to the official discovery documentation, the official marketplace claude-plugins-official is automatically available at Claude Code startup, and you can explore it in the Discover tab of /plugin or install with /plugin install github@claude-plugins-official.
According to the official documentation, a plugin marketplace is a catalog of plugins created by someone. First, add a marketplace, then individually install desired plugins from it. The official marketplace is provided automatically, while community marketplaces must be added manually.
Example of adding a community marketplace:
/plugin marketplace add anthropics/claude-plugins-communityExample of installation:
/plugin install some-plugin@claude-communityThe official documentation explains that plugins in community marketplaces pass automated validation and safety screening and are pinned to specific commit SHAs in the catalog.
The official marketplace contains various types of plugins.
The official discovery documentation explains that code intelligence plugins provide Claude with LSP-based code navigation, diagnostics, type information, etc., and external integration plugins bundle MCP server configurations for tools like GitHub, GitLab, Jira, Figma, and Sentry.
Before creating your own plugins, beginners should first try installing necessary plugins from the official marketplace.
When you start creating team plugins, dependency management becomes important.
For example, suppose deploy-kit plugin depends on secrets-vault plugin. If secrets-vault changes MCP tool names in a new version, deploy-kit could break.
The official dependency documentation explains that plugins can declare other plugin dependencies in plugin.json or marketplace entry, by default follow the latest version, but version constraints can pin to a validated range.
Example:
{
"name": "deploy-kit",
"version": "3.1.0",
"dependencies": [
"audit-logger",
{ "name": "secrets-vault", "version": "~2.1.0" }
]
}Beginners don't need to handle dependencies from the start. However, when you start deploying team plugins, you must always consider "is it safe if updates come in automatically?"
Since we've learned many features, let's review the selection criteria.
The practical guideline is:
Knowledge → Skill
Auto-execute → Hook
External connection → MCP
Delegate work → Subagent
Team deployment → Plugin
Always read basic rules → CLAUDE.mdThe most important thing in unit 25 is understanding "when to separate." You don't need to create plugin marketplaces, design dependency version constraints, or write complex LSP plugins from the start.
At the beginner stage, this is enough:
1. Keep CLAUDE.md short.
2. When repeated procedures appear, separate into .claude/skills/.
3. Set risky operations to not auto-invoke.
4. If repeated across projects, consider plugin.
5. Before deploying to team, test thoroughly with local or plugin-dir.Advanced areas you don't need to know right now:
When creating API endpoints, make sure to handle input validation, error format, and tests.mkdir -p .claude/skills/api-conventions.claude/skills/api-conventions/SKILL.md
---
description: API endpoint implementation rules. Use when creating or modifying API routes, validation, services, or API tests.
---
# API endpoint rules
When implementing API endpoints:
1. Validate all external input.
2. Keep business logic in services.
3. Use consistent error response format.
4. Add tests for success and failure cases.
5. Avoid leaking internal details.
Before editing, list:
- files to change
- validation updates
- service updates
- tests to addAdd a new user profile update API.
Create a plan following project rules.See if Claude auto-applies the skill. If not, invoke directly.
/api-conventions create a plan for adding a user profile update API.As the project grows, you may end up with these files:
.claude/
├── skills/
│ ├── api-conventions/
│ ├── security-review/
│ ├── testing-strategy/
│ └── deploy-checklist/
├── agents/
│ ├── code-reviewer.md
│ └── security-reviewer.md
└── hooks/
└── protect-files.shIf this structure is only used in one project, leave as is.
But if repeated across multiple projects, bundle as a plugin.
team-dev-kit/
├── .claude-plugin/
│ └── plugin.json
├── skills/
│ ├── api-conventions/
│ ├── security-review/
│ ├── testing-strategy/
│ └── deploy-checklist/
├── agents/
│ ├── code-reviewer.md
│ └── security-reviewer.md
└── hooks/
└── hooks.jsonThe official documentation also explains that if you already have skills or hooks in .claude/, you can transition to a plugin to ease sharing and deployment.
Once installed, a plugin can affect every team member's Claude Code environment. Especially plugins with hooks and MCP servers should be reviewed more carefully.
Don't try to become a plugin developer from the start. Learn in this order:
Skills are a feature that provides Claude with project-specific expertise and repeated procedures. If you're repeatedly copying and pasting the same instructions, checklists, or work procedures, separate them into skills. Keep CLAUDE.md with only short basic rules always needed, and move long procedures specific to certain tasks into skills.
Plugins are packages that bundle skills, agents, hooks, and MCP servers for deployment to teams or multiple projects. Start with .claude/ standalone for personal experiments or project-specific configuration, and transition to plugins when you need to reuse across multiple projects or deploy to a team.
Finally, use this guideline:
Beginners should start with creating one good skill. A plugin is the packaging stage when that skill, agents, and hooks are repeatedly needed across the entire team.
Claude Code guide unit 25 complete. Proceed to the next unit if available.
Claude Code's foundation is the terminal CLI.
cd my-project
claudeBut in reality, most developers view code in IDEs like VS Code, Cursor, Windsurf, IntelliJ, PyCharm, and WebStorm. IDE integration connects Claude Code to your IDE and helps it better use the following information.
Currently open files
Selected code ranges
IDE diagnostics
diff viewer
File path @-mentions
Multiple session tabs
Plan reviewIn other words, IDE integration transforms Claude Code from a "terminal-only tool" into a development assistant that sits alongside your code editor.
The best approach for beginners is as follows.
Learn Claude Code basics → Terminal CLI
Real code editing and review → IDE integration
Large logs, tests, Git commands → Terminal
Explain selected code, review diffs → IDEIn VS Code, you can use Claude Code by installing the extension. Requirements are VS Code 1.98.0 or later and an Anthropic account. The extension includes the CLI, so if you need advanced features, you can run claude in VS Code's integrated terminal.
Follow these steps to install.
1. Open Extensions
- macOS: Cmd+Shift+X
- Windows/Linux: Ctrl+Shift+X
2. Search for "Claude Code"
3. Click Install
4. Open Claude Code with the Spark icon
5. Log in in the browserclaudeThe biggest advantage of IDE integration is that you can easily pass the code you're currently viewing to Claude.
For example, select lines 20-40 of a file and ask Claude a question.
Explain what this selected code does.The VS Code extension automatically allows Claude to see the selected text. If you want to explicitly include file paths and line numbers in your prompt, press Option+K on macOS or Alt+K on Windows/Linux to insert a reference like @file.ts#5-10.
Here's a real-world example.
@src/auth/session.ts#15-80
Explain how session expiration handling works in this code.@src/api/users.ts#30-120
Check if there's any missing input validation in this API.When Claude modifies files from the terminal, it's important to check them with git diff. Using IDE integration lets you review this process more visually.
With the VS Code extension, when Claude tries to modify a file, it shows you the original and proposed changes side-by-side in a diff view, and you can accept, reject, or provide additional instructions.
For beginners, this flow works well.
1. Request a modification plan from Claude
2. Check the Plan or diff
3. Review changed lines in the IDE diff viewer
4. Reject or request edits if something looks wrong
5. Run tests after approval
6. Do a final review with git diffUsing Plan Mode inside your IDE makes it easy to review changes like reading a document before implementing them.
/plan refactor the authentication moduleIn the VS Code extension, Plan Mode shows what Claude will do, and no changes are made until you approve.
A good request example looks like this.
/plan add password reset flow
Conditions:
- First investigate only relevant files
- Check if DB migration is needed
- Include test plan
- Summarize security risks separately/Shift+EnterCmd+Esc / Ctrl+EscCmd+Shift+Esc / Ctrl+Shift+EscOption+K / Alt+KCmd+Shift+T / Ctrl+Shift+TShift+EnterEven if you use the IDE extension, there's no need to abandon the CLI. Just open VS Code's integrated terminal and run it normally.
claudeWhen you run claude in VS Code's integrated terminal, the CLI automatically integrates with the IDE so you can use features like diff viewing and diagnostic sharing. If you're using an external terminal, you can run /ide within Claude Code to connect to VS Code.
In practice, you split work like this.
Line-by-line code questions → VS Code panel
Large commands, tests, builds → integrated terminal
Visual change review → IDE diff viewer
Full session control → Either CLI or panel~/.claude/settings.json, .claude/settings.jsonVS Code extension settings control behavior within VS Code, while Claude Code settings are used by both the CLI and extension.
Beginners can remember it this way.
VS Code screen behavior → VS Code settings
Claude Code permissions, hooks, MCP → Claude Code settings.jsonIf you use JetBrains-family IDEs, install the dedicated Claude Code plugin.
Supported IDEs are as follows.
IntelliJ IDEA
PyCharm
Android Studio
WebStorm
PhpStorm
GoLand1. Open Settings → Plugins
2. Search for "Claude Code"
3. Click Install
4. Restart IDE
5. Run claude in the IDE terminalIn JetBrains, running claude from the IDE's integrated terminal activates integrated features.
claudeIf you're running Claude Code from an external terminal, enter the following in your session.
/ide@src/auth.ts#L1-99If you want to see Claude's changes in the IDE diff viewer, check the diff tool setting in /config.
/configThen set the diff tool to one of the following.
auto → Use IDE diff viewer
terminal → View diff in terminalWhen using WSL2 and JetBrains together on Windows, the IDE may not be detected in some cases.
Typical symptoms:
No available IDEs detectedThe main cause is that WSL2's NAT networking or Windows Firewall blocks the connection between WSL2 and the IDE on the Windows host. You can specify the Claude command for WSL in the JetBrains plugin settings.
wsl -d Ubuntu -- bash -lic "claude"Check the IP inside WSL.
hostname -IOpen Windows PowerShell as administrator and create a firewall rule like the example below.
New-NetFirewallRule -DisplayName "Allow WSL2 Internal Traffic" -Direction Inbound -Protocol TCP -Action Allow -RemoteAddress 172.21.0.0/16 -LocalAddress 172.21.0.0/16Adjust the IP range to match your WSL2 subnet.
If you're on Windows 11 22H2 or later, you can add the following to .wslconfig.
[wsl2]
networkingMode=mirroredThen restart WSL from PowerShell.
wsl --shutdownIn JetBrains terminal, Esc may not work to stop Claude Code tasks. This is because the IDE takes Esc first as a shortcut to "move focus to editor".
Solution:
Settings → Tools → Terminal
→ Disable "Move focus to the editor with Escape"When using IDE integration, it's better to ask Claude about the file you're currently viewing and your selection rather than asking it to "search through the entire project".
Bad request:
Analyze the entire project structure for me.Good request:
Based on the auth middleware I've selected,
find the flow that calls this function.
Look at a maximum of 5 related files,
and just summarize—don't make changes.@src/middleware/auth.ts#20-88
Summarize the conditions under which this code rejects requests.
Then find test files connected to these conditions.
Don't make changes.In an IDE, the flow of "selection → question → explore few related files → plan" is most reliable.
When requesting changes in the IDE, it's also good to limit the scope rather than immediately asking "fix this".
@src/api/login.ts#10-90
Add input validation to this function.
Conditions:
- Explain the plan before making changes
- Maintain existing response format
- No new dependencies
- Update related tests if they exist
- Explain changes based on the diffAfter changes, review them in the IDE diff viewer, and if needed, request this way.
Check if the change scope in this diff is excessive.
Revert unnecessary refactoring and keep only what's needed for input validation.Even if Claude made the changes, you should do a final review.
git diff
npm test
npm run lintThe advantage of IDE integration is that you can review changes visually. Here's the recommended workflow.
1. Request a plan from Claude
2. Check changes in the IDE diff viewer
3. Review the full diff again with /diff or git diff
4. Run /code-review
5. Run tests and lint
6. Check git status again before committingReview the current changes.
Focus on:
- Actual bug potential
- Security issues
- Missing tests
- Excessive changes
- Maintainability
Skip stylistic preferences,
and categorize necessary fixes into Critical / Warning / Suggestion.The JetBrains plugin can automatically share IDE diagnostic errors—like lint or syntax errors—with Claude. VS Code can also leverage diagnostic sharing when the IDE and CLI are integrated.
A good request looks like this.
Based on the TypeScript error shown in IDE diagnostics, explain the cause.
Before making fixes, tell me which files need to change.Fix the lint errors in the current file.
But minimize style changes and only modify lines necessary to fix the errors.A common beginner mistake is pasting large logs or entire files directly into Claude's prompt box.
If you paste more than 10,000 characters, Claude Code collapses it to a [Pasted text] placeholder to keep the input usable. VS Code's integrated terminal can also drop characters on very large pastes, so it's better to save large files or long logs to a file and have Claude read that file instead.
Bad approach:
Paste 50,000 lines of logs hereGood approach:
npm test 2>&1 | tee test-output.logThen request from Claude.
@test-output.log Read this and summarize only the failed test names, error messages, and root cause candidates.
Don't reprint the full log.Even when using the IDE, Claude Code's permission system remains important. For example, .env, secrets, and credentials files should continue to be protected.
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Read(./config/credentials.json)"
]
}
}Just because the IDE diff viewer is convenient doesn't mean you should auto-accept all changes. JetBrains official documentation warns that if the auto-edit permission is enabled and Claude Code can modify IDE configuration files, the risk increases when combined with configuration files that IDEs can auto-execute.
For beginners, the guideline is as follows.
Learning phase → Manual approval
Small, safe changes → Auto-accept possible
Large refactoring → Plan Mode + manual approval
IDE config file changes → Always manual review
Security, deployment, environment variable files → Never auto-acceptIf problems occur, check in this order first.
ANTHROPIC_API_KEY not recognizedcode . from terminalclaude --version, plugin settings command path/configEsc doesn't stop tasks@file/status/doctor or claude doctorWhen starting work:
cd my-project
code .Opening VS Code from the terminal is more likely to pass environment variables properly to the IDE. If your API key is in the shell but the extension shows a login prompt, VS Code might not have inherited the shell environment, so running with code . or logging in with your Claude account is a good idea.
@src/auth/session.ts#10-70
Explain the role of this code and any dangerous edge cases.
Don't make changes./plan fix session expiration handling
Conditions:
- Investigate only relevant files
- Present the plan before making changes
- Include test planExplain the changes based on this diff.
Check if there's any unintended refactoring.Testing:
npm test
npm run lintFinal review:
/code-review highExplain the role of the selected code.
Organize it by input, output, exceptions, and calling relationships.
Don't make changes.Add only null handling to the selected function.
Don't change the existing structure and explain the changes based on the diff.Don't fix this file right away.
First, create just the refactoring plan.
Include:
- Files to change
- Files to keep unchanged
- Risky areas
- Test planReview the current diff.
Only point out actual bugs, security issues, and missing tests.
Skip style preferences./config diff tool settingauto or terminal.envpermissions.denyIDE integration is a way to use Claude Code more conveniently, not a replacement for the terminal CLI. The terminal excels at running commands, testing, Git, and automation, while the IDE excels at file selection, visual diffs, code review, and diagnostic sharing.
Beginners can follow this workflow.
1. Select files and code ranges in the IDE.
2. Ask Claude questions based on your selection.
3. Use /plan before large changes.
4. Review changes in the IDE diff viewer.
5. Run tests and lint in the terminal.
6. Do a final check with /diff or git diff.
7. Never auto-accept sensitive or IDE config files.To summarize:
Terminal CLI → Execution and automation
VS Code / JetBrains → Visual review and code context
/ide → Connect external terminal to IDE
/config → Check diff tool and default behaviors
/status or /doctor → Diagnose settings and connection issuesThe most important principle when using IDE and Claude Code together is "don't skip review just because it's convenient." Using the IDE diff viewer, Plan Mode, permission settings, and test execution together creates a safe real-world workflow.
Claude Code and an IDE are most powerful when used together. But convenience should never replace safety.
Following this workflow reduces mistakes even in the IDE.
Section 27. (Part 7 Continued)
Code and logs are easy to explain with text. But visual state, screen layout, error messages, and diagrams are hard to explain in words.
When you add an image, Claude can see and analyze the screen itself.
As a beginner, you can remember it this way.
There are three ways to add images in Claude Code.
Here's how to provide a file path.
Analyze the UI issue in this image: /path/to/screenshot.png
Various examples of the path-based approach.
@docs/screenshots/login-error.png
Find parts of this screen that might confuse users.Or you can provide multiple images together.
Based on the [Image #1] I just pasted,
explain the layout issue in the current login form.Image paste shortcuts differ by terminal and OS.
Ctrl+VCmd+V also worksAlt+V availableAlt+VWhen you paste an image, it inserts as a [Image #N] chip at the cursor position.
Default is Ctrl+V. If the shortcut doesn't work, try in this order.
Ctrl+V defaultCmd+VAlt+VWhen you paste an image, it appears in the Claude Code input like this.
[Image #1]If you have multiple images, they're distinguished by number.
[Image #1] [Image #2] [Image #3]You can use these numbers directly in your prompt.
[Image #1] is the current screen and [Image #2] is the target design. Analyze the differences between the two screens and summarize the CSS changes needed for implementation.
When pasting an error screen, it's better to include context about the situation rather than simply asking "What is this?"
What is this error?[Image #1] is the error screen that appeared right after clicking the login button.
Context:
- Browser: Chrome
- Environment: local dev
- Previous work: modified auth middleware
- Expected behavior: navigate to /dashboard after login
- Actual behavior: error screen displayed
Request:
1. Interpret the key cause from the error message.
2. Guess the files most likely to be involved.
3. Suggest the order to check first, don't fix yet.An even better example is providing logs together.
[Image #1] is the browser error screen, and
@server.log is the server log from the same time.
Look at both pieces of information and organize the cause candidates by priority.
Don't fix it yet.Looking at just the image, you understand the visual state but may not understand the code execution flow. So it's better to provide reproduction conditions, expected behavior, actual behavior, and related logs together.
UI screenshots are good at finding visible problems. However, you need to specify exactly what Claude should look at.
What do you think of this screen?[Image #1] is the current mobile login screen.
Review it from the following perspectives.
1. Layout breakage
2. Button position
3. Input field spacing
4. Text readability
5. Accessibility issues
6. Implementation file candidates
Don't fix it, just organize the problem list and priorities.When you want implementation, do it like this.
[Image #1] is the target design, and
the current implementation file is @src/components/LoginForm.tsx.
Request:
1. Compare the image with the current component structure.
2. Organize required changes focusing on Tailwind classes.
3. Create a plan first, don't fix it yet.Image-based implementation is hard to get perfect on the first try. At first, follow the flow: difference analysis → plan → minimal fix → re-check screenshot.
When creating a component from a design mockup, it's good to provide multiple states together.
[Image #1] default state
[Image #2] hover state
[Image #3] loading state
[Image #4] error stateWrite the prompt like this.
I want to implement a Button component based on these four images.
Conditions:
- React + TypeScript
- Use Tailwind
- States: default, hover, loading, disabled, error
- No new libraries
- Include accessibility attributes
- Suggest the component API first, then implement after I approve.When adding an image, include these four things.
The template is like this.
[Image #1] is the _______ screen. / Context: / Analysis perspective: / Output format:
A detailed template is like this.
[Image #1] is the _______ screen.
Context:
- User action taken:
- Expected behavior:
- Actual behavior:
- Related file:
- Related log:
Analysis perspective:
1. Cause candidates
2. Related code location
3. How to reproduce
4. What to check before fixing
Output format:
- Certain facts
- Estimates
- Needs further confirmation
- Fix planUsing this structure makes it easier for Claude to not just describe the image but connect it to development work.
For good results, images must be clear and important text must be readable. Supported formats are JPEG, PNG, GIF, and WebP. GIF animations use only the first frame even if supported.
Characteristics of bad capture:
Characteristics of good capture:
Images aren't free context. Images use roughly width pixels × height pixels / 750 tokens, and image tokens are included in the model's input token cost.
Also, high-resolution images can use up to about 3 times as many image tokens compared to older models. It's good to reduce unnecessarily large images beforehand.
Beginner standards are like this.
Claude can view and compare multiple images together.
Example is like this.
[Image #1] is the target design, and
[Image #2] is the current implementation screen.
Compare the differences between the two images by the following criteria.
1. spacing
2. typography
3. color
4. alignment
5. missing states
6. implementation priorityOr compare normal and bug screens like this.
[Image #1] is the normal screen,
[Image #2] is the screen where the bug occurred.
Compare the differences and guess what CSS or state condition might be the cause.
Tell me the file candidates to check before fixing.If you only provide an image, Claude understands the screen but may not know the actual code location. Providing code files improves analysis quality.
[Image #1] is the broken mobile screen, and
@src/components/Header.tsx is the related component.
Request:
1. Explain the problem visible on the screen.
2. Find the parts in Header.tsx most likely to be involved.
3. Create a fix plan based on CSS/Tailwind classes.
4. Tell me the plan first, don't fix it yet.A better flow is like this.
[Image #1] screen analysis
→ find related files
→ fix plan
→ approval
→ code modification
→ test/re-check screenshotThis flow connects with Plan Mode.
/plan fix the mobile header layout based on [Image #1]ERD images are useful for DB model design.
[Image #1] is the ERD for the new payment feature.
Request:
1. Organize entities and relationships in a table.
2. Suggest a Prisma schema draft.
3. Mark relationships where cascade delete is risky.
4. Organize questions to ask before migration.You can also compare with current code.
[Image #1] is the target ERD, and
@prisma/schema.prisma is the current schema.
Compare the two structures and organize missing models, fields, and relations.
Don't fix it, just create a migration plan.Important note: Small text in ERD images may not be readable. If table and column names are key, provide enlarged images or the original PDF together.
Architecture diagrams are useful for understanding system structure.
[Image #1] is the current service architecture diagram.
Explain it in the following format.
1. Major components
2. Request flow
3. Data storage location
4. External dependencies
5. Failure points
6. Security boundaries to watchWhen connecting with the codebase, ask like this.
Check if the architecture flow in [Image #1] matches the current codebase.
First find the related files, then
summarize only the parts where the diagram and actual code differ.
Don't fix it.This case may have large exploration scope, so connecting a subagent is also good.
Use the Explore subagent to
find files corresponding to the API gateway, auth service, billing service in [Image #1].
Return only a summary, don't modify anything.Claude Code can read and analyze PDF documents page by page, and you can specify a specific page range.
Example is like this.
Analyze this PDF: /path/to/document.pdfOr:
Read pages 1-5 of the PDF: /path/to/report.pdfClaude can analyze not just text in PDFs but also figures, charts, and tables.
PDFs use more context than you might think. Standard PDF has a max request size of 32MB and max 600 pages, and a 200K context model has a max 100 pages per request. However, PDFs with complex tables, small text, and lots of graphics may fill context before the page limit.
As a beginner, narrow the page range rather than putting the entire PDF in at once.
Analyze this entire 300-page PDF for me.Read only pages 12-18 of this PDF and
summarize only the requirements related to the authentication flow.Read pages 12-18 of this PDF and organize them in the following format.
- Requirement ID
- Related screen
- API impact
- DB impact
- Questions before implementationIf a PDF is just a text document, text extraction alone may be sufficient. But if charts, tables, diagrams, and scanned images are important, visual analysis is needed.
Analyze the chart on page 5 of this PDF.
Not just a simple summary, but organize the trends the chart shows and parts that could impact implementation requirements.Or:
Read the table on page 8 of this PDF and
suggest a list of fields that could be converted to an API response schema.The important thing in visual PDF analysis is that each page is also processed as an image, so questions about charts, diagrams, and non-text elements are possible.
However, in certain API environments (Bedrock Converse API), the citations option may be needed for complete visual PDF analysis, and without citations, it may be processed in basic text extraction mode.
Screenshots contain more sensitive information than you think.
Before uploading an image, check the following.
In this section, "how to mask what should not be shown" is just as important as "how to use images well."
Before capturing, reduce unnecessary areas as much as possible.
Good order:
macOS: Use Cmd+Ctrl+Shift+4 to capture the selected area to clipboard, then paste into Claude Code.
Windows: Use Snipping Tool or Win+Shift+S to capture the selected area, then you can paste it in.
Learning each OS method in advance creates an efficient capture and paste workflow.
You can also specify it in the prompt like this.
All sensitive information is masked in the screenshot.
Don't guess the actual values for masked parts, and
analyze based only on screen structure and error messages.Capture the error screen, related UI, and some console messages.
Mask sensitive information.
[Image #1] is the error screen that appeared after clicking the payment button.
Context:
- local environment
- Stripe test mode
- Previous change: modified checkout API
- Expected behavior: create checkout session
- Actual behavior: error displayLook at the error message in the image and screen state and
organize cause candidates by priority.
Don't fix it, suggest files and logs to check first.@src/api/checkout.ts
@src/components/CheckoutButton.tsx
Looking at these two files with [Image #1] and narrow down the cause./plan fix checkout error shown in [Image #1][Image #1] is the target design,
[Image #2] is the current implementation screen.
Analyze the differences.
Don't fix it, just organize the priorities.@src/components/ProfileCard.tsx
@src/components/ProfileCard.module.css
Comparing these files with the two images,
plan what style changes are needed.Good. Fix only spacing and typography first, the parts with the biggest difference from the target design.
Don't change colors yet.After fixing, paste the screenshot again.
[Image #3] is the screen after fixing.
Compare with the target design [Image #1] and organize the remaining differences.You can find accessibility issues with images too.
[Image #1] is the signup screen.
Review from an accessibility perspective.
1. Color contrast
2. label and input relationship
3. Button state distinction
4. Error message location
5. Parts where keyboard users might be confused
6. Parts that seem to need screen reader explanation
Don't fix code, just create a checklist.Images alone can't show actual ARIA attributes or DOM structure. Accessibility review is better done with code files.
Look at [Image #1] and @src/components/SignupForm.tsx together and
organize visual issues and code accessibility issues separately.If you learned MCP in section 23 and IDE integration in section 26, image input also connects with browser automation. For example, a workflow where you capture a screen with Playwright or Chrome integration, analyze the screenshot to find UI issues.
Open the signup page in a browser,
take a screenshot with mobile viewport, then
analyze layout breakage and accessibility issues.This method is closer to automation than manually pasting images. But at beginner stage, it's better to learn direct capture → paste → request analysis first.
Image-based work can include estimates. So it's safer to use Plan Mode rather than fixing right away.
I want to fix the mobile layout issue based on [Image #1].
Use /plan to proceed first.
Conditions:
- Separate what's clearly visible in the image from estimates
- Find related files first
- Minimize fix scope
- Include test or verification methodOr separate the commands.
/plan fix mobile layout issue shown in [Image #1]Plan Mode enforces investigation and planning before file modification, so it reduces the risk of over-fixing that can happen from interpreting images.
If you've modified code based on an image, you must verify results.
Prompt example is like this.
[Image #1] is before the fix,
[Image #2] is after the fix.
Compare the two images and
check if the problem is resolved and if new UI issues appeared.Also do code verification.
Based on git diff, review if this UI fix exceeded the scope needed to solve the target problem.[Image #1] is an error screen.
Context:
- Occurred after:
- Expected behavior:
- Actual behavior:
- Related file:
- Related log:
Request:
1. Interpret the error message
2. Cause candidates
3. Files to check
4. Verification order before fixing[Image #1] is a broken UI on mobile screen.
Analyze by the following criteria.
- Broken location
- Possible CSS cause
- Related component candidates
- Fix priority
- Verification method
Don't fix right away, just suggest a plan.[Image #1] is the target design.
Create a plan to implement with React + TypeScript + Tailwind.
Suggest component structure, props, state, and accessibility considerations first.
Don't modify files until I approve.[Image #1] is the old screen,
[Image #2] is the screen after change.
Separate intended changes from unintended changes and organize.[Image #1] is a database ERD.
Organize entities, relations, cardinality, nullable fields, and risky cascade relationships.
Then suggest a Prisma schema draft.Read only pages 10-15 of this PDF.
Goals:
- Extract implementation requirements
- API impact
- DB impact
- UI impact
- Organize questions to ask before developmentImages and multimodal input are a way to accurately convey visual problems to Claude Code that are hard to explain in words. They are especially useful for tasks where the screen itself matters, like error screens, UI bugs, design mockups, architecture diagrams, ERDs, and PDFs.
Images are powerful, but Claude seeing only a screen doesn't mean Claude knows all code context. The best use is image + context explanation + related files + logs + Plan Mode together.
Section 28. Connecting Claude Code with Browser Automation
This section covers how to narrow down problems step by step when you encounter issues with Claude Code, before blindly reinstalling or wiping your settings.
Section 28 in the uploaded comprehensive guide focuses on separating installation problems, authentication issues, permission issues, command execution failures, and MCP / hook / plugin issues.
According to the official documentation, if you don't know where a problem originated, run /doctor first while inside Claude Code, and if Claude Code itself won't start, run claude doctor in the terminal as your starting diagnostic point. /doctor checks installation status, configuration validity, MCP setup, and context usage all at once.
Most Claude Code problems fall into one of these categories:
Don't try to fix everything at once; classify the problem first.
Claude Code is acting weird. Should I reinstall?Does the claude command run?
Am I logged in?
Is the problem specific to one project?
Does the problem only appear when a specific MCP or hook is enabled?
Does it reproduce even with a fresh empty config?The official troubleshooting documentation also recommends separating issues by symptom: installation and login problems, configuration not being applied, API errors, IDE problems, and performance/search problems.
When you encounter problems, check in this order:
claude --version
claude doctorIf you're already inside Claude Code, run:
/status
/doctor
/contextFor configuration and extension problems, also check:
/memory
/permissions
/hooks
/mcp
/skills
/agents
/plugin/debug [issue] enables debug logging in the current session and helps Claude diagnose the problem based on logs and configuration paths.
Installation problems typically show up as:
The official installation troubleshooting documentation separately covers command not found, PATH issues, permission issues, network problems, TLS errors, Windows shell command confusion, and WSL issues.
First check the version:
claude --versionIf that doesn't work, check your PATH:
echo $PATH | tr ':' '\n' | grep -Fx "$HOME/.local/bin"If it's not there, add it:
echo 'export PATH="$HOME/.local/bin:$PATH"' » ~/.zshrc
source ~/.zshrcecho 'export PATH="$HOME/.local/bin:$PATH"' » ~/.bashrc
source ~/.bashrc$env:PATH -split ';' | Select-String '\.local\\bin'According to the official documentation, the native installer places Claude Code at ~/.local/bin/claude on macOS/Linux, and %USERPROFILE%.localinclaude.exe on Windows. If installation succeeded but the command isn't found, you need to check that this path is in your PATH.
Installing Claude Code multiple times through npm, Homebrew, native installer, WinGet, etc., can cause version conflicts.
which -a claude
ls -la ~/.local/bin/claude
ls -la ~/.claude/local/
npm -g ls @anthropic-ai/claude-code 2>/dev/nullwhere.exe claude
Test-Path "$env:USERPROFILE.localinclaude.exe"The official documentation warns that having multiple Claude Code installations can cause version mismatch or unexpected behavior, so keep only one. The native installer location ~/.local/bin/claude or Windows %USERPROFILE%.localinclaude.exe is recommended.
npm uninstall -g @anthropic-ai/claude-coderm -rf ~/.claude/localIf installation fails at the download stage, first check if you can reach the download server:
curl -sI https://downloads.claude.ai/claude-code-releases/latestIf you get HTTP/2 200, access is working. If you get no output, timeout, or DNS errors, it could be a network, proxy, or firewall issue. The official documentation also notes that the installer downloads from downloads.claude.ai, so verify access to that URL.
If you're behind a corporate proxy, set environment variables:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080
curl -fsSL https://claude.ai/install.sh | bash$env:HTTP_PROXY = 'http://proxy.example.com:8080'
$env:HTTPS_PROXY = 'http://proxy.example.com:8080'
irm https://claude.ai/install.ps1 | iexIf you encounter TLS errors, check your system CA certificates, corporate TLS inspection, and NODE_EXTRA_CA_CERTS settings. The official installation documentation explains that errors like unable to get local issuer certificate or SELF_SIGNED_CERT_IN_CHAIN can come from corporate proxy TLS inspection.
If you used npm installation on WSL, it often picks up the wrong Windows npm:
which npm
which nodeIf the path starts with /mnt/c/, you're using Windows-side Node/npm. It's safer to use Linux paths like /usr/... or ~/.nvm/... from within WSL.
The uploaded documentation also notes that for WSL path issues, which npm should start with /usr, not /mnt/c.
If npm-based installation encounters platform mismatch, you can try:
npm config set os linux
npm install -g @anthropic-ai/claude-code --forceHowever, the official documentation says to skip this WSL npm troubleshooting section if you used the native installer. npm installation issues only apply to npm-based installations.
If nvm isn't loading, add it to your shell configuration:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. $NVM_DIR/nvm.sh
[ -s "$NVM_DIR/bash_completion" ] && \. $NVM_DIR/bash_completionAuthentication problems typically show up as:
First check your current authentication status:
claude auth statusOr inside Claude Code:
/statusLog in again:
claude auth loginOr from within the session:
/loginAccording to the official documentation, if the login issue isn't clear, completely logging out with /logout, closing Claude Code, and then running claude again to complete authentication from scratch resolves most cases.
/logoutThen close and restart Claude Code:
claudeclaude auth logout
claude auth loginThe uploaded documentation also notes to use claude auth logout && claude auth login when switching between accounts or organizations.
In WSL2, SSH, or container environments, the browser may open on a different host and the redirect can't return to Claude Code's local callback server. In this case, when the browser displays the code, paste it into the terminal prompt. The official documentation also instructs to copy the code and paste it into the terminal if the browser redirect doesn't return automatically in WSL2, SSH, or containers.
If the browser doesn't open, press c to copy the OAuth URL.
To open Windows Chrome directly from WSL2:
export BROWSER="/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
claudeIf you're logged in but getting strange organization errors or acting like an old company account, an old API key may be left in environment variables:
echo $ANTHROPIC_API_KEYIf you want to use subscription login, unset it:
unset ANTHROPIC_API_KEY
claudeAlso check permanent configuration files:
grep -n "ANTHROPIC_API_KEY" ~/.zshrc ~/.bashrc ~/.profile 2>/dev/nullPermission problems typically show up as:
First check your current permission status:
/permissions
/status
/doctorAccording to the official debug configuration documentation, /permissions shows currently active allow/deny rules, and /status shows active settings sources and managed settings status.
Check permission configuration file locations:
According to the official settings documentation, Claude Code configuration scope is divided into managed, user, project, and local; project settings are shared in the repository, and local settings apply only to the current user in that repository.
If you added settings but Claude seems to ignore them, verify that the settings actually loaded:
/status
/doctorAnd check the configuration file location again:
Putting permissions, hooks, env in ~/.claude.json~/.claude/settings.json
.claude/settings.json
.claude/settings.local.jsonThe official debug configuration documentation explains that ~/.claude.json contains app state and UI toggles, while permissions, hooks, and env should go in ~/.claude/settings.json.
When Claude runs a Bash command and it fails, first separate "Claude issue" from "project command issue".
For example, npm test failure might not be a Claude Code problem but a project test failure.
Run directly in the terminal:
npm testDon't paste full logs to Claude; save them to a file and let Claude read it:
npm test 2>&1 | tee test-output.logRequest Claude like this:
Read @test-output.log and summarize only the failed test names, key error messages, and suspected root causes.
Don't print the entire log again.If a command seems stuck, press Ctrl+C to cancel. The official troubleshooting documentation explains that if Claude Code isn't responding, try Ctrl+C to cancel the current operation, and if that doesn't work, close the terminal and restart, then run claude --resume from the same directory to continue.
Bash command failures fall into three categories:
For example, if Claude can't run npm run test, first check:
which npm
npm --version
npm run testRequest Claude like this:
Is this a Claude Code permission issue, a shell environment issue, or a project test failure? Separate them.
First propose just the verification commands to run.As conversations grow long, these problems can occur:
First check:
/context
/usageThe official troubleshooting documentation recommends using /compact regularly with high CPU or memory usage, restarting Claude Code between large tasks, and adding large build directories to .gitignore.
If auto-compaction keeps failing, large files or tool output may immediately refill the context. The official documentation recommends having Claude read files in small line ranges or function units, specifying focus like /compact keep only the plan and the diff, moving large file work to a subagent, or using /clear if necessary.
If Claude can't find files, @file mention acts strange, or custom agents/skills can't find files, it might be a ripgrep issue.
Symptoms to watch for:
Install system ripgrep:
brew install ripgrepsudo apt install ripgrepwinget install BurntSushi.ripgrep.MSVCThen set the environment variable:
export USE_BUILTIN_RIPGREP=0The official troubleshooting documentation explains that the Search tool, @file mention, custom agents, and custom skills may not find files when bundled ripgrep doesn't run on the system. Install platform-specific ripgrep and set USE_BUILTIN_RIPGREP=0.
On WSL, project location also matters. Working under /mnt/c/ on the Windows file system can slow searches or return fewer results. The official documentation recommends moving projects to the Linux file system /home/ when possible on WSL and narrowing search scope by directory or file type.
MCP problems show up as:
First check status:
/mcpAlso check from the terminal:
claude mcp list
claude mcp get <name>The official debug configuration documentation explains that /mcp shows all configured servers, connection status, and current project approval status. Project-scoped servers require one-time approval, and if you closed the prompt, you need to re-approve in /mcp.
The official debug configuration documentation explains that project MCP config should be in .mcp.json at the repository root, not inside .claude/, and that settings.json doesn't read the mcpServers key.
For local stdio MCP servers, try running directly:
npx -y some-mcp-serverOr test the command and args from .mcp.json directly in the terminal.
Check debug output:
claude --debug mcpThe official debug configuration documentation explains that if the server is connected but shows 0 tools, try reconnecting in /mcp, and if it stays at 0 tools, use claude --debug mcp to check the server's stderr output.
If an MCP server fetches external content, also consider prompt injection risks. The official MCP documentation warns to verify that a server is trustworthy before connecting, and notes that servers fetching external content can create prompt injection risks.
Hook problems typically show up as:
First check the current hook list:
/hooksThe official debug configuration documentation explains that /hooks shows all hooks registered in the current session, organized by event.
The official debug configuration documentation explains that if hook matcher is an array, it causes a schema error, and the matcher must be a single string like "Edit|Write". Tool names must match case: Bash, Edit, Write, Read.
To watch real-time hook evaluation:
claude --debug hooksAccording to the official documentation, debug logs record each event, checked matchers, and hook exit code and output.
To check if the hook script itself is the problem, run it directly outside Claude Code.
For example, if protect-files.sh expects JSON stdin:
echo '{"tool_input":{"file_path":".env"}}' | .claude/hooks/protect-files.sh
echo $?If exit code is 2, it may work as a blocking hook. The uploaded documentation clarifies that exit code 2 blocks tool calls as a blocking hook, while exit code 1 means a non-blocking hook failure.
Plugin problems show up as:
First check plugin status:
/pluginOr start with debug:
claude --debugThe official plugin reference explains that claude --debug shows which plugins load, plugin manifest errors, skill/agent/hook registration, and MCP server initialization.
Skill SKILL.md changes may reflect immediately in the current session, but other plugin components differ:
hooks/
.mcp.json
agents/
output-styles/If you changed these components, run:
/reload-pluginsOr restart Claude Code:
The official plugin reference explains that changes to hooks/, .mcp.json, agents/, and output-styles/ don't reflect automatically; /reload-plugins or restarting Claude Code is needed.
The project-scope skills-directory plugin only loads from .claude/skills/ in the current directory where you started Claude Code. If your plugin is at the repository root but you start Claude Code from a subdirectory, it may be missed. Run from the repository root or use /reload-plugins.
my-plugin/
├── .claude-plugin/
│ └── plugin.json
├── skills/
├── agents/
├── hooks/
├── .mcp.json
└── scripts/my-plugin/
└── .claude-plugin/
├── plugin.json
├── skills/
├── agents/
└── hooks/The official plugin reference explains that only plugin.json goes inside .claude-plugin/, while components like commands, agents, and hooks should be at the plugin root level.
IDE issues were covered in detail in section 26, but here's a quick checklist:
The official troubleshooting documentation directs you to separate troubleshooting for VS Code extension not connecting, JetBrains plugin, and IDE not detected issues on each surface.
To check if the problem is configuration-related, run in "clean settings":
cd /tmp && CLAUDE_CONFIG_DIR=/tmp/claude-clean claudeThis session starts without the usual user/project settings, hooks, MCP servers, plugins, or memory. The official debug configuration documentation recommends setting CLAUDE_CONFIG_DIR to an empty directory and running from a directory without .claude, .mcp.json, or CLAUDE.md to compare with a clean session when the root cause is hard to narrow down.
Judgment works like this:
Works in clean session → Problem with existing ~/.claude or project .claude settings
Fails in clean session too → Installation, network, authentication, managed settings, environment variable problemIf the problem is caused by existing settings, gradually restore files one by one to find the cause.
Wiping configuration is a last resort. Backup first:
mkdir -p ~/claude-backup
cp -R ~/.claude ~/claude-backup/claude-dir 2>/dev/null
cp ~/.claude.json ~/claude-backup/claude.json 2>/dev/null
cp -R .claude ~/claude-backup/project-claude-dir 2>/dev/null
cp .mcp.json ~/claude-backup/project-mcp.json 2>/dev/nullrm ~/.claude.json
rm -rf ~/.claude/rm -rf .claude/
rm .mcp.jsonThe uploaded documentation also separates user settings reset from project settings reset commands. For beginners, clean session testing before full deletion is safer.
The official error reference documents Claude Code runtime error messages by type and recovery method, including API 5xx, 529, 429, authentication, network, request size, and model access issues. Transient failures also auto-retry up to 10 times with exponential backoff before showing an error.
Not always an error message. Sometimes Claude:
In this case, first check context and memory:
/context
/memory
/statusCheck if CLAUDE.md actually loaded:
/memoryThe official debug configuration documentation explains that if the memory file doesn't appear in /memory, you should check the file location. Also, subdirectory CLAUDE.md loads on-demand when Claude reads files in that directory with the Read tool, not at session start.
Also, if CLAUDE.md instructions are too long, vague, or conflicting, compliance rates drop. Keep project rules short and specific, and use permissions or hooks to enforce things that must be blocked.
To ask someone or file an issue, gather:
claude --version
claude doctorInside Claude Code:
/status
/doctor
/contextFor MCP issues:
claude mcp list
claude mcp get <name>claude --debug hooksclaude --debugFor performance/memory issues, you can use /heapdump. The official troubleshooting documentation explains that if memory usage stays high, /heapdump creates JavaScript heap snapshot and memory breakdown files in ~/Desktop or Linux home directory, and you should attach both files when reporting memory issues on GitHub.
Always remove sensitive information before sharing logs:
When a problem occurs, move through this order:
claude --version
echo $PATH
which -a claudeCheck PATH or duplicate installations.
claude auth status
claude auth logout
claude auth loginCheck if environment variable ANTHROPIC_API_KEY overrides OAuth.
brew install ripgrep # macOS
sudo apt install ripgrep # Ubuntu/Debian
winget install BurntSushi.ripgrep.MSVC # Windows
export USE_BUILTIN_RIPGREP=0On WSL, move your project under /home/.
/permissions
/status
/doctorCheck priority of settings.json, settings.local.json, and managed settings.
/mcpclaude mcp list
claude mcp get <name>
claude --debug mcpCheck .mcp.json location, approval status, relative paths, and env location.
/hooksclaude --debug hooksCheck if matcher is a string, tool name capitalization, and script execute permission.
/reload-pluginsOr restart:
claude --debugMy Claude Code config isn't working as expected.
Diagnose in this order.
1. Interpret /status results
2. Interpret /doctor results
3. Interpret /permissions results
4. Explain which config file takes priority
5. Before fixing, list suspected causes onlyMy MCP server shows failed status in /mcp.
Analyze only these based on claude mcp get results and .mcp.json:
- command problem
- args problem
- env problem
- authentication problem
- project approval problem
- relative path problem
Don't fix, just propose check order.My PostToolUse hook isn't running.
Review settings.json based on these items:
- hooks key location
- event name
- matcher format
- tool name capitalization
- script path
- execute permission
- exit code meaning
List suspected causes by priority before fixing.Claude Code session got slow.
First analyze /context results
to see what takes up space,
then separate what to keep and what to drop.
Next suggest a sentence to add to /compact.For complex problems, follow this routine exactly:
claude --version
claude doctorwhich -a claude 2>/dev/null || where.exe claudeclaude auth statuscd /tmp && CLAUDE_CONFIG_DIR=/tmp/claude-clean claudeInside Claude Code:
/status
/doctor
/context
/permissions
/mcp
/hooks
/pluginProblem-specific debug:
claude --debug
claude --debug hooks
claude --debug mcpIf still not resolved, use /feedback or check GitHub issues. Prepare: version, OS, shell, install method, claude doctor results, relevant debug logs, and reproduction steps.
The core of Claude Code troubleshooting is separation diagnosis, not reinstall. First split: Does Claude Code run? Am I authenticated? Is it a project-specific setting? Is it an extension like MCP, hook, or plugin?
The most important commands are:
By problem type:
Good debugging isn't fixing every problem immediately — it's narrowing the problem scope quickly. As Claude Code grows more complex, /doctor, /status, /context, and clean session comparison become your most powerful fundamentals.
This unit focuses on team operations, security, costs, and review systems rather than individual productivity. While personal use of Claude Code prioritizes convenience, team use emphasizes "who can execute what with which permissions," "what settings should be shared and what should remain personal," and "how should we review AI-generated changes."
Section 29 in the comprehensive guide is designed to cover separating shared and personal settings, permission policies, cost management, review and approval workflows, and writing team CLAUDE.md.
When individuals use Claude Code, these are important:
Finding files quickly
Editing quickly
Running tests quickly
Getting reviews quicklyIn a team, these are added:
Do all team members follow the same rules?
Are sensitive files blocked from reading or modification?
Are dangerous bash commands restricted?
Are AI-generated code changes reviewed by humans?
Are costs and token usage monitored?
Are only trustworthy MCPs, hooks, and plugins used?Official security documentation recommends reviewing proposed commands before approval when using Claude Code, confirming important file changes, and considering isolated environments like VMs when dealing with external web services or scripts. MCP servers should come from trusted providers or be self-written, and access can be restricted through permission settings.
When introducing Claude Code to a team, establish operating principles before enabling features.
Beginning teams don't need to build all enterprise-grade policies from the start. But at minimum, decide on these:
1. Never read or modify .env, credentials, or secrets.
2. Large changes always start with /plan.
3. AI-generated changes go through git diff and tests.
4. main branch pushes and production deploys are never auto-approved.
5. Team common rules go in CLAUDE.md and .claude/settings.json.The first principle of team operations is separating what to share from what not to share.
According to official configuration documentation, Claude Code uses a hierarchical settings.json structure. User settings go in ~/.claude/settings.json, project settings shared with the team in .claude/settings.json, and personal experiments or preferences in .claude/settings.local.json. .claude/settings.local.json is automatically git-ignored on creation, making it ideal for personal settings. Organization-level managed settings cannot be overridden by user or project settings.
The scope and purpose of configuration files are as follows:
Beginner teams can divide them this way:
All team members must follow → .claude/settings.json
Only I use → .claude/settings.local.json
I use in all projects → ~/.claude/settings.json
Security team must enforce → managed settingsThe uploaded documentation also identifies anti-patterns: "putting all settings in user settings" and "committing personal preferences." Team standards should go in project settings and personal settings in settings.local.json.
It's important not to allow team common settings too broadly.
The basic structure of the .claude/settings.json file is as follows:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(git status:*)",
"Bash(git diff:*)",
"Bash(git log:*)",
"Bash(npm test:*)",
"Bash(npm run test:*)",
"Bash(npm run lint:*)",
"Bash(npm run build:*)",
"Edit(src/**)",
"Edit(tests/**)",
"Write(src/**)",
"Write(tests/**)"
], "ask": [
"Bash(npm install:*)",
"Bash(pnpm add:*)",
"Bash(yarn add:*)",
"Bash(docker:*)",
"WebFetch"
],
"deny": [
"Read(.env)",
"Read(.env.*)",
"Read(secrets/**)",
"Read(config/credentials*)",
"Read(**/*secret*)",
"Read(**/*token*)",
"Edit(.env)",
"Edit(.env.*)",
"Edit(secrets/**)",
"Edit(.git/**)",
"Edit(package-lock.json)",
"Write(.env)",
"Write(.env.*)",
"Write(secrets/**)",
"Bash(rm -rf:*)",
"Bash(sudo:*)",
"Bash(chmod 777:*)",
"Bash(git push --force:*)",
"Bash(git push origin main:*)",
"Bash(kubectl delete:*)",
"Bash(terraform apply:*)"
]
}
}The goal of this configuration is "allow Claude to handle everyday development needs like reading, searching, testing, linting, and building, but block sensitive files and dangerous commands."
Don't put personal preferences in team common settings. For example, these are better in personal settings:
My preferred output style
My favorite model
My local machine paths
My personal MCP servers
My personal experimental hooks
My color and terminal display settings.claude/settings.local.json example:
{
"outputStyle": "Explanatory",
"env": {
"DEBUG": "app:*"
}
}Examples of what should not go in team common settings:
{
"env": {
"DATABASE_URL": "postgres://user:password@localhost:5432/mydb",
"GITHUB_TOKEN": "ghp_xxx"
}
}Sensitive information should not be placed directly in configuration files, but instead separated through shell environment, secret managers, OAuth, or MCP authentication flows.
Small teams can start with .claude/settings.json alone. But managed settings are needed in these situations:
Developers cannot bypass security policy through local settings
MCP server allowlists must be managed centrally
Only approved hooks can be executed
Same permission policy must be enforced across the entire company
SSO, compliance, and audit requirements existAccording to official documentation, managed settings can be deployed through Anthropic servers, macOS MDM managed preferences, Windows registry, or file-based system directories, and user and project settings cannot override them.
Security or platform teams can establish minimum policies like this:
/etc/claude-code/managed-settings.json
{
"permissions": {
"deny": [
"Read(**/.env*)",
"Read(**/secrets/**)",
"Read(**/credentials/**)",
"Read(**/*.pem)",
"Read(**/*.key)",
"Bash(rm -rf:*)",
"Bash(sudo:*)",
"Bash(git push --force:*)",
"Bash(kubectl delete:*)",
"Bash(terraform apply:*)"
]
},
"disableBypassPermissionsMode": true,
"allowedMcpServers": ["github", "sentry", "linear"],
"deniedMcpServers": ["untrusted-browser", "unknown-db"]
}This example blocks files and commands the company will never allow at the organizational level and manages MCP servers with an allowlist-centric approach.
When creating team permission policies, start with "what must we absolutely block?" rather than "what should we allow?"
The situations for each permission mode in a team are as follows:
Teams can adopt these basic rules:
Large changes → plan
Sensitive areas → plan
File modifications → approve before execution
Bash execution → verify command before approval
Operational impact → never Claude aloneTeams should not use overly broad Bash allowlist rules.
Bad example:
{
"permissions": {
"allow": ["Bash(*)"]
}
}Good example:
{
"permissions": {
"allow": [
"Bash(git status:*)",
"Bash(git diff:*)",
"Bash(npm test:*)",
"Bash(npm run lint:*)",
"Bash(npm run build:*)"
],
"ask": ["Bash(npm install:*)", "Bash(docker:*)"],
"deny": [
"Bash(rm -rf:*)",
"Bash(sudo:*)",
"Bash(git push --force:*)",
"Bash(kubectl delete:*)",
"Bash(terraform apply:*)"
]
}
}In a team, automating with hooks is more stable than "asking Claude to format every time."
For example, run prettier after file modifications:
.claude/hooks/format-edited-file.sh
#!/usr/bin/env bash
set -euo pipefail
input="$(cat)"
file_path="$(echo "$input" | jq -r '.tool_input.file_path // empty')"
case "$file_path" in
*.js|*.jsx|*.ts|*.tsx|*.json|*.md|*.css)
npx prettier --write "$file_path"
;;
esacRegister hooks in .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format-edited-file.sh",
"args": []
}
]
}
]
}
}Official hooks documentation notes that hooks scoped to .claude/settings.json apply to a single project, can be committed to the repo for sharing, and this enables team-wide automation.
Particularly important in teams is when settings change during a session. Official security documentation presents team security best practices as: using managed settings, sharing approved permission configurations through version control, training team members, monitoring usage through OpenTelemetry metrics, and using ConfigChange hooks to audit or prevent mid-session configuration changes.
For beginners, the policy is:
Team common setting changes → PR review
Personal setting changes → settings.local.json
Permission relaxation changes → security review
MCP server additions → team review
Hook additions → script content review
Plugin additions → component verification before installMCPs are powerful but connect to external systems, so they require the most caution in team operations.
When adding an MCP to your team, document the following:
If you want your team to use only GitHub and Sentry, you can manage them at project scope:
.mcp.json
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${GITHUB_TOKEN}"
}
},
"sentry": {
"type": "http",
"url": "https://mcp.sentry.dev/mcp"
}
}
}Don't put actual tokens in .mcp.json; separate them with environment variables. Share only the structure with the team repository, never commit personal tokens or operational credentials.
Instead of putting all repeated domain rules in CLAUDE.md, separate them as skills.
For example, create a skill for API implementation rules:
.claude/
└── skills/
└── api-conventions/
└── SKILL.mdThe uploaded documentation notes that project skills are committed to git, so team members automatically get them with a pull, and this standardizes specialized knowledge across the entire team.
Good practice divides short basic rules in CLAUDE.md and specific task procedures in skills:
Team CLAUDE.md is not better the longer it is. Since it's read every session, it must be short and clear.
Good CLAUDE.md structure looks like this:
# Project Guide for Claude Code
## Project overview
This repository contains the web application and API for the product.
## Commands
- Install: `npm install`
- Test: `npm test`
- Lint: `npm run lint`
- Build: `npm run build`
## Coding rules
- Use TypeScript strict mode.
- Keep business logic in `src/services`.
- Keep route handlers thin.
- Add tests for behavior changes.
- Do not introduce new dependencies without approval.
## Security rules
- Never read or edit .env, credentials, secrets, private keys.
- Do not print tokens, API keys, customer data.
- Ask before changing auth, billing, permissions, migrations, deployment.
## Workflow rules
- For large changes, use /plan before editing.
- After editing, run relevant tests and lint.
- Before final answer, summarize changed files and risks.Don't put these in CLAUDE.md:
The uploaded documentation also notes that putting all information in CLAUDE.md wastes session context every time, so keep it under 500 lines.
In a team, AI-generated code should be reviewed at the same level as human-written code. The basic flow is:
1. Clarify requirements
2. Write modification plan with /plan
3. Human approves plan
4. Claude makes minimal changes
5. Run tests, lint, build
6. Review changes with /diff or git diff
7. Run /code-review or security-review
8. Human reviews PR
9. Merge after CI passesLarge changes must maintain an "explain → plan → approve → execute → verify" flow.
Add Claude Code usage and verification items to team PR template:
.github/pull_request_template.md
## Summary
Describe what changed.
## Claude Code usage
- [ ] Claude Code was not used
- [ ] Claude Code was used for exploration only
- [ ] Claude Code suggested code changes
- [ ] Claude Code generated or edited code
## Verification
- [ ] I reviewed the full diff manually
- [ ] I ran tests
- [ ] I ran lint
- [ ] I ran build, if relevant
- [ ] I checked for secrets or credentials
- [ ] I checked security-sensitive changes
## Risk areas
- Auth / permissions:
- Billing / payments:
- Database / migrations:
- Deployment / infrastructure:
- Customer data:There's no need to automatically reject AI-generated code. But the procedure "AI changes reviewed by humans" must be clear.
The following areas always require additional review:
Clear prompts are important:
This change is about authentication code.
Conditions:
- Don't modify immediately, start with /plan
- Organize security risks in a separate section
- Check for missing permission checks
- Include test plan
- Don't modify files until I approveIn a team, Claude Code costs should be viewed as "which work patterns increase costs?" rather than "how much does one person use?"
Official cost documentation notes that Claude Code costs are based on API token consumption, and for team cost management, recommends /usage, context management, model selection, extended thinking adjustment, and reducing MCP overhead.
Common patterns that increase team costs are:
Individual developers verify in their sessions:
/usage
/contextTeam managers use analytics and monitoring. According to official analytics documentation, Claude for Teams and Enterprise provide usage metrics, contribution metrics, leaderboard, and CSV export.
Official monitoring documentation explains that the claude_code.cost.usage metric shows team or individual usage trends, high-usage sessions, and cost attribution by skill, plugin, and agent type.
1. Start new work with /clear.
2. Long sessions use /compact.
3. Save logs to files and request summaries only.
4. Read only the needed range from large documents.
5. Separate repeated rules as skills, not in CLAUDE.md.
6. Delegate test log analysis to subagents.
7. Connect only necessary MCP servers.
8. Use high effort and higher models only for difficult design.The uploaded documentation also recommends aggressively using /compact in long sessions and using cheaper models for subagents and simple tasks.
There are four main ways to use Claude Code in a team:
Official IAM documentation presents Claude Code access methods for teams and organizations. Teams are self-service plans suitable for collaboration, admin tools, and billing management, while Enterprise provides SSO, domain capture, and role-based permissions.
The most common team member question is "Is our code used for training?"
According to official data usage documentation, Free, Pro, and Max consumer plans allow users to opt in to model improvement data usage, but commercial users like Team, Enterprise, API, and third-party platforms do not have customer code or prompts sent to Claude Code used for generative model training unless customers separately choose to provide them for model improvement.
In team training materials, write it like this:
- Company code is used only under approved accounts and organization policy.
- Don't analyze company repos from personal accounts.
- Check transcripts for sensitive information before using /feedback.
- Block reading and modification of sensitive files with permissions.deny.
- Only use approved MCP servers from the allowlist.Before new team members use Claude Code, verify:
1. Logged in with approved authentication method
2. claude --version verified
3. claude doctor verified
4. Running claude from repository root
5. /status shows correct settings source
6. /permissions shows expected permission policy
7. /mcp shows connected MCP servers
8. /usage shows cost display is understood
9. Read CLAUDE.md
10. First practice with small read-only taskStart first practice with read-only, not modification tasks:
Read this project structure and
summarize the main directories and test commands.
Don't modify files.Then move to small edits:
/plan add a small validation test for the login formFix everyday development flow like this:
1. claude -c or start new session
2. /status
3. /context
4. Describe work
5. Large work → /plan
6. Approve then edit
7. Tests, lint, build
8. /diff
9. /code-review
10. Create PRPrompt example:
I want to add login form validation.
Team rules:
- /plan before editing
- No new dependencies
- Keep existing response format
- Add related tests
- Run npm test and npm run lint after
- Summary of changed files and risks at the endacceptEdits and auto-accept are convenient, but teams need clear standards.
Different teams may have different AI usage attribution policies. At minimum, it's good to keep this internally:
Claude Code usage in PR description
What work used it for
What humans reviewed
Test results
Security-sensitive areasWhether to enforce AI usage labels in commit messages depends on team policy. What matters most is "attribution responsibility" not "labeling itself."
Frequently used review prompts in a team should be standardized as skills or commands.
Example:
Review the current diff by team standards.
Focus on:
1. Actual bugs
2. Security issues
3. Missing tests
4. Excessive changes
5. Maintainability
Exclude:
- Personal preferences
- Simple style debates
- Issues lint already handles
Output:
- Critical
- Warning
- Suggestion
- Tests to addThis prompt can be separated as .claude/skills/review-checklist/SKILL.md:
---
description: Team code review checklist. Use when reviewing diffs, PRs, or completed code changes.
---
Review changes for correctness, security, tests, and maintainability.
Do not focus on style issues handled by lint.
Return findings in this format:
- Critical
- Warning
- Suggestion
- Tests to addSecurity-sensitive changes need a separate review prompt:
Review this diff from a security perspective.
Focus on:
- Authentication bypass
- Missing permission checks
- Missing user input validation
- SQL injection possibility
- IDOR possibility
- Sensitive information in logs
- Token/session handling issues
- File upload risks
- Billing/permission boundary damage
Organize results by severity, file path, reasoning, and fix suggestions.
Don't modify files.Teams can create this as a security-reviewer subagent or skill for reuse.
Hooks can execute shell commands, so they're code review subjects.
Hook PR checklist:
- Which event triggers it
- Matcher not too broad
- Command is safe
- Doesn't print sensitive info to stdout/stderr
- File paths quoted
- Exit code 2 used intentionally
- Not overly dependent on local environment
- Doesn't excessively block dev workflow on failureOfficial hooks documentation notes that matchers can be exact string lists or regex, and team hooks are safer when attached only to needed tools and events rather than broad matchers.
Plugins can include skills, agents, hooks, and MCPs, so verify components before installing.
Review items:
1. Which skills are added
2. Which agents are added
3. Which hooks execute
4. Which MCP servers connect
5. External network access
6. Shell command execution
7. Credential requirements
8. Conflicts with team policyInstead of freely opening the plugin marketplace, teams should operate with an approved marketplace or internal marketplace focus.
Subagents are good for separating context and delegating exploration, but overuse in teams increases costs and review complexity.
The uploaded documentation notes that subagents suit focused work that just reports results, while agent teams where multiple teammates directly message and coordinate through shared task lists cost more.
Team rule examples:
- Log analysis, security review, test failure summary can use subagents
- 3+ parallel subagent executions need justification
- Agent teams only for large refactoring or PR review with clear purpose
- Subagents with edit permission restricted to least privilege
- Security review subagents read-only by defaultThe same policy doesn't apply to every repository. Vary by risk level:
docs/claude-code-policy.md
# Claude Code Team Policy
## Allowed use
Claude Code may be used for:
- code exploration
- implementation planning
- test generation
- refactoring suggestions
- documentation updates
- code review assistance
## Restricted use
Do not use Claude Code to:
- read or modify secrets
- execute production deployment
- run destructive infrastructure commands
- change database migrations without review
- push directly to main
- bypass code review## Required workflow
For non-trivial changes:
1. Start with /plan.
2. Review the plan.
3. Apply minimal changes.
4. Run tests and lint.
5. Review git diff.
6. Create a PR.
7. Get human approval before merge.
## Sensitive areas
Extra review is required for:
- authentication
- authorization
- billing
- customer data
- migrations
- infrastructure
- deploymentReference this document from CLAUDE.md:
## Team policy
Follow `docs/claude-code-policy.md`.Beginning teams can start safely with this structure alone:
repo/
├── CLAUDE.md
├── docs/
│ └── claude-code-policy.md
├── .claude/
│ ├── settings.json
│ ├── skills/
│ │ ├── review-checklist/
│ │ │ └── SKILL.md
│ │ └── api-conventions/
│ │ └── SKILL.md
│ └── hooks/
│ ├── format-edited-file.sh
│ └── protect-files.sh
├── .mcp.json
└── .github/
└── pull_request_template.mdRole of each component:
Don't enable all features from the start:
Phase 1: Write CLAUDE.md
Phase 2: .claude/settings.json blocks sensitive files
Phase 3: Add Claude Code usage to team PR template
Phase 4: Train /plan, /diff, /usage, /permissions
Phase 5: Pilot with 5-10 team members
Phase 6: Verify costs and review quality
Phase 7: Add formatter and protection hooks
Phase 8: Add read-focused MCPs like GitHub/Sentry
Phase 9: Standardize skills and subagents
Phase 10: Deploy managed settings and plugins if neededThe uploaded documentation also recommends starting a pilot with 5-10 developers before full deployment in the enterprise architect guide.
Start with these commands rather than teaching every advanced feature.
These requests should be blocked or at least require manual review under team policy:
Forbidden prompts:
Fix everything automatically without permission.
If tests fail, fix everything and push automatically.
Read .env file, connect to DB, and find the root cause.
Deploy directly to production.
Run terraform apply.Instead, change them like this:
Just plan before editing.
Don't read sensitive files.
Suggest related tests and verification method first.
Don't modify files until I approve.I want to add a new feature.
Start with /plan.
Conditions:
- Examine only relevant files
- Minimize change scope
- No new dependencies
- Include test plan
- Separate security impact
- Don't edit until I approveBefore fixing this bug, investigate possible root causes.
Conditions:
- No file modifications
- List only relevant files and evidence
- Show 1-3 most likely root causes
- Suggest test commands to verifyReview the current diff by team standards.
Focus on:
- Actual bugs
- Security risks
- Missing tests
- Excessive changes
- Maintainability
Exclude style preferences.If incorrect changes from Claude Code are introduced or sensitive information exposure is suspected, immediately:
1. Stop the session
2. Check git status / git diff
3. Check if sensitive information was output, committed, or logged
4. Immediately rotate related tokens
5. Revert incorrect commits
6. Restrict PR or branch access
7. Check transcript for sensitive info before using /feedback
8. Review settings, hooks, permissions
9. Add policies to prevent recurrenceThe important thing in security incident response is "why did Claude do that" less than "which permission and settings allowed it."
Beginning teams only need to reach Phase 2:
CLAUDE.md
.claude/settings.json
PR template
/plan and /diff habitsThese four things come first.
Things to verify before adoption:
- Decide authentication method
- Write team CLAUDE.md
- Set sensitive file deny
- Set dangerous Bash command deny
- Update PR template
- Train /plan, /diff, /usageThings to verify during pilot:
- Track costs
- Check frequently asked permissions
- Collect project rules Claude confuses frequently
- Remove excessive content from CLAUDE.md
- Separate repeated prompts as skillsThings to verify before scaling:
- Finalize MCP allowlist
- Review hooks scripts
- Finalize plugin installation criteria
- Decide if managed settings needed
- Set up analytics or OTel monitoringThings to regularly check during operations:
- /permissions regular check
- MCP server regular check
- Check cost spikes
- Sample review security-sensitive PRs
- Update team policy documentationTo safely use Claude Code in a team, treat it not as a personal productivity tool but as team development infrastructure. The key is separating shared and personal settings, blocking sensitive files and dangerous commands, and creating a workflow where humans review AI-generated changes.
The most important standard is:
The minimum set a beginning team needs when starting:
1. Short CLAUDE.md
2. Safe .claude/settings.json
3. PR template
4. /plan → edit → test → /diff → review workflow
5. Deny sensitive files and dangerous commandsFollowing these five practices alone allows you to use Claude Code much more safely and consistently in your team.
The core fundamentals that beginners absolutely need to know to use Claude Code well have already been covered in previous sections. Below are the key areas we've learned so far.
Most of the features covered in Section 30 are in the "advanced entry" zone. You don't need to use all of them right now. Instead, you can understand them by the criteria below.
The advanced features in Section 30 can be looked up "when needed" based on the following criteria.
The natural progression from beginner to advanced user follows this order.
You don't need to jump straight to stages 8-11. Most real productivity gains already come from stages 1-7. Stages 8 and beyond are expansion features you use when "your work scale grows."
Background agent is a feature that keeps a Claude Code session running in the background without tying it to your terminal. /background [prompt] or /bg detaches the current session as a background agent, freeing up your terminal, and you can monitor it later with claude agents. /exit detaches (rather than terminates) the session when you're attached to a background session, and /stop stops an attached background session.
Basic usage example:
/background Investigate the full test failure and summarize it for me.Or start directly from terminal:
claude --bg "investigate the flaky test and summarize likely causes"--bg starts the session as a background agent and immediately prints the session ID and management commands. Combined with --exec, you can run a shell command as a background job instead of a Claude session.
claude --bg --exec 'pytest -x'They look similar but serve different purposes.
Claude Code can run bash commands in the background and returns a background task ID immediately. You can press Ctrl+B to send a running Bash tool invocation to the background. tmux users may need to press Ctrl+B twice due to prefix key conflicts.
Agent View is an operations interface for viewing multiple Claude Code background sessions on one screen. Running claude agents opens Agent View, where you can see whether each session is running, waiting for input, or completed. Each background session continues to run as a single Claude Code conversation, even without being attached to a terminal.
claude agentsWhen you enter a prompt, a new background session is created. If you enter another prompt, it doesn't send a follow-up to the existing session but starts a new session in parallel. You can send multiple tasks simultaneously, but each session uses quota independently.
Agent View is suitable for these situations.
Example prompts:
Investigate why login tests are flaky.Review the current PR for security risks.Find outdated API docs and propose updates.Agent View is a research preview that requires Claude Code v2.1.139 or later, and its interface and shortcuts may change as features evolve. Don't treat Agent View itself as a quality gate in team operations—final validation should still be based on tests, diff review, PR review, and hook results.
Claude Code on the web is a research preview feature for delegating coding tasks from your browser. Tasks run on Anthropic-managed cloud infrastructure and are available to Pro, Max, Team users and Enterprise premium seat or Chat + Claude Code seat users. Sessions persist even after closing the browser, and you can monitor them from the Claude mobile app.
Official web documentation covers cloud environment, setup scripts, network access, Docker, session management, PR auto-fix, and terminal-web transition features like --remote and --teleport.
/teleport or /tp brings a Claude Code on the web session to your current terminal, and /remote-control or /rc makes a local session remotely controllable from claude.ai. /web-setup connects your GitHub account to Claude Code on the web using your local gh CLI credentials.
Common workflow:
claude --remote "fix the failing CI on this branch"/teleport/remote-controlDynamic workflows are an advanced feature for orchestrating subagents at scale. A dynamic workflow is a JavaScript script written by Claude that coordinates multiple subagents, which the runtime executes in the background. It's ideal for tasks like codebase audits, large-scale migrations, and research that requires cross-validation, which would be difficult for a single conversation to directly coordinate.
Dynamic workflows are a research preview and require Claude Code v2.1.154 or later. They're available on all paid plans, Anthropic API access, Bedrock, Vertex AI, Microsoft Foundry, and on Pro you need to enable them in Dynamic workflows row of /config.
The difference between subagents, skills, and workflows can be explained by "who decides the next step."
Subagent and skill are coordinated turn-by-turn by Claude, but workflow runs scripts with loop, branching, and intermediate result handling. Therefore, only the final answer remains in Claude's context.
Small delegation → subagent · Repeated procedure → skill · Large-scale parallel orchestration → workflow
Claude Code has a built-in /deep-research workflow, and during workflow execution you can view progress with /workflows. The /workflows view shows agent count per phase, token total, and elapsed time. You can drill down by phase or agent to see prompt, tool call, and result.
/deep-research What changed in the Node.js permission model between v20 and v22?/workflowsIf you want to create your own workflow, you can request it by including the word workflow in your prompt.
Create a workflow to audit all API endpoints for missing authorization checks. Do not edit files. Return a prioritized report with file paths and evidence.Or you can enable /effort ultracode. ultracode is a setting that combines xhigh reasoning effort and automatic workflow orchestration. It uses more tokens and time, so when returning to routine work, it's good to lower it with /effort high.
Workflows are powerful but shouldn't be overused by beginners.
Workflows have limits like maximum 16 concurrent agents, up to 1,000 agents per run. The workflow itself doesn't directly access filesystem or shell—agents handle reading, writing, and execution. Also, since many agents are spawned, meaningful token usage can be significantly higher than processing the same task in conversation.
As team size grows, personal settings and project settings alone aren't enough. At the Enterprise stage, centralized policy, security controls, cost monitoring, and audit logs become important. Organization admins can set permission rules, sandboxing, managed policy CLAUDE.md, MCP server control, plugin marketplace control, customization lockdown, hook restrictions, Agent View disabling, and minimum version policy.
Not all advanced features suit all organizations. The official settings documentation includes policy items like disableAgentView to turn off background agents and Agent View, disableRemoteControl to prevent remote control, disableSkillShellExecution to prevent skill shell execution, and disableWorkflows to turn off workflows.
{
"disableAgentView": true,
"disableRemoteControl": true,
"disableWorkflows": true,
"disableSkillShellExecution": true
}Features difficult to control by company policy should be disabled first, then establish safety standards with a pilot team before gradually enabling them.
For organizations, /usage alone may not be enough. Claude Code can export metrics, logs/events, and optional traces through OpenTelemetry, which can be connected to your organization's monitoring backend to track session, tool, token, and cost usage.
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
claudeAt the team stage, watching these is usually enough.
Claude Code is a fast-moving tool. So guides should fix the "current moment" as reference, but inform readers how to check the latest.
Check within session:
/release-notesCheck version from terminal:
claude --versionUpdate:
claude update/release-notes opens an interactive version picker so you can view release notes for a specific version or all versions. /usage shows session cost, plan usage limits, and activity stats, and /cost, /stats are aliases for /usage.
When reading changelog, don't include every item in the guide. Select by these criteria.
For example, changelog v2.1.157 added .claude/skills directory plugin auto-load, claude plugin init <name>, /plugin autocomplete, and v2.1.158 added Bedrock, Vertex, Foundry Opus 4.7/4.8 auto mode opt-in. These items affect feature descriptions and become guide update candidates.
claudeclaude "explain this project"claude -p "query"claude -cclaude -r "<session>"/exit/clear [name]/resume/rename auth-refactor/branch [name]/plan [description]/diff/code-review [low|medium|high|xhigh|max|ultra]/code-review --fix/simplify/security-review/run, /verify/rewind/btw <question>/code-review performs review for correctness bugs and cleanup perspective, and can apply findings to working tree with --fix. Since v2.1.154, /simplify has been split off as a cleanup-only review rather than finding correctness bugs.
/usage/cost, /stats/model/effort/fast/context/compact/clear/recap/usage shows session cost, plan usage limits, and activity stats. On Pro/Max/Team/Enterprise plans, it also includes usage breakdown by skill, subagent, plugin, and MCP server. /cost and /stats are aliases for /usage.
/status/config, /settings/permissions/memory/hooks/mcp/agents/skills/reload-skills/plugin/reload-plugins/doctor, /debug/background, /bgclaude agents/stop/tasks, /bashesclaude --bg --exec 'pytest -x'/workflows/deep-research <question>/teleport, /tp/remote-control, /rc/web-setup! git status! git diff or /diff@src/file.ts/add-dir <path>/init/review [PR]/autofix-pr [prompt]claude --from-pr 123/autofix-pr can detect open PRs on the current branch and spawn a web session to fix CI failures or review comments. /review reviews PRs in a local session.
Ctrl+R history search searches prompts from all projects by default. You can cycle through current session, current project, and all projects with Ctrl+S. Background bash can be sent to background with Ctrl+B.
Workflows saved in .claude/workflows/ become project shared commands, and workflows in ~/.claude/workflows/ become personal commands available across all projects. If names conflict, project workflow takes priority.
/plan/context → /compact/usage/doctor, /debugIf you only memorize the absolute minimum:
Slash commands to remember:
Terminal commands to remember:
claude
claude --version
claude doctor
claude update
claude -c
claude -p "query"
claude agents
claude mcp list
claude mcp get <name>
claude plugin listWhen learning advanced features, always start with small experiments.
Don't immediately jump to production deploy, DB migration, or large-scale automated fixes. Advanced features of Claude Code are powerful, but the more powerful the feature, the more permission, cost, and validation are needed.
The most stable routine for daily development.
For large work, extend the basic routine this way.
For team work, standardize this way: Check CLAUDE.md → Verify .claude/settings.json permissions → Approve /plan → Edit minimum scope → CI and human review → Separate security review for sensitive changes.
Claude Code is not just a chat-based coding assistant. It's an agent-based CLI that reads codebases, edits files, runs commands, and extends through hooks, MCP, subagents, skills, plugins, and workflows. Experienced users delegate exploration and specialized work to delegation layers and configure the extension layer to match their workflow.
By this point, you're ready to treat Claude Code not as "just a tool that fixes code," but as a work partner that operates alongside your development workflow.
Starting out, /plan, /diff, /usage, /context, and /permissions alone are enough. Once you're comfortable, automate repeated work with hooks, connect external tools with MCP, divide large work with subagents and skills, and in teams, standardize configuration and review flow.
Delegate to Claude, but keep final responsibility and judgment with the developer. Good tools don't replace people—they make us work more carefully and accurately. This guide is your starting point for using Claude Code safely and confidently.