24 numbered tips
Claude Code tips and tricks: 24 habits that pay off
Updated November 17, 20268 min read
These Claude Code tips are the small habits that make the biggest difference: a short CLAUDE.md, clear prompts, a check Claude can run, and a few keyboard shortcuts. Most of them come straight from Anthropic's own Claude Code best practices page. There are 24 of them, in four groups: setting up a project, prompting, spending less of your usage, and staying safe. Every command and shortcut here was checked against Anthropic's own documentation as of November 2026.
Setup tips for a project Claude understands
A little setup saves you from explaining the same things in every session. Most of it lives in one file, CLAUDE.md (a notes file Claude reads at the start of every session).
1. Run /init, then delete most of what it writes
/init writes a starter CLAUDE.md by reading your project. Then cut it down: Anthropic suggests staying under 200 lines, because every line takes a little of Claude's attention on every task. Keep only what Claude cannot work out by reading the code, like how deploys work or a folder that looks unused but is not. Put personal preferences in CLAUDE.local.md and add that file to .gitignore.
2. Put your test command in CLAUDE.md
Anthropic calls the command that runs your tests the single most useful line in CLAUDE.md. With it, Claude can check its own work instead of guessing. Add the typecheck and lint commands too, plus how to run one test file.
# Commands
- Install: pnpm install
- Run one test file: pnpm vitest run path/to/file.test.ts
- Typecheck: pnpm tsc --noEmit3. Give folder-specific rules their own file
A rule that only matters in one part of the code does not need to load for every task. Put it in .claude/rules/ with a paths: filter, and Claude only reads it while working on matching files.
---
paths:
- "src/api/**/*.ts"
---
Validate request bodies with the zod schemas in src/api/schemas/.4. Move long procedures into skills
A release checklist or an incident runbook is too long for CLAUDE.md. Save it as a skill at .claude/skills/<name>/SKILL.md. Claude only reads the full skill when a task needs it. For anything with side effects, add disable-model-invocation: true so it only runs when you type the command yourself.
5. Prefer a command-line tool over an MCP server
If a service has a command-line tool, like gh for GitHub, Claude can usually just use it. MCP servers (plug-ins that connect Claude to outside services) add their tool list to every session even when idle. Turn off the ones you are not using in /mcp. The Claude Code MCP guide covers setup.
6. Learn the keyboard shortcuts that matter
You do not need all of them. These are the Claude Code shortcuts worth knowing by heart, as listed in Anthropic's interactive mode docs:
| Shortcut | What it does |
|---|---|
Esc | Stops Claude mid-step and keeps the work done so far |
Esc Esc on an empty prompt | Opens the rewind menu to roll back code, chat, or both |
Shift+Tab | Cycles permission modes: Manual, accept edits, plan, then bypass and auto where available |
Ctrl+C | Interrupts. On an empty prompt, a second press exits |
Ctrl+R | Searches your earlier prompts |
Ctrl+G | Opens your prompt in your normal text editor |
Ctrl+V (or Alt+V on Windows) | Pastes an image, like a screenshot of an error |
Ctrl+B | Sends a running command or agent to the background |
Ctrl+S | Parks a half-written prompt and brings it back later |
Ctrl+T | Shows or hides Claude's to-do checklist |
Ctrl+O | Opens the detailed transcript of every tool Claude used |
Alt+P (Option+P on Mac) | Switches model without losing your prompt |
\ then Enter, or Ctrl+J | New line without sending |
! at the start | Shell mode: runs a command and shows Claude the output |
? on an empty prompt | Shows the shortcut help panel |
Prompting tips that save you a second attempt
The biggest Claude Code productivity gain usually comes before Claude writes a line: a prompt that includes what only you know. These tips close that gap before work starts.
7. Name the file, the symptom and what fixed looks like
Claude reads code quickly, but it cannot read your mind. Compare "fix the login bug" with "users report login fails after the session times out. look at token refresh in src/auth/, write a failing test that reproduces it, then fix it". The second one usually works first time.
8. Hand things over instead of describing them
Type @ and a path to include a file. Paste a screenshot of the design or the error. Typing @ opens a list of matching paths, and pointing at a folder shows its file list rather than every file inside. Pipe command output straight in from your terminal:
cat error.log | claude -p "what's going on here"9. Say "be ambitious" when you want the full version
By default Claude builds the smallest thing that meets your request, because it cannot tell how much you hoped for. Anthropic notes that "be ambitious" still helps. Add the extras you want, such as empty states, error states and keyboard support.
10. Ask Claude to interview you first
When you are not sure what you want yet, let Claude ask the questions. Then build from the written spec in a fresh session, so the build starts clean.
I want to add rate limiting to the public API but haven't thought it through.
Interview me until you could write the spec, then write it to SPEC.md.11. Plan big changes before any file is touched
Press Shift+Tab until the status bar shows plan mode, or start with claude --permission-mode plan. Claude reads and proposes, but edits nothing until you approve, and you can open the plan in your text editor to change it first. The plan mode guide walks through it.
12. Give Claude a check to run, and ask for proof
Claude stops when the work looks done. A test, a build or a linter lets it find its own mistakes first. Say "run the auth tests after, and keep going until they pass", or set a goal with /goal all tests in tests/auth pass and lint is clean. Then ask for the command it ran and its output. A bare "all tests pass" tells you very little.
13. Press Esc early, and clear after two misses
Watch the first minute. The moment Claude heads the wrong way, press Esc and redirect. If you have corrected the same thing twice and it is still wrong, run /clear and write one better prompt that includes what you learned. A third correction mostly adds noise.
Tips for spending less of your Claude Code usage
As of November 2026, Claude Code comes with Pro ($20 a month), Max ($100 a month) and Ultra ($200 a month), and each plan has usage limits. The full breakdown is in Claude Code pricing. These habits stretch whichever plan you have.
14. Look at /usage before changing anything
On Pro, Max, Ultra, Team and Enterprise, /usage breaks your usage down by skill, subagent, plugin and MCP server. It also flags patterns, like very long chats, once one passes 10% of your usage. Fix the biggest item first.
15. Clear between unrelated tasks
Every request sends the whole conversation again. A chat that has collected three old tasks keeps paying for them on the fourth. /clear costs nothing, and /clear oauth-migration names the old chat so you can find it again in /resume. To pick up the most recent chat in a folder later, run claude --continue.
16. Compact with a focus, and not too often
/compact keep the API changes and the test commands shrinks the chat while keeping what you name. On a long chat, compacting is itself a big request, because Claude reads everything to summarize it. When you do not need the history, a fresh chat is cheaper.
17. Match effort to the task
Current models default to medium effort. Use /effort high or /effort xhigh for tricky bugs, /effort low for quick back-and-forth, and save max for hard problems Claude works through alone. For one tough question, put ultrathink in that prompt instead of changing the setting. Phrases like "think harder" are just normal words now.
18. Use smaller models for routine work
Switch with /model or Alt+P. Sonnet costs less for everyday edits, and Haiku suits simple subagents such as file finders and link checkers. See Claude Code subagents for setting a model per agent.
19. Watch what runs while you are away
A /loop, a /goal that gets checked after each turn, and background subagents all keep sending requests when you are not typing. Press Ctrl+X then Ctrl+K twice within 3 seconds to stop every background subagent in the session.
Staying safe while Claude Code edits your files
As of November 2026, new terminal sessions start in auto mode, where a separate checking model looks at each action before it runs and stops the risky ones. That model makes judgment calls, so these tips add the layers that you control and that always apply.
20. Commit before anything big
/rewind, or Esc twice, can roll back files Claude changed with its own edit tools. A file that only a shell command changed is not tracked, so a git commit is still your real safety net. Commit before a big refactor and you can always get back. /rewind also answers to /checkpoint and /undo if those are easier to remember.
21. Put "never" rules in deny rules, not capital letters
A line in CLAUDE.md is followed almost every time. A permission deny rule is followed every time, in every mode. If a file must never be read, block it in .claude/settings.json:
{
"permissions": {
"deny": ["Read(./.env)", "Read(./.env.local)", "Read(./secrets/**)"]
}
}22. Make must-pass checks a Stop hook
A Stop hook runs your script whenever Claude tries to finish, and sends it back to work if the script fails. This one keeps Claude going until the typecheck passes. More examples in Claude Code hooks.
{
"hooks": {
"Stop": [
{ "hooks": [
{ "type": "command", "command": "pnpm tsc --noEmit 1>&2 || exit 2" }
] }
]
}
}23. Turn on the sandbox for an outer fence
/sandbox limits what Claude's shell commands can reach on your files and network, on macOS, Linux and WSL2. It also respects your Read deny rules. By default Claude can still ask to retry a blocked command outside the sandbox. Strict mode, in the Overrides tab of /sandbox, turns that retry off. For anything security-related, use deny rules and the sandbox together.
24. Give parallel work its own folder
Two sessions in one folder will overwrite each other. Start each one with claude -w name so it gets its own worktree, and list your .env files in .worktreeinclude. The worktrees guide explains the details. A second session is also the cheapest reviewer you can get: one writes the code, the other reviews it without having watched it being written. If you would rather not touch git, VibeCodingDeck gives each agent a safe copy of the project and lets you take a save point before anything risky.
Sources
Run up to 12 AI coding agents in one window.
Claude Code, Codex, Gemini, Grok and more, side by side. Windows and Mac. From $29 a month.
Get startedKeep reading
Beginner lesson plan
How to use Claude Code: a six-lesson course for beginners
Before and after
Claude Code plan mode: one task, with and without a plan
Hooks cookbook
Claude Code hooks cookbook: 8 recipes to paste into settings.json
Cost calculator
Claude Code pricing: plans, API rates and which one fits you
Habits and rules
Vibe coding best practices: the 10 mistakes that sink AI-built apps
Agent manager
Claude Code dashboard: the six things you need to see at a glance