File Operations
Tools for reading, writing, and modifying files in your codebase.Read
Read
Purpose: Read files or directories from the local filesystem.Capabilities:Common use cases:
- Read up to 2000 lines by default from any file
- Support for offset and limit parameters for reading specific sections
- Can read image files and PDFs
- Returns content with line numbers for easy reference
- Directory listing with trailing
/for subdirectories
- Reading source code files
- Examining configuration files
- Listing directory contents
- Reading documentation
Write
Write
Purpose: Create new files or overwrite existing files.Capabilities:Common use cases:
- Create new files with specified content
- Overwrite existing files (requires reading the file first)
- Atomic write operations
- Creating new source files
- Generating configuration files
- Writing documentation
- Creating test files
Edit
Edit
Purpose: Perform exact string replacements in files.Capabilities:Common use cases:
- Find and replace exact text matches
- Support for
replaceAllto rename across entire file - Requires reading the file first
- Preserves exact indentation and formatting
- Modifying existing code
- Fixing bugs
- Refactoring variable names
- Updating function implementations
multiedit for making multiple edits to a single file in one operation.MultiEdit
MultiEdit
Purpose: Make multiple edits to a single file in one operation.Capabilities:Common use cases:
- Perform multiple find-and-replace operations efficiently
- Edits applied sequentially in order
- Atomic operation (all edits succeed or none are applied)
- Built on top of the Edit tool
- Refactoring multiple parts of a file
- Updating multiple function calls
- Batch renaming within a file
Apply Patch
Apply Patch
Purpose: Apply structured patches to create, update, or delete files.Capabilities:Example patch format:
- Create new files with
*** Add File: - Update existing files with
*** Update File: - Delete files with
*** Delete File: - Rename files with
*** Move to: - Unified diff-style syntax
Code Search & Discovery
Tools for finding files and searching code.Glob
Glob
Purpose: Fast file pattern matching using glob patterns.Capabilities:Common use cases:
- Find files by name patterns like
**/*.jsorsrc/**/*.ts - Works with any codebase size
- Returns matching file paths sorted by modification time
- Finding all files of a specific type
- Locating test files
- Finding configuration files
- Discovering components by pattern
Grep
Grep
Purpose: Fast content search using regular expressions.Capabilities:Common use cases:
- Search file contents with full regex syntax
- Filter by file patterns with include parameter
- Returns file paths and line numbers with matches
- Sorted by modification time
- Finding function definitions
- Searching for error messages
- Locating TODO comments
- Finding API usage patterns
List (ls)
List (ls)
Purpose: List files and directories in a given path.Capabilities:Common use cases:
- List directory contents
- Support for glob patterns to ignore files
- Uses absolute paths
- Exploring directory structure
- Checking if directories exist
- Verifying file organization
CodeSearch
CodeSearch
Purpose: Search and get relevant context for programming tasks using Exa Code API.Capabilities:Common use cases:
- Provides high-quality, fresh context for libraries, SDKs, and APIs
- Returns comprehensive code examples and documentation
- Adjustable token count (1000-50000)
- Optimized for finding specific programming patterns
- Finding library usage examples
- Learning API patterns
- Discovering best practices
- Understanding framework concepts
Code Intelligence
Tools for advanced code analysis and navigation.LSP (Language Server Protocol)
LSP (Language Server Protocol)
Purpose: Interact with Language Server Protocol servers for code intelligence.Capabilities:Common use cases:
- Go to Definition: Find where symbols are defined
- Find References: Find all references to a symbol
- Hover: Get documentation and type information
- Document Symbol: Get all symbols in a document
- Workspace Symbol: Search for symbols across workspace
- Go to Implementation: Find interface implementations
- Call Hierarchy: Analyze function call relationships
- Incoming/Outgoing Calls: Map caller/callee relationships
- Understanding code structure
- Tracing function calls
- Finding symbol usages
- Code navigation and exploration
System Operations
Tools for executing commands and system operations.Bash
Bash
Purpose: Execute shell commands in a persistent bash session.Capabilities:Common use cases:
- Run terminal operations (git, npm, docker, etc.)
- Persistent shell session across commands
- Optional timeout configuration
- Support for workdir parameter to change directories
- Automatic output truncation for large outputs
- Running git commands
- Installing dependencies (npm, pip, etc.)
- Running tests and builds
- Executing scripts
- System diagnostics
- Use
workdirparameter instead ofcd && command - Quote paths with spaces
- Chain dependent commands with
&& - Use specialized tools for file operations instead of cat/grep/sed
Task Management
Tools for managing and tracking work.TodoWrite
TodoWrite
Purpose: Create and manage structured task lists for coding sessions.Capabilities:When to use:
- Create, update, and manage todo items
- Track task states (pending, in_progress, completed, cancelled)
- Organize complex multi-step tasks
- Provide progress visibility to users
- Complex multi-step tasks (3+ steps)
- Non-trivial and complex tasks
- User provides multiple tasks
- Planning and tracking implementation
pending: Task not yet startedin_progress: Currently working on (limit to ONE at a time)completed: Task finished successfullycancelled: Task no longer needed
TodoRead
TodoRead
Purpose: Read the current todo list for the session.Capabilities:When to use:
- View all todo items with their status
- Check progress on tasks
- Understand what work remains
- Beginning of conversations to see what’s pending
- Before starting new tasks to prioritize
- When uncertain about what to do next
- After completing tasks to see remaining work
Agent Orchestration
Tools for invoking specialized agents.Task
Task
Purpose: Launch specialized subagents to handle complex, multi-step tasks autonomously.Capabilities:Available subagents:
- Invoke General and Explore subagents
- Launch multiple agents concurrently
- Resume existing subagent sessions with task_id
- Execute custom slash commands
- General: Full tool access for complex tasks and research
- Explore: Read-only agent for fast codebase exploration
- Running multiple units of work in parallel
- Delegating complex research tasks
- Fast code exploration without modification risk
- Executing custom slash commands
- Launch multiple agents in parallel when possible
- Provide detailed task descriptions
- Specify what information should be returned
- Tell agents whether to write code or just research
Web Access
Tools for accessing external web content.WebFetch
WebFetch
Purpose: Fetch content from specified URLs.Capabilities:Common use cases:
- Fetch web content in markdown, text, or HTML format
- Automatic HTTPS upgrade for HTTP URLs
- Read-only operations
- Content summarization for large pages
- Reading documentation from websites
- Fetching API documentation
- Accessing online resources
- Reading blog posts or articles
WebSearch
WebSearch
Purpose: Search the web using Exa AI with real-time web searches.Capabilities:Common use cases:
- Real-time web searches for current information
- Configurable result counts
- Live crawling modes (fallback or preferred)
- Search types: auto, fast, or deep
- Domain filtering and advanced search options
- Finding current events and recent information
- Accessing information beyond knowledge cutoff
- Researching latest library versions
- Looking up recent API changes
User Interaction
Tools for gathering user input during execution.Question
Question
Purpose: Ask users questions during execution to gather preferences or clarify requirements.Capabilities:Common use cases:
- Present multiple choice questions
- Support for single or multiple selection
- Optional “Type your own answer” option (enabled by default)
- Recommend specific options
- Gathering user preferences
- Clarifying ambiguous instructions
- Getting decisions on implementation choices
- Offering choices for direction
Performance Optimization
Tools for efficient batch operations.Batch
Batch
Purpose: Execute multiple independent tool calls concurrently to reduce latency.Capabilities:Good use cases:
- Run 1-25 tool calls in parallel
- All calls start simultaneously
- Partial failures don’t stop other tool calls
- Significant efficiency gains (2-5x improvement)
- Reading many files
- Grep + glob + read combinations
- Multiple bash commands
- Multi-part edits on same or different files
- Operations depending on prior tool output
- Ordered stateful mutations where sequence matters
Configuration
Global Tool Configuration
Enable or disable tools globally in youropencode.json:
opencode.json
Per-Agent Tool Configuration
Override tool access for specific agents:opencode.json
Wildcard Tool Control
Use wildcards to control multiple tools at once:opencode.json
Agent-specific tool configurations override the global configuration.
Best Practices
Complete Tool List
Here’s a complete list of all available tools:| Tool | Category | Purpose |
|---|---|---|
read | File Operations | Read files and directories |
write | File Operations | Create or overwrite files |
edit | File Operations | Modify existing files |
multiedit | File Operations | Multiple edits in one file |
patch | File Operations | Apply structured patches |
glob | Code Search | Find files by pattern |
grep | Code Search | Search file contents |
list | Code Search | List directory contents |
codesearch | Code Search | AI-powered code search |
lsp | Code Intelligence | Language server operations |
bash | System Operations | Execute shell commands |
todowrite | Task Management | Create and manage todos |
todoread | Task Management | Read todo lists |
task | Agent Orchestration | Launch subagents |
webfetch | Web Access | Fetch web content |
websearch | Web Access | Search the web |
question | User Interaction | Ask user questions |
batch | Performance | Execute tools in parallel |