I kept alt-tabbing to ChatGPT, pasting the error, reading the fix, coming back to the terminal. Same 5 errors. 50 times a year.
So I built ai-fix.
Demo
$ python app.py
ModuleNotFoundError: No module named 'uvicorn'
$ ai-fix
✗ Failed: No module named 'uvicorn'
Fix (high confidence): uvicorn is not installed.
→ pip install uvicorn
Apply fix? [Y/n]: y
✓ Fixed! Command succeeded.
Install
pip install ai-fix
export ANTHROPIC_API_KEY=sk-ant-...
That's it. Now just type ai-fix after any failed command.
How it works
- Reads your last command from zsh/bash/fish history
- Re-runs it to capture the full error
- Sends error + context (OS, Python/Node version, project files present) to Claude Haiku
- Gets back exact fix commands — no prose, no explanation to decode
- Applies them, re-runs your original command to confirm
What it fixes
-
ModuleNotFoundError→pip install - Permission denied →
chmod +x - Port already in use →
lsof -ti:PORT | xargs kill -9 - Git push rejected →
git pull --rebase - Docker not running →
open -a Docker - npm/cargo/go build failures
Cost
~$0.0003 per fix (Claude Haiku). You'd need 3,000 fixes to spend $1.
Falls back to GPT-4o-mini if you have OPENAI_API_KEY instead.
Also works as a prefix
ai-fix npm run build # runs it, fixes it if it fails
ai-fix -y python app.py # skip confirmation
ai-fix --dry-run cargo build # see fix without applying
GitHub: https://github.com/anasmohiuddinsyed-bit/ai-fix
MIT license. Would love feedback on the confidence scoring.
Top comments (0)