A regression landed on main last week. The agent-generated PR looked clean, and CI passed. Two days later, a test failed in production.
Nobody wanted to bisect by hand. This story repeats across teams in 2026. AI agents now write a growing share of pull requests.
Reviewers approve diffs, not runtime behavior. Regressions slip through review and reach main. Manual bisect is painfully slow.
It requires log2(n) checkouts for n commits. Each checkout needs a full build and a test run. Humans skip steps under pressure.
Flaky tests mislead everyone involved. This article shows a different path. A free coding model writes the bisect driver.
A free server runs the entire hunt. The laptop stays untouched. MonkeyCode is an open source project with a free tier.
That tier includes model access and a free server option. Disclosure: This article was prepared as part of MonkeyCode's product outreach.
Why Bisect Stalls
Bisect is the correct tool for this job. It finds the breaking commit in log2(n) steps. A 120-commit range needs about seven checks.
The problem is execution, not math. Every step needs a clean build. Every build needs a test run.
On a laptop, that means constant context switching. On a team, it means blame and delays. Automation fixes the process completely.
The machine performs every step. The human reads the final report.
Step 1: Define a Reliable Repro
Bisect needs exactly one command. That command must exit 0 for good commits. It must exit non-zero for bad commits. Everything else is noise.
Start with the failing test:
npm test -- --runInBand tests/regression.spec.ts
Run that command on current main. Confirm it fails consistently. Then check out the last known good tag. Confirm the same command passes there.
If the test is flaky, stop immediately. A flaky repro poisons every bisect step. Fix the flake before starting the hunt.
Step 2: Generate the Driver with a Free Model
The driver script is the core artifact of this workflow. git bisect run calls that script for every candidate commit. The script builds the project, runs the test, and reports the verdict.
A free coding model can write this driver in one pass. Give it the repo layout and the exact test command. Ask for a script that handles build failures gracefully.
Example prompt:
Write a bash script for git bisect run.
It must build this Node project and run one test file.
Exit 0 when the test passes.
Exit 1 when the test fails.
Exit 125 when the build fails.
Use set -euo pipefail.
The generated driver looks like this:
#!/usr/bin/env bash
set -euo pipefail
npm ci > /tmp/build.log 2>&1 || exit 125
npm test -- --runInBand tests/regression.spec.ts > /tmp/test.log 2>&1
Exit 125 tells git to skip a commit. That matters when a candidate cannot compile. A broken build is not a test failure.
Keep the prompt small. Long prompts invite irrelevant logic. Review the script before running it anywhere. The model can misread the repo structure. The build step must match the real toolchain. Test the driver against one known good commit first.
Step 3: Run the Hunt on a Free Server
A free server gives the hunt real isolation. The build cache stays warm between steps. The laptop stays free for other work. The process survives network drops.
Clone the repository and start the bisect:
git clone https://github.com/your-org/your-repo.git
cd your-repo
git bisect start
git bisect bad main
git bisect good v1.2.0
git bisect run ./bisect_driver.sh
A fresh clone avoids local state. Stale branches cause false verdicts. Use a terminal multiplexer for long builds. An SSH session can die during a heavy compile.
tmux new -s bisect
git bisect run ./bisect_driver.sh
Detach with Ctrl-b d. Reattach later with tmux attach -t bisect. The hunt continues while the laptop sleeps.
Step 4: Let the Model Read the Log
Bisect produces a short log at the end. The log names the breaking commit precisely. The diff still needs interpretation.
Paste the log into the free model. Ask for a ranked suspect list:
Here is a git bisect log.
The breaking commit is X.
List the files changed in commit X.
Rank which change is most likely to break tests/regression.spec.ts.
Explain each ranking in one sentence.
Treat the answer as a hypothesis, not a verdict. Read the diff yourself. Revert the suspect change. Re-run the test to confirm.
What This Workflow Costs
A 120-commit range needs about seven build cycles. Each cycle costs server time, not laptop time. The model reads logs at two points only. That keeps token usage low.
The free allowance covers this easily. Ten million free tokens handles hundreds of driver generations. Log reads cost a few thousand tokens each. The free server removes the hardware cost entirely.
The real cost is build time. A slow build makes every step expensive. Optimize the build before starting the hunt.
Limitations
The driver is only as good as the repro. A wrong test command produces a wrong verdict.
Flaky tests break bisect results. Use git bisect skip when a step looks unreliable.
Free servers have CPU limits. Large monorepos may time out. Scope the build to the affected package.
The model can hallucinate toolchain details. Verify the driver against a known good commit first.
Who Should Not Use This
Teams with hour-long builds should fix the build first. Bisect multiplies build time by seven or more.
Teams with chronically flaky tests should fix flakes first. Bisect amplifies test noise.
Projects needing GPUs or special hardware cannot run on a generic free server. Use a local runner instead.
Everyone else gains a repeatable process. The script is the durable artifact. The server makes the hunt disposable.
MonkeyCode's free tier is enough for this entire workflow. The project is open source, so the driver script stays yours. Run it against any git repository.
Top comments (0)