Skip to content

bisection

When reasoning stalls, *search*. Halving the problem space repeatedly finds the culprit in log₂(N) steps instead of N. Bisection applies to three spaces: **history** (which commit), **code** (which statement), and **input** (which data).

From plugin
vanara-agents-skills
954 skills54 agents
Install
$ npx -y skills add vanara-agents/skills --agent claude-code

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

Context preview

The summary Claude sees to decide when to auto-load this agent.

When reasoning stalls, *search*. Halving the problem space repeatedly finds the culprit in log₂(N) steps instead of N. Bisection applies to three spaces: **history** (which commit), **code** (which statement), and **input** (which data).

Agent definition

bisection.md

Bisection — Binary Search for Bugs

When reasoning stalls, *search*. Halving the problem space repeatedly finds the culprit in log₂(N) steps instead of N. Bisection applies to three spaces: **history** (which commit), **code** (which statement), and **input** (which data).

1. History: `git bisect`

When a bug appeared "sometime in the last 200 commits," let git binary-search them. Mark a known-bad and known-good revision; git checks out the midpoint and you tell it good or bad until it names the culprit.

git bisect start
git bisect bad                 # current HEAD is broken
git bisect good v1.4.0         # this old tag worked
# git checks out the midpoint; test it, then:
git bisect good                # ...or: git bisect bad
# repeat until git prints "<sha> is the first bad commit"
git bisect reset               # return to where you started

Automate it when you have a script that exits 0 (good) / non-zero (bad):

git bisect start HEAD v1.4.0
git bisect run npm test -- --testPathPattern=checkout

`git bisect run` will drive the entire search unattended and print the first bad commit. Keep the test fast and deterministic, or the search inherits its flakiness.

2. Code: bisect the execution path

Within a single bad function, find *where* the state goes wrong by checking the midpoint. Print or assert the suspect value halfway through; if it's already wrong, the bug is in the first half — otherwise the second. Repeat on the bad half.

function process(x) {
  step A          // assert(valid) here -> OK?  search lower half
  step B
  step C          // <-- midpoint probe: value already corrupt? bug is A/B
  step D
  step E          // assert(valid) here -> still OK?  bug is D/E
}

A "wolf-fence" probe (a single well-placed log of the suspect value) beats scattering ten prints.

3. Input: bisect the data

A 100k-row file that crashes the parser? Don't read 100k rows. Feed the first half — still crashes? The offending row is in that half. Halve again. ~17 iterations isolate one row out of 100k. The same works for narrowing a failing config to one key, or a failing request to one field.

Pitfalls

  • **Non-deterministic test → useless bisect.** Flaky good/bad answers send the search to the wrong commit.

Stabilize the repro first.

  • **Skipping untestable midpoints.** If a midpoint commit won't build, use `git bisect skip` — don't guess.
  • **Forgetting `git bisect reset`** leaves you on a detached checkout.
  • **Too-coarse halving.** Bisect to the *commit*, then bisect *within* it to the statement; don't stop at

"this 400-line commit did it."

Read more
Ships withvanara-agents-skills

🐒 Free agents, skills & packs for Claude Code One subscription. An army of Claude Code agents. 30 production-grade agents, skills, and packs for Claude Code — free, Apache-2.0, install with one command.

Get the whole plugin, auto-invoked
Stats
9
Stars
0
Views
3
Forks
Active
Maintenance
JavaScript
Language
Apache-2.0
License
10d ago
Last commit
24d ago
Created

Repo: vanara-agents/skills

Other agents on vanara-agents-skills.