---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/operations/agent/how-tools-work.md
  - https://vibe.sourcecraft.dev/portal/docs/ru/code-assistant/operations/agent/how-tools-work.md
  - href: https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/operations/agent/how-tools-work.md
    type: text/markdown
    title: Markdown version
  - href: https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/llms.txt
    rel: describedby
title: How tools work in SourceCraft Code Assistant
description: Overview of SourceCraft Code Assistant tools for managing your code and environment, including reading, editing, running commands, and searching.
---
> **Documentation Index:** Fetch the complete configuration index at https://vibe.sourcecraft.dev/portal/docs/en/llms.txt


# How tools work in SourceCraft Code Assistant

<!-- source: en/_includes/code-assistant/only-in-vscode.md -->
{% note warning %}

This feature is only available in Visual Studio Code.

{% endnote %}
<!-- endsource: en/_includes/code-assistant/only-in-vscode.md -->

To interact with your code and environment, Code Assistant uses dedicated tools, i.e., specialized modules that perform specific actions such as reading files, making changes, running commands, or searching through code. These tools automate common development tasks requiring no manual effort.

## Working with tools {#how-tools-work}

In the chat interface, describe what you would like to do in natural language. Code Assistant will then:
1. Select the most appropriate tool based on your prompt.
1. Suggest the tool and its parameters for your approval.
1. Apply the approved tool and show you the results.
1. Repeat this process until your task is complete.

## Tool reference {#tool-reference}

| Tool name | Description | Category |
| --- | --- | --- |
| `read_file` | Reads file contents with line numbers. | Read |
| `search_files` | Searches for text or regex patterns in files. | Read |
| `list_files` | Lists files and directories in a specified location. | Read |
| `list_code_definition_names` | Gets a list of code definitions, e.g., classes or functions. | Read |
| `write_to_file` | Creates new files or overwrites existing ones. | Editor |
| `apply_diff` | Applies precise, targeted changes to specific parts of a file. | Editor |
| `execute_command` | Runs commands in the VS Code terminal. | Implementation |
| `web_fetch` | Gets the content of a web page or text resource by URL | Browser |
| `browser_action` | Performs actions in a web browser. | Browser |
| `ask_followup_question` | Asks a follow-up question. | Workflow |
| `attempt_completion` | Signals the task is complete. | Workflow |
| `switch_mode` | Switches to a different operation mode. | Workflow |
| `new_task` | Creates a new subtask with a specified starting mode. | Workflow |

### Getting content by URL using web_fetch {#web-fetch}

`web_fetch` runs a GET request against the specified URL and returns the text content of the resource. It automatically converts HTML pages to Markdown, while returning JSON and other text formats without conversion. Long content may get truncated.

The tool supports the following parameters:

* `url`: Resource URL stating the protocol, e.g., `https://example.com`. This is a required setting.
* `render`: Page rendering method. The default value of `false` is suitable for pages whose content can be accessed without executing JavaScript. If `true`, the page gets loaded in a headless browser, which is suitable for websites with dynamic content. This is an optional parameter.

`web_fetch` is for reading only and does not allow you to click buttons, fill out forms, or perform other interactive actions. Use `browser_action` for scenarios like that.

## Example of using tools {#example-usage}

Here is a typical tool workflow:

1. The user types a prompt in the chat: `Create a file named greeting.js that prints a welcome message.`
1. Code Assistant proposes the `write_to_file` tool.

    ```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>
    ```

1. The user clicks **Save** in the chat interface.
1. Code Assistant confirms the file has been created.

## Tool safety and approval {#tool-safety-and-approval}

Every tool invocation requires your explicit approval. When Code Assistant suggests a tool, you will see the following controls:
* **Approve**: Authorizes the action.
* **Reject**: Declines the proposed action.
* **Auto-approve**: Enables [auto-approval](https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/operations/agent/auto-approving-actions.md) for trusted actions. This is optional.

This security measure ensures you maintain full control over which files are modified, which commands are executed, and how your codebase evolves. Always carefully review tool proposals before approving them.
