Skip to content
AI & Agents
Skill

/pymatgen

Analyze, validate, convert, and transform materials structures and computed materials data with current pymatgen APIs, including local phase diagrams, symmetry sensitivity, electronic-structure I/O, and explicitly bounded Materials Project queries.

From plugin
k-dense-ai-scientific-agent-skills
45k166 skills
Install
$ npx -y skills add k-dense-ai/claude-scientific-skills --skill pymatgen --agent claude-code

How 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/pymatgen

Context preview

The summary Claude sees to decide when to auto-load this skill.

Analyze, validate, convert, and transform materials structures and computed materials data with current pymatgen APIs, including local phase diagrams, symmetry sensitivity, electronic-structure I/O, and explicitly bounded Materials Project queries.

SKILL.md

pymatgen.SKILL.md
name: pymatgen
description: Analyze, validate, convert, and transform materials structures and computed materials data with current pymatgen APIs, including local phase diagrams, symmetry sensitivity, electronic-structure I/O, and explicitly bounded Materials Project queries.
license: MIT
compatibility: Python 3.11+ with uv. The verified snapshot uses pymatgen 2026.5.4, pymatgen-core 2026.7.16, and mp-api 0.46.4. Bundled help and planning CLIs use only the standard library; local scientific execution lazily requires the pinned pymatgen packages. Materials Project access additionally requires explicit network approval and the single named secret MP_API_KEY.
allowed-tools: Read Write Bash Glob Python
metadata:
  version: "1.3"
  skill-author: "K-Dense Inc."
  last-reviewed: "2026-07-23"

pymatgen

Use pymatgen for explicit, provenance-preserving work with compositions, molecules, periodic structures, computed entries, symmetry, phase diagrams, electronic structures, and electronic-structure-code files. Treat every parse, conversion, symmetry assignment, transformation, and database result as method- and parameter-dependent.

The MIT frontmatter license covers this skill. `pymatgen` and `pymatgen-core` are MIT; `mp-api` declares BSD-3-Clause-LBNL. Materials Project data is generally CC BY 4.0, while contributed data remains owned by its contributors. Check the exact artifact and data terms before redistribution.

Verified snapshot (2026-07-23)

  • `pymatgen==2026.5.4` is the latest stable wrapper release (2026-05-04).

Package metadata requires Python 3.11+ and directly requires `pymatgen-core>=2026.4.16`.

  • `pymatgen-core==2026.7.16` is the latest stable core release (2026-07-16).

It now contains core objects, symmetry/lattice operations, and the I/O layer, all under the existing `pymatgen.*` namespace.

  • `mp-api==0.46.4` is the latest stable Materials Project client

(2026-06-15), requires Python 3.11+, and depends on `pymatgen>2024.2.20`.

  • The current API site is built from 2026.7.16 core documentation. Pinning both

distributions prevents `pymatgen==2026.5.4` from silently resolving to a different future core.

  • Pymatgen uses date-based versions. PyPI renders the date with dots; do not

infer semantic-version compatibility from the numbers.

Create a project lock for reproducibility:

uv init --python 3.11
uv add "pymatgen==2026.5.4" "pymatgen-core==2026.7.16" "mp-api==0.46.4"
uv lock
uv sync --frozen

For a disposable reviewed environment:

uv venv --python 3.11 .venv-pymatgen
uv pip install --python .venv-pymatgen/bin/python \
  "pymatgen==2026.5.4" "pymatgen-core==2026.7.16" "mp-api==0.46.4"

Direct pins do not freeze all transitive wheels. Preserve `uv.lock`, platform, Python version, package versions, and artifact hashes.

Required workflow

1. State whether the object is a non-periodic `Molecule` or periodic `Structure`; record lattice and periodic boundary conditions. 2. State units. Pymatgen commonly uses Å, degrees, eV, eV/atom, amu, and g/cm³, but each API's documented contract is authoritative. 3. State coordinate mode. `Structure` coordinates are fractional unless `coords_are_cartesian=True`; `Molecule` coordinates are Cartesian. 4. Inspect every parser warning. For CIF, preserve occupancy, site-merging, stoichiometry, and correction warnings; do not silently accept fixes. 5. Report disorder/partial occupancies and oxidation-state decoration. Never guess oxidation states implicitly. 6. Run validation before symmetry, neighbor, transformation, conversion, or thermodynamic analysis. 7. Sweep symmetry tolerances and report `symprec` in Å and `angle_tolerance` in degrees with every assignment. 8. Treat transformations as new artifacts. Preserve the input, parameters, software versions, warnings, and parent/child checksums. 9. Before conversion, identify representation loss. Write only to a new path and round-trip-check scientifically relevant properties. 10. Build phase diagrams only from compatible total energies and correction schemes. A computed hull is conditional on the supplied entry set. 11. Keep all database access off by default. Disclose endpoint, filters, fields, result limit, cache behavior, output, license, and citation before an explicit execution step. 12. Preserve an artifact manifest. Never use pickle or load an untrusted general object graph; use schema-validated JSON and explicit constructors.

Core objects

Use the public convenience imports:

from pymatgen.core import Composition, Element, Lattice, Molecule, Structure

composition = Composition("LiFePO4", strict=True)
iron = Element("Fe")

lattice = Lattice.cubic(5.64)  # Å
structure = Structure(
    lattice,
    ["Na", "Cl"],
    [[0, 0, 0], [0.5, 0.5, 0.5]],
    coords_are_cartesian=False,
    validate_proximity=True,
)

molecule = Molecule(
    ["O", "H", "H"],
    [[0.0, 0.0, 0.0], [0.758, 0.0, 0.504], [-0.758, 0.0, 0.504]],
    charge=0,
    spin_multiplicity=1,
)

`Structure` and `Molecule` are mutable; use `IStructure`/`IMolecule` or an explicit copy when mutation would compromise provenance. See [core classes](references/core_classes.md).

Safe local structure intake

Prefer the bundled validator, which captures CIF and Python warnings and reports units, occupancy, disorder, oxidation states, periodicity, coordinate mode, and minimum distances:

python scripts/composition_structure_validator.py composition "Fe2O3"
python scripts/composition_structure_validator.py structure structure.cif
python scripts/structure_analyzer.py structure.cif --symmetry

For direct CIF work, use the current parser method and inspect both warning channels:

import warnings
from pymatgen.io.cif import CifParser

with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always")
    parser = CifParser("input.cif", check_cif=True)
    structures = parser.parse_structur
Read more
Ships withk-dense-ai-scientific-agent-skills

🔔 Claude Scientific Skills is now Scientific Agent Skills. Same skills, broader compatibility — now works with any AI agent that supports the open Agent Skills standard, not just Claude.

Get the whole plugin
Stats
44,280
Stars
4,019
Forks
Active
Maintenance
Python
Language
MIT
License
9d ago
Last commit
11mo ago
Created
15d ago
Added

Repo: k-dense-ai/claude-scientific-skills