ampl-python

ampl-python is a skill for Claude Code, Codex from marcos-dv/ampl-agents. It costs 75 tokens per session (3,822 once invoked), scanned A, original, MIT.

A specialist guide for using amplpy, the Python interface to AMPL, in applications and data workflows. It connects Python code, AMPL model files, data libraries, solvers, and optimization results.

In plain words
What is it for?
Use it to write or refactor Python scripts, notebooks, FastAPI services, and data pipelines that load AMPL models, configure solvers, run verified solves, and read results.
Why use it?
It helps keep mathematical model structure separate from Python data handling and application logic. It also gives patterns for installation, solver setup, notebooks, services, and result extraction.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is Always-on constraints ([verified solve](../../rules/ampl-verified-solve.md), [model structure](../../rules/ampl-model-structure.md), [session hygiene](../../rul.

Good fit Use it to write or refactor Python scripts, notebooks, FastAPI services, and data pipelines that load AMPL models, configure solvers, run verified solves, and read results.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/marcos-dv/ampl-agents
agentmods
npx agentmods add skills/marcos-dv/ampl-agents/ampl-python

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ampl-python

README.md
[![agentmods](https://agentmods.dev/badge/skills/marcos-dv/ampl-agents/ampl-python/github.svg)](https://agentmods.dev/skills/marcos-dv/ampl-agents/ampl-python)
Your own site
<a href="https://agentmods.dev/skills/marcos-dv/ampl-agents/ampl-python"><img src="https://agentmods.dev/badge/skills/marcos-dv/ampl-agents/ampl-python/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ampl-python

Your own site · 80×15
<a href="https://agentmods.dev/skills/marcos-dv/ampl-agents/ampl-python"><img src="https://agentmods.dev/badge/skills/marcos-dv/ampl-agents/ampl-python.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,822 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00075 $0.03822
Opus 5.5 $0.00030 $0.01529
Sonnet 5.5 $0.00015 $0.00764
Haiku 4.5 $0.00007 $0.00382

Measured 1mo ago against content hash 5aace1338dce, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ampl-python scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

IF you have internet access (WebFetch, browser, or curl):
skills/ampl-python/SKILL.md · 498 lines

How it starts

The opening of the file, as written. The whole thing — 498 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AMPL Python (amplpy) Skill

Always-on constraints (verified solve, model structure, session hygiene) live in rules/ and apply whenever this skill is active.

Mission

You write correct, maintainable amplpy code that drives AMPL models. You know the amplpy API, official best practices, and Colab/MO-Book workflow patterns. You keep model structure in .mod files, use Python for data, orchestration, and results, and always verify solves.

You are not a general Python agent — optimization and AMPL session semantics come first.


Code examples convention

This skill is amplpy-first. Every operational pattern shows Preferred: amplpy then Pure AMPL for the same action (solve, options, queries, IIS). Model structure belongs in model.mod.


AMPL installation

From https://amplpy.ampl.com/en/latest/getting-started.html and https://dev.ampl.com/ampl/python/modules.html.

python -m pip install amplpy --upgrade
python -m amplpy.modules install highs gurobi xpress
python -m amplpy.modules activate <license-uuid>   # https://ampl.com/ce
python -m amplpy.modules run ampl -vvq
from amplpy import AMPL
ampl = AMPL()

Colab:

%pip install -q amplpy
from amplpy import AMPL, ampl_notebook
ampl = ampl_notebook(
    modules=["gurobi", "highs", "xpress"],
    license_uuid="default",
)

Ensure deployed code documents required modules and license UUID source (env var, not committed secrets).


Solver classification (commercial vs open-source)

Sources: https://dev.ampl.com/solvers/index.html , https://dev.ampl.com/ampl/python/modules.html

Open-source modules

Module Solvers Use
highs HiGHS LP, MILP
cbc CBC MILP
coin CBC, Couenne, Ipopt, Bonmin MIP, MINLP, NLP
open All OSS MIP, MINLP, NLP
scip SCIP MIP
gcg GCG Decomposition
gokestrel NEOS Kestrel Remote solvers (Colab)

Read the full file on GitHub · 498 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 498 lines · 75 tokens per session scan A 5aace1338dce

Subscribe to this mod's changes

ampl-python is a skill published in the GitHub repository marcos-dv/ampl-agents (10 stars, last pushed 1mo ago), licensed MIT. It adds 75 tokens to every session and 3,822 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.