code-writer
Skill41 starsChanged 8 months agoMITView on GitHub
Generate implementation code scaffolding from paper descriptions when no source code exists.
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- melonkernel/shuntkittheir own version, first seen Oct 9, 2026
- SalehB1/shunt-anywheretheir own version, first seen Sep 9, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- SalehB1/shunt-anywhere★ 4same name
- melonkernel/shuntkit★ 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-analyzerSkill
- code-reproducerSkill
- formula2codeSkill
- paper-downloaderSkill
- paper-finderSkill
- paper-parserSkill
- paper-presenterSkill
- result-analyzerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 11 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
When a paper has no source code, this skill generates a complete project scaffolding with model, training, data loading, and evaluation …
- Very specific: line 14
After paper-parser has extracted the paper content but paper-finder found no code
- Distinctive: line 15
When reproducing a paper from scratch
- Distinctive: line 109
Read the paper's experiment section for dataset details
- Distinctive: line 112
Check normalization: [0,1] or [-1,1]?
- Very specific: line 126
Use formula2code for any mathematical operations:
- Distinctive: line 134
Check parameter count against paper (if reported)
- Very specific: line 137
Use formula2code to convert the paper's loss equation
- Distinctive: line 138
If it's a standard loss (CE, MSE, etc.), use PyTorch built-in
- Distinctive: line 143
Add learning rate scheduler (check paper for warmup/cosine)
- Distinctive: line 144
Add gradient clipping (if mentioned)
- Distinctive: line 211
When stuck, the agent should fetch these URLs for guidance:
- Distinctive: line 226
When modifying Jinja2 templates:
- Distinctive: line 233
When implementing data loading:
≈ “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.
Files
Code-Writer Skill
Purpose
When a paper has no source code, this skill generates a complete project scaffolding with model, training, data loading, and evaluation code — ready to fill in and run.
When to Use
- Paper has no associated GitHub repository
- User says "implement this paper" or "write code for this model"
- After
paper-parserhas extracted the paper content butpaper-finderfound no code - When reproducing a paper from scratch
Prerequisites
- Paper content (from
paper-parserJSON/MD, or user description) formula2codeskill (for converting paper equations to code)code-analyzerskill (for analyzing reference implementations)paper-finderskill (for searching reference code)
Architecture
Paper Content (JSON/MD/description)
│
▼
Phase 0: Reference Code Discovery ← KEY INNOVATION
│ "Papers don't exist in a vacuum — find code for what they build on"
│ → paper-finder: search for base methods' implementations
│ → code-analyzer: analyze found repos for reusable components
▼
Phase 1: Paper Info Extraction
│ → extractors/paper_info.py: title, abstract, sections
│ → extractors/architecture.py: model components, layer types
│ → extractors/equations.py: LaTeX formulas
│ → extractors/experiment.py: hyperparameters, datasets, metrics
▼
Phase 2: Code Generation (with reference code guidance)
│ → generate.py: fill templates with extracted info
│ → formula2code: convert equations to loss/model code
▼
Phase 3: Output
project/
├── configs/default.yaml # Hyperparameters from paper
├── src/
│ ├── model.py # Architecture skeleton with TODOs
│ ├── train.py # Training loop (standard PyTorch)
│ ├── data.py # Data loading skeleton
│ └── evaluate.py # (generated when metrics detected)
├── references/
│ └── search_plan.md # What code to search for
├── implementation_checklist.md # Step-by-step guide
├── requirements.txt
└── README.mdUsage
Quick Start
# From paper-parser JSON
python code-writer/generate.py --paper workspace/<paper>/paper_content.json -o workspace/<paper>/implementation/
# From markdown
python code-writer/generate.py --markdown workspace/<paper>/paper.md -o workspace/<paper>/implementation/
# From text description
python code-writer/generate.py --describe "A transformer-based model for image classification with self-attention" -o project/Agent Workflow — How to Implement a Paper from Scratch
This is the most important section. Follow this methodology step by step.
Step 0: Reference Code Discovery (BEFORE writing any code)
The paper you're implementing is NOT invented from nothing. It builds on existing methods. Find their code first.
- Read the paper (from paper-parser output) and identify:
- What base methods/architectures it uses (e.g., "extends ResNet", "uses Transformer encoder")
- Which cited papers are most important (usually the "baseline" they compare against)
- Run
generate.pyto get the scaffold AND thereferences/search_plan.md - Execute the search plan using
paper-finder:paper-finder: search "ResNet PyTorch implementation" on GitHub paper-finder: search base paper on Papers With Code - Clone & analyze the most relevant reference repo:
git clone <reference_repo> workspace/<paper>/references/<name> code-analyzer: analyze workspace/<paper>/references/<name> - Study the reference code — pay attention to:
- How they implement the specific layers you need
- Their training loop structure
- Data preprocessing pipeline
- Loss function implementation
Step 1: Data Pipeline (FIRST!)
Why first? Because wrong data = nothing else matters.- Read the paper's experiment section for dataset details
- Implement
src/data.pywith actual data loading - Verify:
print(next(iter(loader)))should match expected shapes - Check normalization: [0,1] or [-1,1]? ImageNet stats?
Step 2: Model Components (Bottom-Up)
Why bottom-up? Build small, test small, then compose.- Implement each component as a separate
nn.Module - For each component:
# Test with dummy tensor block = MyBlock() x = torch.randn(2, 64, 32, 32) # (batch, channels, h, w) print(block(x).shape) # Should match expected output - Use
formula2codefor any mathematical operations:python formula2code/convert.py "<latex from paper>" --to pytorch -v
Step 3: Assemble Model
- Connect components in the main model class
- Verify:
model(dummy_input).shapeshould match paper's output description - Check parameter count against paper (if reported)
Step 4: Loss Function
- Use
formula2codeto convert the paper's loss equation - If it's a standard loss (CE, MSE, etc.), use PyTorch built-in
- Verify: loss should be a scalar
Step 5: Training Loop
- The scaffold already generates a working loop — customize it:
- Add learning rate scheduler (check paper for warmup/cosine)
- Add gradient clipping (if mentioned)
- Add evaluation loop
- Critical test: Overfit on 5 samples
# If loss doesn't approach ~0, you have a bug python src/train.py --epochs 1000 --batch-size 5
Step 6: Evaluate & Compare
- Implement evaluation metrics from the paper
- Compare against paper's reported results (Table 1)
Common Pitfalls & Debugging Guide
| Problem | Symptom | Fix |
| Wrong normalization | Training doesn't converge | Check if paper uses [0,1] or [-1,1] |
| Missing weight init | Poor performance | Check paper appendix for init method |
| Wrong norm layer | NaN losses | BatchNorm vs LayerNorm matters! |
| No LR schedule | Can't match paper results | Add warmup + cosine decay |
| Wrong loss function | Loss doesn't decrease | Verify with formula2code |
| Dimension mismatch | Runtime crash | Test each component with dummy tensors |
Dependencies
pip install -r code-writer/requirements.txt
# Requires: jinja2, pyyamlExamples
See code-writer/examples/ for runnable demos:
| Example | What it Shows |
01_generate_from_description.py | Full project generation from paper-like data |
02_extractors_demo.py | Each extractor running independently |
Quick Example: Architecture Detection
from extractors.architecture import extract_architecture
sections = [{'title': 'Method', 'content': 'We use a U-Net with self-attention...'}]
arch = extract_architecture(sections)
# → {'components': ['attention', 'unet'], 'architecture_type': 'attention'}Quick Example: Hyperparameter Extraction
from extractors.experiment import extract_experiment
sections = [{'title': 'Experiments', 'content': 'Adam optimizer lr 1e-4, batch 64, 200 epochs on CIFAR-10'}]
exp = extract_experiment(sections)
# → {'hyperparameters': {'learning_rate': '1e-4', 'batch_size': '64', ...}, 'datasets': ['CIFAR-10']}Quick Example: Reference Code Discovery
from extractors.reference_finder import find_reference_code
paper_info = {'title': 'My DDPM Paper', 'abstract': 'diffusion model using U-Net...', ...}
refs = find_reference_code(paper_info)
# → {'base_methods': ['U-Net', 'DDPM'], 'search_queries': [...], 'strategy': '...'}📚 Reference URLs (for agent self-help)
When stuck, the agent should fetch these URLs for guidance:
| Topic | URL |
| Jinja2 template syntax | https://jinja.palletsprojects.com/en/3.1.x/templates/ |
| PyYAML documentation | https://pyyaml.org/wiki/PyYAMLDocumentation |
| PyTorch model best practices | https://pytorch.org/tutorials/beginner/introyt/modelsyt_tutorial.html |
| PyTorch training loop | https://pytorch.org/tutorials/beginner/introyt/trainingyt.html |
| PyTorch data loading | https://pytorch.org/tutorials/beginner/basics/data_tutorial.html |
| Papers With Code methods | https://paperswithcode.com/methods |
| torchvision datasets | https://pytorch.org/vision/stable/datasets.html |
| Hugging Face datasets | https://huggingface.co/docs/datasets/ |
| Common training recipes | https://github.com/pytorch/examples |
Template Customization Help
When modifying Jinja2 templates:
# Fetch Jinja2 template syntax docs:
fetch_url("https://jinja.palletsprojects.com/en/3.1.x/templates/")Dataset Implementation Help
When implementing data loading:
# Fetch PyTorch data loading tutorial:
fetch_url("https://pytorch.org/tutorials/beginner/basics/data_tutorial.html")
# Fetch torchvision available datasets:
fetch_url("https://pytorch.org/vision/stable/datasets.html")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.

