Skip to content

azharmateen/git-heal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-heal

Built with Claude Code

AI-powered CLI that reads test failures, finds the bug, generates a fix, and optionally commits it.

PyPI License: MIT Python 3.9+

Your tests are red. You have a stack trace. You know the fix is probably one line. Let the AI find it.

git-heal --auto-run

Why git-heal?

  • Understands test runners - Auto-detects pytest, Jest, go test, cargo test. Parses their specific output formats to extract the exact error, file, and line.
  • Builds smart context - Reads the failing file, traces imports to find related files, and sends only the relevant code to the LLM. No wasted tokens.
  • Multiple LLM backends - OpenAI, Anthropic, or local Ollama. Use GPT-4o for speed, Claude for complex refactors, or Llama locally for free.

Quickstart

pip install git-heal

# Set your API key
export OPENAI_API_KEY=sk-...

# Auto-detect test runner, run tests, fix failures
git-heal --auto-run

# Paste an error directly
git-heal -e "TypeError: unsupported operand type(s) for +: 'int' and 'str'"

# Read error from file
git-heal -f test_output.log

# Use Claude instead of GPT
git-heal --auto-run -b anthropic

# Use local Ollama (free, no API key)
git-heal --auto-run -b ollama -m llama3.1

# Preview fix without applying
git-heal --auto-run --dry-run

Features

  • Auto-detection: Detects pytest, Jest, go test, cargo test from project files
  • Error parsing: Extracts error type, message, file, line number, and stack trace
  • Import tracing: Follows import/require statements to include related source files
  • Unified diff output: Generated fixes are standard unified diffs
  • Interactive apply: Review the diff, apply it, run tests to verify, then commit
  • Auto-commit mode: --auto-commit for CI/CD pipelines
  • Pipe-friendly: pytest 2>&1 | git-heal works

Architecture

Error Input (auto-run / paste / file / stdin)
       |
       v
  Error Parser (pytest / jest / go / rust / generic)
       |
       v
  Context Builder (source file + imports + stack trace)
       |
       v
  LLM Fix Generator (OpenAI / Anthropic / Ollama)
       |
       v
  Diff Applier (patch / git apply / manual)
       |
       v
  Test Verifier (re-runs test suite)
       |
       v
  Git Committer (optional)

Supported Test Runners

Runner Detection Error Parsing
pytest pytest.ini, conftest.py, pyproject.toml Traceback, assertion errors, error type
Jest jest.config.js, package.json Stack trace, expect/received
go test go.mod File:line:message format
cargo test Cargo.toml Compiler errors, test panics

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-parser)
  3. Install dev dependencies: pip install -e ".[dev]"
  4. Add tests in tests/
  5. Submit a pull request

License

MIT - see LICENSE for details.

About

Record, replay, and diff WebSocket sessions for debugging.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages