The most useful Claude Code tips all come back to one idea from Anthropic's own best practices page: "Claude's context window fills up fast, and performance degrades as it fills." Keep context clean, give Claude a way to check its own work, and move repeated instructions into files Claude loads for you. The 20 tips below show how, each with the official doc it comes from.
Every command and shortcut here was checked against code.claude.com/docs on 24 October 2026. Claude Code ships often, so if something behaves differently, run claude update and check the linked page.
How should you set up a project before the first prompt?
1. Start CLAUDE.md with /init, then cut it down
Run /init in a new project and Claude Code drafts a CLAUDE.md from your project structure. Then edit it hard. The memory docs suggest you "target under 200 lines per CLAUDE.md file," because longer files use more context and reduce adherence. Our CLAUDE.md guide covers what belongs in it.
2. Test every CLAUDE.md line with one question
The best practices page gives a simple filter: "Would removing this cause Claude to make mistakes?" If not, cut the line. Keep commands Claude can't guess, style rules that differ from defaults, and project quirks. Drop anything Claude can learn by reading the code. Run /context afterward to confirm the file loaded.
3. Put task-specific instructions in skills, not CLAUDE.md
CLAUDE.md loads in every session, so a long release checklist in it costs tokens even when you are fixing a typo. A skill in .claude/skills/<name>/SKILL.md only loads its full body when it is used. Add disable-model-invocation: true for workflows with side effects you want to trigger yourself with /skill-name. See the skills docs and our Claude Code skills guide.
4. Use hooks for anything that must happen every time
CLAUDE.md instructions are advisory. Hooks are scripts Claude Code runs itself at fixed points, such as after every file edit, so they "guarantee the action happens." You can ask Claude to write one: "Write a hook that runs eslint after every file edit." Run /hooks to see what is configured. Details are in the hooks guide.
5. Prefer CLI tools, and switch off MCP servers you don't use
Anthropic's docs call CLI tools like gh, aws and gcloud "the most context-efficient way to interact with external services." MCP tool definitions are deferred by default, so only names and server instructions load until a tool is used, but each server still adds some context. Run /mcp to disable servers you aren't using. More in our Claude Code MCP guide.
How do you write prompts Claude Code handles well?
6. Give Claude a check it can run
The first tip on the official page is to give Claude a test, a build or a screenshot to compare against. Without one, "looks done" is the only signal, and you become the reviewer for every mistake. A prompt like "write the function, then run the tests and fix failures" lets Claude close the loop itself.
7. Plan first when the change is uncertain
Press Shift+Tab until the status bar shows plan mode, or start with claude --permission-mode plan. Claude reads and proposes a plan without editing files. Press Ctrl+G to open the plan in your editor and change it before Claude starts. The docs add a useful limit: "If you could describe the diff in one sentence, skip the plan." Our plan mode guide walks through it.
8. Point at files with @ and paste images directly
Type @ to autocomplete a file path, and Claude reads the file before it answers. Paste a screenshot with Ctrl+V (or Cmd+V in iTerm2) to insert an image you can refer to in the prompt. Both are listed in the interactive mode reference.
9. Run a quick shell command with !
Start a prompt with ! to run a command directly. Its output goes into the session and Claude responds to it, which is handy for ! git status or a failing test run you want Claude to look at.
10. Ask for deeper reasoning only when you need it
Add ultrathink anywhere in a prompt to ask for deeper reasoning on that one turn, without changing your session's effort level. Use /effort to change the level for the whole session. The model configuration docs note that phrases like "think hard" are passed through as ordinary text, not keywords. Our ultrathink guide explains the levels.
How do you keep the context window under control?
11. Run /clear between unrelated tasks
/clear starts a new conversation with empty context. Old conversation about a different task crowds out what Claude needs next and costs tokens on every message. Run /rename first if you might want to come back, then /resume to find it.
12. Clear after two failed corrections
If you have corrected Claude more than twice on the same issue, the docs say the context "is cluttered with failed approaches." Run /clear and write a better first prompt that includes what you learned. A clean session with a sharper prompt usually beats a long one full of corrections.
13. Compact with a focus before a long new phase
/compact replaces the conversation with a summary. Add instructions to choose what survives, such as /compact focus on the API changes. You can also add a "Compact instructions" section to CLAUDE.md so automatic compaction keeps what matters, like the list of modified files.
14. Check usage with /context and a status line
/context shows a colored grid of what is using space, with suggestions for heavy tools and memory files. To watch usage all the time, set up a status line that shows context_window.used_percentage; the statusline guide has a working example. Our context window guide explains the numbers.
15. Ask side questions with /btw
/btw what was the name of that config file again? gets an answer without adding to the conversation history. It works even while Claude is still busy on the main task.
16. Send research to a subagent
Subagents run in their own context window and return a summary, so dozens of file reads stay out of yours. Say "use subagents to investigate how our auth system handles token refresh." The subagents docs list the built-in Explore, Plan and general-purpose agents, and our subagents guide shows how to define your own.
How do you recover when Claude goes off track?
17. Stop with Esc, rewind with Esc Esc
Esc stops Claude mid-action and keeps the work so far, so you can redirect. On an empty prompt, pressing Esc twice opens the rewind menu, the same as /rewind, where you can restore the conversation, the code, or both to an earlier checkpoint. One caveat from the checkpointing docs: a file that only Bash commands changed is not tracked, so checkpoints don't replace git.
18. Get a second opinion from a fresh context
A reviewer that didn't write the code isn't biased toward it. Run the bundled /code-review skill to review the current diff in a fresh subagent, or open a second session and ask it to review the files the first one changed. Tell the reviewer to flag only gaps that affect correctness, so you don't chase style nits.
How do you automate Claude Code?
19. Use claude -p for scripts and CI
claude -p "your prompt" runs once and exits. Add --output-format json for a single JSON object with a result field, or pipe data in:
cat error.log | claude -p "explain this error"
claude -p "List all API endpoints" --output-format json
The headless docs cover the remaining flags.
20. Fan out big migrations with a loop
For hundreds of files, have Claude write the task list to a file, then loop over it with claude -p, pre-approving only the tools the job needs:
for file in $(cat files.txt); do
claude -p "Migrate $file from Python 2 to Python 3. Return OK or FAIL." \
--allowedTools "Edit,Bash(git commit *)" \
--permission-mode dontAsk
done
dontAsk denies anything else that would need approval, which matters when nobody is watching. Test on two or three files first. For a built-in option, /batch <instruction> splits a change across 5 to 30 subagents, each in its own worktree.
Which shortcuts are worth memorizing?
A short list covers most sessions. All of these come from the interactive mode reference:
| Shortcut | What it does |
|---|---|
Esc |
Stop Claude, keep the work so far |
Esc Esc |
Clear the draft, or open rewind on an empty prompt |
Shift+Tab |
Cycle permission modes, including plan mode |
Ctrl+G |
Open the prompt or plan in your editor |
Ctrl+R |
Search prompt history |
Ctrl+S |
Stash the current prompt, press again to restore |
Ctrl+O |
Open the transcript viewer |
Ctrl+B |
Send running commands and agents to the background |
Option+P / Alt+P |
Switch model without losing your prompt (on macOS, needs Option set as Meta in your terminal) |
? |
Show the shortcut panel (on an empty prompt) |
For a fuller list of commands and flags, see our Claude Code cheat sheet, and for the bigger workflow picture, the best practices guide.
Where should you keep the prompts that work?
After a few weeks you will have prompts you paste again and again: a review brief, a planning template, a migration prompt. Kipt keeps prompts and skills like these as Markdown in a private GitHub repo you own, with {{name}} blanks you fill in and Cmd+K search, and installs every skill into Claude Code with one npx skills add command. To turn one prompt into a skill folder, try the SKILL.md generator.