OpenCode: OpenCode Built-in Tools
Last updated: 2026-08-31
--- title: OpenCode Built-in Tools description: Understand the built-in tool system including file operations, Shell execution, and search order: 11 lang: en
OpenCode's power comes from its built-in tool system—AI calls tools to execute specific operations.
1. What You Will Learn
- Built-in tool overview
- File operation tools
- Shell execution tool
- Search and analysis tools
- Tool configuration and permissions
2. Built-in Tool Overview
| Tool | Function | Permission Level |
|---|---|---|
read |
Read file content | Read-only |
write |
Write/create files | Write |
edit |
Edit/patch files | Write |
bash |
Execute Shell commands | Execute |
grep |
Search file content | Read-only |
glob |
Find files by pattern | Read-only |
list |
List directory contents | Read-only |
webfetch |
Fetch web content | Network |
task |
Call sub-agents | Agent |
3. File Operation Tools
- read: AI auto-reads project files for context
- write: Create new files or overwrite existing ones
- edit: Precisely modify file content using search+replace
4. Shell Execution Tool
Execute any Shell command:
TEXT
📖 Display only
Run npm test and analyze the failing tests
AI will: execute the command → analyze errors → locate problems → suggest fixes → can modify code directly.
5. Search and Analysis Tools
- grep: Search file content across the project
- glob: Find files by name patterns
- list: List directory structure
6. Tool Configuration
Global toggles:
JSON
{
"tools": {
"write": true,
"edit": true,
"bash": true,
"webfetch": false
}
}
Agent-level:
JSON
{
"agent": {
"review": {
"tools": {
"write": false,
"edit": false
}
}
}
}
Permission values: allow (auto), ask (confirm), deny (reject)
❓ FAQ
Q How to prevent AI from executing dangerous operations?
A Set bash permission to ask or deny. Use Glob patterns for fine control: allow
git status, deny rm -rf.Q AI made wrong modifications?
A Use /undo immediately. Recommend setting edit and write permissions to ask for confirmation before changes.
Q Alice allows all tools, Bob only allows read-only—who's safer?
A Bob. Read-only configuration prevents AI from making any modifications—ideal for code review. Alice's setup is more efficient but riskier.
📖 Summary
- Built-in tools: read, write, edit, bash, grep, glob, list, webfetch, task
- Permission levels: allow, ask, deny
- Configurable at global and agent levels
- Bash permissions support Glob pattern fine control
- Extend more tools via MCP
📝 Exercises
-
Basic: Configure tool permissions in opencode.json, set edit to ask.
-
Intermediate: Create a read-only agent with all write/execute tools disabled.
-
Advanced: Use Glob patterns to allow git operations but deny rm and other dangerous commands.