/exp-run
Execute an experiment that has been planned in wiki/experiments/.
Three run modes for different scenarios:
- Default (deploy): Phase 1-2 only — deploy and return immediately. Best for experiments that take hours or days.
--collect: Phase 3-4 only — check whether a deployed experiment has finished; collect results if so (--check is an alias).
--full: All four phases end-to-end. Best for short local experiments that finish in minutes.
Recommended flow: /exp-run <slug> to deploy → /exp-status to monitor → /exp-run <slug> --collect to collect.
Inputs
experiment: slug from wiki/experiments/
- deploy mode: status must be
planned
- --collect mode: status must be
running
- --full mode: status must be
planned
--review (optional): enable Review LLM code review for experiment code in Phase 1 (valid in deploy / full mode)
--collect (optional): collect mode — check if the experiment has finished and collect results; --check is an alias
--full (optional): full mode — execute all 4 phases (best for quick local experiments)
--env local|remote (optional, default local): deployment environment
local: run directly on local GPU
remote: deploy to remote machine via SSH (requires config/server.yaml)
Outputs
- deploy mode:
- Experiment code:
experiments/code/{slug}/ (generated in Phase 1)
wiki/experiments/{slug}.md — status: planned → running
- DEPLOY_REPORT (printed to terminal) — deployment confirmation, session info, next steps
wiki/log.md — appended deploy log
- collect mode (experiment has finished):
wiki/experiments/{slug}.md — status: running → completed; outcome/key_result/date_completed filled in
- RUN_REPORT (printed to terminal) — result summary, metrics comparison, next step suggestions
wiki/log.md — appended collect log
- collect mode (experiment still running):
- Progress report printed to terminal only; wiki is not modified
- full mode: all outputs from both deploy and collect
Wiki Interaction
Reads
wiki/experiments/{slug}.md — experiment config: setup, metrics, baseline, hypothesis, target_claim
wiki/claims/{target-claim}.md — target claim context (understand experiment purpose)
wiki/ideas/{linked-idea}.md — linked idea's approach sketch (guide code implementation)
wiki/papers/*.md — related papers' method details and hyperparameters (implementation reference)
wiki/experiments/*.md — other experiments on the same claim (reference setup, avoid known mistakes)
Writes
experiments/code/{slug}/ — experiment code directory (Phase 1, deploy / full mode)
experiments/code/{slug}/train.py — main training/inference script
experiments/code/{slug}/config.yaml — hyperparameter config file
experiments/code/{slug}/run.sh — launch wrapper script (includes CUDA_VISIBLE_DEVICES etc.)
experiments/code/{slug}/requirements.txt — dependencies (if different from main project)
wiki/experiments/{slug}.md — update status, outcome, key_result, date_completed, run_log, remote block
wiki/log.md — append operation log
Graph edges created
- None. The tested_by edges between experiments and claims are created by /exp-design.
Workflow
Precondition: confirm working directory is the wiki project root (directory containing wiki/, raw/, tools/).
Deploy Mode (default, status == planned)
Phase 1: Prepare
Read experiment page:
wiki/experiments/{slug}.md: extract setup (model, dataset, hardware, framework), metrics, baseline, hypothesis
- Verify status ==
planned
- If status is
running, prompt user to use --collect mode
- If status is
completed/abandoned, refuse to execute
Load implementation context:
- Read linked idea's approach sketch (implementation guide)
- Read related papers' method descriptions (algorithm details)
- Read other experiments on the same claim (reference code structure)
Write experiment code to experiments/code/{slug}/:
train.py: generate training/evaluation script based on setup config, including:
- Argument parsing (argparse, all hyperparameters configurable)
- Data loading (support setup.dataset)
- Model initialization (support setup.model and baseline model)
- Training/inference loop
- Metric computation (matching metrics list)
- Result saving (JSON format, path:
results/{slug}/seed_{N}.json)
- Random seed control (multi-seed runs)
- Checkpoint save/restore (
checkpoints/{slug}/)
config.yaml: all hyperparameters (learning_rate, batch_size, epochs, seeds, etc.)
run.sh: complete launch command wrapper (includes CUDA_VISIBLE_DEVICES, logging, conda activation)
requirements.txt: experiment-specific dependencies (if different from main project requirements)
Optional Review LLM code review (--review):
mcp__llm-review__chat:
system: "You are a senior ML engineer reviewing experiment code.
Focus on: correctness of the training loop, proper evaluation protocol,
fair baseline comparison, reproducibility (seeds, determinism),
proper metric computation, and common pitfalls (data leakage,
wrong split, gradient accumulation bugs)."
message: |
## Experiment
{experiment title and hypothesis}
## Code
{generated code}
## Expected Behavior
{setup details from wiki page}
Review for correctness and potential issues.
Fix code based on Review LLM feedback.
Sanity check (small-scale validation):
- Run at minimal scale (1 epoch / 100 steps / small subset)
- Verify: no code crash, data loads correctly, GPU available, loss decreases
- If sanity fails → fix code, retry once; if still failing, report error and stop
Phase 2: Deploy
Local mode (--env local or default)
Check GPU: nvidia-smi to confirm GPU available and sufficient VRAM
Launch:
screen -dmS exp-{slug} bash -c \
"cd $(pwd) && bash experiments/code/{slug}/run.sh 2>&1 | tee logs/exp-{slug}.log"
Update wiki/experiments/{slug}.md:
- status:
running
- run_log:
logs/exp-{slug}.log
Estimate runtime and write to frontmatter:
Estimate based on setup.hardware (GPU model/count), setup.model (parameter count), setup.dataset (scale):
| Typical scenario |
Estimated range |
| Single GPU + small dataset (CIFAR / small NLP benchmark) |
0.5 – 3h |
| Single A100 + medium dataset (ImageNet / GLUE) |
4 – 12h |
| Multi-GPU or large model fine-tuning (≥7B) |
8 – 48h |
python3 tools/research_wiki.py set-meta \
wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"
python3 tools/research_wiki.py set-meta \
wiki/experiments/{slug}.md estimated_hours {N}
Append log:
python3 tools/research_wiki.py log wiki/ \
"exp-run | deployed {slug} | env: local | session: exp-{slug} | eta: {N}h"
Remote mode (--env remote)
Prerequisite: user has configured config/server.yaml.
Confirm connectivity: python3 tools/remote.py status
- If unreachable → report error and suggest checking config/server.yaml
Find free GPU: python3 tools/remote.py gpu-status
- If no free GPU → report each GPU's usage, suggest waiting
Sync code: python3 tools/remote.py sync-code
Install dependencies (first time or if requirements changed): python3 tools/remote.py setup-env
Launch remote experiment:
python3 tools/remote.py launch \
--name "exp-{slug}" \
--cmd "bash experiments/code/{slug}/run.sh" \
--gpu {gpu_index}
Update wiki/experiments/{slug}.md frontmatter — all of these fields already exist (empty) because /exp-design wrote the full CLAUDE.md template:
# Top-level scalar fields — use set-meta
python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md status running
python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md run_log "logs/exp-{slug}.log"
The nested remote: block cannot be updated via set-meta (it only handles top-level scalar fields). Use the Edit tool directly to replace the five empty sub-field values in place. The pre-existing block in the file looks like:
remote:
server: ""
gpu: ""
session: ""
started: ""
completed: ""
Use five Edit calls (one per sub-field) to set server, gpu, session, started. Leave completed: "" — Phase 4 fills that. If you find the remote: block missing from the file, that means /exp-design did not write the full CLAUDE.md template; stop and report the bug rather than trying to append the block here (appending would drift the file away from the canonical order and break future edits).
Estimate runtime and write to frontmatter (same estimation logic as local mode):
python3 tools/research_wiki.py set-meta \
wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"
python3 tools/research_wiki.py set-meta \
wiki/experiments/{slug}.md estimated_hours {N}
Append log:
python3 tools/research_wiki.py log wiki/ \
"exp-run | deployed {slug} | env: remote | server: {host} | gpu: {gpu} | eta: {N}h"
Print DEPLOY_REPORT to terminal:
# Deploy Report: {experiment title}
### Status: DEPLOYED ✅
- Session: exp-{slug}
- Environment: local | remote ({host} GPU {gpu})
- Log file: logs/exp-{slug}.log
- Code: experiments/code/{slug}/
- Estimated: ~{N}h (expected completion: {YYYY-MM-DD HH:MM})
### Next Steps
1. Monitor progress: `/exp-status`
2. Check this experiment: `/exp-run {slug} --collect`
3. In /research pipeline: progress saved to wiki/outputs/pipeline-progress.md
### Quick Commands
```bash
# Local: check if still running
screen -ls | grep exp-{slug}
# Local: tail log
tail -f logs/exp-{slug}.log
---
### Collect Mode (`--collect` or `--check`, status == running)
**Phase 3: Monitor / Check Run Status**
1. **Read deployment info**: from `wiki/experiments/{slug}.md` frontmatter, get environment (local or remote) and session name.
2. **Check whether the process is still alive**:
- **Local**: `screen -ls | grep exp-{slug}`
- **Remote**: `python3 tools/remote.py check --name "exp-{slug}"`, parse `alive` field
3. **If experiment is still running (alive == true)**:
- Fetch recent logs:
- Local: `tail -30 logs/exp-{slug}.log`
- Remote: `python3 tools/remote.py tail-log --name "exp-{slug}" --lines 30`
- **Anomaly detection**:
- NaN loss: detect `loss: nan`
- OOM: `CUDA out of memory`
- Traceback: Python exception stacktrace
- Inf loss: `loss: inf`
- **Automatic fix attempt** (if anomaly detected, at most 1 attempt):
- NaN/exploding → resume from latest checkpoint, reduce learning rate
- OOM → reduce batch size, restart
- **Print progress report** (do not modify wiki, report only):
```
Experiment {slug}: RUNNING
Progress: step {N} / epoch {E}
Latest metric: {metric} = {value}
Anomalies: {none | NaN detected | ...}
Estimated remaining: ~{N} hours
Run `/exp-status` to monitor all running experiments.
```
- **Return** (do not execute Phase 4)
4. **If experiment has finished (alive == false / session gone)**:
- Continue to Phase 4
**Phase 4: Collect Results**
1. **Pull remote results** (remote mode only):
```bash
python3 tools/remote.py pull-results \
--remote-path "results/{slug}/" \
--local-path "./results/{slug}/"
python3 tools/remote.py pull-results \
--remote-path "logs/exp-{slug}.log" \
--local-path "./logs/"
Check result files exist: results/{slug}/seed_*.json
Parse results:
- Read result files (JSON)
- Compute mean ± std per metric (across seeds)
- Compare with baseline, compute improvement delta
Update experiment page wiki/experiments/{slug}.md:
- status:
completed
- outcome:
succeeded / failed / inconclusive
- succeeded: all success criteria met
- failed: core metrics did not reach target
- inconclusive: mixed results or excessive variance
- key_result: one-sentence summary of the core finding
- date_completed: today's date
- Fill
## Results section: complete results table
- Fill
## Analysis section: preliminary analysis
- If remote mode: update
remote.completed timestamp
Append log:
python3 tools/research_wiki.py log wiki/ \
"exp-run | completed {slug} | outcome: {outcome} | key: {key_result}"
Print RUN_REPORT to terminal:
# Run Report: {experiment title}
## Outcome: {succeeded / failed / inconclusive}
## Results
| Metric | Baseline | Ours (mean±std) | Δ |
|--------|----------|-----------------|---|
| {metric} | {baseline-value} | {mean}±{std} | +{delta} |
## Key Finding
{key_result}
## Next Steps
- Run `/exp-eval {slug}` to update claims in wiki
- {if succeeded: proceed to next experiment in plan}
- {if failed: analyze failure, consider /exp-design revision}
Full Mode (--full, status == planned)
Execute all 4 phases in sequence (Phase 1 → Phase 2 → Phase 3 → Phase 4) without returning.
Use case: quick local CPU/GPU experiments that finish in minutes (sanity checks, toy dataset validation, etc.).
In Phase 3, instead of checking "is it still running", wait for the screen session to actually exit before executing Phase 4:
# Wait for session to end (polling)
while screen -ls | grep -q "exp-{slug}"; do
sleep 30
done
# Session gone, proceed to Phase 4
Constraints
- Deploy mode only accepts planned experiments: if status is running, prompt to use --collect; if completed, refuse
- Collect mode only accepts running experiments: if status is planned, prompt to deploy first; if completed, note it is already done
- Collect mode: do not write wiki when alive: only report progress, do not modify any wiki files
- Code goes in experiments/code/{slug}/: do not write to project root or any other location
- Do not update claims: experiment results are written only to experiments/ pages; claim updates are handled by /exp-eval
- Sanity check must pass: Phase 1 sanity failure blocks deployment (unless user explicitly overrides)
- Results must be saved: all experiment results saved as JSON in
results/{slug}/seed_{N}.json
- Multi-seed results use mean: report mean ± std, not single-run results
- Graph edges are not created here: tested_by edges were created by /exp-design
- Automatic fix attempts are limited to 1: prevents infinite restart loops
Error Handling
- Experiment not found: prompt user to check slug, list candidates in wiki/experiments/ (status=planned or running)
- Deploy mode but status == running: prompt "already running — use
/exp-run {slug} --collect to check status"
- Collect mode but status == completed: prompt "already completed — run
/exp-eval {slug} directly"
- GPU unavailable: report error, suggest using --env remote or waiting for GPU to free up
- Review LLM unavailable (--review mode): skip code review, note "unreviewed" in DEPLOY_REPORT
- Sanity check fails: report detailed error, attempt one automatic fix, if still failing stop and suggest manual debugging
- Remote connection fails: report SSH error, suggest checking connection config and config/server.yaml
- Result files missing (collect mode): report which seeds are missing results; summarize available results normally; if successful seeds < 2, mark inconclusive
- Experiment crashed (traceback detected in collect mode): include crash info and suggested fix directions in report
- --full mode wait timeout: if screen session persists beyond 2× the estimated time, warn user but do not force-terminate
Dependencies
Skills(via Skill tool)
- No direct sub-skill calls
Tools(via Bash)
python3 tools/research_wiki.py log wiki/ "<message>" — append log
python3 tools/remote.py <command> — remote operations (status, gpu-status, sync-code, setup-env, launch, check, tail-log, pull-results)
nvidia-smi — local GPU status
screen — local background process management
Configuration
config/server.yaml — remote server config (required only with --env remote)
MCP Servers
mcp__llm-review__chat — Phase 1 code review (optional, when --review is used)
Claude Code Native
Read — read wiki pages and log files
Write — write experiment code to experiments/code/{slug}/
Bash — execute deployment commands, monitor processes
Called by
/research Stage 3a (deploy mode) and Stage 3c (collect mode)
/exp-status --collect-ready (collect mode)
- User directly
1---2name: exp-run3description: Full experiment execution pipeline — prepare code → deploy → monitor → collect results, supporting three run modes4---56# /exp-run78> Execute an experiment that has been planned in wiki/experiments/.9> **Three run modes** for different scenarios:10> - **Default (deploy)**: Phase 1-2 only — deploy and return immediately. Best for experiments that take hours or days.11> - **`--collect`**: Phase 3-4 only — check whether a deployed experiment has finished; collect results if so (`--check` is an alias).12> - **`--full`**: All four phases end-to-end. Best for short local experiments that finish in minutes.13>14> Recommended flow: `/exp-run <slug>` to deploy → `/exp-status` to monitor → `/exp-run <slug> --collect` to collect.1516## Inputs1718- `experiment`: slug from wiki/experiments/19 - deploy mode: status must be `planned`20 - --collect mode: status must be `running`21 - --full mode: status must be `planned`22- `--review` (optional): enable Review LLM code review for experiment code in Phase 1 (valid in deploy / full mode)23- `--collect` (optional): collect mode — check if the experiment has finished and collect results; `--check` is an alias24- `--full` (optional): full mode — execute all 4 phases (best for quick local experiments)25- `--env local|remote` (optional, default `local`): deployment environment26 - `local`: run directly on local GPU27 - `remote`: deploy to remote machine via SSH (requires `config/server.yaml`)2829## Outputs3031- **deploy mode**:32 - Experiment code: `experiments/code/{slug}/` (generated in Phase 1)33 - `wiki/experiments/{slug}.md` — status: planned → running34 - **DEPLOY_REPORT** (printed to terminal) — deployment confirmation, session info, next steps35 - `wiki/log.md` — appended deploy log36- **collect mode** (experiment has finished):37 - `wiki/experiments/{slug}.md` — status: running → completed; outcome/key_result/date_completed filled in38 - **RUN_REPORT** (printed to terminal) — result summary, metrics comparison, next step suggestions39 - `wiki/log.md` — appended collect log40- **collect mode** (experiment still running):41 - Progress report printed to terminal only; wiki is not modified42- **full mode**: all outputs from both deploy and collect4344## Wiki Interaction4546### Reads47- `wiki/experiments/{slug}.md` — experiment config: setup, metrics, baseline, hypothesis, target_claim48- `wiki/claims/{target-claim}.md` — target claim context (understand experiment purpose)49- `wiki/ideas/{linked-idea}.md` — linked idea's approach sketch (guide code implementation)50- `wiki/papers/*.md` — related papers' method details and hyperparameters (implementation reference)51- `wiki/experiments/*.md` — other experiments on the same claim (reference setup, avoid known mistakes)5253### Writes54- `experiments/code/{slug}/` — experiment code directory (Phase 1, deploy / full mode)55 - `experiments/code/{slug}/train.py` — main training/inference script56 - `experiments/code/{slug}/config.yaml` — hyperparameter config file57 - `experiments/code/{slug}/run.sh` — launch wrapper script (includes CUDA_VISIBLE_DEVICES etc.)58 - `experiments/code/{slug}/requirements.txt` — dependencies (if different from main project)59- `wiki/experiments/{slug}.md` — update status, outcome, key_result, date_completed, run_log, remote block60- `wiki/log.md` — append operation log6162### Graph edges created63- **None**. The tested_by edges between experiments and claims are created by /exp-design.6465## Workflow6667**Precondition**: confirm working directory is the wiki project root (directory containing `wiki/`, `raw/`, `tools/`).6869---7071### Deploy Mode (default, status == planned)7273**Phase 1: Prepare**74751. **Read experiment page**:76 - `wiki/experiments/{slug}.md`: extract setup (model, dataset, hardware, framework), metrics, baseline, hypothesis77 - Verify status == `planned`78 - If status is `running`, prompt user to use `--collect` mode79 - If status is `completed`/`abandoned`, refuse to execute80812. **Load implementation context**:82 - Read linked idea's approach sketch (implementation guide)83 - Read related papers' method descriptions (algorithm details)84 - Read other experiments on the same claim (reference code structure)85863. **Write experiment code** to `experiments/code/{slug}/`:87 - `train.py`: generate training/evaluation script based on setup config, including:88 - Argument parsing (argparse, all hyperparameters configurable)89 - Data loading (support setup.dataset)90 - Model initialization (support setup.model and baseline model)91 - Training/inference loop92 - Metric computation (matching metrics list)93 - Result saving (JSON format, path: `results/{slug}/seed_{N}.json`)94 - Random seed control (multi-seed runs)95 - Checkpoint save/restore (`checkpoints/{slug}/`)96 - `config.yaml`: all hyperparameters (learning_rate, batch_size, epochs, seeds, etc.)97 - `run.sh`: complete launch command wrapper (includes CUDA_VISIBLE_DEVICES, logging, conda activation)98 - `requirements.txt`: experiment-specific dependencies (if different from main project requirements)991004. **Optional Review LLM code review** (`--review`):101 ```102 mcp__llm-review__chat:103 system: "You are a senior ML engineer reviewing experiment code.104 Focus on: correctness of the training loop, proper evaluation protocol,105 fair baseline comparison, reproducibility (seeds, determinism),106 proper metric computation, and common pitfalls (data leakage,107 wrong split, gradient accumulation bugs)."108 message: |109 ## Experiment110 {experiment title and hypothesis}111112 ## Code113 {generated code}114115 ## Expected Behavior116 {setup details from wiki page}117118 Review for correctness and potential issues.119 ```120 Fix code based on Review LLM feedback.1211225. **Sanity check (small-scale validation)**:123 - Run at minimal scale (1 epoch / 100 steps / small subset)124 - Verify: no code crash, data loads correctly, GPU available, loss decreases125 - If sanity fails → fix code, retry once; if still failing, report error and stop126127**Phase 2: Deploy**128129#### Local mode (`--env local` or default)1301311. **Check GPU**: `nvidia-smi` to confirm GPU available and sufficient VRAM1322. **Launch**:133 ```bash134 screen -dmS exp-{slug} bash -c \135 "cd $(pwd) && bash experiments/code/{slug}/run.sh 2>&1 | tee logs/exp-{slug}.log"136 ```1373. Update `wiki/experiments/{slug}.md`:138 - status: `running`139 - run_log: `logs/exp-{slug}.log`1404. **Estimate runtime** and write to frontmatter:141 Estimate based on `setup.hardware` (GPU model/count), `setup.model` (parameter count), `setup.dataset` (scale):142143 | Typical scenario | Estimated range |144 |-----------------|-----------------|145 | Single GPU + small dataset (CIFAR / small NLP benchmark) | 0.5 – 3h |146 | Single A100 + medium dataset (ImageNet / GLUE) | 4 – 12h |147 | Multi-GPU or large model fine-tuning (≥7B) | 8 – 48h |148149 ```bash150 python3 tools/research_wiki.py set-meta \151 wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"152 python3 tools/research_wiki.py set-meta \153 wiki/experiments/{slug}.md estimated_hours {N}154 ```1555. Append log:156 ```bash157 python3 tools/research_wiki.py log wiki/ \158 "exp-run | deployed {slug} | env: local | session: exp-{slug} | eta: {N}h"159 ```160161#### Remote mode (`--env remote`)162163**Prerequisite**: user has configured `config/server.yaml`.1641651. **Confirm connectivity**: `python3 tools/remote.py status`166 - If unreachable → report error and suggest checking config/server.yaml1672. **Find free GPU**: `python3 tools/remote.py gpu-status`168 - If no free GPU → report each GPU's usage, suggest waiting1693. **Sync code**: `python3 tools/remote.py sync-code`1704. **Install dependencies** (first time or if requirements changed): `python3 tools/remote.py setup-env`1715. **Launch remote experiment**:172 ```bash173 python3 tools/remote.py launch \174 --name "exp-{slug}" \175 --cmd "bash experiments/code/{slug}/run.sh" \176 --gpu {gpu_index}177 ```1786. Update `wiki/experiments/{slug}.md` frontmatter — all of these fields already exist (empty) because `/exp-design` wrote the full CLAUDE.md template:179 ```bash180 # Top-level scalar fields — use set-meta181 python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md status running182 python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md run_log "logs/exp-{slug}.log"183 ```184185 The nested `remote:` block cannot be updated via `set-meta` (it only handles top-level scalar fields). Use the `Edit` tool directly to replace the five empty sub-field values in place. The pre-existing block in the file looks like:186 ```yaml187 remote:188 server: ""189 gpu: ""190 session: ""191 started: ""192 completed: ""193 ```194 Use five Edit calls (one per sub-field) to set `server`, `gpu`, `session`, `started`. Leave `completed: ""` — Phase 4 fills that. If you find the `remote:` block missing from the file, that means `/exp-design` did not write the full CLAUDE.md template; stop and report the bug rather than trying to append the block here (appending would drift the file away from the canonical order and break future edits).1951967. **Estimate runtime** and write to frontmatter (same estimation logic as local mode):197 ```bash198 python3 tools/research_wiki.py set-meta \199 wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"200 python3 tools/research_wiki.py set-meta \201 wiki/experiments/{slug}.md estimated_hours {N}202 ```2038. Append log:204 ```bash205 python3 tools/research_wiki.py log wiki/ \206 "exp-run | deployed {slug} | env: remote | server: {host} | gpu: {gpu} | eta: {N}h"207 ```208209**Print DEPLOY_REPORT to terminal**:210211```markdown212# Deploy Report: {experiment title}213214### Status: DEPLOYED ✅215216- Session: exp-{slug}217- Environment: local | remote ({host} GPU {gpu})218- Log file: logs/exp-{slug}.log219- Code: experiments/code/{slug}/220- Estimated: ~{N}h (expected completion: {YYYY-MM-DD HH:MM})221222### Next Steps2232241. Monitor progress: `/exp-status`2252. Check this experiment: `/exp-run {slug} --collect`2263. In /research pipeline: progress saved to wiki/outputs/pipeline-progress.md227228### Quick Commands229```bash230# Local: check if still running231screen -ls | grep exp-{slug}232233# Local: tail log234tail -f logs/exp-{slug}.log235```236```237238---239240### Collect Mode (`--collect` or `--check`, status == running)241242**Phase 3: Monitor / Check Run Status**2432441. **Read deployment info**: from `wiki/experiments/{slug}.md` frontmatter, get environment (local or remote) and session name.2452462. **Check whether the process is still alive**:247 - **Local**: `screen -ls | grep exp-{slug}`248 - **Remote**: `python3 tools/remote.py check --name "exp-{slug}"`, parse `alive` field2492503. **If experiment is still running (alive == true)**:251 - Fetch recent logs:252 - Local: `tail -30 logs/exp-{slug}.log`253 - Remote: `python3 tools/remote.py tail-log --name "exp-{slug}" --lines 30`254 - **Anomaly detection**:255 - NaN loss: detect `loss: nan`256 - OOM: `CUDA out of memory`257 - Traceback: Python exception stacktrace258 - Inf loss: `loss: inf`259 - **Automatic fix attempt** (if anomaly detected, at most 1 attempt):260 - NaN/exploding → resume from latest checkpoint, reduce learning rate261 - OOM → reduce batch size, restart262 - **Print progress report** (do not modify wiki, report only):263 ```264 Experiment {slug}: RUNNING265 Progress: step {N} / epoch {E}266 Latest metric: {metric} = {value}267 Anomalies: {none | NaN detected | ...}268 Estimated remaining: ~{N} hours269 Run `/exp-status` to monitor all running experiments.270 ```271 - **Return** (do not execute Phase 4)2722734. **If experiment has finished (alive == false / session gone)**:274 - Continue to Phase 4275276**Phase 4: Collect Results**2772781. **Pull remote results** (remote mode only):279 ```bash280 python3 tools/remote.py pull-results \281 --remote-path "results/{slug}/" \282 --local-path "./results/{slug}/"283284 python3 tools/remote.py pull-results \285 --remote-path "logs/exp-{slug}.log" \286 --local-path "./logs/"287 ```2882892. **Check result files exist**: `results/{slug}/seed_*.json`2902913. **Parse results**:292 - Read result files (JSON)293 - Compute mean ± std per metric (across seeds)294 - Compare with baseline, compute improvement delta2952964. **Update experiment page** `wiki/experiments/{slug}.md`:297 - status: `completed`298 - outcome: `succeeded` / `failed` / `inconclusive`299 - succeeded: all success criteria met300 - failed: core metrics did not reach target301 - inconclusive: mixed results or excessive variance302 - key_result: one-sentence summary of the core finding303 - date_completed: today's date304 - Fill `## Results` section: complete results table305 - Fill `## Analysis` section: preliminary analysis306 - If remote mode: update `remote.completed` timestamp3073085. **Append log**:309 ```bash310 python3 tools/research_wiki.py log wiki/ \311 "exp-run | completed {slug} | outcome: {outcome} | key: {key_result}"312 ```3133146. **Print RUN_REPORT to terminal**:315 ```markdown316 # Run Report: {experiment title}317318 ## Outcome: {succeeded / failed / inconclusive}319320 ## Results321 | Metric | Baseline | Ours (mean±std) | Δ |322 |--------|----------|-----------------|---|323 | {metric} | {baseline-value} | {mean}±{std} | +{delta} |324325 ## Key Finding326 {key_result}327328 ## Next Steps329 - Run `/exp-eval {slug}` to update claims in wiki330 - {if succeeded: proceed to next experiment in plan}331 - {if failed: analyze failure, consider /exp-design revision}332 ```333334---335336### Full Mode (`--full`, status == planned)337338Execute all 4 phases in sequence (Phase 1 → Phase 2 → Phase 3 → Phase 4) without returning.339340Use case: quick local CPU/GPU experiments that finish in minutes (sanity checks, toy dataset validation, etc.).341342In Phase 3, instead of checking "is it still running", wait for the screen session to actually exit before executing Phase 4:343```bash344# Wait for session to end (polling)345while screen -ls | grep -q "exp-{slug}"; do346 sleep 30347done348# Session gone, proceed to Phase 4349```350351---352353## Constraints354355- **Deploy mode only accepts planned experiments**: if status is running, prompt to use --collect; if completed, refuse356- **Collect mode only accepts running experiments**: if status is planned, prompt to deploy first; if completed, note it is already done357- **Collect mode: do not write wiki when alive**: only report progress, do not modify any wiki files358- **Code goes in experiments/code/{slug}/**: do not write to project root or any other location359- **Do not update claims**: experiment results are written only to experiments/ pages; claim updates are handled by /exp-eval360- **Sanity check must pass**: Phase 1 sanity failure blocks deployment (unless user explicitly overrides)361- **Results must be saved**: all experiment results saved as JSON in `results/{slug}/seed_{N}.json`362- **Multi-seed results use mean**: report mean ± std, not single-run results363- **Graph edges are not created here**: tested_by edges were created by /exp-design364- **Automatic fix attempts are limited to 1**: prevents infinite restart loops365366## Error Handling367368- **Experiment not found**: prompt user to check slug, list candidates in wiki/experiments/ (status=planned or running)369- **Deploy mode but status == running**: prompt "already running — use `/exp-run {slug} --collect` to check status"370- **Collect mode but status == completed**: prompt "already completed — run `/exp-eval {slug}` directly"371- **GPU unavailable**: report error, suggest using --env remote or waiting for GPU to free up372- **Review LLM unavailable** (--review mode): skip code review, note "unreviewed" in DEPLOY_REPORT373- **Sanity check fails**: report detailed error, attempt one automatic fix, if still failing stop and suggest manual debugging374- **Remote connection fails**: report SSH error, suggest checking connection config and config/server.yaml375- **Result files missing** (collect mode): report which seeds are missing results; summarize available results normally; if successful seeds < 2, mark inconclusive376- **Experiment crashed** (traceback detected in collect mode): include crash info and suggested fix directions in report377- **--full mode wait timeout**: if screen session persists beyond 2× the estimated time, warn user but do not force-terminate378379## Dependencies380381### Skills(via Skill tool)382- No direct sub-skill calls383384### Tools(via Bash)385- `python3 tools/research_wiki.py log wiki/ "<message>"` — append log386- `python3 tools/remote.py <command>` — remote operations (status, gpu-status, sync-code, setup-env, launch, check, tail-log, pull-results)387- `nvidia-smi` — local GPU status388- `screen` — local background process management389390### Configuration391- `config/server.yaml` — remote server config (required only with `--env remote`)392393### MCP Servers394- `mcp__llm-review__chat` — Phase 1 code review (optional, when `--review` is used)395396### Claude Code Native397- `Read` — read wiki pages and log files398- `Write` — write experiment code to `experiments/code/{slug}/`399- `Bash` — execute deployment commands, monitor processes400401### Called by402- `/research` Stage 3a (deploy mode) and Stage 3c (collect mode)403- `/exp-status --collect-ready` (collect mode)404- User directly