/atomistic-skills:ml-generative-mattergenfrom Atomistic Skills
Generates novel inorganic material structures using MatterGen, a diffusion-based model for crystalline materials. Supports unconditional generation and chemical system conditioning.
Ships in Atomistic Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill provides tools for generating novel inorganic material structures using MatterGen, a state-of-the-art diffusion-based generative model for crystalline materials.
[!IMPORTANT] GPU Required: MatterGen generation needs a CUDA GPU (NVIDIA driver ≥ 525).
Runs as the mattergen MCP server and its scripts run in the mattergen environment: on x86_64 a uv environment created on first use (CUDA 12.6 or 13 by driver), on aarch64 the generative container image.
A MatterGen checkout next to this project as ../mattergen, or anywhere with MATTERGEN_REPO pointing to it. MatterGen's PyPI distribution omits the data files it needs (sampling configs, GemNet scale factors), so it runs from the checkout, as upstream installs it. Fetch it with the setup script, which pins the verified commit, skips the LFS checkpoints (the weights come from Hugging Face) and replaces np.math, which NumPy 2 removed:
${CLAUDE_SKILL_DIR}/../../venv/run mattergen python ${CLAUDE_SKILL_DIR}/scripts/setup_mattergen.py
venv/run mounts it into the container on aarch64.
On aarch64 (e.g. NVIDIA DGX Spark) the image carries PyG's extensions compiled for CUDA, which PyG publishes no aarch64 wheels for; nothing needs building on the host.
MatterGen provides several pretrained models:
mattergen_base: Base unconditional generative modelmp_20_base: Materials Project base modeldft_mag_density: Model for magnetic density conditioningchemical_system: Model for chemical system conditioningThe MCP tool automatically loads models when needed - no explicit load step required.
Generate novel structures without conditioning:
from mcp_base import mattergen.generate_structures
result = mattergen.generate_structures(
model_name="mattergen_base",
num_structures=10,
batch_size=10,
output_dir="research/my_project/generated"
)
Generate structures from a specific chemical system (controls which elements appear):
result = mattergen.generate_structures(
chemical_system="Li-Fe-P-O", # Automatically uses chemical_system model
guidance_scale=1.0, # Recommended for chemical system conditioning
num_structures=20,
batch_size=10,
output_dir="research/cathode_materials/generated"
)
[!NOTE] Chemical system conditioning controls which elements appear, but NOT the exact stoichiometry. For example,
chemical_system="Li-Zr-Cl"can generate Li3Cl5, LiZrCl4, Li2ZrCl5, etc., but you cannot specify exactly "Li2ZrCl6".
Fine-tune MatterGen on custom datasets using the skill scripts:
# Convert structures and properties to CSV format
${CLAUDE_SKILL_DIR}/../../venv/run mattergen python ${CLAUDE_SKILL_DIR}/scripts/prepare_training_data.py \
--structures-json training_structures.json \
--property-name "formation_energy" \
--output training_data.csv
Training data JSON format:
[
{
"structure": {<pymatgen Structure dict>},
"properties": {"formation_energy": -2.5}
},
...
]
${CLAUDE_SKILL_DIR}/../../venv/run mattergen python ${CLAUDE_SKILL_DIR}/scripts/run_finetuning.py \
--training-data training_data.csv \
--property-name "formation_energy" \
--base-model "mattergen_base" \
--epochs 100 \
--output-dir finetuned_formation_energy
Fine-tuning parameters:
--training-data: Path to CSV from Step 1--property-name: Property to condition on (must match CSV column)--base-model: Starting model (mattergen_base, chemical_system, etc.)--epochs: Training epochs (100-200 recommended)--learning-rate: Learning rate (default: 5e-6)--batch-size: Batch size (default: 32)[!TIP]
- Start with 2 epochs for quick testing
- Use 100-200 epochs for actual fine-tuning
- GPU required (fine-tuning on CPU is extremely slow)
structure_XXXX.cif: Generated structure filesgeneration_metadata.json: Metadata about generation parameterscheckpoints/: Model checkpoint files (.ckpt)config.yaml: Hydra configuration used[!WARNING] Chemical System vs. Stoichiometry
chemical_systemparameter controls which elements are encouraged to be present.- It does NOT guarantee that all specified elements will be in the output structure.
- It does NOT prevent other elements from occasionally appearing if guidance is too low.
- Example:
chemical_system="Li-Zr-Cl"might generate LiCl, ZrCl4, or even structures missing Li, alongside the desired ternaries (e.g., Li2ZrCl6).- Action Required: You MUST write a post-processing script to filter the output
.ciffiles and keep only the ones that match your exact target elemental composition.
[!WARNING] CSP Mode Not Available
- Target composition control (
target_compositionsparameter) requires CSP-trained models- CSP models are NOT publicly available - must be custom-trained
- Public models (mattergen_base, chemical_system, etc.) are generation models only
[!IMPORTANT]
- GPU Required: MatterGen requires a CUDA-compatible GPU. CPU is extremely slow.
- Batch Size: Use larger batches (10-50) for efficient GPU utilization
- Guidance Scale: Higher values (1.0-5.0) enforce stronger conditioning
- Composition Filtering: Always filter the generated output CIFs using
pymatgento verify that the structures contain exactly the target elements.- Validation: Always validate generated structures via relaxation and stability analysis
[!TIP]
- Start with unconditional generation to understand model behavior
- Use chemical_system conditioning to explore specific element combinations
- Fine-tune on domain-specific data for specialized applications (e.g., cathode materials)
MatterGen works well in combination with:
See examples/ for:
Author: Bowen Deng Contact: GitHub @learningmatter-mit
examples/finetuning/README.md (opens in a new tab)examples/finetuning/example_finetuned_model/adapter_config.json (opens in a new tab)examples/finetuning/example_finetuned_model/adapter_model.bin (opens in a new tab)examples/finetuning/make_dummy.py (opens in a new tab)examples/finetuning/run_finetune_example.sh (opens in a new tab)scripts/prepare_training_data.py (opens in a new tab)scripts/run_finetuning.py (opens in a new tab)scripts/setup_mattergen.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub learningmatter-mit/atomisticskills --plugin atomistic-skills133 skills in this plugin
/chem-bond-dissociationCalculate homolytic and heterolytic bond dissociation energies (BDEs) for all single bonds in a molecule using MLIPs with RDKit fragmentation./chem-conformer-searchGenerate molecular conformers with RDKit ETKDG, relax with MLIPs, and rank by energy with Boltzmann weighting./chem-db-mofQuery multiple MOF databases (QMOF via MPContribs; ARC-MOF DB7/Majumdar et al. via Materials Cloud) and download CIF structures with optional element or identifier filters.Other plugins' skills for the same job