Zum Inhalt springen

Tools

Verwalte, welche Tools ein LLM nutzen darf.

Tools erlauben dem LLM Aktionen in deiner Codebasis. OpenCode bringt eingebaute Tools mit und laesst sich ueber Custom Tools oder MCP-Server erweitern.

Standardmaessig sind alle Tools aktiviert und brauchen keine Freigabe. Das Verhalten steuerst du ueber Berechtigungen.


Configure

Nutze das Feld permission, um Tool-Verhalten zu steuern. Pro Tool kannst du erlauben, verbieten oder eine Rueckfrage verlangen.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "deny",
"bash": "ask",
"webfetch": "allow"
}
}

Mit Wildcards kannst du mehrere Tools auf einmal steuern. Zum Beispiel, um fuer alle Tools eines MCP-Servers eine Freigabe zu verlangen:

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"mymcp_*": "ask"
}
}

Mehr dazu, wie du Berechtigungen konfigurierst.


Built-in

Hier sind alle in OpenCode verfuegbaren eingebauten Tools.


bash

Fuehrt Shell-Befehle in deiner Projektumgebung aus.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"bash": "allow"
}
}

Damit kann das LLM Terminal-Befehle wie npm install, git status oder andere Shell-Kommandos ausfuehren.


edit

Bearbeitet bestehende Dateien ueber exakte String-Ersetzungen.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "allow"
}
}

Dieses Tool fuehrt praezise Aenderungen per exakter Textsuche aus. Es ist der zentrale Weg, wie das LLM Code aendert.


write

Erstellt neue Dateien oder ueberschreibt bestehende Dateien.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "allow"
}
}

Damit erlaubst du dem LLM, neue Dateien anzulegen. Bestehende Dateien werden dabei ueberschrieben.


read

Read file contents from your codebase.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"read": "allow"
}
}

This tool reads files and returns their contents. It supports reading specific line ranges for large files.


grep

Search file contents using regular expressions.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"grep": "allow"
}
}

Fast content search across your codebase. Supports full regex syntax and file pattern filtering.


glob

Find files by pattern matching.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"glob": "allow"
}
}

Search for files using glob patterns like **/*.js or src/**/*.ts. Returns matching file paths sorted by modification time.


list

List files and directories in a given path.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"list": "allow"
}
}

This tool lists directory contents. It accepts glob patterns to filter results.


lsp (experimental)

Interact with your configured LSP servers to get code intelligence features like definitions, references, hover info, and call hierarchy.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"lsp": "allow"
}
}

Supported operations include goToDefinition, findReferences, hover, documentSymbol, workspaceSymbol, goToImplementation, prepareCallHierarchy, incomingCalls, and outgoingCalls.

To configure which LSP servers are available for your project, see LSP Servers.


patch

Apply patches to files.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "allow"
}
}

This tool applies patch files to your codebase. Useful for applying diffs and patches from various sources.


skill

Load a skill (a SKILL.md file) and return its content in the conversation.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"skill": "allow"
}
}

todowrite

Manage todo lists during coding sessions.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"todowrite": "allow"
}
}

Creates and updates task lists to track progress during complex operations. The LLM uses this to organize multi-step tasks.


todoread

Read existing todo lists.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"todoread": "allow"
}
}

Reads the current todo list state. Used by the LLM to track what tasks are pending or completed.


webfetch

Fetch web content.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"webfetch": "allow"
}
}

Allows the LLM to fetch and read web pages. Useful for looking up documentation or researching online resources.


websearch

Search the web for information.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"websearch": "allow"
}
}

Performs web searches using Exa AI to find relevant information online. Useful for researching topics, finding current events, or gathering information beyond the training data cutoff.

No API key is required — the tool connects directly to Exa AI’s hosted MCP service without authentication.


question

Ask the user questions during execution.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"question": "allow"
}
}

This tool allows the LLM to ask the user questions during a task. It’s useful for:

  • Gathering user preferences or requirements
  • Clarifying ambiguous instructions
  • Getting decisions on implementation choices
  • Offering choices about what direction to take

Each question includes a header, the question text, and a list of options. Users can select from the provided options or type a custom answer. When there are multiple questions, users can navigate between them before submitting all answers.


Custom tools

Mit Custom Tools definierst du eigene Funktionen, die das LLM aufrufen kann. Sie werden in der Konfigurationsdatei definiert und koennen beliebigen Code ausfuehren.

Mehr dazu, wie du Custom Tools erstellst.


MCP servers

MCP-Server (Model Context Protocol) binden externe Tools und Dienste ein. Dazu gehoeren Datenbanken, API-Integrationen und Drittanbieter-Services.

Mehr dazu, wie du MCP-Server konfigurierst.


Internals

Intern verwenden Tools wie grep, glob und list ripgrep. Standardmaessig beachtet ripgrep .gitignore, daher werden dort aufgefuehrte Dateien und Ordner nicht durchsucht.


Ignore patterns

Wenn du normalerweise ignorierte Dateien einschliessen willst, lege im Projekt-Root eine .ignore-Datei an. Dort kannst du Pfade explizit erlauben.

.ignore
!node_modules/
!dist/
!build/

Dieses Beispiel erlaubt ripgrep, in node_modules/, dist/ und build/ zu suchen, auch wenn sie in .gitignore stehen.