From agent-workflows
Executes binary search to isolate root causes in git history, configurations, dependencies, or code modules using pass/fail oracle and iterative midpoint tests.
npx claudepluginhub sjarmak/agent-workflowsThis skill uses the workspace's default tool permissions.
Binary search for root cause. Defines a search space and pass/fail oracle, then iteratively tests midpoints — halving the space each step until the root cause is isolated. Works across git history, configuration, dependencies, or code modules.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Binary search for root cause. Defines a search space and pass/fail oracle, then iteratively tests midpoints — halving the space each step until the root cause is isolated. Works across git history, configuration, dependencies, or code modules.
$ARGUMENTS — format: "description of the bug or regression" with optional flags
Extract:
If the bug description is missing or unclear, ask the user to clarify before proceeding.
Work with the user to establish four things before starting the search loop.
1. The symptom — what is broken? What does failure look like? Get a concrete, observable description (error message, wrong output, crash, performance degradation).
2. The search dimension — where to search. Determine which applies:
3. The test oracle — how to determine pass/fail at each midpoint:
npm test, pytest tests/foo.py, go test ./..., etc.)4. Known bounds — the "good" end and "bad" end of the search space.
For git history bisect, run:
git log --oneline <good_commit>..<bad_commit>
to enumerate the search space. Count the candidates and report: "Search space: N commits. Expected steps: ceil(log2(N))."
For configuration bisect, list all changed config keys between the working and broken state. For dependency bisect, list all upgraded packages with old and new versions sorted by update date.
Present the search space summary to the user and confirm before proceeding. Adjust if the user gives feedback.
Execute the bisect algorithm. This is strictly sequential — each step depends on the previous result.
iteration = 0
while search_space > 1:
iteration += 1
midpoint = calculate_midpoint(search_space)
# Spawn a test agent at the midpoint
agent = spawn_test_agent(midpoint, test_oracle)
result = agent.run() # PASS or FAIL
if result == FAIL:
# Bug exists at midpoint — narrow to the first half
bad_bound = midpoint
else:
# Bug absent at midpoint — narrow to the second half
good_bound = midpoint
report_progress(iteration, midpoint, result, remaining_space)
At each midpoint commit, spawn an agent with subagent_type: "general-purpose" that:
isolation: "worktree" to run in an isolated copy of the repo checked out at the midpoint commitgit worktree remove /tmp/bisect-<short_sha>)Sort the changed config keys into a list. At each step:
Sort dependencies by update date. At each step:
After each iteration, report to the user:
Step N: Testing [midpoint identifier]
Result: PASS / FAIL
Remaining search space: M candidates
Narrowed to: [new bounds description]
If a midpoint produces an inconclusive result (flaky test, build failure unrelated to the bug, untestable state), stop and ask the user:
Once the search space narrows to a single item (one commit, one config key, one dependency):
git show <culprit_commit> and walk through the relevant hunksPresent the final report:
Root Cause The specific change that introduced the regression, with a one-line summary.
Bisect Log A table of every step: iteration number, midpoint tested, result (PASS/FAIL), remaining search space after that step.
Analysis Why the identified change caused the regression. Include relevant code snippets or config values.
Fix Options Ranked remediation paths:
Search Efficiency How many steps were taken versus the theoretical minimum of ceil(log2(N)). Note any skipped midpoints.
git worktree prune at the end of a git bisect.Standalone debugging tool. Does not chain with the ideation-to-implementation pipeline:
bug report / regression → /bisect → root cause + fix proposal