/experiment-code
Write ML experiment code with iterative improvement. Generate training/evaluation pipelines, debug errors, and optimize results through code reflection. Use when implementing experiments for a research paper.
$ npx -y skills add lingzhi227/agent-research-skills --skill experiment-code --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/experiment-code
Context preview
The summary Claude sees to decide when to auto-load this skill.
Write ML experiment code with iterative improvement. Generate training/evaluation pipelines, debug errors, and optimize results through code reflection. Use when implementing experiments for a research paper.
SKILL.md
experiment-code.SKILL.mdname: experiment-code
description: Write ML experiment code with iterative improvement. Generate training/evaluation pipelines, debug errors, and optimize results through code reflection. Use when implementing experiments for a research paper.
argument-hint: [plan-or-idea]
Experiment Code
Generate and iteratively improve ML experiment code for research papers.
Input
- `$0` — Task: `generate`, `improve`, `debug`, `plot`
- `$1` — Research plan, idea description, or error message
References
- Experiment prompts and patterns: `~/.claude/skills/experiment-code/references/experiment-prompts.md`
- Code patterns (error handling, repair, hill-climbing): `~/.claude/skills/experiment-code/references/code-patterns.md`
Action: `generate`
Generate initial experiment code following this structure:
1. **Plan experiments first** — List all runs needed (hyperparameter sweeps, ablations, baselines) 2. **Write self-contained code** — All code in project directory, no external imports from reference repos 3. **Include proper logging** — Save results to JSON, print intermediate metrics 4. **Generate figures** — At minimum Figure_1.png and Figure_2.png
Mandatory Structure
project/
├── experiment.py # Main experiment script
├── plot.py # Visualization script
├── notes.txt # Experiment descriptions and results
├── run_1/ # Results from run 1
│ └── final_info.json
├── run_2/
└── ...
Constraints
- No placeholder code (`pass`, `...`, `raise NotImplementedError`)
- Must use actual datasets (not toy data unless explicitly requested)
- PyTorch or scikit-learn preferred (no TensorFlow/Keras)
- Each run uses: `python experiment.py --out_dir=run_i`
Action: `improve`
Improve existing experiment code: 1. Read current code and results 2. Reflect on what worked and what didn't 3. Apply targeted edits (prefer small edits over full rewrites) 4. Re-run and compare scores 5. Keep the best-performing code variant
Action: `debug`
Fix experiment code errors: 1. Read the error message (truncate to last 1500 chars if very long) 2. Identify the root cause 3. Apply minimal fix 4. Up to 4 retry attempts before changing approach
Action: `plot`
Generate publication-quality plots from experiment results: 1. Read all `run_*/final_info.json` files 2. Generate comparison plots with proper labels 3. Use the figure-generation skill for styling
Rules
- Always plan experiments before writing code
- After each run, document results in notes.txt
- Include print statements explaining what results show
- Method MUST not get 0% accuracy — verify accuracy calculations
- Use seeds for reproducibility
- Before each experiment include a print statement explaining exactly what the results are meant to show
Related Skills
- Upstream: [experiment-design](../experiment-design/), [algorithm-design](../algorithm-design/)
- Downstream: [data-analysis](../data-analysis/), [backward-traceability](../backward-traceability/)
- See also: [code-debugging](../code-debugging/), [paper-to-code](../paper-to-code/)
Read more
name: experiment-code description: Write ML experiment code with iterative improvement. Generate training/evaluation pipelines, debug errors, and optimize results through code reflection. Use when implementing experiments for a research paper. argument-hint: [plan-or-idea]
Experiment Code
Generate and iteratively improve ML experiment code for research papers.
Input
- `$0` — Task: `generate`, `improve`, `debug`, `plot`
- `$1` — Research plan, idea description, or error message
References
- Experiment prompts and patterns: `~/.claude/skills/experiment-code/references/experiment-prompts.md`
- Code patterns (error handling, repair, hill-climbing): `~/.claude/skills/experiment-code/references/code-patterns.md`
Action: `generate`
Generate initial experiment code following this structure:
1. **Plan experiments first** — List all runs needed (hyperparameter sweeps, ablations, baselines) 2. **Write self-contained code** — All code in project directory, no external imports from reference repos 3. **Include proper logging** — Save results to JSON, print intermediate metrics 4. **Generate figures** — At minimum Figure_1.png and Figure_2.png
Mandatory Structure
project/ ├── experiment.py # Main experiment script ├── plot.py # Visualization script ├── notes.txt # Experiment descriptions and results ├── run_1/ # Results from run 1 │ └── final_info.json ├── run_2/ └── ...
Constraints
- No placeholder code (`pass`, `...`, `raise NotImplementedError`)
- Must use actual datasets (not toy data unless explicitly requested)
- PyTorch or scikit-learn preferred (no TensorFlow/Keras)
- Each run uses: `python experiment.py --out_dir=run_i`
Action: `improve`
Improve existing experiment code: 1. Read current code and results 2. Reflect on what worked and what didn't 3. Apply targeted edits (prefer small edits over full rewrites) 4. Re-run and compare scores 5. Keep the best-performing code variant
Action: `debug`
Fix experiment code errors: 1. Read the error message (truncate to last 1500 chars if very long) 2. Identify the root cause 3. Apply minimal fix 4. Up to 4 retry attempts before changing approach
Action: `plot`
Generate publication-quality plots from experiment results: 1. Read all `run_*/final_info.json` files 2. Generate comparison plots with proper labels 3. Use the figure-generation skill for styling
Rules
- Always plan experiments before writing code
- After each run, document results in notes.txt
- Include print statements explaining what results show
- Method MUST not get 0% accuracy — verify accuracy calculations
- Use seeds for reproducibility
- Before each experiment include a print statement explaining exactly what the results are meant to show
Related Skills
- Upstream: [experiment-design](../experiment-design/), [algorithm-design](../algorithm-design/)
- Downstream: [data-analysis](../data-analysis/), [backward-traceability](../backward-traceability/)
- See also: [code-debugging](../code-debugging/), [paper-to-code](../paper-to-code/)
31 skills for Claude Code covering the full academic research paper lifecycle — from literature search to slide generation — plus GitHub repository analysis for research topics. Extracted from 17 GitHub repos studying LLM-agent-driven research automation.
Other skills on agent-research-skills.
- /algorithm-design
Design algorithms with LaTeX pseudocode and UML diagrams. Generate algorithmic environments, Mermaid class/sequence diagrams, and ensure consistency between pseudocode and implementation. Use when formalizing methods for a paper.
Open skill - /atomic-decomposition
Decompose research ideas into atomic, self-contained concepts with bidirectional math-code mapping. For each concept, extract the math formula from papers and find code implementations. Use for complex system papers requiring formal grounding.
Open skill - /backward-traceability
Make every number in the final PDF traceable to the exact code line that produced it. Uses \hypertarget/\hyperlink LaTeX commands and \num{formula} evaluated at compile time. Use for reproducibility and data integrity verification.
Open skill - /citation-management
Manage BibTeX citations for LaTeX papers. Harvest missing citations from a draft using Semantic Scholar, validate cite keys against .bib files, deduplicate entries, and format bibliography. Use when working with references, BibTeX, or citations.
Open skill - /code-debugging
Debug experiment code with structured error analysis. Categorize errors, apply targeted fixes with retry logic, and use reflection to prevent recurring issues. Use when experiment code fails or produces incorrect results.
Open skill - /data-analysis
Generate statistical analysis code with 4-round review. Select appropriate statistical tests, interpret results, and produce analysis reports with p-values, effect sizes, and confidence intervals. Use when analyzing experimental data for a paper.
Open skill

