Skip to content

Guide · Agent skill

How to use the pymatgen Materials Toolkit agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The pymatgen skill teaches an AI agent to work with chemical compositions and crystal structures using the pymatgen Python library, with careful provenance rules for units, parser warnings, occupancies, symmetry tolerances and checksums. It is aimed at materials science students, researchers who need auditable structure work, and developers building computational materials workflows. After this guide you will know how to install the skill, ask for work in plain language, and understand what the bundled scripts do and what they need.

pymatgen Materials ToolkitK-Dense-AI/scientific-agent-skills · MIT

Quick start

  1. 1Download and unzip. Download the ZIP from this page and unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder.
  2. 2Or upload in the Claude apps. Open Settings → Capabilities → Skills and upload the ZIP.
  3. 3Set up Python. Install Python 3.11+ and the uv package manager, then create a project with the pinned pymatgen packages.
  4. 4Ask in plain language. Describe the file or composition and the check you want, such as validation or symmetry sensitivity.
  5. 5Review warnings. Read parser warnings, partial occupancies and oxidation-state notes before trusting any result.
  6. 6Save the manifest. Keep the input, output paths, parameters and checksums in the artifact manifest.

What the pymatgen skill makes the agent do

An agent skill is a folder of instructions and helper files that an AI agent loads when a task matches its description. This one covers compositions, molecules, periodic structures, computed entries, symmetry, phase diagrams and electronic-structure files, using the pymatgen library.

The skill asks the agent to state whether an object is a non-periodic Molecule or periodic Structure, state units and coordinate mode, inspect every parser warning, report partial occupancies and oxidation states, and sweep symmetry tolerances rather than picking one that gives a preferred answer. Every derived file is treated as a new artifact with parent and child checksums.

  • Validate compositions and structures, including CIF parser and Python warnings
  • Report space-group symmetry across a range of tolerances
  • Plan format conversions before any file is written
  • Build phase diagrams from energies you supply
  • Optionally query the Materials Project database with an API key

Install the pymatgen skill

Download the ZIP from this page and unzip it. For a personal install, place the skill folder in ~/.claude/skills/. For a single project, place it in the project's .claude/skills/ folder.

You can also upload the ZIP in the Claude apps under Settings → Capabilities → Skills.

The skill needs Python 3.11+ and the uv package manager. The SKILL.md file lists pinned packages (pymatgen==2026.9.24, pymatgen-core==2026.9.23, mp-api==0.46.5) that are installed for local scientific execution. Create a project environment with uv only when you are ready to run analysis.

  • Personal install: ~/.claude/skills/pymatgen/
  • Project install: .claude/skills/pymatgen/ inside your project
  • Claude apps: Settings → Capabilities → Skills, then upload the ZIP
uv init --python 3.11 uv add "pymatgen==2026.9.24" "pymatgen-core==2026.9.23" "mp-api==0.46.5" uv lock uv sync --frozen

How to trigger the skill with natural requests

The agent loads the skill when your request matches its description: phase diagrams, symmetry sensitivity, electronic-structure I/O, format conversion, structure validation or bounded Materials Project queries. You do not need to name the skill, but naming pymatgen makes it more likely to be used.

Give the file, the composition or the question. The more specific you are about what you want checked, the more the agent can follow the skill's workflow.

  • "Validate this CIF with pymatgen and list any parser warnings and partial occupancies."
  • "Check the space group of structure.cif across symprec 0.001, 0.01 and 0.1 Å."
  • "Plan how to convert this structure to another format without overwriting the input."
  • "Build a phase diagram from these supplied energies and state the correction scheme."

Run the bundled helper scripts

The skill ships small command-line helpers. The validator and planning tools use only the Python standard library. Local scientific execution lazily requires the pinned pymatgen packages.

The structure analyzer reports symmetry for a file, and the symmetry sensitivity report sweeps tolerances. The distance report compares distinct sites under periodic boundary conditions, but it is not a complete check for contacts across very short lattice vectors.

  • scripts/composition_structure_validator.py: validate a composition or structure
  • scripts/structure_analyzer.py: analyze a structure, optionally with symmetry
  • scripts/symmetry_sensitivity_report.py: sweep symprec and angle tolerance
  • scripts/io_conversion_plan.py: plan a conversion before any file is opened
  • scripts/phase_diagram_generator.py: build a phase diagram from supplied entries
  • scripts/mp_query.py: bounded Materials Project query, only with approval
  • scripts/artifact_manifest.py: record checksums and provenance
python scripts/composition_structure_validator.py composition "Fe2O3" python scripts/structure_analyzer.py structure.cif --symmetry python scripts/symmetry_sensitivity_report.py structure.cif --symprec 0.001,0.01,0.1 --angle-tolerance 1,5

Understand what the skill needs and what it can touch

The skill runs local Python scripts. Materials Project access additionally needs explicit network approval and the single named secret MP_API_KEY. Without that approval and key, the database queries are not run. The MIT license covers the skill; pymatgen and pymatgen-core are MIT, mp-api declares BSD-3-Clause-LBNL, and Materials Project data is generally CC BY 4.0, with contributed data owned by its contributors.

Parsers process the contents of the files you give them. Do not parse untrusted CIF or structure files on a machine that holds sensitive credentials, and use isolation with CPU, memory, disk and time limits.

  • Python 3.11+ and uv
  • Optional: MP_API_KEY secret for Materials Project access
  • Network approval is required for any Materials Project query
  • Pickle is not used; the skill expects schema-validated JSON

Example workflow: validate a structure and check symmetry

Start by validating the file so warnings are visible before any analysis. Then sweep symmetry tolerances and read the space group at each setting. If the answer changes between tolerances, report that instead of choosing one.

Keep the input file unchanged. Any converted or transformed output should go to a new path, and the artifact manifest should record the input, parameters, software versions and checksums.

  • Validate the composition and structure
  • Read parser warnings and occupancy reports
  • Run the symmetry sensitivity report
  • Record the artifact manifest
python scripts/composition_structure_validator.py structure structure.cif python scripts/symmetry_sensitivity_report.py structure.cif --symprec 0.001,0.01,0.1 --angle-tolerance 1,5

Tips for reliable results

Units and coordinate mode matter. Structure coordinates are fractional unless you say otherwise, and Molecule coordinates are Cartesian. Ask the agent to state both before trusting a result.

A computed phase diagram is only as good as the entries you supply. Use compatible total energies and the same correction scheme for all entries.

  • Pin the lock file and keep uv.lock with your results
  • Compare symmetry across tolerances; the Materials Project pipeline uses symprec 0.1 Å while the pymatgen default is 0.01 Å
  • Ask for a sensitivity report instead of tuning tolerance until an answer looks right

What people use it for

  • Validate a CIF file and list parser warnings and partial occupancies before further analysis
  • Check how the space group of a structure changes across different symmetry tolerances
  • Plan a format conversion from CIF to another format without overwriting the original file
  • Build a phase diagram from energies you supply, with the correction scheme stated
  • Run a bounded Materials Project query after reviewing endpoint, filters and license terms

Frequently asked questions

Is the pymatgen agent skill free?

The skill's frontmatter license is MIT. pymatgen and pymatgen-core are MIT, and mp-api declares BSD-3-Clause-LBNL. Materials Project data is generally CC BY 4.0, while contributed data remains owned by its contributors, so check terms before redistributing results.

What do I need to install the pymatgen skill?

You need Python 3.11+ and the uv package manager for local analysis. Download the ZIP from this page and place it in ~/.claude/skills/ or a project's .claude/skills/ folder, or upload it under Settings → Capabilities → Skills in the Claude apps.

Do I need a Materials Project API key?

No. The key is optional and only needed for Materials Project queries. Those queries also require explicit network approval, and the skill keeps database access off by default.

Does the skill run code on my computer?

Yes. It runs local Python scripts, and local scientific execution uses the pinned pymatgen packages. Parsers process file contents, so avoid parsing untrusted CIF files on a machine that holds sensitive credentials.

How do I fix a pymatgen version or install error?

Use the pinned versions listed in the skill: pymatgen==2026.9.24, pymatgen-core==2026.9.23 and mp-api==0.46.5, with Python 3.11+. Use uv lock and uv sync --frozen so the environment matches the lock file.

How does this compare with using pymatgen directly?

The skill adds workflow rules and helper scripts on top of pymatgen: validation before analysis, tolerance sweeps, plan-first conversion and checksummed manifests. If you already work in pymatgen and do not need these guardrails, using the library directly is simpler.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you are a materials science student or researcher who wants structure validation, symmetry checks and format conversion recorded in a reproducible way, and you are comfortable with Python and uv. Pick something else if you need to process untrusted files on a sensitive machine, need authoritative thermodynamic conclusions without your own vetted energy data, or want Materials Project queries with no review of endpoints and license terms.

Download the skill