tips
83 tips Claude
One command, setting or habit at a time about Claude: what it does, the line to copy and a caveat or two.
Settings and permissions 25
-
Sets how much of the context window fills up before Claude Code compacts automatically.
/autocompact 500k -
Deletes the transcripts, memory and history Claude Code holds for a project, after showing a plan.
claude purge ~/work/my-repo --dry-run -
Runs an MCP server's OAuth sign-in from the shell and prints the URL when no browser is available.
claude mcp login sentry -
Starts Claude Code with debug logging for only the categories you name, written to a file.
claude --debug='mcp,startup' -
Takes chosen tools away from Claude while a skill is active, until your next message.
--- -
Lets Claude fetch pages from chosen sites without a prompt and keeps asking for the rest.
"permissions": { -
Makes new Claude Code sessions open in plan mode instead of asking per edit.
"permissions": { -
Puts environment variables in settings.json so every Claude Code session and its commands get them.
"env": { -
Forces a confirmation prompt for chosen commands, even in modes that would allow them.
"ask": ["Bash(git push *)"] -
Tells Claude Code to always reply in a language you choose, in every session.
"language": "dutch" -
Hides the hints under the spinner and shows how user, project and local settings stack.
"spinnerTipsEnabled": false -
Starts Claude Code without hooks, skills, plugins, MCP servers or CLAUDE.md, to see whether your setup causes a problem.
claude --safe-mode -
Adds text from a file to the end of Claude Code's default system prompt for one session.
claude --append-system-prompt-file ./extra-rules.txt -
Overrides Claude Code settings for a single session with a JSON file or an inline JSON string.
claude --settings '{"model": "claude-opus-5-5"}' -
Starts Claude Code with only the MCP servers from the file you pass, skipping all others.
claude --strict-mcp-config --mcp-config ./only-this.json -
Limits Claude Code to the built-in tools you list, such as read-only ones.
claude --tools "Read,Grep" -
Changes or removes the attribution text Claude Code adds to commits and pull requests.
// .claude/settings.json -
Sets how many days Claude Code keeps transcripts and other session files before deleting them.
// ~/.claude/settings.json -
Overrides a shared Claude Code project setting for you only, without touching git.
"model": "opus" -
Keeps secrets out of a shared .mcp.json by expanding environment variables.
claude mcp add --transport http shared-server --scope project https://example.com/mcp -
Runs a shell command before a skill loads, so Claude gets fresh data in its prompt.
--- -
Makes a Claude Code rule load only when Claude works on files matching a pattern.
--- -
Pulls other files into Claude Code's CLAUDE.md instructions with one @path line.
See @README for the project overview and @package.json for npm scripts. -
Stops Claude Code from reading your .env file by adding a deny rule to settings.
"permissions": { -
Lets a scripted Claude Code run use only the git commands you list, without prompting.
claude -p "Look at my staged changes and create an appropriate commit" \
Slash commands 19
-
Prints a one-line summary of the current Claude Code session whenever you ask for it.
/recap -
Collapses a Claude Code turn to your prompt, a one-line tool summary and the final response.
/focus -
Lists what each of your skills costs in context and flags the ones nobody has invoked.
/skill-doctor -
Analyses your recent sessions on this machine and writes an HTML report with suggestions.
/insights -
Copies instruction files, MCP servers, commands, subagents and skills from another coding tool into Claude Code.
/import cursor --dry-run -
Lets Claude scan the repository and draft the project instructions file for you.
/init -
Switches the session's working directory and loads that project's settings, without starting over.
/cd ../api-server -
Shows which instruction files Claude Code loads and lets you edit them or switch auto memory off.
/memory -
Reviews the diff between your branch and the main branch for injection, auth and data leaks.
/security-review -
Opens a view of the uncommitted changes in your working tree, including Claude's edits.
/diff -
Switches Claude Code between built-in answer styles such as Concise, Explanatory and Learning.
/output-style concise -
Runs a checkup of a Claude Code install, settings and extensions, and proposes fixes.
/doctor -
Writes the current Claude Code conversation to a text file or your clipboard.
/export session-notes.txt -
Uses Opus while planning and switches to Sonnet when Claude Code starts the actual work.
/model opusplan -
Copies an earlier Claude Code answer, or a single code block from it, to the clipboard.
/copy 2 -
Shows how full the Claude Code context window is and what is taking the space.
/context -
Keeps Claude Code working turn after turn until a condition you describe is met.
/goal all tests in test/auth pass and the lint step is clean -
Asks Claude Code a quick question about your session without adding it to the conversation.
/btw what was the name of that config file again? -
Rolls the code and the conversation back to an earlier prompt in your Claude Code session.
/rewind
Sessions and shortcuts 17
-
Autocompletes file paths in your prompt so Claude looks at exactly the file you mean.
Why does @src/auth/session.ts refresh the token twice? -
Puts an image from the clipboard into your Claude Code prompt as a numbered chip.
Ctrl+V -
Continues from an old conversation under a new session ID, so the original stays untouched.
claude --resume auth-refactor --fork-session -
Opens the model picker in the middle of typing, and your draft stays where it is.
Option+P macOS -
Moves a long-running shell command out of the way so you and Claude can keep working.
Ctrl+B -
Opens the Claude Code sessions that are linked to a specific pull request.
claude --from-pr 123 -
Turns on Vim-style editing in the Claude Code prompt, with jj as an optional Escape.
"editorMode": "vim", -
Starts a Claude chat that skips your history and memory and isn't used for training.
New chat (outside a project) → ghost icon, upper right -
Reopens your most recent conversation in the current directory, so you carry on where you stopped.
claude -c -
Starts a Claude Code session as one of your own subagents, with its tools and model.
You are a code reviewer. Give specific, actionable feedback. -
Lets Claude Code plan first, and lets you edit that plan in your editor before it changes anything.
claude --permission-mode plan -
Shows the full detail of tool calls, hooks and models behind a Claude Code turn.
-
Queues what you type while Claude is busy, and lets you take it back with the Up arrow.
Ctrl+Enter send the queued messages now -
Starts Claude Code sessions with a name so you can resume the right one later.
claude -n auth-refactor -
Copies your gitignored local files, like .env, into every new Claude Code worktree.
.env -
Starts Claude Code in its own git worktree and branch so parallel sessions do not collide.
claude --worktree feature-auth -
Lets one Claude Code session read and edit files in a second project folder.
claude --add-dir ../api-server
Scripting 11
-
Shows which login Claude Code uses and, on recent versions, when a claude.ai sign-in expires.
claude auth status --text -
Lets a script continue one specific Claude Code conversation, even when others ran in between.
claude -p "Now write the three biggest issues as GitHub issue text" --resume "$session_id" -
Shows the answer of a headless Claude Code run live instead of waiting for the end.
claude -p "Explain what this repository does" \ -
Denies every action that would need approval and lets only your allowed tools run.
claude -p "Check the docs folder for broken internal links and list them" \ -
Runs a Claude Code print-mode query without saving the session to disk.
claude -p --no-session-persistence "Explain what this error means: connection refused" -
Prints your active Claude Code background sessions as a JSON array for scripts.
claude agents --json -
Claude Code is mostly a chat in your terminal, but it also has a non-interactive mode that fits in a shell pipeline, so you can use it in small scripts.…
git diff --staged | claude -p "Summarize this diff in one sentence" -
Stops a scripted Claude Code run after a set number of turns or amount of spend.
claude -p --max-turns 3 --max-budget-usd 2 "Fix the failing test in auth.py" --allowedTools "Read,Edit,Bash" -
Makes a scripted Claude Code run return validated JSON instead of free text.
claude -p "Extract the main function names from auth.py" \ -
Sends a log or diff from the shell straight into Claude Code and prints the answer.
cat build-error.txt | claude -p 'concisely explain the root cause of this build error' > output.txt -
Runs a scripted Claude Code call without loading hooks, plugins, MCP servers or CLAUDE.md.
claude --bare -p "Summarize README.md" --allowedTools "Read"
Prompting 7
-
Makes Claude pull the relevant passages out of a long text before it answers.
Find the passages in the contract that say anything about ending it early. -
Asks Claude to check its answer against criteria you name, which catches mistakes in code and math.
Before you finish, verify your answer against these cases: -
Keeps your documents and standing instructions ready in every chat of a Claude project.
Set project instructions -> "Answer in plain English. Ask a question -
Separates instructions from pasted content in a Claude prompt so the two are not confused.
Summarize the email below in two sentences and list any deadlines. -
Adds the reason behind an instruction to a Claude prompt so the answer fits your goal better.
Keep the answer under 100 words, because it goes in an SMS. -
Orders a Claude prompt with the long text first and your question at the end.
Which clauses change the notice period? Quote them first, then explain. -
Searches your earlier Claude Code prompts as you type so you can reuse them.
Hooks 4
-
Runs a command each time you send a prompt and gives its output to Claude as context.
"hooks": { -
Blocks Claude from ending its turn while the test suite fails, with a guard against loops.
echo '{"decision": "block", "reason": "The tests fail. Run npm test and fix them before you stop."}' -
Sends a desktop notification when Claude Code is waiting for your input or approval.
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'" -
Formats every file Claude Code edits by running Prettier from a hook.
"command": "f=$(jq -r '.tool_input.file_path') && npx prettier --write --ignore-unknown \"$f\""
Nothing in this filter yet.