Every repo has a test that fails at 3 AM. It fails for a reason nobody documented. I used to comment it out and move on. Then I found a better ritual.
I send that failure to a free model. MonkeyCode currently offers free models and a free server. That is enough for a serious experiment. Disclosure: This article was prepared as part of MonkeyCode's product outreach.
But not any experiment. I don't ask for a fix directly. I ask for a root cause first. A failing test is a tiny specification. It tells the model what went wrong. The prompt should force explanation before action.
Why does that order matter? Because a patch without a diagnosis is a guess. A guess might pass one test. A guess will break a different test tomorrow. When the model explains first, it has to trace the data flow. That explanation is the part I can review.
So I built a small loop around my failing test list. The list comes from my last CI run. Each test name becomes a prompt. The prompt includes the failure output and asks for two sentences of root cause plus a diff.
while IFS= read -r test_id; do
cat > /tmp/model_prompt.txt <<EOF
Test $test_id fails with:
$(grep -A 10 "$test_id" target/test-reports/*.txt 2>/dev/null || true)
Explain the root cause in two sentences. Propose a minimal diff.
EOF
$MODEL_CMD < /tmp/model_prompt.txt > /tmp/model_patch.diff
git apply --check /tmp/model_patch.diff \
&& echo "$test_id: patch applies" \
|| echo "$test_id: patch rejected"
done < failing_tests.txt
The script is deliberately boring. MODEL_CMD is the command that talks to your chosen model. I use a free model for this step, so I can run it fifty times without watching a meter. The free server option matters too, because it keeps the queue off my laptop. My laptop is already busy running the test suite.
After the loop, I don't merge anything blindly. I run a second gate. For each applied patch, I rerun the original test. Then I read the diff as if a stranger wrote it.
That is where the acceptance table comes in.
| Condition | Verdict |
|---|---|
| Test passes after patch | Keep for human review |
| Root cause appears in the model's explanation | Trust a little more |
| Diff changes only one file | Read slowly, then keep |
| Diff changes imports or locks | Reject and ask for a second hypothesis |
| Model says "I cannot determine the cause" | Accept that answer. It is honest. |
The table is my own rule, not a law. You should build your own. The point is to make the decision repeatable. A free model becomes useful the moment you stop treating it as an oracle and start treating it as a fast intern who needs a checklist.
This ritual also exposes the cold start problem. Free servers often sleep between requests. The first prompt of the morning can take a minute before the model wakes up. That delay is annoying. It is also informative. If you plan to use a tool in an emergency, you need to know its wake-up time before the emergency.
So I schedule the loop every Monday. The script runs against last week's failed tests. The output lands in a file I skim with coffee. No dashboard, no hype, just a list of patches and verdicts.
Now, the limits. This approach is only for deterministic tests. It is not for architecture debates or design reviews. A pass/fail test has a clear answer. A UX question does not.
Do not paste secrets into the prompt. Do not feed it proprietary failure logs unless you trust the server. A free server is a shared resource. Treat it like a shared clipboard, not a vault.
And who should skip this? Anyone who has zero failing tests. If your suite is green and stays green, you don't need a model to fix what isn't broken. Also skip it if you are debugging a year-old monolith with no test isolation. The model will produce plausible diff after diff, and you will spend the afternoon saying no.
But for a normal project, this takes less than an hour. The free models handle the boring part. The free server runs the loop at 2 AM. The only thing left for me is deciding whether to trust the patch. That decision is mine, and the evidence is in the table.
Next time a test fails, don't shrug. Feed it to the free model and see what happens. At worst, you get a wrong patch and a laugh. At best, you get a diagnosis before your coffee is cold.
Top comments (0)