Back to Kilocode

How Tools Work

packages/kilo-docs/pages/automate/how-tools-work.md

7.3.427.2 KB
Original Source

How Tools Work

Kilo Code uses tools to interact with your code and environment. These specialized helpers perform specific actions like reading files, making edits, running commands, or searching your codebase. Tools provide automation for common development tasks without requiring manual execution.

Tool Workflow

Describe what you want to accomplish in natural language, and Kilo Code will:

  1. Select the appropriate tool based on your request
  2. Present the tool with its parameters for your review
  3. Execute the approved tool and show you the results
  4. Continue this process until your task is complete

Tool Categories

{% tabs %} {% tab label="VSCode" %}

CategoryPurposeTool Names
ReadAccess file content and code structureread, glob, grep
EditCreate or modify files and codeedit, write, apply_patch
ExecuteRun commands and perform system operationsbash
WebFetch and search web contentwebfetch, websearch, codesearch
WorkflowManage task flow and sub-agentsquestion, task, todowrite, todoread, plan, skill

{% /tab %} {% tab label="VSCode (Legacy)" %}

CategoryPurposeTool Names
ReadAccess file content and code structureread_file, search_files, list_files, list_code_definition_names
EditCreate or modify files and codeapply_diff, delete_file, write_to_file
ExecuteRun commands and perform system operationsexecute_command
BrowserInteract with web contentbrowser_action
WorkflowManage task flow and contextask_followup_question, attempt_completion, switch_mode, new_task

{% /tab %} {% /tabs %}

Example: Using Tools

Here's how a typical tool interaction works:

{% tabs %} {% tab label="VSCode" %}

{% callout type="info" title="Tool Approval UI" %} When a tool is proposed, you'll see an approval prompt in the Permission Dock at the bottom of the chat. You can approve once, approve always (saves to config), or deny. {% /callout %}

User: Create a file named greeting.js that logs a greeting message

Kilo Code: (Proposes the write tool)

The extension shows the file path and proposed content for review. Click Approve to execute or Deny to cancel.

{% /tab %} {% tab label="VSCode (Legacy)" %}

{% callout type="info" title="Tool Approval UI" %} When a tool is proposed, you'll see Save and Reject buttons along with an optional Auto-approve checkbox for trusted operations. {% /callout %}

User: Create a file named greeting.js that logs a greeting message

Kilo Code: (Proposes the write_to_file tool as shown in the image above)

xml
<write_to_file>
<path>greeting.js</path>
<content>
function greet(name) {
  console.log(`Hello, ${name}!`);
}

greet('World');
</content>
<line_count>5</line_count>
</write_to_file>

User: (Clicks "Save" in the interface)

Kilo Code: (Confirms file creation)

{% /tab %} {% /tabs %}

Tool Safety and Approval

{% tabs %} {% tab label="VSCode" %}

Every tool use is subject to a permission check. The default action for any tool with no matching rule in your config is ask — meaning Kilo will pause and prompt you before executing it.

Default permissions by tool:

Tool(s)Default
read, glob, grepask
edit, write, apply_patchask
bashask (per-command)
external_directoryask (when accessing paths outside the project)
taskask
webfetch, websearch, codesearchask
todowrite, todoread, question, skillask

No tools are auto-approved out of the box. You must explicitly grant allow in your config, or approve them at runtime.

At runtime, the Permission Dock floating UI in the chat panel shows each pending approval. For each tool call you can:

  • Approve once — execute this call only
  • Approve always — save an allow rule to your config so future matching calls are auto-approved
  • Deny — cancel the tool call

To pre-configure permissions in your config file:

json
{
  "permission": {
    "read": "allow",
    "glob": "allow",
    "grep": "allow",
    "edit": "ask",
    "bash": "ask"
  }
}

This safety mechanism ensures you maintain control over which files are modified, what commands are executed, and how your codebase is changed.

{% /tab %} {% tab label="VSCode (Legacy)" %}

Every tool use requires your explicit approval. When Kilo proposes a tool, you'll see:

  • A "Save" button to approve and execute the tool
  • A "Reject" button to decline the proposed tool
  • An optional "Auto-approve" setting for trusted operations

This safety mechanism ensures you maintain control over which files are modified, what commands are executed, and how your codebase is changed. Always review tool proposals carefully before saving them.

{% /tab %} {% /tabs %}

Core Tools Reference

{% tabs %} {% tab label="VSCode" %}

Tool NameDescriptionCategory
readReads file contents with line numbersRead
globFinds files by glob patternRead
grepSearches file contents with regexRead
editMakes precise text replacements in a fileEdit
writeCreates new files or overwrites existing onesEdit
apply_patchApplies unified diffs (used with certain models)Edit
bashRuns shell commandsExecute
webfetchFetches a URLWeb
websearchSearches the web (Kilo/OpenRouter users)Web
codesearchSemantic code search (Kilo/OpenRouter users)Web
questionAsks you a clarifying question with selectable optionsWorkflow
taskSpawns a sub-agent sessionWorkflow
todowriteCreates and updates a session TODO listWorkflow
todoreadReads the current session TODO listWorkflow
planEnters structured planning modeWorkflow
skillInvokes a reusable skill (Markdown instruction module)Workflow

{% /tab %} {% tab label="VSCode (Legacy)" %}

Tool NameDescriptionCategory
read_fileReads the content of a file with line numbersRead
search_filesSearches for text or regex patterns across filesRead
list_filesLists files and directories in a specified locationRead
list_code_definition_namesLists code definitions like classes and functionsRead
write_to_fileCreates new files or overwrites existing onesEdit
apply_diffMakes precise changes to specific parts of a fileEdit
delete_fileRemoves files from the workspaceEdit
execute_commandRuns commands in the VS Code terminalExecute
browser_actionPerforms actions in a headless browserBrowser
ask_followup_questionAsks you a clarifying questionWorkflow
attempt_completionIndicates the task is completeWorkflow
switch_modeChanges to a different operational modeWorkflow
new_taskCreates a new subtask with a specific starting modeWorkflow

{% /tab %} {% /tabs %}

Learn More About Tools

For more detailed information about each tool, including complete parameter references and advanced usage patterns, see the Tool Use Overview documentation.