agentleFS
orange4664orange4664/research-skills/code-reproducer/SKILL.md

code-reproducer

Skill41 starsChanged 8 months agoMITView on GitHub

Automate paper reproduction on remote GPU servers via mcp-ssh, using code-analyzer's reports.

  • Installs packages

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 9 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    code-analyzer: must have been run first (produces code_analysis.json)

    line 22
  2. Distinctive:

    mcp-ssh: must be installed and configured in the MCP client

    line 23
  3. Distinctive:

    After paper-downloader has cloned source code

    line 29
  4. Distinctive:

    Run the code-analyzer skill first:

    line 37
  5. Distinctive:

    Create SSH connection: ask mcp-ssh to connect to the server

    line 53
  6. Very specific:

    Test connection: run echo "Connected" and nvidia-smi

    line 54
  7. Very specific:

    Create a tmux session for persistence: tmux new-session -d -s repro

    line 55
  8. Very specific:

    Create remote workspace: mkdir -p ~/reproduce/<project>

    line 59
  9. Distinctive:

    Start training in the tmux session:

    line 99
  10. Distinctive:

    Import errors → missing dependency, install it

    line 135
  11. Distinctive:

    Error recovery: If training fails:

    line 137
  12. Distinctive:

    Read the error message

    line 138
  13. Distinctive:

    Check what was generated:

    line 145

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

  1. "What is your GPU server's SSH address and port?"
  2. "What is your username?"
  3. "Do you use SSH key or password authentication?"
  4. "Does your server need a jump/bastion host?"

Then use mcp-ssh to:

  1. Create SSH connection: ask mcp-ssh to connect to the server
  2. Test connection: run echo "Connected" and nvidia-smi
  3. Create a tmux session for persistence: tmux new-session -d -s repro

Phase 3: Upload Code (via mcp-ssh)

  1. Create remote workspace: mkdir -p ~/reproduce/<project>
  2. Upload code via mcp-ssh file upload tool
  3. 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
# Wait for completion, then:
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:

# For PyTorch
python -c "import torch; print(f'CUDA: {torch.cuda.is_available()}, GPUs: {torch.cuda.device_count()}')"

# For TensorFlow
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.

  1. 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
  1. 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:

# Get latest log lines
tmux capture-pane -t repro -p | tail -20

# Or check the log file
tail -20 ~/reproduce/<project>/training.log

# Check if process is still running
ps aux | grep python | grep train

# Check GPU usage
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:

  1. Read the error message
  2. Diagnose and fix (install missing package, adjust hyperparameters)
  3. Restart in the same tmux session

Phase 7: Download Results (via mcp-ssh)

After training completes:

  1. 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
  1. Download result files via mcp-ssh to local:
    • Model checkpoints
    • Training logs
    • Generated images/figures
    • Evaluation metrics
  2. 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

ProblemSolution
CUDA version mismatchCheck nvcc --version and install matching PyTorch
OOM (Out of Memory)Reduce batch size, enable gradient checkpointing
Missing dataCheck README for dataset download instructions
Deprecated API callsCheck the paper's publication year, install matching lib versions
Training too slowVerify GPU is being used: nvidia-smi during training
tmux session losttmux ls to list sessions, tmux attach -t repro to reattach
Permission deniedchmod +x <script> or check directory permissions

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.