---
title: "CI Auto-Fix"
description: "Automatically fix CI failures on your pull requests."
section: "automation"
url: "https://forkline.dev/docs/automation/ci-auto-fix"
markdown: "https://forkline.dev/docs/automation/ci-auto-fix.md"
source: "src/content/docs/automation/ci-auto-fix.mdx"
---

# CI Auto-Fix

Automatically fix CI failures on your pull requests.

## Overview

CI auto-fix is designed for validation failures that are visible from logs and can be corrected with a focused repository change.

_Interactive figure (CiAutoFixDiagram) — see the HTML version of this page._

> **Info**: CI auto-fix requires webhook events for CI status such as check runs, pipeline events, or status updates.

> **Info**: On GitLab, CI auto-fix runs only for merge request pipelines. A pipeline that runs for a branch without a merge request is not fixed, so set up your GitLab CI to run pipelines for merge requests. The merge request number is used as the pull request number. CI auto-fix is skipped for merge requests from forks, for merge requests that are no longer open, and for pipelines that run in a project other than the target project.

## Supported CI Sources

Forkline works with any CI system that reports the right webhook signals, including:

- GitHub Actions
- GitLab CI
- Forgejo Actions
- External CI systems that emit supported status events

## Enabling CI Auto-Fix

1. Navigate to **Repositories**
2. Find your repository
3. Click **Settings** on the repository card
4. Select the **Automation** tab
5. Find **CI Auto-Fix**
6. Set the mode to **Enable**
7. Set **Maximum fix attempts per PR**
8. Click **Save**

## What It Usually Fixes Well

- Linting errors
- Type errors
- Straightforward test failures
- Build errors such as missing imports or syntax issues

## What Usually Needs Manual Intervention

- Complex failures that require product or business logic decisions
- Architecture-level problems
- Multi-file refactors without a clear local fix
- Infrastructure issues outside the repository
- External service failures

## Result Comments

### Starting

```markdown
🔧 CI Auto-Fix started

Detected failure in GitHub Actions workflow "Test".
Analyzing logs and generating fix...

Attempt 1/3
```

### Success

```markdown
✅ CI Auto-Fix completed

Fixed issue in src/utils/validation.ts:
- Updated email regex to reject consecutive dots
- Added test case for invalid email format

Commit: abc1234
```

## Maximum Attempts

When CI auto-fix reaches the maximum number of consecutive attempts for a PR without success, it stops automatically. This prevents infinite retry loops when issues cannot be fixed automatically.

When this happens, Forkline posts a comment indicating that CI auto-fix is paused:

```markdown
⏸️ CI Auto-Fix paused

Maximum consecutive fix attempts (3/3) reached for this PR without success.
CI auto-fix is now paused to prevent infinite retry loops.

You can:
- Review the CI logs and fix the issue manually
- Use `/reset` or `/reset-ci-auto-fix` to give CI auto-fix another chance after making changes

To configure the maximum attempts, go to **Repository Settings** > **Automation** > **CI Auto-Fix**.
```

You can configure the maximum attempts in repository settings under **Automation** > **CI Auto-Fix** > **Maximum fix attempts per PR**.

## Pausing and Resuming

### Automatic Pause

CI auto-fix automatically pauses when you push a commit to the PR branch after Forkline has pushed a fix. This prevents conflicts between your changes and automated fixes. This works on GitHub and Forgejo; on Forgejo, enable the **Push** trigger on the webhook (it only serves CI auto-fix, so it is optional otherwise).

> **Info**: On GitLab, pushing your own commit after an automated fix does not pause CI auto-fix, because Forkline does not act on push events from GitLab. Pausing after the maximum number of attempts works on all providers.

When this happens on GitHub, Forkline posts a comment indicating that CI auto-fix is paused (on Forgejo the pause is applied without a comment):

```markdown
⏸️ CI Auto-Fix paused

A user commit was detected after an automated fix. CI auto-fix is now paused
to prevent conflicts with your changes.

To resume CI auto-fix, use the `/reset` or `/reset-ci-auto-fix` command.
```

### Resuming with `/reset`

To resume CI auto-fix after it has been paused (either due to user commits on GitHub or Forgejo, or reaching maximum attempts), use the `/reset` command:

```markdown
@forkline /reset
```

You can also use the longer form `/reset-ci-auto-fix`:

```markdown
@forkline /reset-ci-auto-fix
```

Both commands do the same thing:
1. **Resets the attempt counter** - Clears the consecutive failure count back to zero
2. **Unpauses the automation** - Allows CI auto-fix to process new failures

> **Note**: After running `/reset-ci-auto-fix`, the bot immediately re-evaluates the current CI status for the PR. If CI is still failing, a new fix attempt starts right away — you don't need to wait for a new push or CI run. If CI is passing, no action is taken.

> **Note**: Like other commands, `/reset` and `/reset-ci-auto-fix` only work for users the repository's [trigger policy](https://forkline.dev/docs/automation/trigger-policies) allows.

### When to Use

Use `/reset` when:
- You've resolved the conflict that caused the pause and want CI auto-fix to continue monitoring
- CI auto-fix hit the maximum attempt limit, but you believe the issue can now be fixed (e.g., after you made manual changes)
- You want to give CI auto-fix another chance after manually addressing part of the problem

## Next Steps

- [Configure webhooks](https://forkline.dev/docs/automation/webhooks)
- [Learn about merge conflict auto-fix](https://forkline.dev/docs/automation/merge-conflicts)
