Skip to content

Guide · Agent skill

How to use the TorchDrug agent skill (molecular graph ML)

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

The TorchDrug skill is an instruction package for an AI coding agent. Once it is installed, the agent knows how to write and repair code that uses TorchDrug, a PyTorch library for learning from molecules, proteins and knowledge graphs. This guide explains what the skill changes, how to install it, how to phrase requests that trigger it, and what to check before running anything it produces.

TorchDrug Molecular Graph SkillK-Dense-AI/scientific-agent-skills · MIT

Quick start

  1. 1Download and unzip the skill. Get the ZIP from the directory page and unzip it into ~/.claude/skills/ for personal use or the project's .claude/skills/ folder for one project.
  2. 2Prepare a Python 3.10 environment. Create a dedicated environment with uv, as the skill describes, so the older TorchDrug stack does not conflict with your other projects.
  3. 3Install the pinned packages. Install PyTorch 2.0.0, the matched torch-scatter and torch-cluster builds, and TorchDrug 0.2.1 with its listed dependencies.
  4. 4Ask for a concrete task. Describe the goal in plain words, such as predicting toxicity from molecules, and name the dataset if you have one.
  5. 5Run and check the output. Read the generated script, run it on a small slice first, and compare results with the split sizes and metrics it reports.

What the TorchDrug skill makes the agent do

The skill covers TorchDrug 0.2.1 workflows for molecular graphs, property prediction, self-supervised pretraining, molecule generation, retrosynthesis, protein representation learning and knowledge graph reasoning. It describes TorchDrug as four layers: a dataset loader, a representation model, a task that wraps the model with an objective, and core.Engine, which trains and evaluates the result.

Before writing or debugging code, the skill tells the agent to check the Python, PyTorch and TorchDrug versions in the environment. This matters because the library is old and only supports a limited range of Python and PyTorch versions.

  • Molecular property prediction, for example toxicity classification on ClinTox with a GIN model
  • Self-supervised pretraining with InfoGraph or attribute masking
  • Molecule generation with GCPN or GraphAF
  • Retrosynthesis with center identification and synthon completion
  • Knowledge graph completion with RotatE or NeuralLP
  • Protein modeling with sequence and structure encoders

Install the TorchDrug skill

Download the skill ZIP from the directory 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. In the Claude apps, you can instead upload the ZIP under Settings, then Capabilities, then Skills.

Installing the skill does not install TorchDrug itself. The skill's own instructions describe a dedicated Python 3.10 environment. The commands below come from the skill's SKILL.md and are shown so you can see what the agent will expect; check the official installation page before running them, because CUDA and platform builds differ.

  • Requirements listed by the skill: Python 3.7 to 3.10, PyTorch 1.8 to 2.0, torch-scatter and torch-cluster matched to your PyTorch and CUDA build, TorchDrug, RDKit (rdkit-pypi), fair-esm, numpy, scipy and decorator
  • Do not install both the rdkit and rdkit-pypi packages into the same environment
  • The fair-esm package imports as esm; a different newer distribution also named esm is a separate SDK
  • Network access is needed for datasets and model weights that are not already cached
uv venv --python 3.10 source .venv/bin/activate uv pip install "torch==2.0.0" "numpy==1.26.4" "setuptools<81" wheel uv pip install "torchdrug==0.2.1" "numpy==1.26.4" "scipy==1.13.1" "rdkit-pypi==2022.9.5" "fair-esm==2.0.0" "decorator==5.1.1"

Trigger the skill with natural requests

The skill is meant to load when the agent is working with code that imports torchdrug, or when you ask for its datasets, models, tasks or Engine. You do not need to name the skill. Mention TorchDrug or the task you want, and say what the code should do.

Good requests name the goal, the data and the output. Ask the agent to check your environment first if you are unsure which versions you have.

  • Write a TorchDrug script that trains a GIN model on ClinTox to predict toxicity, using a scaffold split
  • My TorchDrug import fails on Apple Silicon. Help me fix the torch-scatter build
  • Repair this TorchDrug training loop that crashes inside core.Engine
  • Show me how to pretrain a GIN with InfoGraph and then fine-tune it for property prediction
  • Set up a RotatE knowledge graph completion run on FB15k237

Safety notes: scripts, network and downloads

The skill allows the agent to read and write files and run shell commands. Its examples run Python scripts. Dataset constructors download and cache data under the path you give them, and some archives are large. The skill notes that dataset constructors can fetch large archives as a side effect, so check the source, checksum, size and license before a first run.

Checkpoints and external files used in examples must come from sources you trust. The skill also says the training examples were illustrative and were not run to convergence, so they are starting points rather than validated results.

  • Read generated code before running it, especially any download or file-loading step
  • Pick a cache folder you control, such as ~/molecule-datasets/
  • Confirm the dataset license before reusing data in a project

Tips for getting working code

Start with the version check the skill recommends. Most failures on this stack come from mismatched PyTorch, torch-scatter, torch-cluster or NumPy builds rather than from the TorchDrug code itself.

For molecular property prediction, the skill recommends a scaffold split for tests of generalization to new molecular structures. A random split is a baseline for tutorials. Record the split sizes and class counts you actually get, because scaffold grouping may not match the requested lengths exactly.

  • Use CPU-only builds unless you have a supported CUDA device; add gpus only when one is available
  • Apple Silicon runs on CPU only, and MPS is not supported
  • The ClinTox legacy download URL fails, so follow the skill's cache repair step before training

What people use it for

  • Training a graph neural network to predict toxicity labels for molecules in ClinTox
  • Reproducing a TorchDrug tutorial pipeline with a known dataset, model and task
  • Pretraining a molecular encoder with self-supervised tasks and then fine-tuning it
  • Learning how the dataset, model, task and Engine layers fit together in a drug-discovery project

Frequently asked questions

Is the TorchDrug skill free to use?

The directory lists the skill under the MIT license. The SKILL.md file inside the package states Apache-2.0, so check the LICENSE file in the downloaded folder before relying on either. TorchDrug datasets each have their own license, which you should confirm before use.

What do I need to run the TorchDrug skill?

You need Python 3.7 to 3.10, PyTorch 1.8 to 2.0, matched torch-scatter and torch-cluster builds, TorchDrug 0.2.1, RDKit, fair-esm and network access for uncached data. The skill says newer Python or PyTorch versions are unverified and may break.

How do I install TorchDrug on Apple Silicon?

The skill says Apple Silicon is CPU only and needs native builds of torch-scatter and torch-cluster from source, because the wheel index has no macOS ARM64 wheels. MPS GPU acceleration is not supported.

Why does the ClinTox dataset download fail?

The TorchDrug 0.2.1 class uses a legacy HTTP URL that returned an error during the skill's review. The skill provides a repair step that populates the cache from the current HTTPS asset, which has the same checksum.

Can I use TorchDrug with the latest PyTorch or Python?

Not as a supported setup. The skill lists the supported range for 0.2.1 and treats other combinations as unverified. Create a compatible environment instead.

What are alternatives to TorchDrug for molecular machine learning?

The skill does not compare TorchDrug with other libraries, so this guide cannot make that comparison. If you need current library versions or a different stack, you will have to evaluate those tools separately.

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 developer, researcher or student who needs a working TorchDrug 0.2.1 starting point and can run an older Python and PyTorch environment. Pick a different tool if you need current Python or PyTorch versions, Apple Silicon GPU acceleration, or model outputs you can rely on for clinical or safety decisions.

Download the skill