> ## Documentation Index
> Fetch the complete documentation index at: https://chatcli.edilsonfreitas.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fix tests with /coder

> Practical recipe: see how the AI uses the @coder plugin to fix tests autonomously.

In this recipe, you will see how the AI calls engineering tools (`@tool_call`) to fix tests.

<Steps>
  <Step title="The User Defines the Goal">
    Start `/coder` mode with a clear instruction about what needs to be fixed.

    ```bash theme={"system"}
    /coder fix the failing tests
    ```
  </Step>

  <Step title="The AI Investigates (ReAct Loop)">
    The AI analyzes the request and calls the plugin to run the tests and identify the errors:

    ```xml theme={"system"}
    <reasoning>
    Run go test to see errors.
    </reasoning>
    <tool_call name="@coder" args="{&quot;cmd&quot;:&quot;test&quot;,&quot;args&quot;:{&quot;dir&quot;:&quot;.&quot;}}"/>
    ```
  </Step>

  <Step title="ChatCLI Executes">
    The command result is returned to the AI. ChatCLI acts as an intermediary, executing the requested command and capturing the output.
  </Step>

  <Step title="The AI Continues (Reading)">
    Based on the errors found, the AI requests to read the problematic file:

    ```xml theme={"system"}
    <reasoning>
    Read the file with the error.
    </reasoning>
    <tool_call name="@coder" args="{&quot;cmd&quot;:&quot;read&quot;,&quot;args&quot;:{&quot;file&quot;:&quot;main.go&quot;}}"/>
    ```
  </Step>

  <Step title="Applying the Fix (Patch)">
    After analyzing the code, the AI generates and applies the necessary patch:

    ```xml theme={"system"}
    <reasoning>
    Apply patch to fix logic.
    </reasoning>
    <tool_call name="@coder" args="{&quot;cmd&quot;:&quot;patch&quot;,&quot;args&quot;:{&quot;file&quot;:&quot;main.go&quot;,&quot;encoding&quot;:&quot;base64&quot;,&quot;search&quot;:&quot;base64_old&quot;,&quot;replace&quot;:&quot;base64_new&quot;}}"/>
    ```
  </Step>
</Steps>

<Info>
  This entire flow happens autonomously within `/coder` mode. The AI executes a ReAct loop (Reason + Act) where each step informs the next, until all tests pass.
</Info>
