Help us improve
Share bugs, ideas, or general feedback.
From research-lab
Iterative optimization loop: propose changes, cheap gate, implement via git commit, measure, validate correctness, keep/discard with ratchet pattern. Includes futility stopping and JSONL logging. Use standalone for any measurable optimization task. Say "run an experiment", "iterate on this", "optimize with methodology", or "autoresearch loop".
npx claudepluginhub cosmicdreams/claude-plugins --plugin research-labHow this skill is triggered — by the user, by Claude, or both
Slash command
/research-lab:experimentThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Execute a methodology-driven iteration loop with ratchet-based keep/discard decisions.
Creates p5.js generative art with seeded randomness, noise fields, and interactive parameter exploration. Use for algorithmic art, flow fields, or particle systems.
Share bugs, ideas, or general feedback.
Execute a methodology-driven iteration loop with ratchet-based keep/discard decisions.
This skill implements the autoresearch pattern: pick a metric, measure it, try something, measure again, keep if better, revert if worse, repeat. That's the entire loop. This skill owns the loop mechanics — ratchet, futility stopping, git discipline, JSONL logging. It does NOT own domain knowledge. What to measure, how to measure it, what to try — all come from the methodology document. The skill is domain-agnostic. It works for cache optimization, performance tuning, code quality scores, or any goal with a measurable metric.
Read these references before starting:
${CLAUDE_PLUGIN_ROOT}/skills/experiment/references/iteration-protocol.md — JSONL schema, git protocol, ratchet rules${CLAUDE_PLUGIN_ROOT}/skills/experiment/references/methodology-spec.md — methodology.md formatYou MUST be working in a dedicated worktree — never in worktrees/main/.
Verify before starting: your working directory must NOT be named main or have the main branch checked out.
If no worktree exists, STOP and ask the PI to create one via /create-worktree.
Required:
05-methodology.md (or any methodology file)results.jsonlOptional:
Check for existing results:
RESULTS_PATH="${RESULTS_PATH:-results.jsonl}"
if [ -f "$RESULTS_PATH" ]; then
# Find the current ratchet (best metric from keeps)
python3 -c "
import json
keeps = []
with open('$RESULTS_PATH') as f:
for line in f:
r = json.loads(line)
if r.get('decision') == 'keep':
keeps.append(r)
if keeps:
best = max(keeps, key=lambda x: x.get('metric_after', 0))
print(f\"Resuming. Ratchet: {best['metric_after']} (iteration {best['iteration']})\")
print(f\"Total iterations: {sum(1 for _ in open('$RESULTS_PATH'))}\")
else:
print('No keeps yet. Starting fresh.')
"
fi
cat "$METHODOLOGY_PATH"
Extract:
Validate: The methodology must specify a single metric with a direction. If it has two metrics, mixed qualitative/quantitative criteria, or no clear direction — STOP and ask the PI to fix the methodology before proceeding.
Before the first iteration, measure the metric across the FULL page sample defined in the methodology. This establishes the true baseline and prevents false conclusions from narrow sampling.
# Run the measurement protocol from the methodology against ALL sample pages
# Record the result as the baseline
Log the survey as iteration 0:
{"iteration": 0, "timestamp": "...", "change": "Baseline survey", "gate": "pass", "metric_before": null, "metric_after": MEASURED, "ratchet": MEASURED, "decision": "keep", "reason": "Baseline established across N pages. Details: ..."}
The ratchet seed = this measured baseline. Do NOT use the baseline value written in the methodology if it differs from what you measure — the actual measurement is the truth.
For each iteration until budget exhausted, target achieved, or futility triggered:
Based on the methodology's ranked hypotheses and results so far, propose the next change.
Before implementing, ask: "Can this plausibly improve the metric?"
Make the change in the working directory. Then commit:
cd "$WORKING_DIR"
git add -A
git commit -m "$(cat <<'EOF'
perf(<engagement>): <description of change>
EOF
)"
Run the measurement harness:
# Use the methodology-defined harness or the template
$MEASURE_COMMAND
For noisy metrics, run N times (N from methodology) and take the median:
for i in $(seq 1 $N); do
$MEASURE_COMMAND >> /tmp/measurements.txt
done
# Compute median
Run correctness checks from the methodology:
Compare measured metric against the ratchet:
On discard:
cd "$WORKING_DIR"
git revert HEAD --no-edit
Append to results.jsonl using the logging script:
${CLAUDE_PLUGIN_ROOT}/scripts/log-iteration.sh "$RESULTS_PATH" \
ITERATION_NUMBER "DESCRIPTION" "pass" RATCHET_VALUE MEASURED_VALUE NEW_RATCHET_VALUE "keep_or_discard" "WHY"
Stop when any of:
On termination, report:
When used outside of research-lab:run: