Open Source · MIT License

Your CI breaks.
Stitch fixes it.

An AI agent that autonomously detects, diagnoses, and patches CI pipeline failures. Drop two jobs into your config. That's it. No servers, no setup, no babysitting.

$ pip install stitch-agent
150+
Error Patterns
9
Error Types
0
Servers to Deploy
2
CI Jobs Needed

Everything your CI pipeline needs to self-heal

Stitch catches what slips through code review — lint errors, type mismatches, broken tests — and fixes them before you even notice.

Safe by Design

Every patch is validated before pushing. Rejects changes that rewrite too much, modify signatures, or add dependencies.

Zero Infrastructure

Runs as a CI job, not a separate service. No servers to deploy, no webhooks to configure, nothing to maintain.

Any Model, Any Provider

Powered by OpenRouter with access to 200+ models. Simple errors use a fast, cheap model; complex issues escalate automatically. You choose the best price/performance ratio.

150+ Error Patterns

Regex-based classification engine covers lint, format, type errors, broken tests, build failures, and more.

Human Escalation

When Stitch can't fix it, your team gets notified via Slack or webhook. No fix is ever forced through silently.

Per-Repo Config

Customize behavior with .stitch.yml — set languages, linters, models, conventions, validation thresholds, and notification channels.

Cost Transparent

Every fix reports exact token usage and real cost in USD. No estimates — actual amounts charged, fetched directly from the API.

Multi-Platform

GitLab and GitHub, including self-hosted instances. Auto-detects your platform from CI environment variables.

Three phases. Fully automatic.

From failure detection to pull request — Stitch handles the entire loop without human intervention.

Detect & Fix

CI fails. Stitch reads the logs, classifies the error across 150+ patterns, and generates a minimal, safe patch via OpenRouter.

Verify

The fix is pushed to a stitch/fix-* branch. CI runs again on the new branch. If it passes, a PR is created automatically.

Retry or Escalate

If the fix fails, Stitch retries with a stronger model. After max attempts, it escalates to your team via Slack or webhook.

Two jobs. That's the setup.

Add two CI jobs to your existing pipeline. Stitch runs as a post-stage and handles everything else.

.github/workflows/stitch.yml
on:
  workflow_run:
    workflows: ["*"]
    types: [completed]

jobs:
  fix:
    if: github.event.workflow_run.conclusion == 'failure'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install stitch-agent
      - run: stitch ci
        env:
          STITCH_OPENROUTER_API_KEY: ${{ secrets.STITCH_OPENROUTER_API_KEY }}
          STITCH_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
.gitlab-ci.yml
# Job 1: Fix failures on normal branches
stitch-fix:
  stage: .post
  when: on_failure
  image: python:3.12-slim
  except:
    refs:
      - /^stitch\//
  script:
    - pip install stitch-agent
    - stitch ci

# Job 2: Verify fixes on stitch branches
stitch-check:
  stage: .post
  when: always
  image: python:3.12-slim
  only:
    refs:
      - /^stitch\//
  script:
    - pip install stitch-agent
    - stitch ci

Knows what broke and why

A weighted regex engine classifies errors across 9 categories with confidence scoring, so each fix uses the right strategy.

Lint Errors

Unused imports, style violations, naming conventions

Formatting

Indentation, whitespace, line length issues

Type Errors

Missing annotations, basic type mismatches

Build Failures

Missing dependencies, import errors, module resolution

CI Config

YAML syntax, missing variables, broken pipelines

Test Contracts

Broken assertions, mock mismatches, expected outputs

Complex Types

Generic inference, conditional types, advanced TS

Logic Errors

Off-by-one, incorrect conditions, wrong operators

Unknown

Unclassified errors escalated for human review

Guardrails, not guardropes

Every patch is programmatically validated before it ever touches your codebase. Stitch rejects anything that looks risky.

Diff Ratio Guard

Rejects patches that rewrite more than 40% of any file

Signature Protection

Won't modify function signatures or remove exports

Import Lockdown

Blocks patches that add new dependencies or imports

File Limits

Maximum 5 files and 200 lines changed per fix

No Deletions

Never deletes files — only modifies existing code

.stitch.yml
languages: [python, typescript]
linter: ruff
test_runner: pytest
max_attempts: 3

models:
  classifier: google/gemini-2.5-flash-lite
  light: google/gemini-2.5-flash-lite
  heavy: google/gemini-2.5-flash

validation:
  max_diff_ratio: 0.40
  max_files_changed: 5
  max_lines_changed: 200
  block_new_imports: true
  block_signature_changes: true
  block_export_removal: true

conventions:
  - "Always use explicit return types"
  - "Never downgrade dependency versions"

notify:
  channels:
    - type: slack
      webhook_url: https://hooks.slack.com/...

Use it as a library too

Beyond CI integration, Stitch exposes a clean async Python API for custom workflows and automation.

example.py
import asyncio, os
from stitch_agent import StitchAgent, FixRequest
from stitch_agent.adapters.github import GitHubAdapter

adapter = GitHubAdapter(token=os.environ["GITHUB_TOKEN"])
agent   = StitchAgent(
    adapter,
    api_key=os.environ["OPENROUTER_API_KEY"],
    base_url="https://openrouter.ai/api/v1",
)

async def main():
    request = FixRequest(
        platform="github",
        project_id="x24labs/my-app",
        pipeline_id="9876",
        job_id="1234",
        branch="main",
    )
    async with adapter:
        result = await agent.fix(request)

    print(result.status)    # 'fixed' | 'escalate' | 'error'
    print(result.mr_url)    # PR URL if fixed

asyncio.run(main())

Stop babysitting
your pipeline

Install Stitch in under a minute. Let your CI heal itself while you ship what matters.