VasylEvery time I asked an AI to fix a bug, it rewrote my entire file. I'd ask: "fix the empty list check...
Every time I asked an AI to fix a bug, it rewrote my entire file.
I'd ask: "fix the empty list check on line 47."
The AI would return: 300 lines of "improved" code.
Half my carefully tuned logic — gone.
This happened to me one too many times. So I built something different.
Most AI coding assistants work like this:
Copilot, Cursor, and friends are great — but they all have this problem when you're working on existing code you care about.
I built AI Code Sherlock around one core idea:
The AI should only touch the exact block that needs changing.
Every response from the AI looks like this:
[SEARCH_BLOCK]
result = data[0]["value"]
[REPLACE_BLOCK]
if not data:
return None
result = data[0]["value"]
[END_PATCH]
The engine finds this exact string in your file, validates it appears exactly once, creates a backup, and replaces only that block. Nothing else is touched.
If the search block isn't found — or matches more than once — the patch is rejected. No silent corruption.
This is where it gets interesting.
You configure:
Then press Run and walk away.
The pipeline:
Real terminal output looks like this:
[PIPELINE] Iteration 3/10 strategy=SAFE_RATCHET goal="f1 > 0.85"
[RUN] python train_model.py → exit 0 (14.3s)
precision=0.71 recall=0.68 f1=0.69
[AI] Analysing metrics... building patch...
[APPLY] ✓ Patch applied · syntax OK · backup created
[RUN] python train_model.py → exit 0 (13.8s)
f1=0.73 ↑+0.04
[RATCHET] metrics improved — continuing to iteration 4...
Different problems need different approaches:
| Strategy | When to use |
|---|---|
| 🛡️ Conservative | Only fix explicit errors |
| ⚖️ Balanced | Fix + moderate improvements (default) |
| 🔥 Aggressive | Maximum changes, refactor logic |
| 🔒 Safe Ratchet | Apply only if metrics improve |
| 🧭 Explorer | Different approach every iteration |
| 🔬 Hypothesis | Form hypothesis → test → validate |
| 🎭 Ensemble | Generate 3 variants, pick best |
| 📈 Exploit | Double down on what worked |
No API key required. Just run:
ollama serve
ollama pull deepseek-coder-v2
And point AI Code Sherlock at localhost. Your code never leaves your machine.
It also supports OpenAI, Gemini, Groq, Mistral — any OpenAI-compatible endpoint.
Query multiple models at once and let them vote:
Every error gets stored with its confirmed solution. When the same error appears again, the AI sees: "this exact problem was fixed before — here's what worked."
Avoid-patterns prevent the AI from repeating approaches that already failed.
GitHub: https://github.com/signupss/ai-code-sherlock
Website: https://codesherlock.dev
git clone https://github.com/signupss/ai-code-sherlock.git
cd ai-code-sherlock
pip install -r requirements.txt
python main.py
Free and open source under MIT License.
Would love to hear what you think — especially if you've tried to build something similar or have ideas for the pipeline. What would make this useful for your workflow?