code-analyzer
Skill41 starsChanged 8 months agoMITView on GitHub
Deep analysis of ML source code repositories — AST call graphs, training loop dissection, reproducibility scoring.
- Installs packages
6 other projects use a version of this.
Adopted by
Most recently taken up by
- jerry-guo-mys/skillstheir own version, first seen Nov 8, 2026
- jablonkai/skillstheir own version, first seen Oct 1, 2026
- maurigre/mgr-methodtheir own version, first seen Jul 15, 2026
- CharTyr/Mai-Skill-Loadertheir own version, first seen Jun 25, 2026
- zb-keen/skillstheir own version, first seen Apr 22, 2026
- nimbalyst/skillstheir own version, first seen Feb 16, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- nimbalyst/skills★ 28same name
- CharTyr/Mai-Skill-Loader★ 4same name
- jablonkai/skills★ 2same name
- maurigre/mgr-method★ 2same name
- jerry-guo-mys/skills★ 1same name
- zb-keen/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- code-reproducerSkill
- code-writerSkill
- formula2codeSkill
- paper-downloaderSkill
- paper-finderSkill
- paper-parserSkill
- paper-presenterSkill
- result-analyzerSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
After paper-downloader has cloned source code
- Distinctive: line 25
Before running code-reproducer (to generate the reproduction plan)
- Distinctive: line 26
When evaluating whether a codebase is worth trying to reproduce
- Very specific: line 50
Class hierarchy: All classes, especially nn.Module subclasses
- Distinctive: line 141
When encountering issues with code analysis, fetch these URLs:
- Very specific: line 164
Solution: Ensure graphviz is installed system-wide.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Analyzer Skill
Purpose
Perform comprehensive analysis of a cloned ML research repository to understand:
- What framework it uses (PyTorch, TensorFlow, JAX, HuggingFace)
- How its code is structured (classes, functions, call graphs)
- How training works (optimizer, loss, scheduler, loop structure)
- What configuration system it uses (argparse, Hydra, YAML, etc.)
- How reproducible it is (0-100 score based on ML Code Completeness Checklist)
This skill produces a structured JSON report consumed by other skills:
- code-reproducer: Uses the reproduction plan to run experiments
- paper-presenter: Uses AST analysis for code-theory alignment
When to Use
- After paper-downloader has cloned source code
- User asks to "analyze", "understand", or "review" source code
- Before running code-reproducer (to generate the reproduction plan)
- When evaluating whether a codebase is worth trying to reproduce
Quick Start
# Install optional dependencies (for flowchart generation)
pip install -r code-analyzer/requirements.txt
# Run full analysis
python code-analyzer/analyze.py workspace/<paper>/code/<repo>/ -o workspace/<paper>/code_analysis.json
# With optional code2flow flowchart
python code-analyzer/analyze.py <code_dir> -o analysis.json --flowchartWhat It Analyzes
1. Framework Detection
Scans imports and dependency files to identify:
- PyTorch, TensorFlow, JAX, HuggingFace, Diffusers, scikit-learn
- Gives confidence scores for each framework
2. AST Deep Analysis (Python ast module, PyCG-inspired)
- Function call graph: Who calls whom
- Class hierarchy: All classes, especially
nn.Modulesubclasses - Model layer extraction:
self.conv1 = nn.Conv2d(...)from__init__ - Key functions: trains, forwards, losses, evaluates, samples, generates
- Import dependency graph: Module → imported modules
3. Training Loop Dissection
- Locates
for epoch in range(...)training loops via AST - Identifies optimizer type (Adam, SGD, AdamW, etc.)
- Identifies loss function type (CrossEntropy, MSE, custom, etc.)
- Detects LR scheduler, logging framework (WandB, TensorBoard, etc.)
- Extracts hyperparameters (lr, batch_size, epochs, etc.)
- Detects checkpoint saving, distributed training, mixed precision
4. Configuration System Detection
- Detects: argparse, Hydra, OmegaConf, click, fire, sacred, absl, yacs
- Extracts all argparse arguments with name, type, default, help
- Parses YAML/TOML config files
- Consolidates key hyperparameters
5. Reproducibility Scoring (ML Code Completeness Checklist)
Based on NeurIPS/PwC standards:
| Check | Points |
| Dependency spec (requirements.txt) | 15 |
| Training code | 15 |
| Evaluation code | 10 |
| Pre-trained models | 10 |
| Config files | 10 |
| README training commands | 10 |
| Results table | 10 |
| Dockerfile | 5 |
| LICENSE | 5 |
| .gitignore | 5 |
| Tests | 5 |
Total: 100 points → Grade A/B/C/D/F
6. Reproduction Plan Generation
Automatically generates a step-by-step reproduction plan with shell commands.
Output Format
The JSON report contains:
{
"framework": {"primary": "pytorch", "all": {...}},
"structure": {"total_files": 42, "total_py_files": 28},
"ast_analysis": {
"model_classes": [...],
"key_functions": {"train": [...], "forward": [...], "loss": [...]},
"call_graph": {"module.func": ["callee1", "callee2"]},
"stats": {"total_functions": 150, "model_classes": 3}
},
"training": {
"training_loops": [...],
"optimizers": ["AdamW"],
"loss_functions": ["CrossEntropyLoss"],
"hyperparameters": {"lr": "0.001", "batch_size": "32"}
},
"configs": {
"config_systems": ["argparse"],
"argparse_args": [{"name": "--lr", "default": "0.001"}]
},
"reproducibility": {
"total_score": 75,
"grade": "B",
"recommendations": [...]
},
"reproduction_plan": [
{"step": 1, "name": "Environment Setup", "commands": [...]},
{"step": 2, "name": "Training", "commands": [...]}
]
}Dependencies
- Core: Python 3.10+ (stdlib only —
ast,re,json,pathlib) - Optional:
code2flowfor flowchart generation (pip install code2flow)
Integration with Other Skills
- Input: Cloned source code directory (from paper-downloader)
- Output:
code_analysis.jsonused by:code-reproducer→ reads reproduction plan, training commandspaper-presenter→ reads AST analysis for code-theory alignmentresult-analyzer→ reads expected metrics for comparison
📚 Reference URLs (for agent self-help)
When encountering issues with code analysis, fetch these URLs:
| Topic | URL |
Python ast module docs | https://docs.python.org/3/library/ast.html |
| PyCG call graph analysis | https://github.com/vitsalis/PyCG |
| PyCG paper (ICSE'21) | https://arxiv.org/abs/2103.00587 |
| code2flow flowcharts | https://github.com/scottrogowski/code2flow |
| ML Code Completeness Checklist | https://medium.com/paperswithcode/ml-code-completeness-checklist-e9127b168501 |
| Papers With Code trends | https://paperswithcode.com/trends |
| PyTorch model inspection | https://pytorch.org/docs/stable/generated/torch.nn.Module.html |
| HuggingFace Trainer API | https://huggingface.co/docs/transformers/main_classes/trainer |
Troubleshooting AST Analysis
Problem: AST parsing fails on a Python file. Likely cause: Non-standard Python syntax, encoding issues, or Python 2 code.
# Fetch Python ast docs:
fetch_url("https://docs.python.org/3/library/ast.html")Troubleshooting code2flow
Problem: code2flow not generating flowcharts.
Solution: Ensure graphviz is installed system-wide.
# Windows
choco install graphviz
# Ubuntu
apt-get install graphviz# Fetch code2flow docs:
fetch_url("https://github.com/scottrogowski/code2flow")Understanding Reproducibility Scores
Problem: Need to understand why a repo scored low.
# Fetch the ML Code Completeness methodology:
fetch_url("https://medium.com/paperswithcode/ml-code-completeness-checklist-e9127b168501")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
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.

