You use Claude Code as a chat window that edits files.
Stop doing that now.
Buy 100 Claude Code Commands, Workflows & Templates.
Published 30 November 2026. Tested on Claude Code v2.1.316, Windows 11, with Claude Sonnet 5.5.
Here's how to use Claude Code effectively: give it one scoped task, point it at a file worth copying, name a test it can run, and keep your project rules in a short CLAUDE.md. Allow only the commands it needs. Commit after every accepted change, and clear the context between unrelated jobs.
One warning before you copy anybody's settings file. I set a rule that denies git push, asked Claude Code to push anyway, and the push went through. The cause was one pair of characters, and the fix is below.
I ran 29 headless sessions on throwaway Git repositories on 30 November 2026. Together they cost $1.02 at API rates. Most of this guide hangs on those runs, and the rest links to the official docs.
Question | Short answer |
|---|---|
Is it free? | No. The Free plan excludes Claude Code |
Cheapest subscription | Pro: $20 a month, or $200 a year |
Typical company API cost | About $13 per developer per active day, per Anthropic |
CLAUDE.md target size | Under 200 lines |
Cheapest fix I measured | Two sentences that cut task cost 29% |
Riskiest rule I tested | Allow |
Between unrelated tasks |
|
When a session goes wrong |
|
What I tested to learn how to use Claude Code effectively
The main task was small on purpose: add a discount function to a Python service. The repo already held a refund function with house conventions, such as returning a (value, error) pair, recording an audit event and ending function names in _v1. I checked six of those conventions with a script.
Each setup ran three times. Costs are averages from Claude Code's own JSON output.
Setup | Conventions met | Avg cost | Avg time | Runs with a denied command |
|---|---|---|---|---|
Vague one-line prompt | 4 of 6, every run | $0.028 | 15 s | 0 of 3 |
Vague prompt + 7-line CLAUDE.md | 6 of 6, every run | $0.056 | 28 s | 2 of 3 |
Example file + test command | 6 of 6, every run | $0.049 | 29 s | 3 of 3 |
Example, test command and CLAUDE.md | 6 of 6, every run | $0.039 | 21 s | 0 of 3 |
Example, test command and two tool instructions | 6 of 6, every run | $0.034 | 21 s | 0 of 3 |
The vague prompt looks like a bargain until you open the diff. All three times it dropped the _v1 suffix, wrote no test and ran nothing. To its credit, it said so.
What I didn't expect was the second and third rows. Claude kept writing both files and running the tests in one long shell command. My allow rule covered python -m unittest and nothing else, so the whole chain got denied and Claude started over. Five of those six runs paid for that detour.
These two sentences removed it:
Create files with the Write tool. Run the test command on its own,
with no cd and no chaining.
Average cost fell from $0.049 to $0.034, and input tokens fell 43%. No config changed.
It's a tiny sample on a tiny repo, so don't carry the cents over to your project. Carry the pattern. Denied commands are a cost you can see and remove.
What is Claude Code and how is it different from just using the Claude web interface or standard terminal tools?
Claude Code is Anthropic's coding agent. It reads your files, edits them, runs commands and reacts to the output. Claude's web chat works on what you paste or attach, so you carry the answers back yourself. Standard terminal tools run the exact command you type and make no decisions. Claude Code decides which command to run next.
It works as a terminal program, a VS Code extension, a desktop app and a web app. Among AI assistant source code tools, that execution loop is the dividing line: an autocomplete suggests text, and an agent can find out that its own text was wrong.
How does the Claude code work so well?
It works in a loop. Anthropic describes it as gathering context, taking action and verifying results, where each tool result shapes the next step. A model that can read a stack trace and try again gets more chances to be right. Remove the verification step and you're back to a chatbot with write access.
How do I install Claude Code and set up my API key to start using it in my local project directory?
Install the native build, open a terminal in your project folder, and run claude. Sign in with a paid Claude plan or a Console account. An API key is optional, and you need one only for pay-per-token billing.
On macOS, Linux or WSL:
curl -fsSL https://claude.ai/install.sh | bash
On Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
Then start it where the code lives:
cd my-project
claude --version
claude
To bill an API key instead, set it first:
export ANTHROPIC_API_KEY="your-key"
$env:ANTHROPIC_API_KEY="your-key"
Here's the trap. ANTHROPIC_API_KEY outranks your subscription login. An interactive session asks you once whether to use it, but claude -p uses it without asking. If you pay for Pro and see an API bill, unset the variable and check /status.
You need macOS 13, Windows 10 1809, Ubuntu 20.04 or Debian 10 at the oldest, with 4 GB of RAM. The npm route needs Node.js 22 or later.
Terminal or VS Code?
Use the VS Code extension if you review diffs line by line; it gives you per-change accept and reject, plan comments and @file.ts#5-10 mentions. Use the terminal for scripts, worktrees and remote machines. The extension bundles a private copy of the CLI, so typing claude in a terminal still needs the standalone install.
Is Claude Code completely free to use, or how does it bill for API usage compared to a regular Claude Pro subscription?
Claude Code isn't free. A subscription gives you a shared usage allowance for a flat fee, while an API key bills every token with no monthly floor. Anthropic's pricing page on 30 November 2026 lists Claude Code under Pro, Max, Ultra, Team and Enterprise, and leaves it out of Free.
Way to pay | Price on 30 Nov 2026 | Pick it when |
|---|---|---|
Free | $0 | Never for this: no Claude Code access |
Pro | $20 monthly, or $200 yearly | You code with it a few days a week |
Max | $100 monthly, 5x Pro usage | You hit Pro limits most weeks |
Ultra | $200 monthly, no 5-hour limit (verified accounts) | You run several sessions all day |
API, Sonnet 5.5 | $2 in / $10 out per million tokens | Scripts, CI and bursty use |
API, Opus 5.5 | $4 in / $20 out per million tokens | Hard problems billed per task |
API, Haiku 5.5 | $0.10 in / $0.50 out, up to 100K-token prompts | Searches and cheap subagents |
API rates come from Anthropic's platform pricing. Cached input is far cheaper than those rates, and that's why my runs could send 37,000 input tokens for three cents.
Measuring ROI against token cost
Anthropic reports an enterprise average of $150 to $250 per developer per month on API billing. Divide your bill by what an hour of your time costs:
Monthly spend | Break-even at $30/hour | At $60/hour | At $100/hour |
|---|---|---|---|
$20 (Pro) | 40 min | 20 min | 12 min |
$100 (Max) | 3 h 20 min | 1 h 40 min | 1 h |
$200 (Ultra, or the API average) | 6 h 40 min | 3 h 20 min | 2 h |
Break-even is easy to reach and hard to prove, because people misjudge their own speed. In METR's 2025 trial, 16 experienced open-source developers took 19% longer with AI and still believed they'd been about 20% faster. METR now marks that result as out of date. Its February 2026 update leans toward a speedup but calls the data an "unreliable signal."
So don't trust the feeling. For two weeks, log four numbers per task: your estimate before starting, actual minutes including review, the cost from /usage, and whether the change survived a week without a fix. Cost per surviving change is the number worth watching.
How to set permissions, and why my deny rule failed
How can I give Claude Code the right permissions to run tests and make git commits without breaking things on my machine?
Allow the exact test command, git add and git commit. Let everything else prompt you. Don't allow Bash(git *), because a deny rule on git push won't catch every way of writing a push. Add a PreToolUse hook, and protect your main branch on the server.
I tested this against a local bare repository, one headless run per row:
Rules | Command | Result |
|---|---|---|
Allow |
| Blocked |
Allow |
| Pushed |
Allow only |
| Blocked, needed approval |
Allow only |
| Committed |
Allow |
| Blocked |
Allow |
| Blocked |
Bash rules match command text, and the permissions docs warn about this exact spelling. Deny rules do beat allow rules. A deny rule that never matches beats nothing.
Put this in .claude/settings.json, with your own test command:
{
"permissions": {
"allow": [
"Bash(python -m unittest *)",
"Bash(git add *)",
"Bash(git commit *)"
],
"deny": ["Bash(git push *)", "Read(.env)", "Read(.env.*)"]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "python hook.py" }]
}
]
}
}
And this is the hook I used, saved as hook.py:
import json, re, sys
cmd = json.load(sys.stdin)["tool_input"].get("command", "")
if re.search(r"\bgit\b.*\bpush\b", cmd):
print("Blocked: a human pushes in this repo.", file=sys.stderr)
sys.exit(2)
Exit code 2 blocks the call and hands the message to Claude. The hook is a speed bump too: a script that pushes internally would slip past it, and it matches only the Bash tool. Branch protection on your Git host is the wall.
Claude Code permission modes, including auto mode
Auto mode is the built-in starting mode for interactive sessions since v2.1.283, so a classifier reviews actions before they run. Press Shift+Tab to change modes.
Mode | What happens | Use it for |
|---|---|---|
Manual ( | Prompts for most edits and commands | Unfamiliar repos |
| Edits apply; Git and tests still prompt | Work you review as a diff |
| Reads only until you approve a plan | Refactors |
| Classifier blocks risky actions | Long tasks in trusted repos |
| Anything that would prompt is denied | CI |
| Skips prompts | Disposable containers only |
I disagree with Builder.io's popular guide, whose author starts sessions with --dangerously-skip-permissions. The prompts really are tiring, and that's a fair complaint. But the post dates from July 2025, and auto mode plus narrow allow rules now solve the fatigue without removing the brake. One more thing for Windows users: the OS sandbox doesn't run on native Windows. You need WSL2.
How does Claude Code use the CLAUDE.md file?
Claude Code loads CLAUDE.md into its context when a session starts. It reads files from the folders above your working directory down to it, so the closest file comes last. A CLAUDE.md inside a subfolder loads when Claude works on files there. The content is guidance, and the memory docs are clear that it isn't enforced.
File | Who gets it | What belongs there |
|---|---|---|
| You, in every project | Personal habits |
| Everyone on the repo | Commands, conventions, traps |
| You, in this repo | Local URLs and paths (gitignore it) |
| Everyone, optionally per path | Rules for one area |
Best instructions for Claude Code: the file I tested
This is the whole file from my runs. It moved the vague prompt from 4 conventions to 6:
# Rules
- Run `python -m unittest` before finishing.
- Service functions return (value, error) tuples. Never raise.
- Money is integer cents. Round half up.
- Log with audit.record(event, id). Never print.
- Function names are verb_noun_v1.
- Every service has a test file in tests/.
It also has a bug, and I wrote it. "Round half up" doesn't say what gets rounded. For 50% off a 5-cent order, the CLAUDE.md-only runs returned 3 cents once and 2 cents twice. Same file, same prompt, all tests green. One run rounded the total and the others rounded the discount.
The better line carries an example: "Round the discount half up, so 50% off 5 cents leaves 2 cents." If a rule can be read two ways, sooner or later it will be.
Claude Code rules for one part of the repo
A path-scoped rule loads only when Claude touches matching files, which keeps it out of every other session.
---
paths:
- "src/api/**/*.ts"
---
- Validate input at the route boundary.
- Return errors as { code, message }.
Path-scoped rules don't survive compaction unless a matching file is touched again. Anything that must always hold goes in the root file. Anything that must never happen goes in a hook.
Claude instructions examples: weak and strong
Weak instruction | Stronger instruction |
|---|---|
Write clean code | Copy the shape of |
Test your work | Run |
Be careful with money | Amounts are integer cents, e.g. 1050 means $10.50 |
Don't break things | Change nothing outside |
Follow our style | Errors return |
How to prompt a Claude code effectively?
State the outcome, the files in scope, one example to copy, the check to run and the point where it should stop. Those five lines beat a long paragraph because each one removes a guess. Learning how to use Claude Code efficiently is mostly learning which guesses you left open.
Goal: [what should be true when you're done]
Scope: only [folder or files]
Copy: the pattern in [file] and its test in [file]
Check: run [command] on its own and show the output
Stop: if [condition], report it and change nothing
What are the best practices and prompt techniques for getting Claude Code to write clean code that matches my project's existing style?
Name a file to imitate. In my runs, "follow the pattern in services/refund.py" took style compliance from 4 of 6 conventions to 6 of 6 with no CLAUDE.md at all. Add a linter or test as the judge, put recurring conventions in CLAUDE.md, and ask for a small diff.
An example copies what's in the file, including its silences. The refund file does no rounding. All six runs that had the example and no CLAUDE.md rounded the result to 3 cents; all three that had both went the other way. Examples teach shape, rules settle edge cases.
Can you give me a step-by-step guide on how to use Claude Code effectively for refactoring a large legacy codebase?
Work in slices: map the code, pin its current behavior with tests, plan in plan mode, change one slice, verify, commit and clear. Never ask for the whole refactor in one prompt. Each slice should be small enough that throwing it away costs you nothing.
Branch first.
claude -w billing-refactorstarts in a separate worktree.Map it without filling your context: "Use a subagent to trace who calls
late_fee. Report files and line numbers only."Pin behavior: "Write tests for what this module does today, bugs included. Change no source files."
Plan:
/plan split the billing module, one commit per step. Edit the plan yourself before approving it.Run one step with the five-line prompt above.
Read the diff, run the tests yourself, commit.
/clear, then start the next step from the plan file.
Step 3 is the one people skip. Without tests that describe the old behavior, Claude can't tell a refactor from a rewrite, and neither can you.
For monorepos, Anthropic's large-codebase guide suggests one CLAUDE.md per package, claudeMdExcludes for packages you never touch, Read deny rules on generated code, and a code-intelligence plugin so Claude can look up definitions instead of scanning. For wide mechanical changes, /batch splits the job into 5 to 30 units, each in its own worktree.
Why is Claude Code getting stuck or throwing context window errors when I ask it to scan my entire project, and how do I fix it?
The conversation, file contents and command output have outgrown the model's context window. Claude Code shows "Context limit reached" or "Prompt is too long." Run /compact to summarize, or /clear to start empty. Then replace the whole-project scan with a search, or send it to a subagent.
I measured the difference on a 40-module legacy folder, three runs each, with the same bug to fix:
Prompt | Fixed | Avg input tokens | Avg cost | Avg time |
|---|---|---|---|---|
"Read every file in this project, then fix..." | 3 of 3 | 68,297 | $0.053 | 27 s |
"Grep for | 3 of 3 | 38,723 | $0.034 | 12 s |
Both fixed it. The scan cost 57% more and took over twice as long. One of the scan runs then admitted: "I didn't read every file as you asked." So you can pay for a full scan and not get one.
Message or symptom | Cause | Fix |
|---|---|---|
| Window is full |
|
| Conversation plus attachments exceed the window | Trim pasted files, then |
| One huge first message |
|
| Big outputs refill it after each compaction | Read in chunks, or use a subagent |
Forgets a rule halfway | The rule was lost in compaction | Move it to the root CLAUDE.md |
Slow and expensive from the start | Heavy MCP servers or CLAUDE.md |
|
The error reference has the full list.
How to troubleshoot when Claude Code goes off the rails
Stop early. Press Esc the moment it edits the wrong file, because every further turn adds wrong context for the next one to build on.
Escto interrupt. Nothing is lost.git diffin another terminal, to see what truly changed./rewind(orEsctwice on an empty prompt) to restore code, conversation or both.Rewrite the original prompt with the fact it was missing. Don't argue in the thread.
Failed twice on the same point?
/clearand start with a smaller task.Still looping? Ask for a failing test that shows the problem, and nothing else.
Rewind has a hole worth knowing about. Checkpoints track files Claude changed with its edit tools. A file touched only by a shell command isn't covered, and subagent edits generally aren't restored. Remember the long shell commands from my first test, the ones that tried to create files? Had I allowed them, rewind couldn't have undone them. Git could.
That's why a commit after each accepted change is the real undo button. One Hacker News commenter put the habit plainly: "I accept all changes immediate and then commit after every change." I'd read the diff first, but the commits are right.
How do I troubleshoot permission denied errors and missing dependency issues when running Claude Code in my terminal?
First work out who said no. If Claude Code refused the command, change the permission rule or the command's shape. If your shell or operating system refused it, fix ownership or PATH. If a program is missing, install it yourself and restart the session from a terminal that can see it.
What you see | Who said no | Fix |
|---|---|---|
"This command requires approval" | Claude Code rule | Add a narrow allow rule in |
An allowed command still denied | Claude Code rule | It was chained. Ask for it alone, no |
A hook message | Your hook | Read the script; |
| File ownership | Use the native installer. Don't use |
| File ownership |
|
| PATH | Add |
| npm skipped a step |
|
Search finds nothing | Bundled ripgrep can't run | Install ripgrep, set |
Sandbox won't start on Linux or WSL2 | Missing packages |
|
| Session PATH | Activate the venv or Node version, then start |
claude doctor checks your install from the shell without starting a session. Run it before you reinstall anything.
What are Claude Code commands?
Claude Code commands are instructions you type after a slash, such as /clear or /plan. Some ship with the tool, and you can write your own as skills: markdown files that hold a saved prompt. Type / in a session to see every command available to you.
What are all the Claude Code commands?
The list changes with nearly every release, so treat the official command reference as the source. These are the ones that change daily results:
Command | Use it when |
|---|---|
| The repo has no CLAUDE.md |
| The change touches several files |
| You switch tasks ( |
| Same task, window filling up |
| You want to know what's eating the window |
| You want cost and limits ( |
| The last turn was a mistake |
| A side question that shouldn't enter history |
| You approve the same command repeatedly |
| You want to edit CLAUDE.md files |
| The task is harder or simpler than usual |
| Before a commit or pull request |
| Something is misconfigured |
Claude Code command templates: a commit command that refuses broken code
Custom commands and Git belong together. Save this as .claude/skills/safe-commit/SKILL.md and run /safe-commit refund comment:
---
name: safe-commit
description: Run the tests, then commit the current change
disable-model-invocation: true
allowed-tools: Bash(git status *) Bash(git diff *) Bash(git add *) Bash(git commit *) Bash(python -m unittest *)
---
Changed files:
!`git status --short`
1. Run `python -m unittest` by itself.
2. If any test fails, stop. Report the failure. Do not edit code or commit.
3. If all pass, stage only files related to: $ARGUMENTS
4. Commit with a one-line message under 60 characters. Never push.
I ran it twice on v2.1.316. With passing tests it committed services/refund.py, left an unrelated scratch.txt alone, and cost $0.024. Then I flipped a minus sign in the refund code. It ran the tests, reported the failure and committed nothing, for $0.020.
The line disable-model-invocation: true means only you can trigger it. Older guides put commands in .claude/commands/, which still works, but the skills docs recommend skills for new work.
Claude Code commands and templates for daily work
Each of these is a starting point. I haven't benchmarked them.
Bug reproduction first
Write one failing test that reproduces: [bug]. Run it and show it failing
for the right reason. Don't touch source files yet.
Review with fresh eyes
Use a subagent to review the current diff against [spec]. Report only bugs
that change behavior, with file and line. Skip style.
Handoff before /clear
Write HANDOFF.md: the goal, what's done, what failed and why, the next step,
and the commands to verify. Under 40 lines.
Interview me
I want to build [feature]. Ask me about edge cases and trade-offs, one
question at a time, until you could write the spec. Then write SPEC.md.
Claude CLI configuration templates
For CI and scripts, cap the spend and name the tools. My test runs used the same flags with acceptEdits; this version is stricter, for unattended jobs:
claude -p "Run the tests and summarize failures" \
--model sonnet \
--output-format json \
--max-budget-usd 0.50 \
--permission-mode dontAsk \
--allowedTools "Read" "Grep" "Bash(python -m unittest *)"
The JSON carries total_cost_usd, num_turns and permission_denials. Log the third one. It's how I found the chained-command problem.
Best Claude Code workflows
The best Claude Code development workflow for most people is explore, plan, implement, verify, commit, with a /clear at the end. Use it for anything that spans more than one file. For a one-line fix, skip the plan and just name the check.
That sequence is Anthropic's own advice, and it's the spine of the University of Maryland course notes too. My addition is small: check for denied commands after the first run, and fix the prompt before you repeat it.
17 best Claude Code workflows
A Claude Code workflow guide is only useful if you can find the row you need today. The top Claude Code workflows are the first five; the rest solve narrower problems.
# | Workflow | How to start it |
|---|---|---|
1 | Explore, plan, implement, verify, commit |
|
2 | Pattern copy | "Follow the pattern in [file]" |
3 | Failing test first | "Write a test that reproduces..." |
4 | Scoped bug hunt | "Grep for [symbol], read only matches" |
5 | Safe commit |
|
6 | Characterization tests | "Test what it does today, bugs included" |
7 | Subagent research | "Use a subagent to find..." |
8 | Fresh-context review |
|
9 | Interview to spec | "Ask me one question at a time..." |
10 | Handoff and restart |
|
11 | Parallel worktrees |
|
12 | Wide migration |
|
13 | Screenshot matching | Paste the design, ask it to compare its result |
14 | Codebase onboarding | "Explain how [request] flows through this repo" |
15 | Log triage | Pipe a log into |
16 | CI check |
|
17 | Enforced guardrail | A PreToolUse hook with exit code 2 |
How to get the most usage out of a Claude code?
Send less context per turn. Scope each task, clear between tasks, delegate noisy searches to a subagent, use a cheaper model for simple work, and fix repeated permission denials. On a subscription this stretches your limits, and on an API key it lowers the bill.
I'd tackle them in this order:
Remove denied-command retries. Worth 29% of cost in my test.
Scope the search. The unscoped version cost 57% more.
Keep CLAUDE.md under 200 lines and move procedures into skills, which load only when used.
Disable MCP servers you aren't using.
Compact on purpose:
/compact keep the failing test and the API decisions.Mind the breaks. Prompt cache lasts about an hour on a subscription and five minutes on an API key, so returning after lunch means paying to reload.
Think twice about agent teams. Anthropic puts them at roughly 7x the tokens when teammates run in plan mode.
How to improve the use of the Claude code?
Change one thing at a time and keep a log. After every correction, ask whether it belongs in the prompt, CLAUDE.md, a skill or a hook. A one-off goes in the prompt, a convention in CLAUDE.md, a procedure in a skill, and a hard rule in a hook. That sorting habit improves every later session.
Between Claude Code, GitHub Copilot, and Cursor, which one is actually the best for a solo developer working on full-stack web apps?
Claude Code is my pick for a solo full-stack developer who wants to hand over whole tasks, such as a migration plus API route plus tests. Choose GitHub Copilot if you mainly want inline completions at the lowest price. Choose Cursor if you want the agent built into the editor you work in all day.
Claude Code | GitHub Copilot | Cursor | |
|---|---|---|---|
Free tier | No | Yes, 2,000 completions a month | Yes, limited |
Entry paid plan | $20/month | $10/month | $8/month |
Entry plan catch | Usage shared with Claude chat | Agent work draws on credits | Cursor's own models only |
Step-up plan | $100 | $39 | $30 |
Best at | Delegated, multi-file tasks | Completions and GitHub work | Editing with the agent in view |
The strongest case against my pick is price. Copilot Pro costs half as much with unlimited completions, and Cursor Plus costs less than half. If typing speed is your bottleneck, they win. A solo developer's bottleneck is usually finishing things nobody else will finish, and that favors delegation. I compared plans and features here. I didn't benchmark the three tools against each other.
Is Claude Code more suited for senior engineers automating repetitive tasks, or can junior developers use it effectively to learn faster?
Both can use it, in opposite ways. Seniors can delegate work they're able to judge. Juniors learn more by asking for explanations and writing the code themselves, because delegating everything can weaken the skill they're trying to build.
There's evidence for that caution. Anthropic ran a randomized trial with 52 mostly junior engineers learning a Python library, and the AI group averaged 50% on the quiz against 67% for those who coded by hand. The speed gain, about two minutes, wasn't statistically significant. The study used a chat sidebar instead of Claude Code, and the groups were small.
Participants who asked conceptual questions scored well. So if you're learning, try this:
Don't write code. I'll paste my attempt at [task]. Ask me one question that
would lead me to the bug. Give the answer only when I ask for it.
How to use Claude Code effectively: Reddit and Hacker News advice, checked
Power users agree on more than they argue about: keep the context small, hold Git close, and make Claude verify itself. The most useful community list I read is ykdojo's claude-code-tips, with over 45 entries. Reddit blocked my reader, so nothing here quotes a Reddit thread.
Community advice | Verdict |
|---|---|
Let it pull freely, keep push manual | Right, but a deny rule alone won't do it. See my test |
Write a HANDOFF.md, then start fresh | Right for long tasks |
Commit after every change | Right. Rewind doesn't cover shell-made files |
Skip permissions to go faster | No, except in a disposable container |
Review every snippet | Right for production. One commenter calls results "hit or miss sometimes" |
How to best use Claude AI overall comes down to matching the surface to the job. Use chat to think and Claude Code when the answer has to run.
FAQ: how to use Claude Code effectively
Does Claude Code work without an API key?
Yes. Sign in with a Pro, Max, Ultra, Team or Enterprise plan and Claude Code uses that subscription. A key is for pay-per-token billing through the Console. If a key is set in your environment, it takes priority over the subscription login.
How long should a CLAUDE.md file be?
Under 200 lines, per Anthropic. Mine had seven.
What is the difference between /clear and /compact?
/clear starts a new conversation with empty context, which suits a new task. /compact summarizes the current conversation and keeps going, which suits a long task. Add a focus to /compact so the summary keeps the details you need. You can return to a cleared conversation with /resume.
Is auto mode safe?
Auto mode is safer than skipping permissions, because a classifier reviews actions and blocks risky ones. It isn't a guarantee. Keep hooks for hard rules, work on a branch, protect main on your Git host, and use a container or WSL2 sandbox for code you don't trust.
Can Claude Code undo its changes?
Partly. /rewind restores files that Claude changed with its edit tools. It doesn't track files touched only by shell commands, and it generally doesn't restore subagent edits. Use Git commits as the dependable undo.
Try the test yourself
Five minutes is enough to check the claim that matters most. In a throwaway repo with a local bare remote, allow Bash(git *), deny Bash(git push *), and ask Claude Code to run git -C . push origin HEAD:main. Look at the remote. Then swap in the narrow rules and run it again.
If you change one thing about how you work today, change that allow rule.
Limits of these tests: 29 runs, one machine, one model (claude-sonnet-5-5), small synthetic Python repos, user settings and MCP servers excluded, three runs per prompt setup and one per guardrail row. Dollar figures are API-equivalent costs reported by Claude Code.
