mcpField

Investigation Script Loop

FeaturedOn demand
Code QualityUp to 8 rounds

About Investigation Script Loop

A manually started debugging loop. Each round forms a hypothesis, edits scripts/investigate.mjs, then runs node scripts/investigate.mjs and reads the output. It runs for up to 8 rounds and is listed for Cursor and Claude Code.

Key features

  1. 01Manual trigger
  2. 02Capped at 8 rounds
  3. 03Judged by the output of node scripts/investigate.mjs
  4. 04Supports Cursor and Claude Code

Use cases

  1. 01Tracking down a hard-to-locate intermittent bug
  2. 02Giving a team runnable evidence of a problem's root cause
  3. 03Checking that a suspected cause holds before writing a fix
Goal
A minimal repro script demonstrates the root cause of the problem.
Exit when
Stop when the output of node scripts/investigate.mjs demonstrates the root cause, or after the 8-round limit is reached.
Between iterations run
node scripts/investigate.mjs

Launch prompt

Paste into Cursor / Claude Code. The agent repeats the steps below until the exit condition is met.

prompt.md
Start the "Investigation Script Loop" loop.
Goal: A minimal repro script demonstrates the root cause of the problem.
Max iterations: 8.
Step 1: Form a hypothesis — Using the known symptoms and the previous round's output, write down a root-cause guess that can be confirmed or ruled out.
Step 2: Update the script — Edit scripts/investigate.mjs so it keeps only the code needed to trigger the problem and prints information that tells the hypotheses apart.
Step 3: Run and read the output — Execute node scripts/investigate.mjs and check whether the output reproduces the problem and agrees with the hypothesis.
Step 4: Judge the evidence — If the output clearly shows the root cause, end the loop. If it is ambiguous or contradicts the hypothesis, carry the new findings into the next round.
Between iterations run: `node scripts/investigate.mjs`
Exit when: Stop when the output of node scripts/investigate.mjs demonstrates the root cause, or after the 8-round limit is reached.

Steps

Each round runs in order; if the exit condition isn’t met, another round starts, up to 8.

01
Form a hypothesis

Using the known symptoms and the previous round's output, write down a root-cause guess that can be confirmed or ruled out.

02
Update the script

Edit scripts/investigate.mjs so it keeps only the code needed to trigger the problem and prints information that tells the hypotheses apart.

03
Run and read the output

Execute node scripts/investigate.mjs and check whether the output reproduces the problem and agrees with the hypothesis.

04
Judge the evidence

If the output clearly shows the root cause, end the loop. If it is ambiguous or contradicts the hypothesis, carry the new findings into the next round.

Not met → next roundExits when met

Supported agents

Coding agents that can run this loop directly.

Cursor
Claude Code
Codex

Comments

Markdown supported