Claude Code: Guide & Tips
This guide provides a broad overview on how to get the most from Claude Code.
If you're already using Claude Code and want to go beyond the basics, this guide covers model selection, the CLAUDE.md context file, "plan mode", undoing / rewinding, settings and permissions, plugins and marketplaces, Claude Skills, Agents, MCP Servers, and custom status lines.
Quick Reference Cheatsheet
Prefixes
!- Bash mode prefix@- Mention files/folders
Keyboard Shortcuts
- Esc+Esc - Open rewind menu (undo changes)
- Shift+Tab - Auto accept edits mode
- Shift+Tab+Tab - Plan mode
Slash Commands
/init- Creates a CLAUDE.md file/login- Switch Claude accounts/model [model]- Sets model (optionally taking a model name)/usage- Spent and remaining usage/rewind- Open rewind menu (undo changes)/clear- Clears all context window/compact [instructions]- Compacts/summarises context (with optional compacting instructions)/config- Views current configuration settings/permissions- Views current allowed commands/review- Request code review/status- Shows status, including MCP connections/memory- Allows editing Claude's memory/plugin- Lists available and installed plugins/mcp- Lists connected and unconnected MCP servers/agents- Lists user and built-in agents, option to create new agent/doctor- Shows diagnostics and current Claude Code version/help- Shows help menu
Contents
- Quick Reference Cheatsheet
- Installation
- Starting Claude Code
- Using Claude Code
- Models
- CLAUDE.md - Providing Claude Code with Context
- Prompting, Planning, and Execution
- Checkpoints: Undoing Code and Context
- Git and Version Control
- Usage and Context Control
- Settings and Permissions
- Claude Plugins and Plugin Marketplaces
- Claude Commands
- Claude Skills
- Claude Subagents
- Claude MCP Servers
- Custom Statuslines
Installation
To install Claude Code, refer to the official instructions at code.claude.com/docs/en/setup.
Starting Claude Code
Claude Code runs from the directory (folder) you open it in. This will likely be the directory of the application you are developing.
To start Claude Code in your terminal, run:
claude
Logging In
When first running Claude Code, you should be prompted to log in. This will open up a web browser. You will need to be on a paid plan, either "Pro", "Max", or "Team".
If you are not prompted to log in, you can type the following "slash" command:
/login
Using Claude Code
Prompts (instructions) for Claude Code are typed in the input bar. You can also paste into the terminal (Ctrl+Shift+v on Linux for example). You can paste in text and screenshot images. You can also drag and drop files and images into the terminal.
For example, if you are developing a website and have a visual bug, you can screenshot the website element and paste it (or drag and drop the screenshot file) into Claude Code and ask Claude to fix it.
Essential Commands and Shortcuts
"Slash" Commands
When typing a forward slash /, Claude Code will show available commands. This guide will go into some of these shortly, including how to add custom commands.
Shift+Tab
Using the Shift+Tab shortcut will switch Claude Code between accept edits mode, plan mode, and back to default mode.
Auto-Accept Edits
By default, Claude Code will ask each time to add or edit files.
Using Shift+Tab and having accept edits on will allow Claude Code to add and edit files without asking each time.
Plan Mode
Using Shift+Tab and having plan mode on will tell Claude to enter "plan mode". This is where Claude will assess your requirements, ask any clarifying questions if necessary, and output the plan before adding and modifying files.
This is a really useful feature, and should be used before getting Claude to implement features. This guide will go into more detail about this below.
Bash Mode
You can switch into "Bash mode" to run terminal commands yourself without having to exit Claude Code or have another terminal window open.
To do this, simply type:
!
For example, if you want to list the directory contents:
! ls
Models
Claude Code has access to the three main Claude LLM models:
- Opus - the biggest, most intelligent, slowest, and most costly model
- Sonnet - the mid-tier model, quicker and more cost-effective than Opus
- Haiku - the smallest model, very fast and very cost-effective
You can switch between models in Claude Code by running the slash command:
/model
Which Models to Use
Opus
Opus is the most intelligent, but will use up your limits rather quickly.
Opus is great for planning features, and implementing more challenging features.
Sonnet
Sonnet is faster than Opus and will not use up your limits as quickly.
Sonnet is great for most use-cases. You will likely find that Sonnet is great as the default implementation model - the model writing the code.
Haiku
Haiku is the fastest model, and will not use up limits as quickly as either Opus or Sonnet.
Haiku can be good for implementing standard features. For example, creating a website in React JS, or a data analysis project in Python.
Hybrid: Recommended Setup
Using Opus in Plan Mode, then executing the plan using Sonnet is a great default. Fortunately, there is a slightly hidden feature to have this occur automatically:
/model opusplan
This will automatically have Claude Code use Opus in Plan Mode, then implement the plan using Sonnet.
CLAUDE.md - Providing Claude Code with Context
An absolutely essential way to get the most out of Claude Code is to have a CLAUDE.md file.
The CLAUDE.md file is where you outline common development commands, explain the project layout and architecture, and describe essential development practices.
Creating a CLAUDE.md File
You can have Claude Code create a CLAUDE.md file automatically using a slash command:
/init
If the project directory is empty this won't contain much at all, if anything. If you already have existing files, Claude will explore your project files and create the CLAUDE.md file contents.
CLAUDE.md Example
Here is an example CLAUDE.md file for this website:
# CLAUDE.md## Development Commands### Local Development- `bun run dev` - Start development server at http://localhost:5173- `bun run build` - Build for production- `bun run test` - Run Vitest tests- `bun run format` - Format code with Biome (includes linting and fixing)### Deployment- `bun run deploy` - Build and deploy to production (Cloudflare Workers)## Project ArchitectureThis is a personal website built with React Router v7, deployed on Cloudflare Workers.The architecture follows modern React patterns with server-side rendering support.### Key Architecture Components**Framework**: React Router v7 with SSR enabled**Styling**: Tailwind CSS v4 with custom animations**Content Structure**:- Each route is a self-contained TSX file with meta() exports for SEO- Structured data (JSON-LD) implemented for rich snippets**Components**:- `NavBar` - Main navigation with hamburger menu- `Footer` - Site footer with links- `SocialLinks` - Social media icon links### Key Development Patterns**SEO**: Comprehensive meta tags, Open Graph, Twitter Cards, and JSON-LD structured data**Accessibility**: Skip links, semantic HTML, proper heading hierarchy, and keyboard navigation support
Prompting, Planning, and Execution
The key to having Claude Code perform well is in effective prompting and planning.
Prompting
When providing instructions to Claude Code, clarity and context are key.
Imagine you are a Product Owner, instruct Claude as you would a Software Developer. Be clear about the requirements. Use natural language.
If your prompt will be quite long, you can write your prompt to a file then import that file into Claude Code.
For example, if you write a long prompt to a file called prompt.md, you can use this file in Claude Code as your prompt by prefixing the file location with the @ character:
@prompt.md
Planning
As previously outlined, Claude Code has a "Plan Mode". You can enter Plan Mode by Shift+Tab where you will see plan mode on under the input bar.
Claude Code can also enter Plan Mode automatically through instructions.
For example, you want to add a new search feature to a website built in React. You could instruct Claude Code as follows:
Plan the implementation of a new search feature. There should be a search icon in the website header which expands to take a search term input. The search functionality should search through the articles, guides, and blog posts on the website.
If you have the /model opusplan model configuration enabled, Claude Code will switch to use the Opus model, and output:
● Entered plan mode
Claude Code may ask clarifying questions, and will present a plan for the implementation.
If you are happy with the plan, you can instruct Claude to proceed with the implementation using the plan. If the plan requires amending, you can provide Claude with further instructions until you are happy with the plan.
Execution
When Claude Code starts executing the plan, it may ask whether you want to allow certain commands to be allowed to run automatically each time, or have Claude Code ask you each time.
Claude will proceed to write the code, and will ask for any further commands it wants to run. This guide will later outline how common commands can be configured to be allowed to run automatically, ask every time, or not be allowed to run at all.
Parallel Agents for Brainstorming Solutions
Sometimes you may want to have Claude brainstorm potential implementation strategies or general ideas.
You can have Claude Code run multiple instances in parallel to achieve this more efficiently. To have Claude Code do this, just specify it in your prompt. For example:
Use parallel subagents to brainstorm 3 potential ways to implement a contact form that send an email to my email address when someone uses the form. The solution should be able to be run on Cloudflare workers.
Checkpoints: Undoing Code and Context
Sometimes Claude can go down a path that is just not what you intended or expected.
Fortunately you do not need to start a new session, or instruct Claude to undo what it has started.
Checkpoints allow you to revert either the context, the code, or both, to a previous prompt stage.
/checkpoints
The checkpoints are not a replacement for version control via Git.
Git and Version Control
Committing and Branching
When a new feature or bug fix is implemented and you are reasonably happy with it, you can ask Claude to commit the changes to Git (or create a new Git branch then commit the changes).
History and Explanations
Claude Code can access Git history. This can be useful for understanding why a feature or fix had previously been implemented.
You can ask Claude something like:
Look at the Git history for the `Header.tsx` file and explain who implemented the search functionality and what changes were made at the time
Usage and Context Control
Usage and Limits
Claude Code can use a lot of "tokens", which heavily count towards the overall Claude limits.
You can view your remaining usage with the following slash command:
/usage
Context Control
The "context" (very basically) is the amount of "tokens" Claude Code is holding in your current session.
Viewing Context Use
You can view the current context use with the following slash command:
/context
Clearing Context
For long-running sessions the context can fill up quite quickly. Claude Code will manage this itself largely. However, when beginning a new feature you can force a context reset with the slash command:
/clear
Compacting Context
You can "compact" your message history context to free up context. This will basically summarise where you are currently at. This can be done with the slash command:
/compact
Settings and Permissions
Having Claude Code ask for permissions to run commands each time is not ideal. Fortunately, you can specify command permissions, along with other settings, in a ./claude/settings.local.json file. This will be generated automatically by Claude, and can be edited and added to.
The .claude/settings.local.json should not be committed to a Git repository, for shared settings that can be committed to a Git repository use the file .claude/settings.json.
You can also have a "default" settings.json file which will be used by all Claude Code projects. On Linux and Mac this is located in your home directory, under ~/.claude/settings.json.
Here is an example ~/.claude/settings.json file covering common Bash commands and development tools, with some being explicitly allowed to run, some requiring asking each time, and some denied altogether.
{"permissions": {"allow": ["Bash(cat:*)","Bash(pwd:*)","Bash(head:*)","Bash(tail:*)","Bash(ls:*)","Bash(touch:*)","Bash(grep:*)","Bash(awk:*)","Bash(sed:*)","Bash(find:*)","Bash(type:*)","Bash(which:*)","Bash(locate:*)","Bash(date:*)","Bash(man:*)","Bash(uname:*)","Bash(du:*)","Bash(make:*)","Bash(mkdir:*)","Bash(cd:*)","Bash(npm run test:*)","Bash(npm run build:*)","Bash(npm run dev:*)","Bash(npm run start:*)","Bash(npm run lint:*)","Bash(npm install:*)"],"ask": ["Bash(rm:*)","Bash(curl:*)","Bash(wget:*)","Bash(chmod:*)","Bash(chown:*)","Bash(git:*)","Bash(docker:*)"],"deny": ["Bash(ssh:*)","Read(./.env)","Read(./.env.*)","Read(./.j2.*)"],"env": {"CLAUDE_CODE_ENABLE_TELEMETRY": "0","ANTHROPIC_MODEL": "opusplan"}}}
The example above also sets the default model for new sessions, the opusplan model described earlier, as well as disabling telemetry.
More information can be found in the Claude Code documentation: code.claude.com/docs/en/settings.
Claude Plugins and Plugin Marketplaces
Plugins and the plugin marketplaces are a way to install Claude Skills and MCP servers from external sources.
Plugins which are available by default and where the marketplace for external plugins have been added can be viewed using the slash command:
/plugin
When installing from external sources, use caution - anyone can create a plugin and host it on GitHub, ensure you trust the source.
The official Claude plugins marketplace has "code intelligence" plugins available (code.claude.com/docs/en/discover-plugins#code-intelligence). These allow Claude Code to find code references and see type errors.
For example, to install the TypeScript code intelligence:
/plugin install typescript-lsp@claude-plugins-official
Note: the TypeScript code intelligence needs the TypeScript language server to be installed, this can be done in your terminal outside of Claude Code, or by using the Bash mode prefix ! in the Claude Code input:
npm install -g typescript-language-server typescript
More information can be found at code.claude.com/docs/en/discover-plugins.
Claude Skills
Claude Skills are a way of loading specialised knowledge into Claude Code. The main benefit is that unlike the CLAUDE.md file, full Skills file contents are not loaded into the context until used.
Skills can be run either by asking Claude to use the Skill, or with a custom slash command. More information can be found at code.claude.com/docs/en/skills.
Example Custom Skill: React Component Optimiser
Here is how you could create your own Skill. This will be a Skill to help optimise React components.
First create the directory for the Skill in your home directory so it can be used across projects:
mkdir -p ~/.claude/skills/react-optimiser
Then create a SKILL.md file inside the new directory (~/.claude/skills/react-optimiser/SKILL.md).
In this file there will need to be a name and a description in the top block. Then the instructions afterwards. It must follow this format to work.
---name: react-optimiserdescription: Analyses React components for performance issues and implements optimisations. Use when reviewing component performance, addressing re-render issues, or when asked to optimise React code.---When optimising React components:1. **Analyse first**: Examine the component for:- Unnecessary re-renders (missing React.memo, useCallback, useMemo)- Expensive computations in render- Large inline objects/arrays in JSX- Props drilling and context overuse- Improper dependency arrays in hooks- Key prop issues in lists2. **Create optimisation plan**: List specific issues found with:- Current problem and performance impact- Proposed solution- **Potential side-effects** (e.g., stale closures, reference equality assumptions)- Priority (critical/moderate/minor)3. **Wait for approval**: Present the plan and ask which optimisations to implement.4. **Implement carefully**: When requested:- Apply changes incrementally- Preserve existing functionality- Highlight any behavioural changesFocus on React and TypeScript performance patterns only. Avoid project-wide configuration changes.
Save the file, then restart (or start) Claude Code. You can then use the Skill by either asking Claude:
Use the React Optimiser skill to analyse the `Header.tsx` component
Or by using the slash command:
/react-optimiser ./components/Header.tsx
Claude Subagents
Custom subagents can be created to handle specific tasks.
For example, you might create a "Code Reviewer" subagent to review existing code, or a "Security Reviewer" subagent to specifically work on identifying potential security issues in your application.
More information can be found at code.claude.com/docs/en/sub-agents.
To create a subagent, the simplest way to get started is to have Claude Code create one for you based on your instructions.
First use the slash command:
/agents
Then select Create new agent and choose Personal to save the subagent in your home directory (~/.claude/agents/) so it can be used in multiple projects. If you have a project-specific requirement, select Project.
Select Generate with Claude and describe your requirement when asked. For example, for a Security Reviewer subagent:
A security reviewer agent that explores the code to highlight any potential security risks, vulnerabilities, or oversights. It should explain the risk or vulnerability and provide solutions or mitigations.
You will then be asked to select the tool required. For the Security Reviewer we likely only need Read-only tools, so deselect everything else using the Enter key.
You will then be asked to select a model. Unless your application is very specialised or unusual, Sonnet will be a good choice.
You will then be asked to select a colour. This will highlight when this agent is running in the terminal.
You can then run the subagent by asking Claude to use it:
Use the security-reviewer agent to explore the codebase and highlight any potential vulnerabilities
Claude MCP Servers
Model Context Protocol (MCP) is a standardised way of allowing Claude (and others) to interact with external services. These could be email providers (eg. Gmail), project management tools (eg. Asana), communication applications (eg. Slack), and design applications (eg. Canva).
More information can be found at code.claude.com/docs/en/mcp.
Below are two examples of two popular MCP tools available from the official Claude plugins: Playwright and Context7.
Playwright MCP
Playwright MCP allows Claude Code to see a website or web application.
To install the Playwright MCP:
/plugin install playwright@claude-plugins-official
Restart Claude Code. Then you can use Playwright by asking Claude something like:
Use Playwright to inspect my homepage and suggest layout changes to reduce bounce rates
Claude will use a web browser to view the page.
Context7
Context7 is a really useful MCP. It allows Claude to look up up-to-date documentation and examples, rather than relying just on the training data (which quickly becomes outdated in the world of software development).
To install the Context7 MCP:
/plugin install context7@claude-plugins-official
Custom Statuslines
A custom statusline, an area below the main input box in Claude Code, can be added.
This can be configured to display variables such as the current Git branch, current working directory, context window usage, and the current model Claude Code is using.
Example Custom Statusline
Here is how to add a custom statusline that looks like the following:

First, create a file in the Claude Code user settings directory: ~/.claude/statusline.sh with the following contents:
#!/bin/bash# Read JSON input from stdininput=$(cat)# Extract values using jqsession_id=$(echo "$input" | jq -r '.session_id // "unknown"')cwd=$(echo "$input" | jq -r '.workspace.current_dir // empty')model_name=$(echo "$input" | jq -r '.model.display_name // "unknown"')context_remaining=$(echo "$input" | jq -r '.context_window.remaining_percentage // empty')# Truncate session ID to first 8 characters for brevitysession_short="${session_id:0:8}"# Get directory basename for displayif [ -n "$cwd" ]; thendir_name="${cwd##*/}"[ -z "$dir_name" ] && dir_name="/"elsedir_name="~"fi# Change to working directory for git operationscd "$cwd" 2>/dev/null || cd "$HOME"# Get git branch (if in a git repository)git_branch=""git_status_icon=""if git rev-parse --git-dir > /dev/null 2>&1; thenbranch=$(git branch --show-current 2>/dev/null)if [ -n "$branch" ]; thengit_branch="$branch"else# Detached HEAD - show short commit hashgit_branch=$(git rev-parse --short HEAD 2>/dev/null)fi# Check for uncommitted changesif [ -n "$(git status --porcelain 2>/dev/null)" ]; thengit_status_icon=" ●" # Indicates dirty working treefifi# Build progress bar for context remainingbuild_progress_bar() {local percentage=$1local width=10local filled=$((percentage * width / 100))local empty=$((width - filled))local bar=""# Determine colour based on percentageif [ "$percentage" -gt 50 ]; thenbar+="\\e[1;32m" # Bright greenelif [ "$percentage" -gt 25 ]; thenbar+="\\e[1;33m" # Bright yellowelsebar+="\\e[1;31m" # Bright redfi# Build the barfor ((i=0; i<filled; i++)); do bar+="█"; donebar+="\\e[0;90m"for ((i=0; i<empty; i++)); do bar+="░"; donebar+="\\e[0m"echo -e "$bar"}# Format context remaining with colour and progress barcontext_display=""if [ -n "$context_remaining" ] && [ "$context_remaining" != "null" ]; then# Round to integerctx_int=$(printf "%.0f" "$context_remaining")progress_bar=$(build_progress_bar "$ctx_int")# Colour for percentage textif [ "$ctx_int" -gt 50 ]; thenctx_colour="\\e[1;32m" # Bright greenelif [ "$ctx_int" -gt 25 ]; thenctx_colour="\\e[1;33m" # Bright yellowelsectx_colour="\\e[1;31m" # Bright redficontext_display="${progress_bar} ${ctx_colour}${ctx_int}%\\e[0m"fiC_RESET="\\e[0m"C_DIM="\\e[0;90m"C_WHITE="\\e[0;37m"C_BLUE="\\e[1;34m"C_MAGENTA="\\e[1;35m"C_CYAN="\\e[1;36m"C_ORANGE="\\e[38;5;208m"C_PURPLE="\\e[38;5;141m"C_PINK="\\e[38;5;213m"C_GREEN="\\e[1;32m"C_YELLOW="\\e[1;33m"ICON_SESSION="💻"ICON_FOLDER="📁"ICON_GIT="🌳"ICON_MODEL="🧠"ICON_CONTEXT="🪟"ICON_DIRTY="●"output=""# Session ID (abbreviated) with iconoutput+="${C_DIM}${ICON_SESSION} ${C_PURPLE}${session_short}${C_RESET}"# Separatoroutput+=" ${C_DIM}│${C_RESET} "# Current directory with iconoutput+="${C_ORANGE}${ICON_FOLDER} ${C_BLUE}${dir_name}${C_RESET}"# Git branch (if available) with iconif [ -n "$git_branch" ]; thenoutput+=" ${C_DIM}(${C_PINK}${ICON_GIT} ${git_branch}${C_YELLOW}${git_status_icon}${C_DIM})${C_RESET}"fi# Separatoroutput+=" ${C_DIM}│${C_RESET} "# Model name with iconoutput+="${C_CYAN}${ICON_MODEL} ${model_name}${C_RESET}"# Context remaining (if available) with icon and progress barif [ -n "$context_display" ]; thenoutput+=" ${C_DIM}│${C_RESET} "output+="${C_DIM}${ICON_CONTEXT}${C_RESET} ${context_display}"fiprintf "%b" "$output"
Save the file, and grant it executable permissions with:
chmod +x ~/.claude/statusline.sh
Then edit the user Claude Code settings JSON file ~/.claude/settings.json and include the following:
"statusLine": {"type": "command","command": "~/.claude/statusline-command.sh","padding": 0}
The full ~/.claude/settings.json file may now look something like this:
{"permissions": {"allow": ["Bash(cat:*)","Bash(grep:*)"]},"statusLine": {"type": "command","command": "~/.claude/statusline-command.sh","padding": 0}}
Exit Claude Code and go back into it, and you should see the new statusline below the input box.