Agent skill

Medchem Compound Filters

by davila7 in davila7/claude-code-templates

Screens compound libraries in Python with the medchem library: drug-likeness rules, PAINS filters, structural alerts and complexity metrics for prioritizing molecules.

MITAuto-check passedResearch & Science

Install Medchem Compound Filters

skills CLI
$ npx skills add davila7/claude-code-templates --skill medchem -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install davila7/claude-code-templates medchem --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/davila7/claude-code-templates.git skills-src && mkdir -p .claude/skills && cp -r skills-src/cli-tool/components/skills/scientific/medchem .claude/skills/medchem && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
medchem
GitHub stars
33k
Used in
11 other repos
Token cost
~2.5k tokens
SKILL.md length
566 words
Files
4 (incl. scripts, references)
Skills in repo
479
Repo updated
First seen
Licence
MIT

At a glance

Screens compound libraries in Python with the medchem library: drug-likeness rules, PAINS filters, structural alerts and complexity metrics for prioritizing molecules.

  • Works in 8 steps: Medicinal Chemistry Rules → Structural Alert Filters → Functional API for High-Level Operations → …
  • Applying Lipinski and Veber drug-likeness rules to a compound library
  • SKILL.md covers Overview, When to Use This Skill, Installation and Core Capabilities, plus 4 more sections
  • Runs Python scripts from its folder; calls uv and python

What it does

Medchem is a Python library for filtering and prioritizing molecules in drug discovery. The skill covers the `medchem.rules` module, which applies rules such as Lipinski's Rule of Five, Veber, Oprea, CNS, leadlike, Reos, the Rule of three, the Rule of drug, the Golden triangle and PAINS, returning pass or fail results with details for each rule.

A second module, `medchem.structural`, detects problematic patterns using common alerts built from ChEMBL curation and literature, the NIBR filter set and the Lilly demerit system, which rejects molecules above 100 demerits across 275 rules. A functional module offers high-level shortcuts for quick filtering. The script `scripts/filter_molecules.py` and references on the API and the rules catalog support it. Results are meant as guidelines to combine with domain expertise.

When your agent uses it

  • Applying Lipinski and Veber drug-likeness rules to a compound library
  • Flagging PAINS patterns or reactive functional groups in screening hits
  • Ranking compounds for lead optimization by medicinal chemistry quality
  • Calculating molecular complexity metrics for a set of SMILES

Example prompts

  • “Run the Rule of Five and Veber filters on molecules.smi and tell me how many pass each.”
  • “Check these screening hits against the NIBR filters and the Lilly demerits and list the rejected ones.”
  • “Flag any PAINS matches in my compound library and write the clean set to a new file.”

Requirements

  • Python with `medchem` installed
  • `datamol` for loading molecules, as used in the examples

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Medicinal Chemistry Rules
  2. Structural Alert Filters
  3. Functional API for High-Level Operations
  4. Chemical Groups Detection
  5. Named Catalogs
  6. Molecular Complexity
  7. Constraints Filtering
  8. Medchem Query Language

What it can do on your machine

Read from SKILL.md and the folder at commit c0ca7da. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • uv
    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • medchem-docs.datamol.io
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Medchem Compound Filters loads about 2.5k tokens when it runs, and up to ~8.7k if it reads all its reference files. Until then it costs about 47 tokens; SKILL.md has 566 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~47
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~8.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from davila7/claude-code-templates at commit c0ca7da, republished under its MIT licence (© davila7). 566 words, ~2,520 tokens.

Download SKILL.mdSave it as .claude/skills/medchem/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
medchem
description
Medicinal chemistry filters. Apply drug-likeness rules (Lipinski, Veber), PAINS filters, structural alerts, complexity metrics, for compound prioritization and library filtering.

Medchem

Overview

Medchem is a Python library for molecular filtering and prioritization in drug discovery workflows. Apply hundreds of well-established and novel molecular filters, structural alerts, and medicinal chemistry rules to efficiently triage and prioritize compound libraries at scale. Rules and filters are context-specific—use as guidelines combined with domain expertise.

When to Use This Skill

This skill should be used when:

  • Applying drug-likeness rules (Lipinski, Veber, etc.) to compound libraries
  • Filtering molecules by structural alerts or PAINS patterns
  • Prioritizing compounds for lead optimization
  • Assessing compound quality and medicinal chemistry properties
  • Detecting reactive or problematic functional groups
  • Calculating molecular complexity metrics

Installation

bash
uv pip install medchem

Core Capabilities

1. Medicinal Chemistry Rules

Apply established drug-likeness rules to molecules using the medchem.rules module.

Available Rules:

  • Rule of Five (Lipinski)
  • Rule of Oprea
  • Rule of CNS
  • Rule of leadlike (soft and strict)
  • Rule of three
  • Rule of Reos
  • Rule of drug
  • Rule of Veber
  • Golden triangle
  • PAINS filters

Single Rule Application:

python
import medchem as mc

# Apply Rule of Five to a SMILES string
smiles = "CC(=O)OC1=CC=CC=C1C(=O)O"  # Aspirin
passes = mc.rules.basic_rules.rule_of_five(smiles)
# Returns: True

# Check specific rules
passes_oprea = mc.rules.basic_rules.rule_of_oprea(smiles)
passes_cns = mc.rules.basic_rules.rule_of_cns(smiles)

Multiple Rules with RuleFilters:

python
import datamol as dm
import medchem as mc

# Load molecules
mols = [dm.to_mol(smiles) for smiles in smiles_list]

# Create filter with multiple rules
rfilter = mc.rules.RuleFilters(
    rule_list=[
        "rule_of_five",
        "rule_of_oprea",
        "rule_of_cns",
        "rule_of_leadlike_soft"
    ]
)

# Apply filters with parallelization
results = rfilter(
    mols=mols,
    n_jobs=-1,  # Use all CPU cores
    progress=True
)

Result Format: Results are returned as dictionaries with pass/fail status and detailed information for each rule.

2. Structural Alert Filters

Detect potentially problematic structural patterns using the medchem.structural module.

Available Filters:

  1. Common Alerts - General structural alerts derived from ChEMBL curation and literature
  2. NIBR Filters - Novartis Institutes for BioMedical Research filter set
  3. Lilly Demerits - Eli Lilly's demerit-based system (275 rules, molecules rejected at >100 demerits)

Common Alerts:

python
import medchem as mc

# Create filter
alert_filter = mc.structural.CommonAlertsFilters()

# Check single molecule
mol = dm.to_mol("c1ccccc1")
has_alerts, details = alert_filter.check_mol(mol)

# Batch filtering with parallelization
results = alert_filter(
    mols=mol_list,
    n_jobs=-1,
    progress=True
)

NIBR Filters:

python
import medchem as mc

# Apply NIBR filters
nibr_filter = mc.structural.NIBRFilters()
results = nibr_filter(mols=mol_list, n_jobs=-1)

Lilly Demerits:

python
import medchem as mc

# Calculate Lilly demerits
lilly = mc.structural.LillyDemeritsFilters()
results = lilly(mols=mol_list, n_jobs=-1)

# Each result includes demerit score and whether it passes (≤100 demerits)
3. Functional API for High-Level Operations

The medchem.functional module provides convenient functions for common workflows.

Quick Filtering:

python
import medchem as mc

# Apply NIBR filters to a list
filter_ok = mc.functional.nibr_filter(
    mols=mol_list,
    n_jobs=-1
)

# Apply common alerts
alert_results = mc.functional.common_alerts_filter(
    mols=mol_list,
    n_jobs=-1
)
4. Chemical Groups Detection

Identify specific chemical groups and functional groups using medchem.groups.

Available Groups:

  • Hinge binders
  • Phosphate binders
  • Michael acceptors
  • Reactive groups
  • Custom SMARTS patterns

Usage:

python
import medchem as mc

# Create group detector
group = mc.groups.ChemicalGroup(groups=["hinge_binders"])

# Check for matches
has_matches = group.has_match(mol_list)

# Get detailed match information
matches = group.get_matches(mol)
5. Named Catalogs

Access curated collections of chemical structures through medchem.catalogs.

Available Catalogs:

  • Functional groups
  • Protecting groups
  • Common reagents
  • Standard fragments

Usage:

python
import medchem as mc

# Access named catalogs
catalogs = mc.catalogs.NamedCatalogs

# Use catalog for matching
catalog = catalogs.get("functional_groups")
matches = catalog.get_matches(mol)
6. Molecular Complexity

Calculate complexity metrics that approximate synthetic accessibility using medchem.complexity.

Common Metrics:

  • Bertz complexity
  • Whitlock complexity
  • Barone complexity

Usage:

python
import medchem as mc

# Calculate complexity
complexity_score = mc.complexity.calculate_complexity(mol)

# Filter by complexity threshold
complex_filter = mc.complexity.ComplexityFilter(max_complexity=500)
results = complex_filter(mols=mol_list)
7. Constraints Filtering

Apply custom property-based constraints using medchem.constraints.

Example Constraints:

  • Molecular weight ranges
  • LogP bounds
  • TPSA limits
  • Rotatable bond counts

Usage:

python
import medchem as mc

# Define constraints
constraints = mc.constraints.Constraints(
    mw_range=(200, 500),
    logp_range=(-2, 5),
    tpsa_max=140,
    rotatable_bonds_max=10
)

# Apply constraints
results = constraints(mols=mol_list, n_jobs=-1)
Show full SKILL.md (226 more words)Show less
8. Medchem Query Language

Use a specialized query language for complex filtering criteria.

Query Examples:

# Molecules passing Ro5 AND not having common alerts
"rule_of_five AND NOT common_alerts"

# CNS-like molecules with low complexity
"rule_of_cns AND complexity < 400"

# Leadlike molecules without Lilly demerits
"rule_of_leadlike AND lilly_demerits == 0"

Usage:

python
import medchem as mc

# Parse and apply query
query = mc.query.parse("rule_of_five AND NOT common_alerts")
results = query.apply(mols=mol_list, n_jobs=-1)

Workflow Patterns

Pattern 1: Initial Triage of Compound Library

Filter a large compound collection to identify drug-like candidates.

python
import datamol as dm
import medchem as mc
import pandas as pd

# Load compound library
df = pd.read_csv("compounds.csv")
mols = [dm.to_mol(smi) for smi in df["smiles"]]

# Apply primary filters
rule_filter = mc.rules.RuleFilters(rule_list=["rule_of_five", "rule_of_veber"])
rule_results = rule_filter(mols=mols, n_jobs=-1, progress=True)

# Apply structural alerts
alert_filter = mc.structural.CommonAlertsFilters()
alert_results = alert_filter(mols=mols, n_jobs=-1, progress=True)

# Combine results
df["passes_rules"] = rule_results["pass"]
df["has_alerts"] = alert_results["has_alerts"]
df["drug_like"] = df["passes_rules"] & ~df["has_alerts"]

# Save filtered compounds
filtered_df = df[df["drug_like"]]
filtered_df.to_csv("filtered_compounds.csv", index=False)
Pattern 2: Lead Optimization Filtering

Apply stricter criteria during lead optimization.

python
import medchem as mc

# Create comprehensive filter
filters = {
    "rules": mc.rules.RuleFilters(rule_list=["rule_of_leadlike_strict"]),
    "alerts": mc.structural.NIBRFilters(),
    "lilly": mc.structural.LillyDemeritsFilters(),
    "complexity": mc.complexity.ComplexityFilter(max_complexity=400)
}

# Apply all filters
results = {}
for name, filt in filters.items():
    results[name] = filt(mols=candidate_mols, n_jobs=-1)

# Identify compounds passing all filters
passes_all = all(r["pass"] for r in results.values())
Pattern 3: Identify Specific Chemical Groups

Find molecules containing specific functional groups or scaffolds.

python
import medchem as mc

# Create group detector for multiple groups
group_detector = mc.groups.ChemicalGroup(
    groups=["hinge_binders", "phosphate_binders"]
)

# Screen library
matches = group_detector.get_all_matches(mol_list)

# Filter molecules with desired groups
mol_with_groups = [mol for mol, match in zip(mol_list, matches) if match]

Best Practices

  1. Context Matters: Don't blindly apply filters. Understand the biological target and chemical space.

  2. Combine Multiple Filters: Use rules, structural alerts, and domain knowledge together for better decisions.

  3. Use Parallelization: For large datasets (>1000 molecules), always use n_jobs=-1 for parallel processing.

  4. Iterative Refinement: Start with broad filters (Ro5), then apply more specific criteria (CNS, leadlike) as needed.

  5. Document Filtering Decisions: Track which molecules were filtered out and why for reproducibility.

  6. Validate Results: Remember that marketed drugs often fail standard filters—use these as guidelines, not absolute rules.

  7. Consider Prodrugs: Molecules designed as prodrugs may intentionally violate standard medicinal chemistry rules.

Resources

references/api_guide.md

Comprehensive API reference covering all medchem modules with detailed function signatures, parameters, and return types.

references/rules_catalog.md

Complete catalog of available rules, filters, and alerts with descriptions, thresholds, and literature references.

scripts/filter_molecules.py

Production-ready script for batch filtering workflows. Supports multiple input formats (CSV, SDF, SMILES), configurable filter combinations, and detailed reporting.

Usage:

bash
python scripts/filter_molecules.py input.csv --rules rule_of_five,rule_of_cns --alerts nibr --output filtered.csv

Documentation

Official documentation: https://medchem-docs.datamol.io/ GitHub repository: https://github.com/datamol-io/medchem

© davila7, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references) in cli-tool/components/skills/scientific/medchem of davila7/claude-code-templates.

  • SKILL.md
  • references/api_guide.md
  • references/rules_catalog.md
  • scripts/filter_molecules.py

Open the folder on GitHubat commit c0ca7da

Used in 11 other repositories

We found 13 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 11 other GitHub owners. This page covers the copy in davila7/claude-code-templates, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Medchem Compound Filters next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Medchem Compound Filters compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Medchem Compound Filters this skilldavila7/claude-code-templates33k11 repos~2.5kAutomated safety check: PassMIT
DiffDock Molecular DockingK-Dense-AI/scientific-agent-skills48k1 repos~3kAutomated safety check: NotesMIT
Edu Chem Reactionwy51ai/edulab1.4k—~1.2kAutomated safety check: PassApache-2.0
Rowanlamm-mit/scienceclaw2464 repos~3.1kAutomated safety check: WarnProprietary
Coot Rdkitpemsley/coot168—~981Automated safety check: PassGPL-3.0
RDKit Conformer Generatorjinzhezenggroup/computational-chemistry-agent-skills148—~2.4kAutomated safety check: PassLGPL-3.0

Similar skills

  • DiffDock Molecular Docking

    K-Dense-AI/scientific-agent-skills

    Predicts how small molecules bind to a protein with DiffDock, covering batch docking, pose ranking by confidence and checks on the results; not for binding affinity.

    48k GitHub starsUsed in 1 repo~3k tokens
    Research & ScienceAuto-check: notes
  • Edu Chem Reaction

    wy51ai/edulab

    把一个化学反应做成自包含的微观 3D 交互演示网页:左/上为 Three.js 可交互分子动画 (拖滑块看断键·成键·原子重组,分步高亮),右为 KaTeX 反应方程 + 分步讲解 + 原子守恒计数 + 可选能量-反应进程曲线。支持三入口——给定文字反应/方程、随机出题、上传图片识别后演示。

    1.4k GitHub stars~1.2k tokensUpdated today
    Research & ScienceAuto-check passed
  • Rowan

    lamm-mit/scienceclaw

    Cloud-based quantum chemistry platform with Python API. An agent skill from lamm-mit/scienceclaw.

    246 GitHub starsUsed in 4 repos~3.1k tokens
    Research & ScienceAuto-check: warnings
  • Coot Rdkit

    pemsley/coot

    RDKit molecular manipulation and visualization within Coot's Python environment.

    168 GitHub stars~981 tokensUpdated 2 days ago
    Research & ScienceAuto-check passed
  • RDKit Conformer Generator

    jinzhezenggroup/computational-chemistry-agent-skills

    Generates 3D molecular conformers from SMILES strings or files with RDKit, keeps the lowest-energy one per molecule, and falls back to 2D coordinates when embedding fails.

    148 GitHub stars~2.4k tokensUpdated 2 days ago
    Research & ScienceAuto-check passed
  • RDKit Descriptors and Fingerprints

    jinzhezenggroup/computational-chemistry-agent-skills

    Computes RDKit physicochemical descriptors and molecular fingerprints from SMILES through a uv-run CLI script that skips and logs invalid molecules.

    148 GitHub stars~2.3k tokensUpdated 2 days ago
    Research & ScienceAuto-check passed

More from davila7/claude-code-templates

All 479 skills in this repo
  • Perplexity Web Search

    davila7/claude-code-templates

    Runs web-grounded searches through Perplexity's Sonar models over OpenRouter for current events, recent literature and cited facts beyond the model's training cutoff.

    33k GitHub starsUsed in 11 repos~3.5k tokens
    Auto-check: notes
  • Neuropixels Data Analysis

    davila7/claude-code-templates

    Analyzes Neuropixels recordings from SpikeGLX or Open Ephys through preprocessing, drift correction, Kilosort4 spike sorting, quality metrics and curation.

    33k GitHub starsUsed in 9 repos~2.8k tokens
    Auto-check passed
  • Scientific Venue Templates

    davila7/claude-code-templates

    Supplies LaTeX templates and formatting rules for journals, conferences, posters, and grant proposals, then can check a draft against them.

    33k GitHub starsUsed in 9 repos~5.1k tokens
    Auto-check: notes
  • Brand Voice Content Creator

    davila7/claude-code-templates

    Analyzes a brand's existing writing to lock in a consistent voice, then builds SEO blog posts and platform-specific social content around it.

    33k GitHub starsUsed in 3 repos~1.9k tokens
    Auto-check passed
  • CAPA Officer

    davila7/claude-code-templates

    Guides corrective and preventive action (CAPA) work in a quality management system, from initiation and root cause analysis through effectiveness verification.

    33k GitHub starsUsed in 1 repo~2k tokens
    Auto-check passed
  • Fda Consultant Specialist

    davila7/claude-code-templates

    Senior FDA consultant and specialist for medical device companies including HIPAA compliance and requirement management.

    33k GitHub starsUsed in 1 repo~2.7k tokens
    Auto-check passed

Works with

Questions about Medchem Compound Filters

What does Medchem Compound Filters do?

Screens compound libraries in Python with the medchem library: drug-likeness rules, PAINS filters, structural alerts and complexity metrics for prioritizing molecules. Medchem is a Python library for filtering and prioritizing molecules in drug discovery.rules` module, which applies rules such as Lipinski's Rule of Five, Veber, Oprea, CNS, leadlike, Reos, the Rule of three, the Rule of drug, the Golden triangle and PAINS, returning pass or fail results with details for each rule.

When should I use Medchem Compound Filters?

Medchem Compound Filters fits situations like: applying Lipinski and Veber drug-likeness rules to a compound library; flagging PAINS patterns or reactive functional groups in screening hits; ranking compounds for lead optimization by medicinal chemistry quality; calculating molecular complexity metrics for a set of SMILES.

How do I install Medchem Compound Filters in Claude Code?

Run `npx skills add davila7/claude-code-templates --skill medchem -a claude-code`. Or copy the skill folder (cli-tool/components/skills/scientific/medchem in davila7/claude-code-templates) into .claude/skills/medchem in your project. Claude Code loads it when a task matches its description.

How do I install Medchem Compound Filters in Codex?

Run `npx skills add davila7/claude-code-templates --skill medchem -a codex`. Or copy the skill folder (cli-tool/components/skills/scientific/medchem in davila7/claude-code-templates) into .agents/skills/medchem in your project. Codex loads it when a task matches its description.

Can I use Medchem Compound Filters in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add davila7/claude-code-templates --skill medchem -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/medchem, .gemini/skills/medchem, .github/skills/medchem and .opencode/skills/medchem in your project.

What does Medchem Compound Filters need to run?

Going by SKILL.md and its folder, Medchem Compound Filters needs Python for the scripts in its folder and the command-line tools its instructions call (uv and python). Our summary lists: Python with `medchem` installed; `datamol` for loading molecules, as used in the examples.

Does Medchem Compound Filters access the network?

SKILL.md names 2 domains. As links in the text: medchem-docs.datamol.io and github.com. This is read from the text; nothing was executed.

Is Medchem Compound Filters safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Medchem Compound Filters use?

Medchem Compound Filters is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Medchem Compound Filters use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 6.2k tokens, read only when the agent opens those files.

What are the alternatives to Medchem Compound Filters?

Skills that share tags, products or a category with Medchem Compound Filters: DiffDock Molecular Docking (K-Dense-AI/scientific-agent-skills, 48k stars), Edu Chem Reaction (wy51ai/edulab, 1.4k stars), Rowan (lamm-mit/scienceclaw, 246 stars) and Coot Rdkit (pemsley/coot, 168 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Medchem Compound Filters?

davila7 (a GitHub user) maintains it in davila7/claude-code-templates, which has 32,512 GitHub stars. The repository holds 479 skills in this directory. The repository was last updated on October 10, 2026.

Source: davila7/claude-code-templates on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.