# Claude Code Claude Code is a CLI tool, described as an "agentic coding tool" made by Anthropic. It can be installed using `npm`. Once installed and configured, it can be used directly from the terminal. Key features: - Editing files and fixing bugs across your codebase - Answering questions about your code’s architecture and logic - Executing and fixing tests, linting, and other commands - Searching through git history, resolving merge conflicts, and creating commits and PRs - Customizable commands: it's possible to create personalized commands with associated prompts ## Installation Pre-reqs: - [[Node.js]] - [[Git]] - [[GitHub]] or [[GitLab]] CLI for PR workflows (optional) - `ripgrep`: https://github.com/BurntSushi/ripgrep?tab=readme-ov-file#installation - Debian: `sudo apt install ripgrep` ````sh npm install -g @anthropic-ai/claude-code ```` After installing: - Go to your project folder - Run `claude` - Run `/init` to create a `CLAUDE.md` file with codebase documentation WSL: - To fix OS detection issues: `npm config set os linux` then install using `npm install -g @anthropic-ai/claude-code --force --no-os-check` (without using `sudo`) ## Ways to use Claude Code By default, Claude Code is used through an interactive session (REPL), where a CLI GUI enables entering prompts and commands. But it's also possible to use it non-interactively, using the `-p` or `--print` CLI flag: `claude -p "Summarize this codebase"`. ## Usage Core tasks and workflows - Understand code - what does xxx do? - find where xxx are checked - explain how xxx works - Automate Git operations - commit my changes - commit and push all changes - create a PR - which commit added xxx back in yyy? - rebase on main and resolve any merge conflicts - Edit code - add xxx to yyy - refactor the xxx to yyy - fix xxx in yyy - Test and debug code - run tests for xxx and fix failures - find and fix security vulnerabilities - explain why this test is failing - Encourage deeper thinking - think about how we should architect xxx - "think" triggers extended thinking (basic) - think hard about the edge cases in xxx - "think hard" triggers more extended thinking - Automate CI/infra workflows - `export ANTHROPIC_API_KEY=sk...` - `claude --print "update the README with ... --allowedTools "Bash(git diff:*)" "Bash(git log:*) Write --disallowedTools ...` ## Configuration Last update: 2025-06-11 Version: 1.0.18 (Claude Code) ### Scopes Claude Code's configuration may be defined at different levels: - Local (default) - User - Project ### Global settings & settings files Settings (i.e., parameters, themes and environment variables) are stored at different levels: - Global: `~/.claude/settings.json` - Project-level: `.claude/settings.json` and `.claude/settings.local.json` (for settings that need to be ignored by git) For enterprise deployments, Claude Code also supports enterprise-managed policy settings: https://docs.anthropic.com/en/docs/claude-code/settings#settings-files Settings are applied using the following order of precedence: - Enterprise policies - Command-line arguments - Local project settings - Shared project settings - User settings Interesting available settings (as of 2025-06-12): - `cleanupPeriodDays`: How long to locally retain chat transcripts (default: 30 days) - `env`: Environment variables that'll be applied to all sessions - `CLAUDE_CODE_ENABLE_TELEMETRY` (set to 0 to disable telemetry) - `DISABLE_AUTOUPDATER` (set to 1 to disable auto updates) - `DISABLE_ERROR_REPORTING` (set to 1 to disable error reporting) - `DISABLE_TELEMETRY` (set to 1 to opt out of Statsig telemetry) - Full list of supported environment variables: https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables - `includeCoAuthoredBy`: whether to include the `co-authored-by Claude` byline in git commits and pull requests (default: true) - permissions: define the allow/deny rules (cfr https://docs.anthropic.com/en/docs/claude-code/settings#permissions) - preferredNotifChannel: define how Claude Code should notify you - terminal_bell: terminal sound - verbose: whether to show full Bash and command outputs (default: false) ### Manage the configuration Use `claude config [options] [command]`: ``` get [options] <key> Get a config value set [options] <key> <value> Set a config value remove|rm [options] <key> [values...] Remove a config value or items from a config array list|ls [options] List all config values add [options] <key> <values...> Add items to a config array (space or comma separated) help [command] display help for command ``` ## Commands and flags ### CLI Commands The following commands can be passed to the CLI: ``` config Manage configuration (eg. claude config set -g theme dark) mcp Configure and manage MCP servers migrate-installer Migrate from global npm installation to local installation doctor Check the health of your Claude Code auto-updater update Check for updates and install if available ``` ### CLI Flags Those flags can be passed to the `claude` CLI: ``` -d, --debug Enable debug mode --verbose Override verbose mode setting from config -p, --print Print response and exit (useful for pipes) --output-format <format> Output format (only works with --print): "text" (default), "json" (single result), or "stream-json" (realtime streaming) (choices: "text", "json", "stream-json") --input-format <format> Input format (only works with --print): "text" (default), or "stream-json" (realtime streaming input) (choices: "text", "stream-json") --dangerously-skip-permissions Bypass all permission checks. Recommended only for sandboxes with no internet access. --allowedTools <tools...> Comma or space-separated list of tool names to allow (e.g. "Bash(git:*) Edit") --disallowedTools <tools...> Comma or space-separated list of tool names to deny (e.g. "Bash(git:*) Edit") --mcp-config <file or string> Load MCP servers from a JSON file or string -c, --continue Continue the most recent conversation -r, --resume [sessionId] Resume a conversation - provide a session ID or interactively select a conversation to resume --model <model> Model for the current session. Provide an alias for the latest model (e.g. 'sonnet' or 'opus') or a model's full name (e.g. 'claude-sonnet-4-20250514'). --add-dir <directories...> Additional directories to allow tool access to (must be absolute paths) -v, --version Output the version number -h, --help Display help for command ``` ### Slash commands Those commands can be used within the Claude Code REPL: ``` /bug - Submit feedback about Claude Code /clear - Clear conversation history and free up context /compac - Clear conversation history but keep a summary in context. Optional: /compact [instructions for summarization] /config - Open config panel /cost - Show the total cost and duration of the current session /doctor - Checks the health of your Claude Code installation /exit - Exit the REPL /help - Show help and available commands /ide - Manage IDE integrations and show status /init - Initialize a new CLAUDE.md file with codebase documentation /install-github-app - Set up Claude GitHub Actions for a repository /login - Switch Anthropic accounts /logout - Sign out from your Anthropic account /mcp - Show MCP server connection status /memory - Edit Claude memory files /migrate-installer - Migrate from global npm installation to local installation /model - Set the AI model for Claude Code /permissions (allowed-tools) - Manage allow & deny tool permission rules /pr-comments - Get comments from a GitHub pull request /release-notes - View release notes /review - Review a pull request /status - Show Claude Code status including version, model, account, API connectivity, and tool statuses /upgrade - Upgrade to Max for higher rate limits and more Opus /vim - Toggle between Vim and Normal editing modes ``` Most frequently useful: - /clear: clear the conversation history and free up context - /compact: clear conversation history but keep a summary in context - /cost: monitor costs - /ide: connect an IDE - /memory: edit the memory files - /model: set the model to use - /permissions: configure permissions - /pr-comments: get comments from a GitHub PR - /review: review a PR - /status: check status, version, model, account, tools statuses, etc ## Tools available to Claude Code Claude Code has a number of built-in tools. As of 2026-06-12: | Tool | Description | Permission Required | | ---------------- | ---------------------------------------------------- | ------------------- | | **Agent** | Runs a sub-agent to handle complex, multi-step tasks | No | | **Bash** | Executes shell commands in your environment | Yes | | **Edit** | Makes targeted edits to specific files | Yes | | **Glob** | Finds files based on pattern matching | No | | **Grep** | Searches for patterns in file contents | No | | **LS** | Lists files and directories | No | | **MultiEdit** | Performs multiple edits on a single file atomically | Yes | | **NotebookEdit** | Modifies Jupyter notebook cells | Yes | | **NotebookRead** | Reads and displays Jupyter notebook contents | No | | **Read** | Reads the contents of files | No | | **TodoRead** | Reads the current session’s task list | No | | **TodoWrite** | Creates and manages structured task lists | No | | **WebFetch** | Fetches content from a specified URL | Yes | | **WebSearch** | Performs web searches with domain filtering | Yes | | **Write** | Creates or overwrites files | Yes | ## [[Model Context Protocol (MCP)]] Support In addition to the built-in tools, Claude Code supports [[Model Context Protocol (MCP)]]. You can use the `--mcp-config <path>` CLI flag to load MCP servers from a JSON file or string. ### Configure MCP Servers The MCP servers configuration can be managed using `claude mcp`: ``` serve [options] Start the Claude Code MCP server add [options] <name> <commandOrUrl> [args...] Add a server remove [options] <name> Remove an MCP server list List configured MCP servers get <name> Get details about an MCP server add-json [options] <name> <json> Add an MCP server (stdio or SSE) with a JSON string add-from-claude-desktop [options] Import MCP servers from Claude Desktop (Mac and WSL only) reset-project-choices Reset all approved and rejected project-scoped (.mcp.json) servers within this project help [command] display help for command ``` To add an MCP server you can use: `claude mcp add [options] <name> <commandOrUrl> [args...]` Alternatively you can add an MCP server (stdio or SSE) using a JSON string using `claude mcp add-json [options] <name> <json>`. Options: ``` -s, --scope <scope> Configuration scope (local, user, or project) (default: "local") -t, --transport <transport> Transport type (stdio, sse) (default: "stdio") -e, --env <env...> Set environment variables (e.g. -e KEY=value) -H, --header <header...> Set HTTP headers for SSE transport (e.g. -H "X-Api-Key: abc123" -H "X-Custom: value") -h, --help Display help for command ``` ### Import MCP Servers from Claude Desktop Servers can be imported from [[Claude]] using `claude mcp add-from-claude-desktop` (only supported on MacOS and WSL). Note that under WSL, this command cannot import from Claude if Claude is not installed within WSL as well. A workaround consists in passing the path to the Windows Claude MCP servers configuration file stored (`~/AppData/Roaming/Claude/claude_desktop_config.json`) so that [[Claude Code]] uses those. Example: `claude --mcp-config /c/Users/foo/AppData/Roaming/Claude/claude_desktop_config.json` Unfortunately, when used that way, the servers are not "remembered" by Claude Code, so the CLI flag needs to be passed each time. I've created an alias to forget about that: ``` alias claude='claude --mcp-config /c/Users/foo/AppData/Roaming/Claude/claude_desktop_config.json' ``` Moreover, that approach breaks for all MCP servers using Windows-specific paths in their configuration. If you have servers like that in your configuration, then it's best to manually add the MCP servers in [[Claude Code]] using `claude mcp add ...` Example for [[Dockmaster]]: ``` claude mcp add dockmaster /c/Users/foo/AppData/Local/MCP\ Dockmaster/mcp-proxy-server.exe ``` Additional info, tips & tricks: https://docs.anthropic.com/en/docs/claude-code/mcp ## Manage Memory ### Memory files Claude Code's memory files are stored in different locations: - Project memory: `project root/CLAUDE.md` - Project memory (local): `project root/CLAUDE.local.md` (added to .gitignore!) - User memory: `~/.claude/CLAUDE.md` The memory files can be edited using the `/memory` command in [[Claude Code]]. ## How memory files are located/loaded Claude Code reads memories recursively, starting in the current working directory (cwd). Then it recurses up to `/`, and reads any `CLAUDE.md` or `CLAUDE.local.md` files it finds along the way. Claude Code also discovers memory files nested in subtrees under the current working directory. Those are NOT loaded at launch, but only when Claude Code reads files in those subtrees. ### Memory file imports Memory files can import additional instructions using `@path/to/import`. For example: ``` See @README for project overview and @package.json for available npm commands for this project. ## Additional Instructions - git workflow @docs/git-instructions.md ``` Both relative and absolute paths are allowed. Loading home dir files is possible too: ``` # Individual Preferences - @~/.claude/project-preferences.md ``` Note that imports are NOT evaluated inside Markdown code spans and code blocks ## How to quickly add memories The fastest way to add a memory is to start your input with the `#` character. Claude Code will then ask you where you want to store the new memory. ## Memory best practices - Be specific - Use structure to organize memory files (e.g., using Markdown headings as section and bullet points within) - Review regularly and update memories as the project evolves ## Manage Permissions Claude Code has a strict permission model for configuring which commands it may or may not use. To manage the permissions, run [[Claude Code]] then use `/permissions`. Alternatively, edit one of the `settings.json` files (cfr Configuration section). Permissions are defined using the following format: `Type(optional specifier)`. Types of permissions: - Read: read files - Edit: edit files (applies to all built-in tools that edit files) - WebFetch - mcp Read and Edit rules follow the [gitignore specification](https://git-scm.com/docs/gitignore). Patterns are resolved relative to the directory containing `.claude/settings.json`. To reference an absolute path, use `//`. For a path relative to the home directory, use `~/`. Tool-specific permission rules: - `Bash(...)` - `Bash(npm run build)`: match the exact command - `Bash(npm run test:*)`: match all commands starting with `npm run test` - Note that Claude Code is aware of shell operators like `&&` - `Edit(docs/**)`: match edits to files in the `docs` directory - `Read(~/.zshrc)` - `WebFetch(domain:example.com)`: Matches fetch requests to `example.com` - `mcp__puppeteer`: Matches any tool provided by the `puppeteer` [[Model Context Protocol (MCP)]] server (name configured in Claude Code) - `mcp__puppeteer__puppeteer_navigate`: Matches the `puppeteer_navigate` tool provided by the `puppeteer` MCP server ## Custom Slash Commands It's possible to create custom Claude Code slash commands. There are two types of commands: - Project-specific: commands that are stored in the project/repository and shared with others. Those are stored under `<project root folder>/.claude/commands/` - Prefix: `/project:` - Personal: Commands that are shared across all projects. Those are stored under `~/.claude/commands` - Prefix: `/user:` Syntax: `/<prefix>:<command_name> [arguments]` Where - Prefix: command scope, `project` for project-specific, `user` for personal) - Command Name: derived from the Markdown file name (without the `.md` extension) - Arguments: optional arguments to pass to the command Custom slash commands can also be namespaces: `<prefix>:<namespace>:<command>`. For example: `.claude/commands/frontend/component.md` creates the following command: `/project:frontend:component` Arguments can pass dynamic values to commands, using the `$ARGUMENTS` placeholder. For example: ``` # Command definition echo "Fix issue #$ARGUMENTS following our coding standards" > .claude/commands/fix-issue.md # Usage > /project:fix-issue 123 ``` Command files MUST: - Use the Markdown format (`.md` file extension) - Contain the prompt or instructions as file content - Be placed in the appropriate commands directory ## IDE Integration Claude Code can be integrated with various IDEs. The supported IDE integrations are documented here: https://docs.anthropic.com/en/docs/claude-code/ide-integrations. For instance, Claude Code supports [[Visual Studio Code (VSCode)]], including forks like [[Cursor.com]], [[Windsurf]], and Jetbrains IDEs. ## Visual Studio Code For [[Visual Studio Code (VSCode)]], open the built-in terminal and run the `claude` command. It will connect the IDE to Claude automatically. Then, run `claude` then `/config` to configure the integration. ## Jetbrains IDEs Plugin for Jetbrains IDEs: https://plugins.jetbrains.com/plugin/27310-claude-code-beta- For IntelliJ IDEs, either install the plugin from the Marketplace or run the `claude` command in the built-in terminal. ## How to update Claude Code Claude Code has an auto update feature. If you want, you can also update manually using the following command: `claude update`. ## Privacy See https://docs.anthropic.com/en/docs/claude-code/overview#license-and-data-usage ## Tips & Tricks - Course correct early and often: Cancel whatever Claude is doing and adapt your prompt whenever needed - Use `/clear` to keep the context "clean" (i.e., focused) - Use checklists and scratchpads for complex workflows. Ask Claude to generate a task list, then tell it to read and process it, marking the items as done to track progress - Pipe data into Claude instead of copy/pasting (e.g., `cat foo.txt | claude`) - Ask Claude to read files or fetch URLs (also works with images!) - Enable sound alters to know when Claude Code is done: `claude config set --global preferredNotifChannel terminal_bell` - Claude Code supports a subset of Vim keybindings that can be enabled with `/vim` or configured via `/config`: https://docs.anthropic.com/en/docs/claude-code/settings#vim-mode - Create an alias to run Claude Code without permission checks (AKA YOLO mode): `alias cc="claude --dangerously-skip-permissions` (be careful about this!) - Add/configure/leverage [[Model Context Protocol (MCP)]] servers - Run multiple tasks in parallel: `Use 3 parallel agents to ...` - Claude Code can use tons and tons of commands, but also things such as `git` or `gh` (GitHub CLI) - If you're using Git, leverage worktrees (create multiple worktrees, launch Claude in each, and let it do its magic) - `git worktree add ../project-feature-a feature-a && cd ../project-feature-a && claude` - Keep one terminal tab per worktree - Use separate IDE windows for different worktrees - Cleanup when you're done: `git worktree remove ../project-feature-a` ## Recommendations - Avoid pasting long content. Instead, use file-based workflows. Put the content in a file and ask Claude Code to read it - Create `CLAUDE.md` files to make Claude Code behavior as it should in your specific project(s) - Recommended format: Markdown headings and bullet points - Explore > Plan > Confirm > Do: `Analyze X then propose different approaches and let me choose one before you continue` - Leverage screenshots: `Do X then screenshot Y using Z and ...` - Leverage Claude Code commands to automate specific tasks More: https://www.anthropic.com/engineering/claude-code-best-practices ## Keyboard Shortcuts - Shift + Tab: switch between modes (e.g., auto accept edits) - `#`: create a memory - `!` enter Bash mode - `@`: add a file/folder to context - `Esc`: cancel - `Esc Esc`: jump back in history, `--resume` to resume - `CTRL/CMD + R`: verbose output (see entire output) - `\` followed by Enter: create a newline ## SDK Claude Code may be integrated programmatically into other systems/applications. Different approaches: - Integrate with Bash or other shells: Claude Code command with the `--prompt` and `--output-format` parameters - TypeScript: The official Claude Code package can also be used programmatically - Python: https://github.com/anthropics/claude-code-sdk-python More details here: https://docs.anthropic.com/en/docs/claude-code/sdk ## Third-party Integrations See here: https://docs.anthropic.com/en/docs/claude-code/third-party-integrations ## References - Documentation: https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview - Usage: https://docs.anthropic.com/en/docs/claude-code/common-tasks - CLI usage: https://docs.anthropic.com/en/docs/claude-code/cli-usage - IDE integrations: https://docs.anthropic.com/en/docs/claude-code/ide-integrations - Plugin for Jetbrains IDEs: https://plugins.jetbrains.com/plugin/27310-claude-code-beta- - Memory management: https://docs.anthropic.com/en/docs/claude-code/memory - Settings: https://docs.anthropic.com/en/docs/claude-code/settings - Settings files: https://docs.anthropic.com/en/docs/claude-code/settings#settings-files - Privacy: https://docs.anthropic.com/en/docs/claude-code/overview#license-and-data-usage - Supported environment variables: https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables - MCP: https://docs.anthropic.com/en/docs/claude-code/mcp - TypeScript & CLI SDK: https://docs.anthropic.com/en/docs/claude-code/sdk - https://www.npmjs.com/package/@anthropic-ai/claude-code - Python SDK: https://github.com/anthropics/claude-code-sdk-python - Troubleshooting: https://docs.anthropic.com/en/docs/claude-code/troubleshooting - Proxy to connect Claude Code to other LLMs: https://github.com/1rgs/claude-code-proxy - Create custom slack commands: https://docs.anthropic.com/en/docs/claude-code/slash-commands#custom-slash-commands ## Related - [[Claude]]