Skip to main content
Glama

AutoFixAgent

IDE-grade automated refactoring agent — detect once, fix everywhere, deterministic-first.

AutoFixAgent receives a request like detect("UnnecessaryCast"), finds (or authors and caches) the cheapest capable detector and fixer, returns occurrences, and applies IntelliJ-grade deterministic fixes — verifying each batch compiles and passes tests before reporting success. AI writes the algorithms once; the cached algorithms do the rest.

  OpenCode / any MCP client / Gradle plugin / GitHub Action
                        │  MCP (stdio) · CLI
  ┌─────────────────────▼─────────────────────────────────┐
  │  Core (FastMCP + asyncio)                             │
  │  MCP tools · CLI verbs · Job manager                  │
  │  ┌──────────────┐   ┌───────────────────────────┐     │
  │  │ Rule registry│   │ AI author layer           │     │
  │  │ + artifact   │   │ (synthesize · self-verify)│     │
  │  │ cache        │   └───────────────────────────┘     │
  │  └──────┬───────┘                                     │
  │  ┌──────▼───────────────────────────────────────┐     │
  │  │ Engines: OpenRewrite (Java) · ast-grep       │     │
  │  │ (JS/TS +) · ts-morph sidecar · ESLint ·      │     │
  │  │ Joern (data flow, call graph)                │     │
  │  └──────────────────────────────────────────────┘     │
  │  Verification gate (worktree + build + test)          │
  │  Workspace Profile (derived + .autofix/config.yaml)   │
  │  Toolchain cache (~/.cache/autofixagent/tools)        │
  └───────────────────────────────────────────────────────┘

Why

IntelliJ can fix Unnecessary cast in one keystroke; CI tooling reports the same finding a thousand times and waits for humans. AutoFixAgent closes that gap:

  • Cache-first: the detect/fix algorithm for a rule is authored once (AI-assisted), verified against golden samples, and cached keyed by (rule, language, engine, engine_version). The second request is instant and deterministic.

  • Deterministic-first: engines run before the LLM. Occurrences are tagged deterministic | AI_ONLY; only the latter ever need a model.

  • Safe by construction: fixes apply on a branch in a temp git worktree, pass a compile/test gate, and come back as a diff with per-occurrence verdicts. The agent never mutates the caller's checkout and never installs anything into the target.

Related MCP server: CodePecker

Quickstart

pip install git+https://github.com/sleroy/autofix-agent.git

autofix-agent doctor -w /path/to/repo          # toolchain + workspace profile check
autofix-agent detect UseDiamondOperator -w /path/to/repo
autofix-agent fix UseDiamondOperator -w /path/to/repo --apply

MCP (OpenCode / any MCP client):

{
  "mcpServers": {
    "autofix-agent": {
      "command": "autofix-agent",
      "args": ["mcp"]
    }
  }
}

Tools: detect, fix, fix_batch, job_status, rules, explain, doctor. See docs/mcp.md for the contract.

Engines

Selection rule: the best engine per language — technologies multiply on purpose.

Language

Detect

Fix

Deep analysis

Java

OpenRewrite search recipes, PMD/Checkstyle

OpenRewrite recipes (Maven CLI goal / Gradle init-script — build files never touched), JavaParser LexicalPreservingPrinter for custom fixers

Joern (data flow, call graph)

JS/TS

ast-grep YAML rules, ESLint

ast-grep fix (node-range splice), ts-morph sidecar, ESLint --fix

Joern

Python

ast-grep / tree-sitter

LibCST (lossless concrete tree, codemod framework)

—

Others (Go, Kotlin, Rust, ...)

ast-grep (tree-sitter grammars)

ast-grep fix

—

Range-edit contract: every fix — engine or AI-authored — is expressed as ranged edits (start, end, replacement) spliced into the original text. Full-file rewrites are forbidden; comments, formatting and blame survive. See src/autofixagent/edits.py.

All engines are pinned and checksummed in ~/.cache/autofixagent/tools (see autofix-agent doctor, air-gap tarball supported).

Status

M0 — scaffold. Roadmap: M1 CLI detect+fix (ast-grep + OpenRewrite) → M2 MCP server → M3 verification gate → M4 AI author layer → M5 Gradle plugin → M6 GitHub Action → M7 Joern data-flow rules → M8 concurrency hardening.

License

Apache-2.0

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI clients to perform local code search, indexing, and analysis across Java, JavaScript/TypeScript, .NET/C#, and Python projects through the MCP protocol.
      1
      Apache 2.0
    • F
      license
      A
      quality
      Not graded
      maintenance
      MCP server that reviews and fixes code across four dimensions (security, standards, production readiness, sustainability), runs tests to verify fixes, and provides findings with diffs.
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides evidence-backed, transactional code refactoring for JavaScript/TypeScript and other languages via MCP, enabling semantic renames, signature changes, edits, and safe bulk operations with preview, atomic apply, and rollback.
      MIT