claude-almanac
Core

Built-in Tools Reference

Reference for all 18 default tools available in the Claude Code CLI, organized into six categories.

Claude Code Built-in Tools Reference

Complete reference for all default tools available in Claude Code CLI.


Overview

Claude Code provides 18 built-in tools organized into six categories:

CategoryTools
File OperationsRead, Write, Edit, MultiEdit, NotebookEdit
Search & DiscoveryGlob, Grep, LS
ExecutionBash, KillShell
Web & NetworkWebFetch, WebSearch
Task ManagementTask, TodoWrite
Planning & InteractionExitPlanMode, AskUserQuestion, Skill

File Operations

Read

Purpose: Read file contents from the filesystem.

Parameters:

ParameterTypeRequiredDescription
file_pathstringYesAbsolute path to the file
offsetnumberNoLine number to start reading from
limitnumberNoNumber of lines to read

Behavior:

  • Reads up to 2000 lines by default
  • Returns content with line numbers (cat -n format)
  • Truncates lines longer than 2000 characters
  • Can read images (PNG, JPG) and display them visually
  • Can read PDFs with text and visual content extraction
  • Can read Jupyter notebooks (.ipynb) with all cells and outputs

Best Practices:

  • Always use absolute paths, not relative paths
  • Use offset and limit for files larger than 2000 lines
  • Read files before using Edit or Write tools
  • Combine with Grep for targeted reading

Example:

Read /Users/project/src/main.js
Read /Users/project/data.json offset=100 limit=50

Write

Purpose: Create new files or completely overwrite existing files.

Parameters:

ParameterTypeRequiredDescription
file_pathstringYesAbsolute path for the file
contentstringYesComplete content to write

Behavior:

  • Overwrites entire file content (not append)
  • Creates parent directories if needed
  • Creates a checkpoint before writing (allows revert)
  • Requires permission (ask/allow in settings)

Best Practices:

  • Use for creating new files from scratch
  • Use Edit tool instead for modifying existing files
  • Must Read existing files before overwriting
  • Never use bash echo/cat for file writing

Permission Required: Yes


Edit

Purpose: Make targeted replacements in files without overwriting the entire file.

Parameters:

ParameterTypeRequiredDescription
file_pathstringYesAbsolute path to the file
old_stringstringYesExact text to find and replace
new_stringstringYesReplacement text
replace_allbooleanNoReplace all occurrences (default: false)

Behavior:

  • Performs exact text matching (case-sensitive, whitespace-sensitive)
  • Fails if old_string is not unique (unless replace_all is true)
  • Creates checkpoint before editing
  • Shows context around changes

Best Practices:

  • Must Read the file first before editing
  • Preserve exact indentation from the file
  • Include surrounding context to make old_string unique
  • Use replace_all for renaming variables across the file

Permission Required: Yes

Example:

Edit /path/to/file.js
  old_string: "function oldName()"
  new_string: "function newName()"

MultiEdit

Purpose: Make multiple sequential find-and-replace operations in a single file atomically.

Parameters:

ParameterTypeRequiredDescription
file_pathstringYesAbsolute path to the file
editsarrayYesArray of edit operations

Each edit in the array contains:

  • old_string: Text to find
  • new_string: Replacement text

Behavior:

  • Applies all edits sequentially in order
  • Atomic operation (all succeed or all fail)
  • Single checkpoint for all edits

Best Practices:

  • Use for multiple related changes in one file
  • More efficient than multiple Edit calls
  • Order matters - edits apply sequentially

Permission Required: Yes


NotebookEdit

Purpose: Modify Jupyter notebook cells (.ipynb files).

Parameters:

ParameterTypeRequiredDescription
notebook_pathstringYesAbsolute path to .ipynb file
new_sourcestringYesNew content for the cell
cell_idstringNoID of the cell to edit
cell_typestringNoType: code or markdown
edit_modestringNoMode: replace, insert, or delete

Behavior:

  • replace: Replace cell content (default)
  • insert: Add new cell after specified cell_id
  • delete: Remove the specified cell
  • Preserves notebook structure and metadata

Best Practices:

  • Use for Jupyter notebook modifications
  • Maintain logical flow between cells
  • Test notebook with kernel after modifications

Permission Required: Yes


Search & Discovery

Glob

Purpose: Find files matching glob patterns without searching file contents.

Parameters:

ParameterTypeRequiredDescription
patternstringYesGlob pattern (e.g., **/*.js)
pathstringNoDirectory to search in (default: cwd)

Supported Patterns:

PatternMatches
*Any characters except /
**Any characters including / (recursive)
?Single character
[abc]Character class
{a,b}Alternatives

Behavior:

  • Returns file paths sorted by modification time
  • Works with any codebase size
  • Fast file discovery

Best Practices:

  • Use before Read for efficient file discovery
  • Perform multiple searches in parallel when useful
  • Use **/* for recursive search

Permission Required: No

Examples:

Glob pattern="**/*.js"                    # All JavaScript files
Glob pattern="src/**/*.ts"                # TypeScript in src/
Glob pattern="**/test/**/*.spec.js"       # Test spec files
Glob pattern="*.{js,ts,jsx,tsx}"          # Multiple extensions

Grep

Purpose: Search file contents using regex patterns (powered by ripgrep).

Parameters:

ParameterTypeRequiredDescription
patternstringYesRegex pattern to search for
pathstringNoFile or directory to search
output_modestringNofiles_with_matches (default), content, or count
typestringNoFile type filter (js, py, rust, go, etc.)
globstringNoGlob pattern filter (e.g., *.tsx)
-ibooleanNoCase-insensitive search
-nbooleanNoShow line numbers (default: true in content mode)
-AnumberNoLines to show after match
-BnumberNoLines to show before match
-CnumberNoLines to show before and after match
multilinebooleanNoEnable multiline matching
head_limitnumberNoLimit output to first N entries
offsetnumberNoSkip first N entries

Output Modes:

ModeReturns
files_with_matchesFile paths only (default)
contentMatching lines with context
countMatch count per file

Behavior:

  • Uses ripgrep (highly optimized)
  • Full regex syntax support
  • NEVER use bash grep or rg - always use this tool

Best Practices:

  • Use files_with_matches for initial discovery
  • Use content mode with -C for context
  • Combine with type or glob to narrow scope
  • Use head_limit to avoid overwhelming output

Permission Required: No

Examples:

Grep pattern="function.*auth" type="js"           # Auth functions in JS
Grep pattern="TODO|FIXME" output_mode="content"   # Find TODOs with context
Grep pattern="import.*React" glob="**/*.jsx"      # React imports
Grep pattern="class.*Error" -C=3                  # Error classes with context

LS

Purpose: List directory contents.

Parameters:

ParameterTypeRequiredDescription
pathstringYesAbsolute path to directory
ignorearrayNoGlob patterns to ignore

Behavior:

  • Lists files and directories at the specified path
  • Can filter out patterns with ignore parameter

Best Practices:

  • Use for exploring directory structure
  • Use Glob instead for pattern-based file finding
  • Never use bash ls command

Permission Required: No


Execution

Bash

Purpose: Execute shell commands in a persistent bash session.

Parameters:

ParameterTypeRequiredDescription
commandstringYesShell command(s) to execute
descriptionstringNoDescription of what the command does
timeoutnumberNoTimeout in ms (max 600000 / 10 min)
run_in_backgroundbooleanNoRun command in background

Behavior:

  • Working directory persists across commands
  • Environment variables do NOT persist between commands
  • Default timeout: 120000ms (2 minutes)
  • Output truncated if exceeds 30000 characters
  • Supports pipes, redirects, and complex shell syntax

Best Practices:

  • Use && to chain dependent commands
  • Use absolute paths in scripts
  • Quote file paths with spaces: cd "/path with spaces"
  • Use for: git, npm, docker, pytest, build tools
  • NEVER use for: find, grep, cat, head, tail, sed, awk, echo

Prohibited Commands: Use dedicated tools instead:

Instead ofUse
findGlob
grep, rgGrep
cat, head, tailRead
sed, awkEdit
echo >, cat <<EOFWrite

Permission Required: Yes (configurable with patterns)

Examples:

Bash command="npm test"
Bash command="git status"
Bash command="cd /project && npm install && npm run build"
Bash command="python script.py" timeout=300000
Bash command="npm run dev" run_in_background=true

KillShell

Purpose: Stop a running background bash shell.

Parameters:

ParameterTypeRequiredDescription
shell_idstringYesID of the background shell

Behavior:

  • Stops background bash execution
  • Cleans up task tracking
  • Shell IDs visible with /tasks command

Permission Required: Yes


Web & Network

WebFetch

Purpose: Fetch and analyze content from URLs.

Parameters:

ParameterTypeRequiredDescription
urlstringYesFully-formed valid URL
promptstringYesQuestion/prompt about the content

Behavior:

  • Automatically upgrades HTTP to HTTPS
  • Converts HTML to markdown
  • Processes content with small, fast AI model
  • 15-minute cache for repeated access
  • Handles redirects (provides new URL to fetch)

Best Practices:

  • Provide clear, specific prompts
  • Use for documentation and reference material
  • If redirected to different host, make new request with redirect URL

Permission Required: Yes

Example:

WebFetch url="https://docs.example.com/api" prompt="List available endpoints"
WebFetch url="https://github.com/user/repo" prompt="What is the project purpose?"

WebSearch

Purpose: Search the web for current information.

Parameters:

ParameterTypeRequiredDescription
querystringYesSearch query (min 2 characters)
allowed_domainsarrayNoOnly include results from these domains
blocked_domainsarrayNoExclude results from these domains

Behavior:

  • Returns search results with markdown hyperlinks
  • Provides up-to-date information beyond knowledge cutoff
  • Only available in the US

Best Practices:

  • Include year in queries for recent information
  • Use domain filtering for specific sources
  • Always cite sources in responses

Permission Required: Yes

Example:

WebSearch query="React 2026 best practices"
WebSearch query="Claude API updates" allowed_domains=["anthropic.com"]

Task Management

Task

Purpose: Launch specialized sub-agents for complex, multi-step tasks.

Parameters:

ParameterTypeRequiredDescription
promptstringYesTask description for the agent
descriptionstringYesShort summary (3-5 words)
subagent_typestringYesType of agent to use
modelstringNoModel: sonnet, opus, or haiku
run_in_backgroundbooleanNoRun agent in background
resumestringNoAgent ID to resume from

Available Agent Types:

TypePurposeTools
BashCommand executionBash
ExploreCodebase explorationAll except Edit, Write, Task
PlanImplementation planningAll except Edit, Write, Task
general-purposeMulti-step researchAll tools
claude-code-guideClaude Code questionsGlob, Grep, Read, WebFetch, WebSearch

Behavior:

  • Spawns agent with fresh, isolated context
  • Agent context doesn't bloat main conversation
  • Returns summarized results when complete
  • Can be resumed with agent ID

Best Practices:

  • Use for complex tasks requiring multiple steps
  • Launch multiple agents in parallel when possible
  • Use Explore agent for codebase searches
  • Use haiku model for quick, simple tasks

Permission Required: No

Example:

Task subagent_type="Explore" description="Find auth handlers"
  prompt="Find all files that handle user authentication"

Task subagent_type="Plan" description="Plan refactoring"
  prompt="Create a plan to refactor the database module"

TodoWrite

Purpose: Create and manage structured task lists for tracking progress.

Parameters:

ParameterTypeRequiredDescription
todosarrayYesArray of todo items

Each todo item contains:

FieldTypeRequiredDescription
contentstringYesTask description (imperative form)
activeFormstringYesPresent continuous form
statusstringYespending, in_progress, or completed

Behavior:

  • Exactly ONE task should be in_progress at a time
  • Mark tasks complete immediately after finishing
  • Task list visible in UI

When to Use:

  • Complex multi-step tasks (3+ steps)
  • User provides multiple tasks
  • Non-trivial implementations
  • After receiving new instructions

When NOT to Use:

  • Single, straightforward tasks
  • Trivial operations (< 3 steps)
  • Purely conversational requests

Permission Required: No

Example:

{
  "todos": [
    {"content": "Run tests", "activeForm": "Running tests", "status": "completed"},
    {"content": "Fix type errors", "activeForm": "Fixing type errors", "status": "in_progress"},
    {"content": "Update documentation", "activeForm": "Updating documentation", "status": "pending"}
  ]
}

Planning & Interaction

ExitPlanMode

Purpose: Signal completion of planning phase and request user approval.

Parameters:

ParameterTypeRequiredDescription
allowedPromptsarrayNoBash permissions needed for the plan

Behavior:

  • Reads plan from the plan file (already written)
  • Signals readiness for user review
  • Can request semantic permissions for bash commands

Best Practices:

  • Write plan to plan file before calling
  • Use for implementation tasks requiring approval
  • Request specific, scoped permissions

Permission Required: Yes (user approval)


AskUserQuestion

Purpose: Ask users questions to gather requirements or clarify ambiguity.

Parameters:

ParameterTypeRequiredDescription
questionsarrayYesArray of questions (1-4)

Each question contains:

FieldTypeRequiredDescription
questionstringYesThe question to ask
headerstringYesShort label (max 12 chars)
optionsarrayYes2-4 answer options
multiSelectbooleanYesAllow multiple selections

Each option contains:

FieldTypeRequiredDescription
labelstringYesDisplay text (1-5 words)
descriptionstringYesExplanation of the option

Behavior:

  • Users can always select "Other" for custom input
  • Use multiSelect: true for non-mutually-exclusive choices
  • Put recommended option first with "(Recommended)" suffix

Best Practices:

  • Use sparingly to avoid interrupting workflow
  • Provide clear, specific questions
  • Offer reasonable default choices

Permission Required: No


Skill

Purpose: Execute a custom skill (slash command) within the conversation.

Parameters:

ParameterTypeRequiredDescription
skillstringYesSkill name (e.g., commit, review-pr)
argsstringNoArguments for the skill

Behavior:

  • Invokes skill immediately as first action
  • Only uses skills listed in available skills
  • Does not invoke already-running skills

Permission Required: Varies by skill


Permission Configuration

Permission Modes

Toggle with Shift+Tab:

ModeBehavior
DefaultAsk before file edits and shell commands
Auto-AcceptEdit files without asking, still ask for commands
PlanRead-only tools only, creates plan for approval

Configuring Permissions

In .claude/settings.json:

{
  "permissions": {
    "allow": [
      "Read",
      "Glob",
      "Grep",
      "Bash(npm test)",
      "Bash(git:*)",
      "Write(src/**)"
    ],
    "deny": [
      "Bash(rm -rf:*)",
      "Read(.env*)"
    ]
  }
}

Permission Patterns

PatternMatches
ToolAll uses of the tool
Tool(pattern)Specific command/path pattern
Tool(*:*)All uses with any arguments
Bash(git:*)Git subcommands only
Write(src/**)Write to src/ directory only

Quick Reference

ToolCategoryPermissionBest For
ReadFilesNoReading files, images, PDFs
WriteFilesYesCreating new files
EditFilesYesTargeted file modifications
MultiEditFilesYesMultiple edits in one file
NotebookEditFilesYesJupyter notebook changes
GlobSearchNoFinding files by pattern
GrepSearchNoSearching file contents
LSSearchNoListing directories
BashExecutionYesRunning commands
KillShellExecutionYesStopping background tasks
WebFetchWebYesFetching URL content
WebSearchWebYesSearching the internet
TaskTask MgmtNoRunning sub-agents
TodoWriteTask MgmtNoTracking progress
ExitPlanModePlanningYesCompleting plans
AskUserQuestionInteractionNoGathering user input
SkillInteractionVariesRunning custom commands

Sources

Official:

Community references (unofficial, may be outdated):

On this page