| name | code-reproducer |
| description | Automate paper reproduction on remote GPU servers via mcp-ssh, using code-analyzer's reports. |
Code Reproducer Skill
Purpose
Automate the full reproduction of a research paper's experiments on remote GPU servers. This skill reads the analysis report from code-analyzer and executes the reproduction plan via mcp-ssh.
Architecture
code-analyzer (analysis) โ code-reproducer (this skill) โ mcp-ssh (SSH)
โโโ code_analysis.json โโโ Reads analysis report โโโ SSH connection
โโโ Framework โโโ Environment setup โโโ Command execution
โโโ Training scripts โโโ Training execution โโโ File upload/download
โโโ Configs โโโ Progress monitoring โโโ tmux sessions
โโโ Reproduction plan โโโ Result downloading โโโ Persistent sessions
Prerequisites
- code-analyzer must have been run first (produces
code_analysis.json)
- mcp-ssh must be installed and configured in the MCP client
- Install:
git clone https://github.com/shuakami/mcp-ssh.git && cd mcp-ssh && npm install && npm run build
- Config: Add to your MCP config (Cursor/Claude Desktop
mcp.json)
- Docs: https://github.com/shuakami/mcp-ssh
When to Use
- After paper-downloader has cloned source code
- User asks to "reproduce", "train", "run experiments", or "replicate results"
- User wants to execute code on a remote GPU server
Workflow
Phase 1: Analyze Repository (LOCAL) โ via code-analyzer
Run the code-analyzer skill first:
python code-analyzer/analyze.py workspace/<paper>/code/<repo>/ -o workspace/<paper>/code_analysis.json
This produces a comprehensive JSON report containing framework detection, AST call graph, training loop analysis, reproducibility score, and a step-by-step reproduction plan. See code-analyzer/SKILL.md for full details.
Phase 2: Setup Server (via mcp-ssh)
First-time setup โ ask the user these questions:
- "What is your GPU server's SSH address and port?"
- "What is your username?"
- "Do you use SSH key or password authentication?"
- "Does your server need a jump/bastion host?"
Then use mcp-ssh to:
- Create SSH connection: ask mcp-ssh to connect to the server
- Test connection: run
echo "Connected" and nvidia-smi
- Create a tmux session for persistence:
tmux new-session -d -s repro
Phase 3: Upload Code (via mcp-ssh)
- Create remote workspace:
mkdir -p ~/reproduce/<project>
- Upload code via mcp-ssh file upload tool
- Verify:
ls -la ~/reproduce/<project>/
Phase 4: Setup Environment (via mcp-ssh)
Based on code_analysis.json, execute the appropriate commands IN the tmux session:
For conda + requirements.txt:
tmux send-keys -t repro "conda create -n repro_<project> python=3.10 -y" Enter
tmux send-keys -t repro "conda activate repro_<project>" Enter
tmux send-keys -t repro "cd ~/reproduce/<project> && pip install -r requirements.txt" Enter
For environment.yml:
tmux send-keys -t repro "conda env create -f ~/reproduce/<project>/environment.yml -n repro_<project>" Enter
For Docker:
tmux send-keys -t repro "cd ~/reproduce/<project> && docker build -t repro ." Enter
After setup, verify:
python -c "import torch; print(f'CUDA: {torch.cuda.is_available()}, GPUs: {torch.cuda.device_count()}')"
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
Phase 5: Run Training (via mcp-ssh + tmux)
[!IMPORTANT]
Always use tmux for training. This ensures the training continues even if the SSH session drops.
- Start training in the tmux session:
tmux send-keys -t repro "cd ~/reproduce/<project>" Enter
tmux send-keys -t repro "python <training_script> <args> 2>&1 | tee training.log" Enter
- The training command comes from
code_analysis.json โ reproduction_plan:
- First priority: README training commands
- Second: detected training scripts (with confidence scores)
- Third: ask the user
Phase 6: Monitor Training (periodic)
[!TIP]
For long training runs: After starting training, wait/sleep for a reasonable interval (e.g., 10-30 minutes for quick tests, 1-2 hours for full training), then check progress.
Check progress via mcp-ssh:
tmux capture-pane -t repro -p | tail -20
tail -20 ~/reproduce/<project>/training.log
ps aux | grep python | grep train
nvidia-smi
What to look for:
- Loss decreasing โ training is working
- OOM errors โ reduce batch size
- CUDA errors โ check CUDA version compatibility
- NaN loss โ check learning rate, data preprocessing
- Import errors โ missing dependency, install it
Error recovery: If training fails:
- Read the error message
- Diagnose and fix (install missing package, adjust hyperparameters)
- Restart in the same tmux session
Phase 7: Download Results (via mcp-ssh)
After training completes:
- Check what was generated:
find ~/reproduce/<project> -name "*.pt" -o -name "*.pth" -o -name "*.ckpt" -o -name "*.png" -o -name "*.csv" -o -name "*.log" | head -30
-
Download result files via mcp-ssh to local:
- Model checkpoints
- Training logs
- Generated images/figures
- Evaluation metrics
-
Save to workspace/<paper>/results/
Phase 8: Report to User
Tell the user:
- โ
Training completed (or โ failed with reason)
- Duration
- Final metrics (loss, accuracy, FID, etc.)
- Files downloaded
- Next steps (run result-analyzer for comparison with paper)
Dependencies
Common Pitfalls and Solutions
| Problem | Solution |
|---|
| CUDA version mismatch | Check nvcc --version and install matching PyTorch |
| OOM (Out of Memory) | Reduce batch size, enable gradient checkpointing |
| Missing data | Check README for dataset download instructions |
| Deprecated API calls | Check the paper's publication year, install matching lib versions |
| Training too slow | Verify GPU is being used: nvidia-smi during training |
| tmux session lost | tmux ls to list sessions, tmux attach -t repro to reattach |
| Permission denied | chmod +x <script> or check directory permissions |