pypsa-solve-and-debug

pypsa-solve-and-debug is a skill for Claude Code from nimabahrami/pypsa-skills-kit. It costs 128 tokens per session (745 once invoked), scanned A, original, MIT.

A skill for solving and troubleshooting PyPSA optimization models. It covers solver choices, failed or slow runs, infeasible or unbounded models, numerical problems, and larger planning workflows.

In plain words
What is it for?
Use it to choose HiGHS or a licensed solver, investigate optimization failures, improve performance, and debug PyPSA-Eur or Snakemake runs.
Why use it?
It helps distinguish solver failures from incorrect model data, such as impossible constraints or free-energy loops. It provides an ordered approach for checking consistency, realism, logs, and infeasibility causes.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Part of the pypsa-skills plugin — 9 skills shipped together

Good fit Use it to choose HiGHS or a licensed solver, investigate optimization failures, improve performance, and debug PyPSA-Eur or Snakemake runs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nimabahrami/pypsa-skills-kit/pypsa-solve-and-debug
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add nimabahrami/pypsa-skills-kit --skill pypsa-solve-and-debug
Clone the repo
git clone --depth 1 https://github.com/nimabahrami/pypsa-skills-kit

Made for: Claude Code.

Or install pypsa-skills, the plugin that ships this one along with the rest of its 9 skills.

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 pypsa-solve-and-debug

README.md
[![agentmods](https://agentmods.dev/badge/skills/nimabahrami/pypsa-skills-kit/pypsa-solve-and-debug/github.svg)](https://agentmods.dev/skills/nimabahrami/pypsa-skills-kit/pypsa-solve-and-debug)
Your own site
<a href="https://agentmods.dev/skills/nimabahrami/pypsa-skills-kit/pypsa-solve-and-debug"><img src="https://agentmods.dev/badge/skills/nimabahrami/pypsa-skills-kit/pypsa-solve-and-debug/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 pypsa-solve-and-debug

Your own site · 80×15
<a href="https://agentmods.dev/skills/nimabahrami/pypsa-skills-kit/pypsa-solve-and-debug"><img src="https://agentmods.dev/badge/skills/nimabahrami/pypsa-skills-kit/pypsa-solve-and-debug.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 128 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 745 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00128 $0.00745
Opus 5 $0.00064 $0.00373
Sonnet 5 $0.00026 $0.00149
Haiku 4.5 $0.00013 $0.00075

Measured 10d ago against content hash a703931e5a35, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

pypsa-solve-and-debug scanned grade A with 0 findings 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 10d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/diagnose_infeasibility.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/pypsa-solve-and-debug/SKILL.md · 33 lines

How it starts

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

PyPSA Solve & Debug

Solver selection

  • HiGHS = open-source default. LPs to ~1e7 nonzeros OK | MILP weaker.
  • Gurobi/CPLEX/COPT = licensed. USE: barrier (method=2) + crossover=0 for big planning LPs. ! barrier duals w/o crossover valid but less clean -> price analysis: enable crossover.
  • MILP (committable units | discrete expansion) -> orders-of-magnitude slowdown. SET: mip gap consciously. ! 1e-3 default gap hides real money in big objectives. ! MILP = no duals/prices -> fixed-commitment LP pricing run: pypsa-market-design.

Failure triage, in order

  1. PyPSA-Eur/Snakemake project -> READ logs/solve_network_* + solver log first; solver config under solving:; re-run one rule w/ snakemake -call <target> (pypsa-network-modeling/references/framework-workflows.md).
  2. RUN: n.consistency_check() + pypsa-physical-realism validator FIRST. Most "solver problems" = data problems.
  3. infeasible -> references/infeasibility.md + scripts/diagnose_infeasibility.py.
  4. unbounded -> free profitable machine: extendable w/ capital_cost<=0 | neg marginal_cost w/o p_nom limit | efficiency>1 loop. RUN: realism validator (catches all 3).
  5. numerical trouble (barrier stalls | "numerical difficulties") -> scale model. SET: cost coefficients within ~1e-2..1e6 of each other. ! avoid 1e9 "bigM" capacities -> use 'inf'-free explicit caps. Gurobi: NumericFocus=3, Aggregate=0.
  6. slow -> references/performance.md (clustering | rolling horizon | aggregation).

Native optimize() levers

! READ references/optimize-levers.md BEFORE hand-rolling any of: rolling horizon (3 traps) | two-stage via fix_optimal_capacities / p_nom_set | stochastic set_scenarios + CVaR | IIS (Gurobi) | transmission_losses | linearized UC (LP prices) | UC gotchas (snapshots-not-hours, up_time_before=1) | MGA near-optimal | N-1 SCLOPF.

Result interpretation

READ: references/interpreting-results.md = n.statistics | energy balances | duals/shadow prices | curtailment | sanity battery. RUN: sanity battery on EVERY solved model before reporting numbers.

Read the full file on GitHub · 33 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 10d ago First seen · 33 lines · 0 tokens per session scan A a703931e5a35

Subscribe to this mod's changes

pypsa-solve-and-debug is a skill published in the GitHub repository nimabahrami/pypsa-skills-kit (23 stars, last pushed 2mo ago), licensed MIT. It adds 128 tokens to every session and 745 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.