Run rq

From marcoemrich/agentic_coding_lab · View interactive version

Run rq is an AI agent skill from the GitHub repository marcoemrich/agentic_coding_lab. Use this skill to drive a research question (RQ) end-to-end: validate the RQ README, generate a fill batch-plan, start the Docker batch in the background, monitor progress, run aggregation, and propose findings updates. Trigger when the user says "RQ-N voranbringen", "run-rq", "fill RQ-N", "run RQ-N

How to use this skill

Skill file

Skill: run-rq

End-to-end orchestration for advancing a single research question (RQ) in this lab repo. Pure orchestration — every operation calls existing repo scripts; no new Python or Bash code is written.

Argument

Repo conventions (from the top-level `README.md` and memory)

```bash

RQ_DIR=$(grep -rlE "^id:[[:space:]]RQ-model-quality[[:space:]]$" \

research/questions-claude/*/README.md \

research/questions-opencode/*/README.md \

research/questions-cross/*/README.md \

research/workflow-dev/*/README.md \

2>/dev/null | head -1 | xargs -r dirname)

```

On no match → ask the user. On multiple → take the first and inform the user. Pass "$RQ_DIR" to all scripts below (they accept any path and write outputs to the dir).

Phases

Run sequentially. On errors in any phase, stop and ask the user, do not skip ahead.


Phase 1 — Validate

  1. Resolve the RQ path into $RQ_DIR via the id-grep in "Repo conventions" above. On no match, ask the user; on multiple, take the first and inform the user.
  2. Read $RQ_DIR/README.md.
  3. Parse the frontmatter block (between the first two --- lines). Check mandatory fields: id, question, factors, controls, outcomes, min_replicates, status. Missing fields → abort phase, inform user.
  4. Check methodology constraints:
  1. Read findings.md (needed in phase 6 as the existing baseline).
  2. Target computation: from factors × controls derive the cell count (every factor multiplies; paired factors like workflow_x_prompt count as a single factor with len(pairing) values). Target runs = cells × min_replicates. Report this number to the user.
  3. Portkey routing detection: scan model values (in controls.model plus every factors.model entry) for a -portkey suffix. If any match:

Output to user (compact):

RQ-N validated: <id>, <#cells> cells × min_replicates=<n> = <target> target runs.
status: <status>
[Portkey routing required — using ~/.claude.portkey/ profile]   ← only if portkey_required

Phase 2 — Plan

  1. Run dry-run:

```

experiments/batch-plan-from-rq.py "$RQ_DIR" --dry-run

```

  1. Output contains the count of missing runs. Inform user:

```

Cells: X, missing runs: Y → would write experiments/batch-plans/rq-{n}-fill.json

```

  1. If Y == 0: no new runs needed — jump straight to phase 5.
  2. Otherwise: get user confirmation ("Write the plan with Y runs now?"). Only proceed after explicit "yes".
  3. Write the plan without --dry-run:

```

experiments/batch-plan-from-rq.py "$RQ_DIR"

```

  1. Briefly inspect the generated plan (Read on experiments/batch-plans/rq-{n}-fill.json) and summarize the cell distribution ({kata, workflow, model} frequencies) to the user.

Phase 3 — Run

  1. Pre-check:
  1. User confirmation before start: "Start batch rq-{n}-fill with Y runs in the background? Expected wallclock ≈ Y × 6 min ≈ Z min." (6 min/run per memory, smart-subset experience.) For Portkey RQs (flag from phase 1.7), append: "via Portkey gateway (auto-detected)".
  2. Start with --detach (backgrounds the batch and disowns the process so the terminal can be closed safely):

```bash

cd experiments/docker && ./batch.sh rq-{n}-fill --detach

```

Portkey routing is auto-detected by batch.sh: it scans the plan JSON for -portkey model names and sets CLAUDE_CONFIG_DIR=~/.claude.portkey automatically. No manual env-var override needed. For sharded runs (>30 runs), add --shards N (max 6):

```bash

cd experiments/docker && ./batch.sh rq-{n}-fill --shards 4 --detach

```

  1. After a few seconds, determine the container name via docker ps --filter name=docker-batch-run --format '{{.Names}}' and report it to the user.

Phase 4 — Monitor

  1. Polling loop with experiments/docker/watch-batch.sh rq-{n}-fill:
  1. Termination conditions:
  1. Important: Take memory patterns seriously:
  1. Mid-execution cleanup after stop: the youngest run dir in experiments/runs/ that lacks analysis-report.md OR transcript.jsonl was interrupted mid-execution. Ask the user: "Delete interrupted run dir <run-dir> (no analysis-report.md)?" Only delete with rm -rf after explicit "yes".
Phase 4b — Resume
  1. Generate a resume plan:

```

experiments/docker/resume-plan.sh rq-{n}-fill

```

→ writes /tmp/rq-{n}-fill-resume.json.

  1. Show the size to the user (jq '.runs | length' /tmp/rq-{n}-fill-resume.json).
  2. Get user confirmation: "Restart with <m> remaining runs?"
  3. After "yes" — resume with --detach (Portkey auto-detected from plan content):

```bash

cd experiments/docker && ./batch.sh /tmp/rq-{n}-fill-resume.json --detach

```

Back to phase 4.


Phase 5 — Aggregate

  1. Pipeline sanity check before aggregating — pipeline bugs masquerade as research findings. Spot-check 2–3 of the matched runs (covering the workflow × model cells most central to the RQ) for divergence between run.log and metrics.json:
  1. Invoke:

```

experiments/aggregate-by-query.py "$RQ_DIR"

```

  1. Expected outputs:
  1. Read summary.md in full and summarize to the user — show the per-cell pivot tables individually.
  2. Sanity check: does every cell have ≥ min_replicates? If not: warn and offer to jump back to phase 2 (additional runs).
  3. Plausibility cross-check before phase 6 — if any cell value contradicts a previously-stable finding by a large margin (e.g. a workflow that was 100% green is suddenly 0%), do NOT treat that as a new finding without first running the spot-check from step 1 against that exact cell. A "the subagents arm is suddenly broken on game-of-life" type observation is more often a pipeline regression than a real shift.

Phase 6 — Findings (write-first)

Write directly to findings.md, then notify the user to review. Markdown tables and trophy assignments are much easier to evaluate as rendered output than as a chat proposal; reverting is cheap (it's only markdown). After writing, send one line (in the user's language), e.g. "written — please review",.

Exception: deletions of existing findings still require explicit user confirmation before the edit — losing a documented finding is more expensive than re-reading a fresh write.

findings.md shows only the current state. No status tags (✅ stabil / ⚠️ bedingt / 🚫 offen / ❌ widerlegt), no comparisons with archive snapshots or older studies, no "previously X, corrected" hints in the prose. Header form: ## F-x.y — title (no · … suffix).

Overview table: findings.md starts with a ## Overview section containing a pivot table of the primary outcome across all factor levels (all models, all prompt styles, etc.) — before the individual F-x.y blocks. This table gives readers the full picture at a glance; individual findings then zoom in on specific effects. Update this table whenever findings are added or updated.

Trophy convention (🏆) in overview tables: append 🏆 to the best value per outcome row. Conventions:

  1. Diff sources:
  1. Three possible actions per effect:
  1. Data gap: if an effect is suspected but coverage is too small for n ≥ min_replicates → note in todos_and_ideas/1-IN/index.md as a bullet with a concrete re-check target. Do not create as a finding in findings.md.
  2. Format per block: statement / data-base table / rationale. Header ## F-x.y — title with no suffix. The namespace before the last dot may carry dots itself (F-4.4.1, F-1.12.5 — chapter-numbered ids are in use and valid). The em-dash — is load-bearing: generate-snapshot-skeleton.py parses headers on it and silently skips any it cannot match, which then reads as "no findings documented" in the snapshot for an RQ that has a full findings.md.

Glossary discipline: terms like code_mass, production_loc, longest_function, smell_total, verification_pct are to be used only in the form from the glossary in the top-level README.md ("Code Mass (APP)", "Production LoC", "Smell Total", "Correctness (external)") or directly via the metric ID in backticks. Synonyms like "Code-Volumen", "Code-Gesamtvolumen", "LoC-Größe" are forbidden — they are ambiguous or collide with established definitions (APP). The three complexity metrics carry no prose name at all: write longest_function, cognitive_max, cognitive_avg or mccabe_max in backticks. "Complexity Peak", "Spitzen-Komplexität", "Cognitive Complexity peak" and "McCabe peak" are forbidden; the first had been used for three different metrics at once. Before writing, read the glossary once and check every term used in the block against the table.

  1. After writing all new/updated blocks, send one short line to the user (in their language), e.g. "written — please review". The user reviews the rendered markdown directly.

Out of scope (deliberately NOT in the skill)

Behavior on errors

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.