Claude Code Guide: Features and Best Practices
Claude Code is Anthropic's official command-line interface (CLI) that brings Claude AI directly into your terminal for AI-assisted software development. It enables developers to write, refactor, debug, and deploy code using natural language prompts whilst maintaining full control over file operations and command execution.
This guide covers installation, model selection, the CLAUDE.md context file, plan mode for feature implementation, checkpoints for undoing changes, Git integration, settings configuration, and advanced features including Claude Skills, subagents, and MCP servers for extending functionality.
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
- Frequently Asked Questions
- Conclusion
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
Installation
To install Claude Code, refer to the official instructions at code.claude.com/docs/en/setup.
Starting Claude Code
Claude Code operates within the directory where you launch it, typically your project's root folder.
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 supports three models:
- Opus - highest capability model, slower response times, higher usage costs
- Sonnet - balanced performance and cost, suitable for most development tasks
- Haiku - fastest responses, lowest usage costs, ideal for straightforward tasks
You can switch between models in Claude Code by running the slash command:
/model
Which Models to Use
Opus
Opus offers the highest capability but consumes usage limits faster than other models.
Use Opus for planning complex features and implementing challenging functionality that requires deep reasoning.
Sonnet
Sonnet provides faster responses than Opus whilst consuming fewer usage limits.
Sonnet serves as an excellent default for most development tasks. Use it as your primary implementation model for writing and editing code.
Haiku
Haiku delivers the fastest responses and consumes the fewest usage limits of all three models.
Haiku excels at implementing standard features such as creating React components, writing Python scripts, or building conventional applications following established patterns.
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
The most effective way to optimise Claude Code performance is to provide a CLAUDE.md file in your project root.
The CLAUDE.md file serves as project documentation for Claude, outlining common development commands, project architecture, directory structure, and essential development practices. This context enables Claude to make informed decisions about code changes and follow your project's conventions.
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
Effective prompting and planning are key to Claude Code's performance.
Prompting
When providing instructions to Claude Code, clarity and context produce the best results.
Write prompts as you would brief a software developer: clearly state requirements, provide context about the existing codebase, and specify expected outcomes. Use natural language rather than attempting to write code-like commands.
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
Claude Code includes a dedicated Plan Mode feature. Enable it manually using Shift+Tab until you see plan mode on displayed below the input bar.
Alternatively, Claude Code enters Plan Mode automatically when your prompt explicitly requests planning (e.g., "Plan the implementation of...").
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
During execution, Claude Code may request permission to run certain commands. You can grant one-time permission or configure persistent rules (allow always, ask every time, or deny).
Claude proceeds to implement the plan by creating and modifying files. The Settings and Permissions section below explains how to configure command permissions to streamline your workflow whilst maintaining security.
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
When Claude Code takes an unintended direction or implements changes you want to reverse, you can use checkpoints to restore previous states without starting a new session.
Checkpoints allow you to revert the conversation context, file changes, or both to any previous point in your session. Each prompt creates an automatic checkpoint.
/checkpoints
Note: Checkpoints are session-specific and temporary. They are not a replacement for Git version control. Always commit important changes to Git for permanent version history.
Git and Version Control
Committing and Branching
After Claude implements a feature or fix, you can request it to commit changes to Git. Claude can also create new branches before committing, following Git workflow best practices.
History and Explanations
Claude Code can analyse Git history to understand the evolution of your codebase. This helps explain why particular implementations exist or how features developed over time.
Example prompt:
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 consumes tokens from your Claude subscription limits. Long sessions, large file reads, and frequent model interactions can consume significant portions of your monthly allocation.
You can view your remaining usage with the following slash command:
/usage
Context Control
Context refers to the conversation history, file contents, and other information Claude Code maintains in the current session. This consumes tokens from your available context window.
Viewing Context Use
You can view the current context use with the following slash command:
/context
Clearing Context
For long-running sessions, context can accumulate rapidly. Whilst Claude Code manages this automatically, you can manually reset context when beginning a new feature or switching tasks using the slash command:
/clear
Compacting Context
You can compact your message history to free up context space. This summarises previous conversations whilst preserving essential information. Use the slash command:
/compact
Settings and Permissions
To avoid repetitive permission prompts, you can configure command permissions and other settings in a .claude/settings.local.json file. Claude Code generates this file automatically, which you can then customise to control which commands run automatically, require confirmation, or are blocked entirely.
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 provide a distribution mechanism for installing Claude Skills and MCP servers from official and community sources.
View available plugins from default marketplaces and any external sources you've configured using the slash command:
/plugin
Exercise caution when installing plugins from external sources. Verify the publisher's identity and review the plugin's code before installation, as plugins have access to your development environment and files.
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, SKILL.md file contents are not loaded into the context until the Skill is invoked.
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 protocol that enables Claude to interact with external services and tools. MCP servers provide integrations with email providers (Gmail), project management platforms (Asana), communication tools (Slack), design applications (Canva), databases, and web browsers.
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 provides Claude with access to current documentation and code examples for frameworks, libraries, and tools. This supplements Claude's training data with up-to-date information, particularly valuable given how rapidly software development practices and APIs evolve.
To install the Context7 MCP:
/plugin install context7@claude-plugins-official
Custom Statuslines
You can configure a custom statusline that appears below the input box in Claude Code to display session information.
Statuslines can show the current Git branch, working directory, context window usage, active model, session ID, and other runtime information. This provides at-a-glance visibility into your Claude Code session state.
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.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.
Frequently Asked Questions
What is the difference between Skills and Subagents?
Skills are reusable prompt templates that load specialised instructions when invoked, without consuming context until used. They're ideal for specific workflows like code reviews or optimisation tasks. Subagents are independent Claude instances that can run in parallel or background, with their own context windows and tool access permissions. Use Skills for repeatable workflows and Subagents for complex, multi-step tasks requiring isolation.
How much does Claude Code cost?
Claude Code requires a paid Claude subscription: Pro (individual use), Max (higher usage limits), or Team (collaborative features). Usage counts against your plan's monthly limits based on the model used (Haiku consumes fewer tokens than Sonnet, which consumes fewer than Opus). Check your current usage with the /usage command.
Can I use Claude Code offline?
No. Claude Code requires an active internet connection as it communicates with Anthropic's API servers to process requests. All AI inference happens on Anthropic's infrastructure, not locally on your machine.
How do I prevent Claude Code from reading sensitive files like environment variable files?
Add deny rules to your ~/.claude/settings.json or .claude/settings.json file. For example:"deny": ["Read(./.env)", "Read(./.env.*)", "Read(**/*.key)"]. This prevents Claude from accessing environment files, private keys, or other sensitive data.
What are MCP servers and why would I use them?
Model Context Protocol (MCP) servers extend Claude Code's capabilities by connecting it to external services like Gmail, Slack, databases, or design tools like Canva. They enable Claude to interact with tools beyond your local filesystem. For example, the Playwright MCP allows Claude to view and interact with websites, whilst Context7 provides access to up-to-date documentation for frameworks and libraries.
Conclusion
Claude Code transforms software development by bringing AI assistance directly into your terminal whilst maintaining full control over your codebase. The key to maximising its effectiveness lies in proper configuration: create a comprehensive CLAUDE.md file, use plan mode for complex features, configure appropriate model selection (opusplan for most workflows), and leverage advanced features like Skills and MCP servers where appropriate.
Start with the basics: installation, CLAUDE.md creation, and model selection. Then progressively adopt advanced features as your workflow matures. Use checkpoints to experiment safely, configure permissions to balance convenience with security, and create custom Skills for repetitive tasks in your domain.
For the latest documentation and updates, refer to the official Claude Code documentation at code.claude.com/docs.