torchdrug▌
davila7/claude-code-templates · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
TorchDrug is a comprehensive PyTorch-based machine learning toolbox for drug discovery and molecular science. Apply graph neural networks, pre-trained models, and task definitions to molecules, proteins, and biological knowledge graphs, including molecular property prediction, protein modeling, knowledge graph reasoning, molecular generation, retrosynthesis planning, with 40+ curated datasets and 20+ model architectures.
TorchDrug
Overview
TorchDrug is a comprehensive PyTorch-based machine learning toolbox for drug discovery and molecular science. Apply graph neural networks, pre-trained models, and task definitions to molecules, proteins, and biological knowledge graphs, including molecular property prediction, protein modeling, knowledge graph reasoning, molecular generation, retrosynthesis planning, with 40+ curated datasets and 20+ model architectures.
When to Use This Skill
This skill should be used when working with:
Data Types:
- SMILES strings or molecular structures
- Protein sequences or 3D structures (PDB files)
- Chemical reactions and retrosynthesis
- Biomedical knowledge graphs
- Drug discovery datasets
Tasks:
- Predicting molecular properties (solubility, toxicity, activity)
- Protein function or structure prediction
- Drug-target binding prediction
- Generating new molecular structures
- Planning chemical synthesis routes
- Link prediction in biomedical knowledge bases
- Training graph neural networks on scientific data
Libraries and Integration:
- TorchDrug is the primary library
- Often used with RDKit for cheminformatics
- Compatible with PyTorch and PyTorch Lightning
- Integrates with AlphaFold and ESM for proteins
Getting Started
Installation
uv pip install torchdrug
# Or with optional dependencies
uv pip install torchdrug[full]
Quick Example
from torchdrug import datasets, models, tasks
from torch.utils.data import DataLoader
# Load molecular dataset
dataset = datasets.BBBP("~/molecule-datasets/")
train_set, valid_set, test_set = dataset.split()
# Define GNN model
model = models.GIN(
input_dim=dataset.node_feature_dim,
hidden_dims=[256, 256, 256],
edge_input_dim=dataset.edge_feature_dim,
batch_norm=True,
readout="mean"
)
# Create property prediction task
task = tasks.PropertyPrediction(
model,
task=dataset.tasks,
criterion="bce",
metric=["auroc", "auprc"]
)
# Train with PyTorch
optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
train_loader = DataLoader(train_set, batch_size=32, shuffle=True)
for epoch in range(100):
for batch in train_loader:
loss = task(batch)
optimizer.zero_grad()
loss.backward()
optimizer.step()
Core Capabilities
1. Molecular Property Prediction
Predict chemical, physical, and biological properties of molecules from structure.
Use Cases:
- Drug-likeness and ADMET properties
- Toxicity screening
- Quantum chemistry properties
- Binding affinity prediction
Key Components:
- 20+ molecular datasets (BBBP, HIV, Tox21, QM9, etc.)
- GNN models (GIN, GAT, SchNet)
- PropertyPrediction and MultipleBinaryClassification tasks
Reference: See references/molecular_property_prediction.md for:
- Complete dataset catalog
- Model selection guide
- Training workflows and best practices
- Feature engineering details
2. Protein Modeling
Work with protein sequences, structures, and properties.
Use Cases:
- Enzyme function prediction
- Protein stability and solubility
- Subcellular localization
- Protein-protein interactions
- Structure prediction
Key Components:
- 15+ protein datasets (EnzymeCommission, GeneOntology, PDBBind, etc.)
- Sequence models (ESM, ProteinBERT, ProteinLSTM)
- Structure models (GearNet, SchNet)
- Multiple task types for different prediction levels
Reference: See references/protein_modeling.md for:
- Protein-specific datasets
- Sequence vs structure models
- Pre-training strategies
- Integration with AlphaFold and ESM
3. Knowledge Graph Reasoning
Predict missing links and relationships in biological knowledge graphs.
Use Cases:
- Drug repurposing
- Disease mechanism discovery
- Gene-disease associations
- Multi-hop biomedical reasoning
Key Components:
- General KGs (FB15k, WN18) and biomedical (Hetionet)
- Embedding models (TransE, RotatE, ComplEx)
- KnowledgeGraphCompletion task
Reference: See references/knowledge_graphs.md for:
- Knowledge graph datasets (including Hetionet with 45k biomedical entities)
- Embedding model comparison
- Evaluation metrics and protocols
- Biomedical applications
4. Molecular Generation
Generate novel molecular structures with desired properties.
Use Cases:
- De novo drug design
- Lead optimization
- Chemical space exploration
- Property-guided generation
Key Components:
- Autoregressive generation
- GCPN (policy-based generation)
- GraphAutoregressiveFlow
- Property optimization workflows
Reference: See references/molecular_generation.md for:
- Generation strategies (unconditional, conditional, scaffold-based)
- Multi-objective optimization
- Validation and filtering
- Integration with property prediction
5. Retrosynthesis
Predict synthetic routes from target molecules to starting materials.
Use Cases:
- Synthesis planning
- Route optimization
- Synthetic accessibility assessment
- Multi-step planning
Key Components:
- USPTO-50k reaction dataset
- CenterIdentification (reaction center prediction)
- SynthonCompletion (reactant prediction)
- End-to-end Retrosynthesis pipeline
Reference: See references/retrosynthesis.md for:
- Task decomposition (center ID → synthon completion)
- Multi-step synthesis planning
- Commercial availability checking
- Integration with other retrosynthesis tools
6. Graph Neural Network Models
Comprehensive catalog of GNN architectures for different data types and tasks.
Available Models:
- General GNNs: GCN, GAT, GIN, RGCN, MPNN
- 3D-aware: SchNet, GearNet
- Protein-specific: ESM, ProteinBERT, GearNet
- Knowledge graph: TransE, RotatE, ComplEx, SimplE
- Generative: GraphAutoregressiveFlow
Reference: See references/models_architectures.md for:
- Detailed model descriptions
- Model selection guide by task and dataset
- Architecture comparisons
- Implementation tips
7. Datasets
40+ curated datasets spanning chemistry, biology, and knowledge graphs.
Categories:
- Molecular properties (drug discovery, quantum chemistry)
- Protein properties (function, structure, interactions)
- Knowledge graphs (general and biomedical)
- Retrosynthesis reactions
Reference: See references/datasets.md for:
- Complete dataset catalog with sizes and tasks
- Dataset selection guide
- Loading and preprocessing
- Splitting strategies (random, scaffold)
Common Workflows
Workflow 1: Molecular Property Prediction
Scenario: Predict blood-brain barrier penetration for drug candidates.
Steps:
- Load dataset:
datasets.BBBP() - Choose model: GIN for molecular graphs
- Define task:
PropertyPredictionwith binary classification - Train with scaffold split for realistic evaluation
- Evaluate using AUROC and AUPRC
Navigation: references/molecular_property_prediction.md → Dataset selection → Model selection → Training
Workflow 2: Protein Function Prediction
Scenario: Predict enzyme function from sequence.
Steps:
- Load dataset:
datasets.EnzymeCommission() - Choose model: ESM (pre-trained) or GearNet (with structure)
- Define task:
PropertyPredictionwith multi-class classification - Fine-tune pre-trained model or train from scratch
- Evaluate using accuracy and per-class metrics
Navigation: references/protein_modeling.md → Model selection (sequence vs structure) → Pre-training strategies
Workflow 3: Drug Repurposing via Knowledge Graphs
Scenario: Find new disease treatments in Hetionet.
Steps:
- Load dataset:
datasets.Hetionet() - Choose model: RotatE or ComplEx
- Define task:
KnowledgeGraphCompletion - Train with negative sampling
- Query for "Compound-treats-Disease" predictions
- Filter by plausibility and mechanism
Navigation: references/knowledge_graphs.md → Hetionet dataset → Model selection → Biomedical applications
Workflow 4: De Novo Molecule Generation
Scenario: Generate drug-like molecules optimized for target binding.
Steps:
- Train property predictor on activity data
- Choose generation approach: GCPN for RL-based optimization
- Define reward function combining affinity, drug-likeness, synthesizability
- Generate candidates with property constraints
- Validate chemistry and filter by drug-likeness
- Rank by multi-objective scoring
Navigation: references/molecular_generation.md → Conditional generation → Multi-objective optimization
Workflow 5: Retrosynthesis Planning
Scenario: Plan synthesis route for target molecule.
Steps:
- Load dataset:
datasets.USPTO50k() - Train center identification model (RGCN)
- Train synthon completion model (GIN)
- Combine into end-to-end retrosynthesis pipeline
- Apply recursively for multi-step planning
- Check commercial availability of building blocks
Navigation: references/retrosynthesis.md → Task types → Multi-step planning
Integration Patterns
With RDKit
Convert between TorchDrug molecules and RDKit:
from torchdrug import data
from rdkit import Chem
# SMILES → TorchDrug molecule
smiles = "CCO"
mol = data.Molecule.from_smiles(smiles)
# TorchDrug → RDKit
rdkit_mol = mol.to_molecule()
# RDKit → TorchDrug
rdkit_mol = Chem.MolFromSmiles(smiles)
mol = data.Molecule.from_molecule(rdkit_mol)
With AlphaFold/ESM
Use predicted structures:
from torchdrug import data
# Load AlphaFold predicted structure
protein = data.Protein.from_pdb("AF-P12345-F1-model_v4.pdb")
# Build graph with spatial edges
graph = protein.residue_graph(
node_position="ca",
edge_types=["sequential", "radius"],
radius_cutoff=10.0
)
With PyTorch Lightning
Wrap tasks for Lightning training:
import pytorch_lightning as pl
class LightningTask(pl.LightningModule):
def __init__(self, torchdrug_task):
super().__init__()
self.task = torchdrug_task
def training_step(self, batch, batch_idx):
return self.task(batch)
def validation_step(self, batch, batch_idx):
pred = self.task.predict(batch)
target = self.task.target(batch)
return {"pred": pred, "target": target}
def configure_optimizers(self):
return torch.optim.Adam(self.parameters()How to use torchdrug on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add torchdrug
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches torchdrug from GitHub repository davila7/claude-code-templates and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate torchdrug. Access the skill through slash commands (e.g., /torchdrug) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
User Story & Requirements Generation
Create detailed user stories, acceptance criteria, and feature specs
Example
Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios
Reduce spec writing time by 50%, ensure comprehensive coverage
Competitive Analysis
Research competitors, compare features, identify gaps
Example
Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities
Complete competitive research in 2 hours instead of 2 days
Roadmap Prioritization
Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs
Example
Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale
Make data-driven prioritization decisions faster
Stakeholder Communication
Draft PRDs, status updates, and stakeholder presentations
Example
Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement
Save 3-5 hours/week on communication overhead
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client
- ›Access to product documentation and roadmap tools (Jira, Notion, etc.)
- ›Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
- ›Stakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Installation Steps
- 1.Install product management skill
- 2.Start with user story generation for known feature
- 3.Progress to competitive analysis: research 2-3 competitors
- 4.Use for roadmap prioritization: apply RICE/ICE scoring
- 5.Draft stakeholder communications and refine based on feedback
- 6.Build template library for recurring PM tasks
- 7.Share effective prompts with product team
Common Pitfalls
- ⚠Not validating competitive research—verify facts before sharing
- ⚠Accepting user stories without involving engineering team
- ⚠Over-relying on frameworks without qualitative judgment
- ⚠Not customizing outputs to company culture and communication style
- ⚠Skipping stakeholder validation of generated requirements
Best Practices▌
✓ Do
- +Validate research and competitive analysis with real data
- +Collaborate with engineering when generating technical requirements
- +Customize frameworks and templates to your company context
- +Use skill for first drafts, refine with stakeholder input
- +Document successful prompt patterns for PM tasks
- +Combine AI efficiency with human judgment and intuition
✗ Don't
- −Don't publish competitive analysis without fact-checking
- −Don't finalize user stories without engineering review
- −Don't make prioritization decisions solely on AI scoring
- −Don't skip customer validation of generated requirements
- −Don't ignore company-specific context and culture
💡 Pro Tips
- ★Provide context: company goals, constraints, customer feedback
- ★Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
- ★Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
- ★Use skill for 70% generation + 30% customization to company needs
When to Use This▌
✓ Use When
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
✗ Avoid When
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path▌
- 1Basic: user stories, feature specs, status updates
- 2Intermediate: competitive analysis, prioritization frameworks, PRDs
- 3Advanced: product strategy, go-to-market planning, OKR setting
- 4Expert: product vision, market positioning, business model innovation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.6★★★★★56 reviews- ★★★★★Nikhil Khanna· Dec 24, 2024
Useful defaults in torchdrug — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★James Ghosh· Dec 12, 2024
I recommend torchdrug for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★William Nasser· Dec 8, 2024
I recommend torchdrug for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Hiroshi Liu· Nov 27, 2024
Keeps context tight: torchdrug is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Soo Gill· Nov 27, 2024
torchdrug reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Soo Desai· Nov 15, 2024
torchdrug is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Mateo Li· Nov 3, 2024
Registry listing for torchdrug matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Nikhil Singh· Nov 3, 2024
Keeps context tight: torchdrug is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Mateo Abbas· Oct 22, 2024
torchdrug reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Nikhil Mehta· Oct 22, 2024
torchdrug is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
showing 1-10 of 56