Agent skill

Cobrapy

by davila7 in davila7/claude-code-templates

Constraint-based metabolic modeling (COBRA). An agent skill from davila7/claude-code-templates.

MITAuto-check passed

Install Cobrapy

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

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

GitHub CLI
$ gh skill install davila7/claude-code-templates cobrapy --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/cobrapy .claude/skills/cobrapy && 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
cobrapy
GitHub stars
32k
Used in
10 other repos
Token cost
~3.1k tokens
SKILL.md length
424 words
Files
3 (incl. references)
Skills in repo
478
Repo updated
First seen
Licence
MIT

At a glance

Constraint-based metabolic modeling (COBRA). An agent skill from davila7/claude-code-templates.

  • Works in 10 steps: Model Management → Model Structure and Components → Flux Balance Analysis (FBA) → …
  • SKILL.md covers Overview, Core Capabilities, Common Workflows and Key Concepts, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Cobrapy is an agent skill from davila7/claude-code-templates. Constraint-based metabolic modeling (COBRA). FBA, FVA, gene knockouts, flux sampling, SBML models, for systems biology and metabolic engineering analysis.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/api_quick_reference.md` and `references/workflows.md`).

The repository describes itself as: CLI tool for configuring and monitoring Claude Code. The licence is MIT.

Example prompts

  • “/cobrapy”

Requirements

  • Python 3

Workflow steps

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

  1. Model Management
  2. Model Structure and Components
  3. Flux Balance Analysis (FBA)
  4. Flux Variability Analysis (FVA)
  5. Gene and Reaction Deletion Studies
  6. Growth Media and Minimal Media
  7. Flux Sampling
  8. Production Envelopes
  9. Gapfilling
  10. Model Building

What it can do on your machine

Read from SKILL.md and the folder at commit 46b4d8b. 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

    No scripts in the folder and no shell commands in SKILL.md (its code samples are 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):

    • cobrapy.readthedocs.io

    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

Cobrapy loads about 3.1k tokens when it runs, and up to ~13k if it reads all its reference files. Until then it costs about 41 tokens; SKILL.md has 424 words of instructions outside code blocks.

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

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); files beside SKILL.md are not scanned.

SKILL.md

The full file from davila7/claude-code-templates at commit 46b4d8b, republished under its MIT licence (© davila7). 424 words, ~3,097 tokens.

Download SKILL.mdSave it as .claude/skills/cobrapy/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
cobrapy
description
Constraint-based metabolic modeling (COBRA). FBA, FVA, gene knockouts, flux sampling, SBML models, for systems biology and metabolic engineering analysis.

COBRApy - Constraint-Based Reconstruction and Analysis

Overview

COBRApy is a Python library for constraint-based reconstruction and analysis (COBRA) of metabolic models, essential for systems biology research. Work with genome-scale metabolic models, perform computational simulations of cellular metabolism, conduct metabolic engineering analyses, and predict phenotypic behaviors.

Core Capabilities

COBRApy provides comprehensive tools organized into several key areas:

1. Model Management

Load existing models from repositories or files:

python
from cobra.io import load_model

# Load bundled test models
model = load_model("textbook")  # E. coli core model
model = load_model("ecoli")     # Full E. coli model
model = load_model("salmonella")

# Load from files
from cobra.io import read_sbml_model, load_json_model, load_yaml_model
model = read_sbml_model("path/to/model.xml")
model = load_json_model("path/to/model.json")
model = load_yaml_model("path/to/model.yml")

Save models in various formats:

python
from cobra.io import write_sbml_model, save_json_model, save_yaml_model
write_sbml_model(model, "output.xml")  # Preferred format
save_json_model(model, "output.json")  # For Escher compatibility
save_yaml_model(model, "output.yml")   # Human-readable
2. Model Structure and Components

Access and inspect model components:

python
# Access components
model.reactions      # DictList of all reactions
model.metabolites    # DictList of all metabolites
model.genes          # DictList of all genes

# Get specific items by ID or index
reaction = model.reactions.get_by_id("PFK")
metabolite = model.metabolites[0]

# Inspect properties
print(reaction.reaction)        # Stoichiometric equation
print(reaction.bounds)          # Flux constraints
print(reaction.gene_reaction_rule)  # GPR logic
print(metabolite.formula)       # Chemical formula
print(metabolite.compartment)   # Cellular location
3. Flux Balance Analysis (FBA)

Perform standard FBA simulation:

python
# Basic optimization
solution = model.optimize()
print(f"Objective value: {solution.objective_value}")
print(f"Status: {solution.status}")

# Access fluxes
print(solution.fluxes["PFK"])
print(solution.fluxes.head())

# Fast optimization (objective value only)
objective_value = model.slim_optimize()

# Change objective
model.objective = "ATPM"
solution = model.optimize()

Parsimonious FBA (minimize total flux):

python
from cobra.flux_analysis import pfba
solution = pfba(model)

Geometric FBA (find central solution):

python
from cobra.flux_analysis import geometric_fba
solution = geometric_fba(model)
4. Flux Variability Analysis (FVA)

Determine flux ranges for all reactions:

python
from cobra.flux_analysis import flux_variability_analysis

# Standard FVA
fva_result = flux_variability_analysis(model)

# FVA at 90% optimality
fva_result = flux_variability_analysis(model, fraction_of_optimum=0.9)

# Loopless FVA (eliminates thermodynamically infeasible loops)
fva_result = flux_variability_analysis(model, loopless=True)

# FVA for specific reactions
fva_result = flux_variability_analysis(
    model,
    reaction_list=["PFK", "FBA", "PGI"]
)
5. Gene and Reaction Deletion Studies

Perform knockout analyses:

python
from cobra.flux_analysis import (
    single_gene_deletion,
    single_reaction_deletion,
    double_gene_deletion,
    double_reaction_deletion
)

# Single deletions
gene_results = single_gene_deletion(model)
reaction_results = single_reaction_deletion(model)

# Double deletions (uses multiprocessing)
double_gene_results = double_gene_deletion(
    model,
    processes=4  # Number of CPU cores
)

# Manual knockout using context manager
with model:
    model.genes.get_by_id("b0008").knock_out()
    solution = model.optimize()
    print(f"Growth after knockout: {solution.objective_value}")
# Model automatically reverts after context exit
6. Growth Media and Minimal Media

Manage growth medium:

python
# View current medium
print(model.medium)

# Modify medium (must reassign entire dict)
medium = model.medium
medium["EX_glc__D_e"] = 10.0  # Set glucose uptake
medium["EX_o2_e"] = 0.0       # Anaerobic conditions
model.medium = medium

# Calculate minimal media
from cobra.medium import minimal_medium

# Minimize total import flux
min_medium = minimal_medium(model, minimize_components=False)

# Minimize number of components (uses MILP, slower)
min_medium = minimal_medium(
    model,
    minimize_components=True,
    open_exchanges=True
)
7. Flux Sampling

Sample the feasible flux space:

python
from cobra.sampling import sample

# Sample using OptGP (default, supports parallel processing)
samples = sample(model, n=1000, method="optgp", processes=4)

# Sample using ACHR
samples = sample(model, n=1000, method="achr")

# Validate samples
from cobra.sampling import OptGPSampler
sampler = OptGPSampler(model, processes=4)
sampler.sample(1000)
validation = sampler.validate(sampler.samples)
print(validation.value_counts())  # Should be all 'v' for valid
8. Production Envelopes

Calculate phenotype phase planes:

python
from cobra.flux_analysis import production_envelope

# Standard production envelope
envelope = production_envelope(
    model,
    reactions=["EX_glc__D_e", "EX_o2_e"],
    objective="EX_ac_e"  # Acetate production
)

# With carbon yield
envelope = production_envelope(
    model,
    reactions=["EX_glc__D_e", "EX_o2_e"],
    carbon_sources="EX_glc__D_e"
)

# Visualize (use matplotlib or pandas plotting)
import matplotlib.pyplot as plt
envelope.plot(x="EX_glc__D_e", y="EX_o2_e", kind="scatter")
plt.show()
9. Gapfilling

Add reactions to make models feasible:

python
from cobra.flux_analysis import gapfill

# Prepare universal model with candidate reactions
universal = load_model("universal")

# Perform gapfilling
with model:
    # Remove reactions to create gaps for demonstration
    model.remove_reactions([model.reactions.PGI])

    # Find reactions needed
    solution = gapfill(model, universal)
    print(f"Reactions to add: {solution}")
10. Model Building

Build models from scratch:

python
from cobra import Model, Reaction, Metabolite

# Create model
model = Model("my_model")

# Create metabolites
atp_c = Metabolite("atp_c", formula="C10H12N5O13P3",
                   name="ATP", compartment="c")
adp_c = Metabolite("adp_c", formula="C10H12N5O10P2",
                   name="ADP", compartment="c")
pi_c = Metabolite("pi_c", formula="HO4P",
                  name="Phosphate", compartment="c")

# Create reaction
reaction = Reaction("ATPASE")
reaction.name = "ATP hydrolysis"
reaction.subsystem = "Energy"
reaction.lower_bound = 0.0
reaction.upper_bound = 1000.0

# Add metabolites with stoichiometry
reaction.add_metabolites({
    atp_c: -1.0,
    adp_c: 1.0,
    pi_c: 1.0
})

# Add gene-reaction rule
reaction.gene_reaction_rule = "(gene1 and gene2) or gene3"

# Add to model
model.add_reactions([reaction])

# Add boundary reactions
model.add_boundary(atp_c, type="exchange")
model.add_boundary(adp_c, type="demand")

# Set objective
model.objective = "ATPASE"

Common Workflows

Workflow 1: Load Model and Predict Growth
python
from cobra.io import load_model

# Load model
model = load_model("ecoli")

# Run FBA
solution = model.optimize()
print(f"Growth rate: {solution.objective_value:.3f} /h")

# Show active pathways
print(solution.fluxes[solution.fluxes.abs() > 1e-6])
Workflow 2: Gene Knockout Screen
python
from cobra.io import load_model
from cobra.flux_analysis import single_gene_deletion

# Load model
model = load_model("ecoli")

# Perform single gene deletions
results = single_gene_deletion(model)

# Find essential genes (growth < threshold)
essential_genes = results[results["growth"] < 0.01]
print(f"Found {len(essential_genes)} essential genes")

# Find genes with minimal impact
neutral_genes = results[results["growth"] > 0.9 * solution.objective_value]
Workflow 3: Media Optimization
python
from cobra.io import load_model
from cobra.medium import minimal_medium

# Load model
model = load_model("ecoli")

# Calculate minimal medium for 50% of max growth
target_growth = model.slim_optimize() * 0.5
min_medium = minimal_medium(
    model,
    target_growth,
    minimize_components=True
)

print(f"Minimal medium components: {len(min_medium)}")
print(min_medium)
Workflow 4: Flux Uncertainty Analysis
python
from cobra.io import load_model
from cobra.flux_analysis import flux_variability_analysis
from cobra.sampling import sample

# Load model
model = load_model("ecoli")

# First check flux ranges at optimality
fva = flux_variability_analysis(model, fraction_of_optimum=1.0)

# For reactions with large ranges, sample to understand distribution
samples = sample(model, n=1000)

# Analyze specific reaction
reaction_id = "PFK"
import matplotlib.pyplot as plt
samples[reaction_id].hist(bins=50)
plt.xlabel(f"Flux through {reaction_id}")
plt.ylabel("Frequency")
plt.show()
Workflow 5: Context Manager for Temporary Changes

Use context managers to make temporary modifications:

python
# Model remains unchanged outside context
with model:
    # Temporarily change objective
    model.objective = "ATPM"

    # Temporarily modify bounds
    model.reactions.EX_glc__D_e.lower_bound = -5.0

    # Temporarily knock out genes
    model.genes.b0008.knock_out()

    # Optimize with changes
    solution = model.optimize()
    print(f"Modified growth: {solution.objective_value}")

# All changes automatically reverted
solution = model.optimize()
print(f"Original growth: {solution.objective_value}")

Key Concepts

DictList Objects

Models use DictList objects for reactions, metabolites, and genes - behaving like both lists and dictionaries:

python
# Access by index
first_reaction = model.reactions[0]

# Access by ID
pfk = model.reactions.get_by_id("PFK")

# Query methods
atp_reactions = model.reactions.query("atp")
Flux Constraints

Reaction bounds define feasible flux ranges:

  • Irreversible: lower_bound = 0, upper_bound > 0
  • Reversible: lower_bound < 0, upper_bound > 0
  • Set both bounds simultaneously with .bounds to avoid inconsistencies
Gene-Reaction Rules (GPR)

Boolean logic linking genes to reactions:

python
# AND logic (both required)
reaction.gene_reaction_rule = "gene1 and gene2"

# OR logic (either sufficient)
reaction.gene_reaction_rule = "gene1 or gene2"

# Complex logic
reaction.gene_reaction_rule = "(gene1 and gene2) or (gene3 and gene4)"
Show full SKILL.md (174 more words)Show less
Exchange Reactions

Special reactions representing metabolite import/export:

  • Named with prefix EX_ by convention
  • Positive flux = secretion, negative flux = uptake
  • Managed through model.medium dictionary

Best Practices

  1. Use context managers for temporary modifications to avoid state management issues
  2. Validate models before analysis using model.slim_optimize() to ensure feasibility
  3. Check solution status after optimization - optimal indicates successful solve
  4. Use loopless FVA when thermodynamic feasibility matters
  5. Set fraction_of_optimum appropriately in FVA to explore suboptimal space
  6. Parallelize computationally expensive operations (sampling, double deletions)
  7. Prefer SBML format for model exchange and long-term storage
  8. Use slim_optimize() when only objective value needed for performance
  9. Validate flux samples to ensure numerical stability

Troubleshooting

Infeasible solutions: Check medium constraints, reaction bounds, and model consistency Slow optimization: Try different solvers (GLPK, CPLEX, Gurobi) via model.solver Unbounded solutions: Verify exchange reactions have appropriate upper bounds Import errors: Ensure correct file format and valid SBML identifiers

References

For detailed workflows and API patterns, refer to:

  • references/workflows.md - Comprehensive step-by-step workflow examples
  • references/api_quick_reference.md - Common function signatures and patterns

Official documentation: https://cobrapy.readthedocs.io/en/latest/

© 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 2 other files (references) in cli-tool/components/skills/scientific/cobrapy of davila7/claude-code-templates.

  • SKILL.md
  • references/api_quick_reference.md
  • references/workflows.md

Open the folder on GitHubat commit 46b4d8b

Used in 10 other repositories

We found 15 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 10 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

Cobrapy 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.

Cobrapy compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cobrapy this skilldavila7/claude-code-templates32k10 repos~3.1kAutomated safety check: PassMIT
CobrapyK-Dense-AI/scientific-agent-skills48k1 repos~2.9kAutomated safety check: NotesGPL-2.0
Cobrapy Metabolic Modelingjaechang-hits/SciAgent-Skills3711 repos~4.9kAutomated safety check: PassGPL-2.0
Bio Workflows Metabolic Modeling PipelineGPTomics/bioSkills1.2k1 repos~5.2kAutomated safety check: PassMIT
OmniRoute Model Catalogdiegosouzapw/OmniRoute74k—~589Automated safety check: PassMIT
Model Bank Metadatalobehub/lobehub83k—~2kAutomated safety check: PassCustom licence

Similar skills

  • Cobrapy

    K-Dense-AI/scientific-agent-skills

    Performs constraint-based metabolic modeling with COBRApy, including FBA, pFBA, FVA, gene knockouts, flux sampling, growth media, production envelopes, gap filling, and SBML model validation for…

    48k GitHub starsUsed in 1 repo~2.9k tokens
    Research & ScienceAuto-check: notes
  • Cobrapy Metabolic Modeling

    jaechang-hits/SciAgent-Skills

    Constraint-based (COBRA) analysis of genome-scale metabolic models: FBA, FVA, knockouts, flux sampling, production envelopes, gapfilling, media optimization.

    371 GitHub starsUsed in 1 repo~4.9k tokens
    Research & ScienceAuto-check passed
  • Orchestrates genome-scale metabolic modeling from a protein FASTA to flux predictions, chaining CarveMe/gapseq reconstruction, memote QC, gap-filling, media-constrained FBA/FVA, gene essentiality…

    1.2k GitHub starsUsed in 1 repo~5.2k tokens
    Research & ScienceAuto-check passed
  • OmniRoute Model Catalog

    diegosouzapw/OmniRoute

    Looks up which AI models an OmniRoute gateway can reach, creates or updates model aliases and tests whether individual models respond.

    74k GitHub stars~589 tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Model Bank Metadata

    lobehub/lobehub

    Fills and maintains the knowledgeCutoff, family and generation fields on model cards in LobeHub's model bank, from a single new model up to repo-wide backfills.

    83k GitHub stars~2k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Enterprise-review-grade threat model from harness threat-model <path.

    74k GitHub stars~363 tokensUpdated today
    SecurityAuto-check: notes

More from davila7/claude-code-templates

All 478 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.

    32k 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.

    32k 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.

    32k 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.

    32k 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.

    32k 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.

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

Questions about Cobrapy

What does Cobrapy do?

Constraint-based metabolic modeling (COBRA). An agent skill from davila7/claude-code-templates. Cobrapy is an agent skill from davila7/claude-code-templates. Constraint-based metabolic modeling (COBRA).

How do I install Cobrapy in Claude Code?

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

How do I install Cobrapy in Codex?

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

Can I use Cobrapy 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 cobrapy -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cobrapy, .gemini/skills/cobrapy, .github/skills/cobrapy and .opencode/skills/cobrapy in your project.

What does Cobrapy need to run?

SKILL.md names no scripts, command-line tools or credentials: Cobrapy is instructions for the agent only. Our summary lists: Python 3.

Does Cobrapy access the network?

SKILL.md names 1 domain. As links in the text: cobrapy.readthedocs.io. This is read from the text; nothing was executed.

Is Cobrapy 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. Review the folder before installing.

What licence does Cobrapy use?

Cobrapy 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 Cobrapy use?

About 3.1k tokens (SKILL.md is roughly 12k 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 9.4k tokens, read only when the agent opens those files.

What are the alternatives to Cobrapy?

Skills that share tags, products or a category with Cobrapy: Cobrapy (K-Dense-AI/scientific-agent-skills, 48k stars), Cobrapy Metabolic Modeling (jaechang-hits/SciAgent-Skills, 371 stars), Bio Workflows Metabolic Modeling Pipeline (GPTomics/bioSkills, 1.2k stars) and OmniRoute Model Catalog (diegosouzapw/OmniRoute, 74k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cobrapy?

davila7 (a GitHub user) maintains it in davila7/claude-code-templates, which has 32,483 GitHub stars. The repository holds 478 skills in this directory. The repository was last updated on October 9, 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.