Skills › Skills For Real Engineers › diagnosing-bugs › hitl-loop.template.sh
hitl-loop.template.sh
44 lines · skills/engineering/diagnosing-bugs/scripts/hitl-loop.template.sh at 4ae2317
1#!/usr/bin/env bash
2# Human-in-the-loop reproduction loop.
3# Copy this file, edit the steps below, and run it.
4# The agent runs the script; the user follows prompts in their terminal.
5#
6# Usage:
7# bash hitl-loop.template.sh
8#
9# Two helpers:
10# step "<instruction>" → show instruction, wait for Enter
11# capture VAR "<question>" → show question, read response into VAR
12#
13# At the end, captured values are printed as KEY=VALUE for the agent to parse.
14#
15# `capture` prints its value back to the terminal, where the agent reads it,
16# so capture observations, and leave signing in to the user as a `step`.
18set -euo pipefail
20step() {
21 printf '\n>>> %s\n' "$1"
22 read -r -p " [Enter when done] " _
23}
25capture() {
26 local var="$1" question="$2" answer
27 printf '\n>>> %s\n' "$question"
28 read -r -p " > " answer
29 printf -v "$var" '%s' "$answer"
30}
32# --- edit below ---------------------------------------------------------
34step "Open the app at http://localhost:3000 and sign in."
36capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
38capture ERROR_MSG "Paste the error message (or 'none'):"
40# --- edit above ---------------------------------------------------------
42printf '\n--- Captured ---\n'
43printf 'ERRORED=%s\n' "$ERRORED"
44printf 'ERROR_MSG=%s\n' "$ERROR_MSG"