DEV Community

Cover image for I built a CLI that runs your CI locally and fixes failures with Claude Code
Robles.H.
Robles.H.

Posted on

I built a CLI that runs your CI locally and fixes failures with Claude Code

I built a CLI that runs your CI locally and fixes failures with Claude Code

Stitch is an open-source CLI that parses your existing GitLab CI / GitHub Actions / Bitbucket Pipelines config, runs the jobs locally in parallel, and when something fails, hands the error to Claude Code or Codex CLI to fix. Re-verifies, commits, pushes. No API keys. MIT.

The loop I wanted to kill

Every push to a branch triggers cloud CI. Cloud CI takes 8–15 minutes. When it fails (and ~30% of pushes fail something), I open the logs in a browser, fix locally, push again, wait another 12 minutes.

On a normal day, that's 30–60 minutes of waiting. On a bad day with a flaky job, it's an afternoon.

I tried the existing tools:

  • act runs GitHub Actions locally, but only GitHub, and it stops at "failed."
  • Gitar / Nx Cloud are SaaS platforms that intercept failures in remote CI. Each fix attempt = a remote CI cycle, and they want your pipelines on their platform.
  • Dagger + AI runs locally but expects you to rewrite every pipeline in their SDK.

None of them solved my actual problem: keep my existing config, run it on hardware I already own, and let the AI agent CLI I already pay for handle the fix loop.

What Stitch does

stitch run claude
  |
  |- parses .gitlab-ci.yml / .github/workflows/*.yml / bitbucket-pipelines.yml
  |- filters jobs (skips deploy, publish, docker-build)
  |- runs each job locally (subprocess with timeout)
  |
  |- job passes? next job
  |- job fails?
  |    |- spawns the AI agent CLI with the error log
  |    |- agent investigates and edits files
  |    |- re-runs the job to verify the fix
  |    |- repeat up to --max-attempts
  |
  |- reports results with a live TUI
Enter fullscreen mode Exit fullscreen mode

A few things that ended up mattering more than I expected:

Parallel execution by default

Wall-clock time is max(job_i) instead of sum(job_i). A 4-job pipeline takes as long as the slowest job, not all four added together.

Batch fixes

When multiple jobs fail together, Stitch sends all the errors to the agent in a single call. One missing import that breaks lint + typecheck + tests gets fixed once, not three times. Fewer tokens, fewer round-trips.

Re-verify, don't re-report

After the agent edits, Stitch re-runs the previously failed jobs to prove the fix actually worked. Up to --max-attempts per job. The fix loop closes only when the job is green.

Native Claude Code skill

Stitch ships with a Claude Code skill that auto-triggers at four moments:

  • Before every push. Ask Claude to push, commit, or open a PR — Stitch runs first.
  • End of a task. When Claude finishes implementing a feature, it runs Stitch as the last step.
  • Before marking a todo complete. If a TodoWrite item touches code, Claude runs Stitch first.
  • Context switch. If you pivot, Claude validates the previous change first.

Install once, never invoke again.

Pluggable agent CLI

Works with Claude Code or Codex CLI today. Uses whichever subscription you already have (Claude Pro, ChatGPT Plus). No Anthropic or OpenAI API key required. Cost of an extra fix: $0.

Watch mode

stitch run claude --watch --jobs lint,test
Enter fullscreen mode Exit fullscreen mode

Re-runs on every save (debounced). Auto-commits the green result. Walk away from your terminal, come back to a clean branch.

History that survives

Every run goes to .stitch/history.jsonl, safe to commit. Streaks compact (100 green runs = 1 line). Fixes never compact — every successful fix gets its own entry with the commit SHA. Syncs across machines naturally with the rest of the repo.

Quick start

Prerequisite: an agent CLI installed and logged in. Either Claude Code or OpenAI Codex CLI:

npm i -g @anthropic-ai/claude-code   # or @openai/codex
Enter fullscreen mode Exit fullscreen mode

Then:

npx stitch-agent doctor              # check setup
npx stitch-agent run claude          # run + fix
Enter fullscreen mode Exit fullscreen mode

Or install globally:

npm install -g stitch-agent
stitch run claude
Enter fullscreen mode Exit fullscreen mode

To install the Claude Code skill:

ln -s "$(npm root -g)/stitch-agent/skills/stitch" ~/.claude/skills/stitch
Enter fullscreen mode Exit fullscreen mode

Where it goes next

What's not in v1: CircleCI, Jenkins, Buildkite parsers. These are the most-requested already and on the near-term roadmap. PRs are very welcome.

Try it

If you have a CI config that you think would break the parser, drop it in an issue. I want to find the edge cases before users do.

MIT, no funding, no telemetry, no SaaS layer. Just a CLI that closes the loop.


Enter fullscreen mode Exit fullscreen mode

Top comments (0)