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

# Fix bugs with your coding agent

> Once it's set up, a loop sends each new bug to your coding agent. Your agent opens a pull request, and QA Wolf checks the fix on its preview.

## What you get

The **Fix new bugs** loop sends each new bug to your coding agent:

| | |
| - | - |
| **When** | A bug is reported. |
| **Then** | Run AI: `Fix the bug using /coding-agent. Keep the change small.` |

For each bug:

**Step 1**

The loop sends the bug to your agent, with the bug report, the failure, and links to the trace and the video.

**Step 2**

Your agent fixes the code and opens a pull request.

**Step 3**

QA Wolf runs the bug's flows on the preview of the pull request, and shows the result on the bug.

Set up one of the options below, then [create the loop](#fix-new-bugs-automatically). You can also select **Send to your coding agent** on one bug.

## Choose an option

| Option | Your agent runs in | QA Wolf needs |
| - | - | - |
| [Claude Code](#claude-code) | A Claude Code scheduled task. | No code access. |
| [Cursor](#cursor) | A Cursor automation. | No code access. |
| [GitHub](#github) | A GitHub Actions workflow in your repository: Claude Code, Codex, Cursor, or your own command. | [QA Wolf Code](https://docs.qawolf.com/github-code-access.md). |
| [GitLab](#gitlab) | A GitLab CI/CD job in your project: Claude Code, Codex, Cursor, or your own command. | The GitLab integration. |
| [Webhook](#webhook) | Warp, Devin, Factory, or your own service. | No code access. |

Each option has its own tab in **Settings > Coding agent**. Only an admin of the workspace's organization can change the setup. If **Settings > Coding agent** is missing, ask your QA Wolf representative.

> [!NOTE]
>
> Claude Code, Cursor, and Webhook share one saved webhook. While it is on, QA Wolf sends every fix of the workspace to it, and starts no GitHub workflow and no GitLab pipeline.

## Set it up from your agent

Each option starts with a prompt that you can paste into your coding agent, such as Claude Code, Codex, or Cursor. Your agent then sets up QA Wolf through the [QA Wolf MCP](https://docs.qawolf.com/qawolf-mcp.md), so you don't use the UI.

**Step 1**

Connect your agent to the [QA Wolf MCP](https://docs.qawolf.com/qawolf-mcp.md). Sign in as an admin of the workspace's organization. QA Wolf refuses a workspace API key and an organization API key for this setup.

**Step 2**

Paste the prompt of your option.

Your agent checks that you can change the setup, saves it, and sends a test. It then offers to create the [Fix new bugs](#fix-new-bugs-automatically) loop.

> [accordion] The MCP tools that your agent uses
>
> | Tool | What it does |
> | - | - |
> | `codingAgent_getWebhook` | Shows the host, the status, and the last four characters of the secret. |
> | `codingAgent_submitWebhook` | Saves the URL, with `format` and `triggerToken` for Claude Code or Cursor. The first save of a generic webhook returns the signing secret. |
> | `codingAgent_sendWebhookTest` | Sends a test and returns the answer of your endpoint. |
> | `codingAgent_rotateWebhookSecret` | Replaces the signing secret and returns the new secret. |
> | `codingAgent_removeWebhook` | Removes the webhook. |
>
> The agent gets each secret one time, and never prints it in chat.

## Claude Code

QA Wolf starts a [Claude Code scheduled task](https://code.claude.com/docs/en/routines) through its API trigger. Anthropic once called a scheduled task a routine.

**Ask your agent to set it up:**

```text theme={null}
Connect QA Wolf to my Claude Code scheduled task. I will give you its Fire URL and token. Save them as the QA Wolf coding agent webhook with the claude-code-routine format, and send a test.
```

**Or set it up yourself:**

**Step 1**

At [claude.ai/code/routines](https://claude.ai/code/routines), create a scheduled task, or open one and select **Edit**.

**Step 2**

In the **Trigger** row, choose **API**. To keep a schedule too, select **+** and add **API** as a second trigger.

**Step 3**

Save the task. Copy the **Fire URL** and the token. Claude shows the token one time.

**Step 4**

Write the task's instructions so that it acts on the text that it receives. For example: "Fix the bug that the routine-fire-payload block describes. Follow its instructions, and report to QA Wolf as it says."

**Step 5**

In the task's cloud environment, set **Network access** to **Limited** and add `app.qawolf.com` to **Allowed domains**, or select **Full**.

**Step 6**

In QA Wolf, open **Settings > Coding agent** and select the **Claude Code** tab.

**Step 7**

Enter the URL in **Fire URL** and the token in **Trigger token**, and select **Save**.

**Step 8**

Select **Send test**. A test starts a real session, and its text tells the agent to stop at once.

> [accordion] About the trigger token
>
> The task checks the trigger token, so QA Wolf signs nothing for Claude Code.
>
> * QA Wolf stores the token encrypted and shows only its last four characters.
> * Enter the token again each time you save.
> * QA Wolf sends the prompt as `{ "text": "<prompt>" }`, with the token as a bearer token. Claude marks the text as untrusted, so without step 4 the task doesn't act on the fix.
> * If the prompt is longer than 65,536 characters, QA Wolf sends a short text that tells the agent to [read the fix](#read-the-fix).
> * A scheduled task accepts 30 fires each hour, and a test counts as one. Each try that QA Wolf sends again starts a new session.

To run Claude Code in GitHub Actions or GitLab CI/CD instead, use [GitHub](#github) or [GitLab](#gitlab).

## Cursor

QA Wolf starts a [Cursor automation](https://cursor.com/docs/cloud-agent/automations) through its webhook trigger.

**Ask your agent to set it up:**

```text theme={null}
Set up QA Wolf to send new bugs to my Cursor automation. I will give you its webhook URL and auth key. Save them as the QA Wolf coding agent webhook with the cursor-automation format, and send a test.
```

**Or set it up yourself:**

**Step 1**

In Cursor, create an automation with a webhook trigger, and save it. Cursor shows the webhook URL, such as `https://api2.cursor.sh/automations/webhook/<id>`.

**Step 2**

Select **Generate auth header**, and copy the key.

**Step 3**

In QA Wolf, open **Settings > Coding agent** and select the **Cursor** tab.

**Step 4**

Enter the URL in **Webhook URL** and the key in **Trigger token**. You can paste the whole copied `Authorization: Bearer ...` line. Select **Save**.

**Step 5**

Select **Send test**. A test starts a real Cursor run, and its text tells the agent to stop at once.

> [accordion] About the trigger token
>
> The automation checks the trigger token, so QA Wolf signs nothing for Cursor.
>
> * QA Wolf stores the token encrypted and shows only its last four characters.
> * Enter the token again each time you save.
> * QA Wolf sends the prompt as `{ "context": "<prompt>" }`, with the key as a bearer token. The agent gets the text with the automation's prompt.

**Network:** Cursor cloud agents have internet access by default. If your Cursor team limits the network of cloud agents, allow `app.qawolf.com`.

## GitHub

QA Wolf starts a workflow in your repository, and your agent runs in it. You put any agent in the workflow: Claude Code, Codex, Cursor, or your own command.

**Ask your agent to set it up:**

```text theme={null}
Set up the QA Wolf coding agent workflow in this repository, and tell me which secret to add for my agent.
```

Paste it in each repository that the agent should fix bugs in.

**Or set it up yourself:**

**Step 1**

Open **Settings > Coding agent**, select the **GitHub** tab, and install QA Wolf Code. Only an owner of the GitHub organization can install it.

**Step 2**

Copy [`qawolf-coding-agent.yml`](https://github.com/qawolf/coding-agent-action/blob/main/workflow/qawolf-coding-agent.yml) to `.github/workflows/qawolf-coding-agent.yml` on your default branch. Keep the file name, because QA Wolf starts the workflow by this name.

**Step 3**

Add one repository secret from the table below. The first secret that is set picks the agent.

**Step 4**

Select **Check again**. The repository shows in the **Repositories** list with its agent.

| Agent | Secret |
| - | - |
| Claude Code | `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN` |
| Codex | `OPENAI_API_KEY` |
| Cursor | `CURSOR_API_KEY` |

To use your own command, set `AGENT: command` in the file and fill in the "Your command" step. For Claude Code or Codex with no stored key, see the federation steps in the [action's README](https://github.com/qawolf/coding-agent-action).

> [accordion] Why does this need code access?
>
> QA Wolf Code is QA Wolf's second GitHub app. It lets QA Wolf do three things that the workflow can't do alone:
>
> * **Start the workflow.** QA Wolf starts it for each fix with `actions: write`. It can't change code.
> * **Find the workflow.** QA Wolf reads your repository with `contents: read`, to find the workflow file and compare the fix branch with your default branch.
> * **Open the pull request.** The workflow pushes the fix branch, and QA Wolf opens the pull request with `pull_requests: write`. A workflow's own token can't open a pull request unless you allow it in your repository settings.
>
> [GitHub code access](https://docs.qawolf.com/github-code-access.md#permissions-of-qa-wolf-code) lists each permission of the app.

## GitLab

QA Wolf starts a job in your project, and your agent runs in it. You put any agent in the job: Claude Code, Codex, Cursor, or your own command.

**Ask your agent to set it up:**

```text theme={null}
Set up the QA Wolf coding agent job in this GitLab project, and tell me which variable and project settings to change.
```

Paste it in each project that the agent should fix bugs in.

**Or set it up yourself:**

**Step 1**

Connect GitLab to the workspace in **Settings > Integrations**.

**Step 2**

Paste the `qawolf-fix` job below into `.gitlab-ci.yml` on your default branch. Keep the job name, because QA Wolf finds the project by this name.

**Step 3**

In **Settings > CI/CD > Variables** of the project, add one agent key from the [GitHub](#github) table as a masked variable.

**Step 4**

In **Settings > CI/CD > Job token permissions**, turn on "Allow Git push requests to the repository".

**Step 5**

In **Settings > CI/CD > Variables**, set "Minimum role to use pipeline variables" to Maintainer or Developer.

**Step 6**

In QA Wolf, open **Settings > Coding agent**, select the **GitLab** tab, and select **Check again**.

**Check again** reads the CI file of each project and starts no pipeline. QA Wolf learns the agent when the first fix starts. A project with no key ends its first fix as not set up, and then shows "No agent key".

QA Wolf starts the fix pipeline on your default branch with the variable `QAWOLF_FIX`. Your other jobs also run in that pipeline, unless their rules skip a pipeline that the API starts.

> [accordion] The qawolf-fix job
>
> ```yaml theme={null}
> qawolf-fix:
>   rules:
>     - if: $QAWOLF_FIX
>   image: node:22
>   timeout: 1h
>   id_tokens:
>     QAWOLF_ID_TOKEN:
>       aud: https://app.qawolf.com
>   variables:
>     QAWOLF_URL: https://app.qawolf.com/api/v1/coding-agent/fixes/$QAWOLF_FIX
>     QAWOLF_PROMPT_FILE: /tmp/qawolf-prompt.md
>     QAWOLF_RESULT_FILE: /tmp/qawolf-result.json
>   script:
>     - |
>       if [ -n "$ANTHROPIC_API_KEY$CLAUDE_CODE_OAUTH_TOKEN" ]; then AGENT=claude-code
>       elif [ -n "$OPENAI_API_KEY" ]; then AGENT=codex
>       elif [ -n "$CURSOR_API_KEY" ]; then AGENT=cursor
>       else AGENT=none; fi
>     - |
>       curl -fsS --retry 5 "$QAWOLF_URL/start" -H "Authorization: Bearer $QAWOLF_ID_TOKEN" -H "Content-Type: application/json" -d "{\"agent\":\"$AGENT\"}" -o /tmp/qawolf-fix.json
>     - node -p 'require("/tmp/qawolf-fix.json").prompt ?? ""' > "$QAWOLF_PROMPT_FILE"
>     - BRANCH="qawolf/fix/$QAWOLF_FIX"
>     - git switch -c "$BRANCH"
>     - git config user.name "$GITLAB_USER_NAME" && git config user.email "$GITLAB_USER_EMAIL"
>     - |
>       case "$AGENT" in
>         claude-code) npx -y @anthropic-ai/claude-code -p --permission-mode acceptEdits --allowedTools Bash < "$QAWOLF_PROMPT_FILE" ;;
>         codex) CODEX_API_KEY="$OPENAI_API_KEY" npx -y @openai/codex exec --sandbox danger-full-access - < "$QAWOLF_PROMPT_FILE" ;;
>         cursor) curl -fsS https://cursor.com/install | bash && ~/.local/bin/agent -p --force "$(cat "$QAWOLF_PROMPT_FILE")" ;;
>         *) echo '{"status":"not_set_up"}' > "$QAWOLF_RESULT_FILE" ;;
>       esac
>     - |
>       if [ "$(node -p 'require(process.env.QAWOLF_RESULT_FILE).status')" = fixed ]; then
>         git add -A
>         git commit -m "$(node -p 'require(process.env.QAWOLF_RESULT_FILE).title')" || true
>         git push "https://gitlab-ci-token:$CI_JOB_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" "HEAD:refs/heads/$BRANCH"
>         node -e 'const fs = require("fs"); const [file, branch, headSha] = process.argv.slice(1); fs.writeFileSync(file, JSON.stringify({ ...JSON.parse(fs.readFileSync(file, "utf8")), branch, headSha }))' "$QAWOLF_RESULT_FILE" "$BRANCH" "$(git rev-parse HEAD)"
>       fi
>   after_script:
>     - |
>       test -f "$QAWOLF_PROMPT_FILE" || exit 0
>       test -f "$QAWOLF_RESULT_FILE" || echo '{"status":"failed","summary":"The job ended without a result"}' > "$QAWOLF_RESULT_FILE"
>       curl -fsS --retry 5 "$QAWOLF_URL/events?type=finished" -H "Authorization: Bearer $(node -p 'require("/tmp/qawolf-fix.json").token')" -H "Idempotency-Key: $CI_JOB_ID" -H "Content-Type: application/json" --data-binary @"$QAWOLF_RESULT_FILE"
> ```

> [accordion] Why does this need the GitLab integration?
>
> The integration's token lets QA Wolf do three things that the job can't do alone:
>
> * **Find the job.** QA Wolf reads `.gitlab-ci.yml` of each project to find the `qawolf-fix` job.
> * **Start the pipeline.** QA Wolf starts it for each fix with the variable `QAWOLF_FIX`, so the project must allow pipeline variables.
> * **Open the merge request.** The job pushes the fix branch with its job token, and QA Wolf opens the merge request.

## Webhook

For a custom setup. QA Wolf posts each fix to your HTTPS endpoint, signs each request, and needs no access to your code. These agents work with the webhook alone:

| Agent | How it checks the request |
| - | - |
| [Warp](https://docs.warp.dev/factories/webhooks/) | A webhook trigger with **Provider signature** authentication and the Standard Webhooks scheme. With the default bearer token, Warp answers `401`. |
| [Devin](https://docs.devin.ai/product-guides/automations) | An automation with a webhook trigger. Put its secret in the URL: `?secret=<secret>`. |
| [Factory](https://docs.factory.com/automations/custom.md) | A custom webhook automation. Put its secret in the URL: `?secret=<secret>`. |
| Your own service | [Check the signature](#check-the-signature). |

**Ask your agent to set it up:**

```text theme={null}
Set up QA Wolf to send bugs to my coding agent through the QA Wolf coding agent webhook. I will give you its webhook URL. Save it, store the signing secret where the agent checks it, and send a test.
```

**Or set it up yourself:**

**Step 1**

Open **Settings > Coding agent** and select the **Webhook** tab.

**Step 2**

Enter the HTTPS URL of your agent's trigger in **Endpoint URL** and select **Save**. The URL must not include a username or password, and must resolve to a public internet address.

**Step 3**

Copy the signing secret. QA Wolf shows it one time.

**Step 4**

Store the secret where your agent's trigger or your service checks the signature. Devin and Factory don't check it, because their secret is in the URL.

**Step 5**

Select **Send test**. A test to Warp, Devin, or Factory starts a real run of your agent. Your own service must start no agent for a request with `"test": true`.

**Network:** your agent must reach `https://app.qawolf.com` to [report back](#the-callback). If its sandbox limits outbound traffic, allow `app.qawolf.com`.

### Build your own service

**Step 1**

Build an HTTPS endpoint that [checks the signature](#check-the-signature) and answers `2xx` within 10 seconds.

**Step 2**

After the answer, start your agent with the `prompt` from the request.

**Step 3**

Have your agent [report back](#the-callback) with the fix token from the request.

### The request

QA Wolf sends one `POST` request for each fix, with a JSON body.

| Header | Value |
| - | - |
| `content-type` | `application/json`. |
| `user-agent` | `QAWolf-Webhooks/1.0 (+https://www.qawolf.com)`. |
| `webhook-id` | The ID of the fix. The same on each try. |
| `webhook-timestamp` | The time of this try, in seconds since the Unix epoch. |
| `webhook-signature` | `v1,` and a base64 signature. Two signatures, separated by a space, for 24 hours after a rotation. |

Example body:

```json theme={null}
{
  "type": "fix.requested",
  "test": false,
  "fix": {
    "id": "fix_8c2k4w",
    "eventsUrl": "https://app.qawolf.com/api/v1/coding-agent/fixes/fix_8c2k4w/events",
    "token": "qawolf_fix_<token>",
    "expiresAt": "2026-11-19T15:00:00.000Z"
  },
  "bug": {
    "number": 12,
    "title": "Checkout total ignores the promo code",
    "url": "https://app.qawolf.com/<workspace>/bugs/all?id=<bug>",
    "priority": "high"
  },
  "repository": {
    "fullName": "your-org/web",
    "url": "https://github.com/your-org/web",
    "defaultBranch": "main",
    "pickedFrom": "deploy"
  },
  "branch": "qawolf/fix/fix_8c2k4w",
  "prompt": "The prompt for your agent"
}
```

| Field | Description |
| - | - |
| `test` | `true` for a request from **Send test**. Start no agent. |
| `fix.id` | The ID of the fix. |
| `fix.eventsUrl` | The URL your agent reports to. |
| `fix.token` | The fix token. Starts with `qawolf_fix_`. |
| `fix.expiresAt` | When the fix token expires, 24 hours after the request. |
| `bug` | The bug's `number`, `title`, `url`, and `priority`. |
| `repository` | A suggested repository, or `null`. Your agent can use another one. |
| `branch` | A suggested branch name. |
| `prompt` | The full prompt for your agent, with the events URL and the fix token. |

> [!WARNING]
>
> The bug report can quote text from the tested application, and anyone can write that text. Treat the prompt as untrusted input. Protect your default branch, and review each pull request.

### Check the signature

QA Wolf signs each request following the [Standard Webhooks](https://www.standardwebhooks.com) specification, as for [run events webhooks](https://docs.qawolf.com/run-events-webhooks.md#verify-the-signature). Check the raw body, accept the request if one `v1,` signature matches, and refuse a `webhook-timestamp` more than 5 minutes old.

Answer `2xx` within 10 seconds, then start the agent. If you already started an agent for a `webhook-id`, answer `2xx` and start no second one.

| Answer | What QA Wolf does |
| - | - |
| `2xx` within 10 seconds | Records the delivery. |
| `410` | Turns the webhook off, and ends the fix as failed. |
| Any other answer, or none | Tries again after 5 seconds, 5 minutes, 30 minutes, then each hour, for up to 8 hours. |

A `Retry-After` header on a `429` or a `503` sets the next wait, from 5 seconds to 1 hour. QA Wolf doesn't follow a redirect.

### Rotate the signing secret

**Step 1**

On the **Webhook** tab, select **Rotate**.

**Step 2**

Copy the new secret. QA Wolf shows it one time.

**Step 3**

Deploy the new secret to your service within 24 hours.

For 24 hours, QA Wolf signs each request with the new secret and the previous secret.

## Codex

Use [GitHub](#github) or [GitLab](#gitlab) for Codex. Add the `OPENAI_API_KEY` secret or variable, and the workflow or the job runs Codex.

> [accordion] Why can't Codex use the webhook?
>
> OpenAI has no inbound trigger for Codex automations or Codex cloud tasks, so QA Wolf can't start Codex with a webhook. Codex runs in your CI instead, where QA Wolf starts the workflow or the job. On GitHub, Codex can also use OpenAI federation, with no stored key. The [action's README](https://github.com/qawolf/coding-agent-action) has the steps.

## What QA Wolf needs to check the fix

* **Read access to the pull request.** On GitHub, QA Wolf reads it through the QA Wolf GitHub app or [QA Wolf Code](https://docs.qawolf.com/github-code-access.md). On GitLab, QA Wolf reads the merge request through the GitLab integration. Without it, the bug shows the link to the pull request, and QA Wolf runs no check.
* **A deployment of the pull request.** Your code host or your deploy job reports the preview to QA Wolf. See [PR testing](https://docs.qawolf.com/deployment-testing/pr-testing.md). QA Wolf waits up to 2 hours for it, and doesn't run flows on a preview URL that the agent reports.

The check is a run, and it uses credits.

## Fix new bugs automatically

**Step 1**

Create a [loop](https://docs.qawolf.com/loops/overview.md) that starts on **A bug** **is reported**, with **Run AI**.

**Step 2**

Under **Start from:**, pick **Fix new bugs**. The instructions become `Fix the bug using /coding-agent. Keep the change small.`

**Step 3**

Select **Create loop**.

The `/coding-agent` command tells the loop's session to send the bug to your agent. You can use it in your own instructions. See [Run AI](https://docs.qawolf.com/loops/run-ai.md#write-instructions). Until a coding agent is set up, the loop doesn't save.

A bug has one open fix. A second request for the same bug joins the open fix. A loop starts the first fix only. When the check still shows the bug, open the bug and select **Try again** to send your agent one more try.

## The callback

Your agent reports with `POST` requests to `fix.eventsUrl`, with the header `Authorization: Bearer <fix token>`. The prompt tells your agent how to do this. Each event has an `id` that you make, such as a UUID, and a `type`. QA Wolf records each `id` one time, so you can send an event again safely. QA Wolf accepts 60 calls each minute for a fix.

| Event | When to send it |
| - | - |
| `working` | While the agent works. Optional `agent` and `url` show on the bug as a link to the agent's run. QA Wolf ends a fix with no event for 2 hours. |
| `finished` | When the agent is done. `status` is `fixed`, `no_fix`, or `failed`. |

Example:

```json theme={null}
{
  "id": "0b9d1c7e-2d3a-4f0e-8a51-6f0f7c1f2b90",
  "type": "finished",
  "status": "fixed",
  "pullRequestUrl": "https://github.com/your-org/web/pull/482",
  "summary": "The total ignored the promo code. The fix applies the discount before tax."
}
```

A `fixed` event must include `pullRequestUrl`. For `no_fix` and `failed`, give the reason in `summary`.

If your agent can't call the endpoint, put this line in the pull request description: `Fixes QA Wolf Bug #<number>: <bug URL>`. QA Wolf then finds the pull request by this line. QA Wolf ignores the line on a pull request from a fork.

### Read the fix

`GET` the fix's URL, `fix.eventsUrl` without `/events`, with the same `Authorization` header. It returns the `branch`, the `prompt`, and the `state` of the fix: `sent`, `fixing`, `pull-request-open`, `no-fix`, or `failed`. Use it when the prompt doesn't fit where your agent starts.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.