/exp-run
Execute an experiment that has been planned in wiki/experiments/.
No matter which operation mode it is, before preparing the experimental codes and deploying them for operation, confirmation shall be obtained from users. Users need to manually check relevant information such as codes and experimental configurations(Dataset paths, interface parameter selection, API configuration, etc.). The operation can only be launched after confirmation; otherwise, revisions shall be made repeatedly until users approve the execution.
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, linked_idea
wiki/ideas/{linked-idea}.md — linked idea's approach sketch (guide code implementation, understand experiment purpose)
wiki/papers/*.md — related papers' method details and hyperparameters (implementation reference)
wiki/experiments/*.md — other experiments on the same idea (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 (deploy / collect mode)
wiki/log.md — append operation log
Graph edges created
- None. The tested_by edges between experiments and ideas 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 idea (reference code structure)
Inspect the dataset and other configurations
- The dataset is specified in the setup section of
wiki/experiments/{slug}.md
- Obtain the dataset path (select local or remote access based on the --env parameter). You may ask users for the local or remote dataset paths and conduct independent retrieval.
- Prompt users if the dataset is missing, clarify the need to download the dataset, and confirm the installation path and download source with users.
- Check the integrity and availability of the dataset, and sort out its built-in structure and usage instructions.
- Other configurations include: LLM model name for invocation, URL, API key, etc.
Write experiment code to experiments/code/{slug}/:
Modular thinking in coding: avoid putting a large amount of code in a single file unless the project is small in scale and simple in logic
train.py: generate training/evaluation script based on setup config as the entry point of the program 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}/)
- Other required code folders and files such as utils, tools (e.g.,
utils.py, data_loader.py, etc.)
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
Gate: Manual User Inspection
Note: Before preparing experimental code for deployment and execution, confirm with users and request them to manually check relevant information including codes and experimental configurations(Dataset paths, interface parameter selection, API configuration, etc.). Proceed with operation only after confirmation; otherwise, make revisions repeatedly until users approve the execution.
Phase 2: Deploy
Local mode (--env local or default)
Check GPU: nvidia-smi to confirm GPU available and sufficient VRAM. If setup.hardware is cpu/none/empty and generated code has no CUDA/GPU keywords, skip GPU check and go to step 2 directly.
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 (skip if setup.hardware is cpu/none/empty and code has no CUDA/GPU keywords)
- 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 the linked idea 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 the linked idea's status: experiment results are written only to experiments/ pages; idea 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: autosci-exp-run3description: Full experiment execution pipeline — prepare code → deploy(Confirm with the user before operation and ask the applicant to conduct manual inspection) → monitor → collect results, supporting three run modes4---56# /exp-run78> Execute an experiment that has been planned in wiki/experiments/.9> **No matter which operation mode it is, before preparing the experimental codes and deploying them for operation, confirmation shall be obtained from users. Users need to manually check relevant information such as codes and experimental configurations(Dataset paths, interface parameter selection, API configuration, etc.). The operation can only be launched after confirmation; otherwise, revisions shall be made repeatedly until users approve the execution.**10> **Three run modes** for different scenarios:11> - **Default (deploy)**: Phase 1-2 only — deploy and return immediately. Best for experiments that take hours or days.12> - **`--collect`**: Phase 3-4 only — check whether a deployed experiment has finished; collect results if so (`--check` is an alias).13> - **`--full`**: All four phases end-to-end. Best for short local experiments that finish in minutes.14>15> Recommended flow: `/exp-run <slug>` to deploy → `/exp-status` to monitor → `/exp-run <slug> --collect` to collect.1617## Inputs1819- `experiment`: slug from wiki/experiments/20 - deploy mode: status must be `planned`21 - --collect mode: status must be `running`22 - --full mode: status must be `planned`23- `--review` (optional): enable Review LLM code review for experiment code in Phase 1 (valid in deploy / full mode)24- `--collect` (optional): collect mode — check if the experiment has finished and collect results; `--check` is an alias25- `--full` (optional): full mode — execute all 4 phases (best for quick local experiments)26- `--env local|remote` (optional, default `local`): deployment environment27 - `local`: run directly on local GPU28 - `remote`: deploy to remote machine via SSH (requires `config/server.yaml`)2930## Outputs3132- **deploy mode**:33 - Experiment code: `experiments/code/{slug}/` (generated in Phase 1)34 - `wiki/experiments/{slug}.md` — status: planned → running35 - **DEPLOY_REPORT** (printed to terminal) — deployment confirmation, session info, next steps36 - `wiki/log.md` — appended deploy log37- **collect mode** (experiment has finished):38 - `wiki/experiments/{slug}.md` — status: running → completed; outcome/key_result/date_completed filled in39 - **RUN_REPORT** (printed to terminal) — result summary, metrics comparison, next step suggestions40 - `wiki/log.md` — appended collect log41- **collect mode** (experiment still running):42 - Progress report printed to terminal only; wiki is not modified43- **full mode**: all outputs from both deploy and collect4445## Wiki Interaction4647### Reads48- `wiki/experiments/{slug}.md` — experiment config: setup, metrics, baseline, hypothesis, linked_idea49- `wiki/ideas/{linked-idea}.md` — linked idea's approach sketch (guide code implementation, understand experiment purpose)50- `wiki/papers/*.md` — related papers' method details and hyperparameters (implementation reference)51- `wiki/experiments/*.md` — other experiments on the same idea (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 block (deploy / collect mode)60- `wiki/log.md` — append operation log6162### Graph edges created63- **None**. The tested_by edges between experiments and ideas 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 idea (reference code structure)85863. **Inspect the dataset and other configurations**87 - The dataset is specified in the setup section of `wiki/experiments/{slug}.md`88 - Obtain the dataset path (select local or remote access based on the --env parameter). You may ask users for the local or remote dataset paths and conduct independent retrieval.89 - Prompt users if the dataset is missing, clarify the need to download the dataset, and confirm the installation path and download source with users.90 - Check the integrity and availability of the dataset, and sort out its built-in structure and usage instructions.91 - Other configurations include: LLM model name for invocation, URL, API key, etc.92934. **Write experiment code** to `experiments/code/{slug}/`:94 **Modular thinking in coding: avoid putting a large amount of code in a single file unless the project is small in scale and simple in logic**95 - `train.py`: generate training/evaluation script based on setup config as the entry point of the program including:96 - Argument parsing (argparse, all hyperparameters configurable)97 - Data loading (support setup.dataset)98 - Model initialization (support setup.model and baseline model)99 - Training/inference loop100 - Metric computation (matching metrics list)101 - Result saving (JSON format, path: `results/{slug}/seed_{N}.json`)102 - Random seed control (multi-seed runs)103 - Checkpoint save/restore (`checkpoints/{slug}/`)104 - Other required code folders and files such as utils, tools (e.g., `utils.py`, `data_loader.py`, etc.)105 - `config.yaml`: all hyperparameters (learning_rate, batch_size, epochs, seeds, etc.)106 - `run.sh`: complete launch command wrapper (includes CUDA_VISIBLE_DEVICES, logging, conda activation)107 - `requirements.txt`: experiment-specific dependencies (if different from main project requirements)1081095. **Optional Review LLM code review** (`--review`):110 ```111 mcp__llm-review__chat:112 system: "You are a senior ML engineer reviewing experiment code.113 Focus on: correctness of the training loop, proper evaluation protocol,114 fair baseline comparison, reproducibility (seeds, determinism),115 proper metric computation, and common pitfalls (data leakage,116 wrong split, gradient accumulation bugs)."117 message: |118 ## Experiment119 {experiment title and hypothesis}120121 ## Code122 {generated code}123124 ## Expected Behavior125 {setup details from wiki page}126127 Review for correctness and potential issues.128 ```129 Fix code based on Review LLM feedback.1301316. **Sanity check (small-scale validation)**:132 - Run at minimal scale (1 epoch / 100 steps / small subset)133 - Verify: no code crash, data loads correctly, GPU available, loss decreases134 - If sanity fails → fix code, retry once; if still failing, report error and stop135136137**Gate: Manual User Inspection**138139> **Note**: Before preparing experimental code for deployment and execution, confirm with users and request them to manually check relevant information including codes and experimental configurations(Dataset paths, interface parameter selection, API configuration, etc.). Proceed with operation only after confirmation; otherwise, make revisions repeatedly until users approve the execution.140141**Phase 2: Deploy**142143#### Local mode (`--env local` or default)1441451. **Check GPU**: `nvidia-smi` to confirm GPU available and sufficient VRAM. If `setup.hardware` is `cpu`/`none`/empty and generated code has no CUDA/GPU keywords, skip GPU check and go to step 2 directly.1462. **Launch**:147 ```bash148 screen -dmS exp-{slug} bash -c \149 "cd $(pwd) && bash experiments/code/{slug}/run.sh 2>&1 | tee logs/exp-{slug}.log"150 ```1513. Update `wiki/experiments/{slug}.md`:152 - status: `running`153 - run_log: `logs/exp-{slug}.log`1544. **Estimate runtime** and write to frontmatter:155 Estimate based on `setup.hardware` (GPU model/count), `setup.model` (parameter count), `setup.dataset` (scale):156157 | Typical scenario | Estimated range |158 |-----------------|-----------------|159 | Single GPU + small dataset (CIFAR / small NLP benchmark) | 0.5 – 3h |160 | Single A100 + medium dataset (ImageNet / GLUE) | 4 – 12h |161 | Multi-GPU or large model fine-tuning (≥7B) | 8 – 48h |162163 ```bash164 python3 tools/research_wiki.py set-meta \165 wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"166 python3 tools/research_wiki.py set-meta \167 wiki/experiments/{slug}.md estimated_hours {N}168 ```1695. Append log:170 ```bash171 python3 tools/research_wiki.py log wiki/ \172 "exp-run | deployed {slug} | env: local | session: exp-{slug} | eta: {N}h"173 ```174175#### Remote mode (`--env remote`)176177**Prerequisite**: user has configured `config/server.yaml`.1781791. **Confirm connectivity**: `python3 tools/remote.py status`180 - If unreachable → report error and suggest checking config/server.yaml1812. **Find free GPU**: `python3 tools/remote.py gpu-status` (skip if `setup.hardware` is `cpu`/`none`/empty and code has no CUDA/GPU keywords)182 - If no free GPU → report each GPU's usage, suggest waiting1833. **Sync code**: `python3 tools/remote.py sync-code`1844. **Install dependencies** (first time or if requirements changed): `python3 tools/remote.py setup-env`1855. **Launch remote experiment**:186 ```bash187 python3 tools/remote.py launch \188 --name "exp-{slug}" \189 --cmd "bash experiments/code/{slug}/run.sh" \190 --gpu {gpu_index}191 ```1926. Update `wiki/experiments/{slug}.md` frontmatter — all of these fields already exist (empty) because `/exp-design` wrote the full CLAUDE.md template:193 ```bash194 # Top-level scalar fields — use set-meta195 python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md status running196 python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md run_log "logs/exp-{slug}.log"197 ```198199 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:200 ```yaml201 remote:202 server: ""203 gpu: ""204 session: ""205 started: ""206 completed: ""207 ```208 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).2092107. **Estimate runtime** and write to frontmatter (same estimation logic as local mode):211 ```bash212 python3 tools/research_wiki.py set-meta \213 wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"214 python3 tools/research_wiki.py set-meta \215 wiki/experiments/{slug}.md estimated_hours {N}216 ```2178. Append log:218 ```bash219 python3 tools/research_wiki.py log wiki/ \220 "exp-run | deployed {slug} | env: remote | server: {host} | gpu: {gpu} | eta: {N}h"221 ```222223**Print DEPLOY_REPORT to terminal**:224225```markdown226# Deploy Report: {experiment title}227228### Status: DEPLOYED ✅229230- Session: exp-{slug}231- Environment: local | remote ({host} GPU {gpu})232- Log file: logs/exp-{slug}.log233- Code: experiments/code/{slug}/234- Estimated: ~{N}h (expected completion: {YYYY-MM-DD HH:MM})235236### Next Steps2372381. Monitor progress: `/exp-status`2392. Check this experiment: `/exp-run {slug} --collect`2403. In /research pipeline: progress saved to wiki/outputs/pipeline-progress.md241242### Quick Commands243```bash244# Local: check if still running245screen -ls | grep exp-{slug}246247# Local: tail log248tail -f logs/exp-{slug}.log249```250```251252---253254### Collect Mode (`--collect` or `--check`, status == running)255256**Phase 3: Monitor / Check Run Status**2572581. **Read deployment info**: from `wiki/experiments/{slug}.md` frontmatter, get environment (local or remote) and session name.2592602. **Check whether the process is still alive**:261 - **Local**: `screen -ls | grep exp-{slug}`262 - **Remote**: `python3 tools/remote.py check --name "exp-{slug}"`, parse `alive` field2632643. **If experiment is still running (alive == true)**:265 - Fetch recent logs:266 - Local: `tail -30 logs/exp-{slug}.log`267 - Remote: `python3 tools/remote.py tail-log --name "exp-{slug}" --lines 30`268 - **Anomaly detection**:269 - NaN loss: detect `loss: nan`270 - OOM: `CUDA out of memory`271 - Traceback: Python exception stacktrace272 - Inf loss: `loss: inf`273 - **Automatic fix attempt** (if anomaly detected, at most 1 attempt):274 - NaN/exploding → resume from latest checkpoint, reduce learning rate275 - OOM → reduce batch size, restart276 - **Print progress report** (do not modify wiki, report only):277 ```278 Experiment {slug}: RUNNING279 Progress: step {N} / epoch {E}280 Latest metric: {metric} = {value}281 Anomalies: {none | NaN detected | ...}282 Estimated remaining: ~{N} hours283 Run `/exp-status` to monitor all running experiments.284 ```285 - **Return** (do not execute Phase 4)2862874. **If experiment has finished (alive == false / session gone)**:288 - Continue to Phase 4289290**Phase 4: Collect Results**2912921. **Pull remote results** (remote mode only):293 ```bash294 python3 tools/remote.py pull-results \295 --remote-path "results/{slug}/" \296 --local-path "./results/{slug}/"297298 python3 tools/remote.py pull-results \299 --remote-path "logs/exp-{slug}.log" \300 --local-path "./logs/"301 ```3023032. **Check result files exist**: `results/{slug}/seed_*.json`3043053. **Parse results**:306 - Read result files (JSON)307 - Compute mean ± std per metric (across seeds)308 - Compare with baseline, compute improvement delta3093104. **Update experiment page** `wiki/experiments/{slug}.md`:311 - status: `completed`312 - outcome: `succeeded` / `failed` / `inconclusive`313 - succeeded: all success criteria met314 - failed: core metrics did not reach target315 - inconclusive: mixed results or excessive variance316 - key_result: one-sentence summary of the core finding317 - date_completed: today's date318 - Fill `## Results` section: complete results table319 - Fill `## Analysis` section: preliminary analysis320 - If remote mode: update `remote.completed` timestamp3213225. **Append log**:323 ```bash324 python3 tools/research_wiki.py log wiki/ \325 "exp-run | completed {slug} | outcome: {outcome} | key: {key_result}"326 ```3273286. **Print RUN_REPORT to terminal**:329 ```markdown330 # Run Report: {experiment title}331332 ## Outcome: {succeeded / failed / inconclusive}333334 ## Results335 | Metric | Baseline | Ours (mean±std) | Δ |336 |--------|----------|-----------------|---|337 | {metric} | {baseline-value} | {mean}±{std} | +{delta} |338339 ## Key Finding340 {key_result}341342 ## Next Steps343 - Run `/exp-eval {slug}` to update the linked idea in wiki344 - {if succeeded: proceed to next experiment in plan}345 - {if failed: analyze failure, consider /exp-design revision}346 ```347348---349350### Full Mode (`--full`, status == planned)351352Execute all 4 phases in sequence (Phase 1 → Phase 2 → Phase 3 → Phase 4) without returning.353354Use case: quick local CPU/GPU experiments that finish in minutes (sanity checks, toy dataset validation, etc.).355356In Phase 3, instead of checking "is it still running", wait for the screen session to actually exit before executing Phase 4:357```bash358# Wait for session to end (polling)359while screen -ls | grep -q "exp-{slug}"; do360 sleep 30361done362# Session gone, proceed to Phase 4363```364365---366367## Constraints368369- **Deploy mode only accepts planned experiments**: if status is running, prompt to use --collect; if completed, refuse370- **Collect mode only accepts running experiments**: if status is planned, prompt to deploy first; if completed, note it is already done371- **Collect mode: do not write wiki when alive**: only report progress, do not modify any wiki files372- **Code goes in experiments/code/{slug}/**: do not write to project root or any other location373- **Do not update the linked idea's status**: experiment results are written only to experiments/ pages; idea updates are handled by /exp-eval374- **Sanity check must pass**: Phase 1 sanity failure blocks deployment (unless user explicitly overrides)375- **Results must be saved**: all experiment results saved as JSON in `results/{slug}/seed_{N}.json`376- **Multi-seed results use mean**: report mean ± std, not single-run results377- **Graph edges are not created here**: tested_by edges were created by /exp-design378- **Automatic fix attempts are limited to 1**: prevents infinite restart loops379380## Error Handling381382- **Experiment not found**: prompt user to check slug, list candidates in wiki/experiments/ (status=planned or running)383- **Deploy mode but status == running**: prompt "already running — use `/exp-run {slug} --collect` to check status"384- **Collect mode but status == completed**: prompt "already completed — run `/exp-eval {slug}` directly"385- **GPU unavailable**: report error, suggest using --env remote or waiting for GPU to free up386- **Review LLM unavailable** (--review mode): skip code review, note "unreviewed" in DEPLOY_REPORT387- **Sanity check fails**: report detailed error, attempt one automatic fix, if still failing stop and suggest manual debugging388- **Remote connection fails**: report SSH error, suggest checking connection config and config/server.yaml389- **Result files missing** (collect mode): report which seeds are missing results; summarize available results normally; if successful seeds < 2, mark inconclusive390- **Experiment crashed** (traceback detected in collect mode): include crash info and suggested fix directions in report391- **--full mode wait timeout**: if screen session persists beyond 2× the estimated time, warn user but do not force-terminate392393## Dependencies394395### Skills(via Skill tool)396- No direct sub-skill calls397398### Tools(via Bash)399- `python3 tools/research_wiki.py log wiki/ "<message>"` — append log400- `python3 tools/remote.py <command>` — remote operations (status, gpu-status, sync-code, setup-env, launch, check, tail-log, pull-results)401- `nvidia-smi` — local GPU status402- `screen` — local background process management403404### Configuration405- `config/server.yaml` — remote server config (required only with `--env remote`)406407### MCP Servers408- `mcp__llm-review__chat` — Phase 1 code review (optional, when `--review` is used)409410### Claude Code Native411- `Read` — read wiki pages and log files412- `Write` — write experiment code to `experiments/code/{slug}/`413- `Bash` — execute deployment commands, monitor processes414415### Called by416- `/research` Stage 3a (deploy mode) and Stage 3c (collect mode)417- `/exp-status --collect-ready` (collect mode)418- User directly