Volver al Blog
IA y optimización

Orchestrating Techno-Economic Energy Modeling with Claude Code and the FIDgate Python SDK

Orchestrating Techno-Economic Energy Modeling with Claude Code and the FIDgate Python SDK
Compartir
AI Should Orchestrate Energy Modeling, Not Do the Math | Claude Code + FIDgate SDK




You finish the base case for a solar-plus-storage project. Then the questions arrive. What if the battery is four hours instead of two? What if the grid connection is smaller? What does the same design look like at fifteen other sites?

In a spreadsheet or a GUI, each question is another round of re-entering inputs, copying results and hoping nothing drifted along the way. For utility-scale solar, storage and hybrid projects (wind generation can be included as an input time series), pre-FID design is a *sweep problem*: many sizes, many sites, a handful of operating scenarios, one consistent method. The bottleneck is rarely the math. It is the manual orchestration around the math.

This guide shows a different pattern. You describe the study in plain English. Claude Code turns that description into a Python script that you can read, review and version in Git. The script calls the FIDgate Python SDK, and FIDcore, FIDgate's deterministic optimization engine, computes every scenario.

**AI orchestrates. Engineers decide. FIDcore does the math.**

**In this guide**

1. The mental model: who does what
2. Prerequisites and setup
3. A real walkthrough: 16 German locations in one run
4. A copy-paste prompt library (4 prompts)
5. Engineering best practices
6. Common mistakes to avoid
7. Get started

> **A note on the numbers.** The benchmark in this post is a workflow demo that used synthetic, illustrative electricity prices. It shows how the workflow runs, not what any real site would earn.

---

## The Mental Model: Claude Is the Director, FIDcore Is the Deterministic Engine

Think of the workflow as four roles.

| Role | What it does |
|---|---|
| **You, the engineer** | Describe the study, review the plan and the script, approve each run, and make the decisions. |
| **Claude Code** | Writes, inspects and runs Python scripts; reads the output files; explains the results back to you. |
| **FIDgate Python SDK & API** | The programmatic interface that sends your project definition to FIDcore. |
| **FIDcore** | The deterministic engine that computes every scenario. |

The rule that makes this safe is simple: **Claude Code is never the source of an energy or financial number.** It writes the script that defines the cases, runs it, and reads and explains the output files. Every scenario result comes from FIDcore. If a number appears in your deliverable, you should be able to trace it to a file FIDcore wrote.

FIDcore is a deterministic mixed-integer linear programming (MILP) optimization engine: run the same inputs again and you get the same answer. It finds the best design within the search space and model you define, which is exactly why you want that search space written down explicitly, in a script, rather than clicked together.

That gives you a clean division of labor:

- **The script is the input.** It is plain Python, so you can read it, diff it and keep it in Git.
- **The CSV files are the output.** They are plain files you can open, check and re-use.
- **Claude Code sits in between.** It translates your intent into the script and helps you read the results. It does not replace the calculation.

---

## Prerequisites and Setup

You need three things. The FIDgate Python SDK & API are live today, and the Early Adopter Program is open now.

### 1. Claude Code installed

Install Claude Code as a command-line tool, a desktop app or an IDE extension, following Anthropic's installation guide for your platform. Any of them works for this workflow.

### 2. A Python environment, the FIDgate Python SDK and API credentials

Create an isolated environment and install the SDK:

```bash
python -m venv .venv
# Windows (PowerShell):  .venv\Scripts\Activate.ps1
# macOS / Linux:         source .venv/bin/activate
pip install fidgate-sdk
```

Early Adopter onboarding gives you API credentials. Keep the token out of prompts, scripts and Git: read it from an environment variable (we use `FIDGATE_API_TOKEN`) or from a git-ignored settings file.

### 3. A clean project folder

```text
my_study/
├── config.py        # the project definition: site, grid, solar, battery, price file
├── run_batch.py     # loops over cases and scenarios, calls the SDK, writes results
├── data/            # input CSVs: generation profile, day-ahead prices
├── outputs/         # results land here, one folder per scenario plus summary tables
├── CLAUDE.md        # standing rules for Claude Code (see below)
└── README.md        # assumptions and how to re-run
```

Keeping the project definition (`config.py`) apart from the orchestration (`run_batch.py`) means you can review the engineering assumptions without wading through loop logic.

Then give Claude Code standing rules in `CLAUDE.md`, so you do not have to repeat them in every prompt:

```markdown
# Project rules for Claude Code
- This project uses the FIDgate Python SDK. FIDcore computes all results.
- Never estimate, recalculate or "sanity-check by hand" any financial or energy result.
  Every number must come from files FIDcore wrote under outputs/.
- Before anything that calls the FIDgate API: show the plan and the assumptions,
  run the offline dry run, and wait for my approval.
- Never print, log or commit API credentials. Read them from the environment.
- Mark every assumed number in config.py with "# ASSUMPTION" and list it in README.md.
- Label results from synthetic or illustrative inputs as such.
```

Here is what the project definition looks like. This is an abridged, illustrative sketch of `config.py`; names in CAPS are your own inputs, which you set explicitly and document:

```python
from fidgate_sdk import ProjectBuilder, exogenous_price_csv, span

builder = ProjectBuilder("demo_pv_bess")
builder.set_timeline(construction_start_year=2026, operation_start_year=2027,
                     operation_end_year=2051)

# Site: coordinates and time zone
builder.set_site(lat=52.52, lon=13.405, tz="Europe/Berlin")

# Grid limits (MW)
builder.set_grid_connection(max_injection_mw=50.0, max_offtake_mw=10.0,
                            allow_grid_charging=True)

# Solar from a generation profile; wind, if any, is also an input profile
builder.add_solar(rated_capacity_mw=50.0, profile_path="data/pv_profile.csv",
                  capex_eur=CAPEX_PV, opex_eur=OPEX_PV)

# Battery 10 MW / 20 MWh, dispatched against day-ahead prices
builder.add_battery(unit_rated_power_mw=5.0, nb_units=2, unit_duration_h=2.0,
                    roundtrip_efficiency=RTE, cycling_cost_per_mwh=CYCLING_COST)
builder.add_merchant_market(price=exogenous_price_csv("data/da_price.csv", fill="hold"))
builder.set_dispatch(seed=7)   # fixed seed: reproducible runs

# Sweep: vary the number of battery units across cases
builder.sweep("BESS_1", nb_units=span(1, 4, 4))
builder.check()                # reports anything missing or defaulted
```

Two details worth noticing: the battery is dispatched against a day-ahead price series that *you* provide, and wind, if your project has it, enters as an input generation profile.

---

## Real-World Walkthrough: 16 German Locations in One Run

Here is the workflow we actually ran, start to finish. The result:

> **32 scenarios across 16 German locations in about 26 minutes in an AI-orchestrated demo.**

![Map of Germany: 32 scenarios run across 16 cities, about 26 minutes total, 1 command](blog-assets/germany-map.png)

**Illustrative electricity price assumptions.** The demo used a synthetic day-ahead price series, identical for every city, and each city's own typical-year weather from PVGIS. Because everything except the location was held constant, the demo isolates what location changes. It is not a statement about real German power markets or about any specific site. The run was a FIDgate staging run on 9 November 2026, and timing is specific to that run: your wall time depends on case size and on how many cases run at once.

**The setup.** The same plant in every city: 50 MWac of PV with a 10 MW / 20 MWh battery. The 16 locations are the German state capitals: Berlin, Stuttgart, Munich, Potsdam, Bremen, Hamburg, Wiesbaden, Schwerin, Hanover, Düsseldorf, Mainz, Saarbrücken, Dresden, Magdeburg, Kiel and Erfurt. Two battery-charging scenarios per city: **PV-only charging** (`max_offtake_mw = 0`) and **PV + grid charging** (`max_offtake_mw = 50`). 16 locations × 2 scenarios = 32 scenarios.

### Step 1: Describe the study in plain language

This is the prompt we gave Claude Code, lightly generalized:

```text
Extend my existing single-site Solar+BESS project into a Germany-wide batch optimization.

Use one representative city from each of Germany's 16 federal states, starting with Berlin.
Find the coordinates yourself and use tz="Europe/Berlin".

Keep the existing Solar+BESS configuration and the same two scenarios for every location:
- Scenario 1: PV-only battery charging (max_offtake_mw = 0).
- Scenario 2: PV + grid battery charging (max_offtake_mw = 50).

Only change the location. Keep all technical, financial and market assumptions identical,
but make sure solar generation is recalculated for each city.
Expected total: 16 locations x 2 scenarios = 32 scenarios.

First, inspect the code and explain your proposed approach.
Do not modify the working Berlin demo or execute anything until I approve.
```

Notice the last two lines. We asked for a plan before any execution. That habit is the most important one in this guide.

### Step 2: Review the plan before anything runs

Claude Code inspected the existing project and replied with an approach, not with results. In short:

- Put the work in a new folder and leave the working Berlin demo untouched.
- One Python script loops over the 16 state capitals, starting with Berlin. Each city gets its own project version, because the location cannot be swept inside a single batch.
- Weather comes from PVGIS at runtime, using each city's coordinates and time zone.
- Two labelled scenarios per city, 32 in total, with results labelled by city and scenario.
- It ended with a question: *"Shall I create the script? I won't run anything on the server without a separate OK."*

We said yes to the script, and only the script.

### Step 3: Read the script, then dry-run it

Claude Code created `run_germany.py`, about 300 lines in our run, and reported that an offline dry run and preflight had passed with zero errors and that nothing had been sent to the server. The generated script offered exactly the controls you want in a batch tool: a **dry run** that builds all 16 configurations offline and sends nothing, an **`--only <city>`** option to run a single location, and a target argument to choose the environment.

```text
python run_germany.py --dry-run               # build the 16 configurations offline, send nothing
python run_germany.py stg --only Berlin       # one city first (stg = the staging environment we used)
python run_germany.py stg                     # all 16 cities
```

These options were generated for this demo, not built into the SDK, but they show what to ask for.

### Step 4: Validate one site, then approve the rest

Claude Code proposed *"Run Berlin first on staging?"*, and we approved only that. Once Berlin's results looked right, we asked which other cities were in the batch, got the list of the remaining 15, and replied: *"yes run all of them."*

Claude Code then launched the remaining 15 cities in the background, reused the finished Berlin results, and reported back when everything was done: all 16 cities finished and all 32 scenarios completed.

### Step 5: Read the structured outputs

Every FIDgate scenario writes plain files. Names reflect our current output format and may evolve.

| File | What it is |
|---|---|
| `kpi_matrix.csv` | One row per scenario in a batch, with the run status and result columns. |
| `cashflows.csv` | An annual table, one per scenario. |
| `operation_hourly.csv` | An hourly dispatch table, one per scenario. |
| `germany_kpis.csv` | The consolidated table Claude Code assembled in this demo: one row per city and scenario. |

Alongside these, FIDgate writes a run summary (JSON) and supporting tables such as prices and annual operation tables. You can open any of them in a spreadsheet, load them with pandas, or diff them between runs.

### Step 6: Ask Claude Code to interpret, with guardrails

For the analysis step we asked Claude Code to rank the 16 cities from the results and answer a few questions, with explicit instructions: use only actual simulation results, clearly flag the synthetic prices and any unverified assumptions, save the ranking table as a CSV, and do not rerun any optimization or modify the existing setup.

It did something worth copying. Rather than presenting a tidy ranking, it flagged that a few neighboring cities differed more than expected and suggested checking the weather inputs before showing the results to anyone. A good reviewer behaves that way, and your prompt should invite it.

---

## Copy-Paste Prompt Library for Energy Engineers

Four prompts you can adapt. Replace everything in `<angle brackets>`. All four assume the `CLAUDE.md` rules above, and every one asks for a plan before execution.

### Prompt 1: Single-site solar + BESS sizing and dispatch sweep

```text
Extend my FIDgate project in config.py into a design sweep for the site at
lat <LAT>, lon <LON>, tz "<Region/City>".

Sweep battery power from 5 MW to 50 MW in steps of one 5 MW unit, and durations of 2 h and 4 h.
Run every combination for two scenarios:
1) PV-only battery charging (max_offtake_mw = 0)
2) PV + grid battery charging (max_offtake_mw = <GRID_LIMIT>)
That is 10 sizes x 2 durations x 2 scenarios = 40 scenarios.

Keep every other assumption identical (solar profile, prices, grid injection limit).
If battery cost depends on size or duration, ask me for the cost basis; do not assume one.
Use the SDK's sweep support. Check what is sweepable before writing code, and tell me if any
variant needs a separate project version (for example, different data files).

First write the script and summarize the plan and assumptions. Run only the offline dry run.
Wait for my approval before calling the API.
Every number in your summary must come from FIDcore outputs.
```

*Why it works:* the sweep space is explicit (40 scenarios), costs are never silently assumed, and the "check what is sweepable" line makes Claude Code verify the SDK's capabilities instead of guessing.

### Prompt 2: Multi-location regional batch loop across coordinates and grid limits

```text
Create run_batch.py that loops over the locations in data/locations.csv
(columns: name, lat, lon, tz, max_injection_mw, max_offtake_mw).

For each row, build the project from config.py with that site's coordinates and grid limits,
run both charging scenarios, and write results under outputs/<name>/.
If the SDK cannot sweep location inside one batch, create one project version per location.

Add: a --dry-run flag that builds every configuration offline and sends nothing,
and an --only <name> option that runs a single location.
When all runs finish, write outputs/summary.csv labelled by location and scenario.

Run order: dry run, then <FIRST_SITE> alone, then, only after I approve, all remaining sites.
Do not modify config.py. Explain your approach before executing anything.
```

*Why it works:* it mirrors the control surface of our 16-city run: dry run, single site, then the full batch.

### Prompt 3: Sensitivity analysis on day-ahead prices or grid limits

```text
Using the validated single-site project, run a sensitivity study. Label every result by variant.

A) Grid limits: vary max_injection_mw across <LIST> and max_offtake_mw across <LIST>.
B) Day-ahead prices: create <N> variants of data/da_price.csv: the base curve, the base curve
   scaled by -20%, -10%, +10% and +20%, and <OTHER_VARIANT> that I will provide.
   Save each variant as its own clearly named file.

Price files cannot be swept inside one batch, so use a separate project version for each price file.
Tell me the total number of scenarios before running anything.
These price variants are sensitivities, not forecasts: say so in the summary table.
Do not rerun the base case. Run only the offline dry run until I approve.
```

*Why it works:* grid limits can be swept as parameters, while file-based price series need one version each. Making that distinction up front avoids a failed batch.

### Prompt 4: The plan-first, dry-run prompt

Use this one before any run, on any project.

```text
Before executing any runs, generate the Python script and summarize the assumptions
so I can review them first.

In your summary, list:
- the inputs I gave you and the inputs you assumed (with numbers and units)
- every file you read and every file you will write
- what will be sent to the FIDgate API
- the number of scenarios you expect, and where the outputs will be written

Run only the offline dry run. Do not call the API until I reply "approved".
Do not compute, estimate or recalculate any result yourself.
```

*Why it works:* it turns every study into a review gate. You approve the plan, the assumptions and the scenario count before a single run is submitted.

---

## Engineering Best Practices

- **Version-control the generated scripts.** Commit `config.py`, `run_batch.py`, your prompts and the README with its assumption list. For any result you share, record which commit produced it.
- **Inspect the structured outputs.** The results are plain CSV and JSON files. Open them, check units and column meanings, and look at outliers before you draw conclusions.
- **Review assumptions before batch execution.** Mark every assumed number with `# ASSUMPTION`, state it in the README, and label results from synthetic or illustrative data as such.
- **Validate one site before sweeping many.** Run a single case end to end, check it against what you expect, then scale up.
- **Make runs reproducible.** Fix the dispatch seed, pin your SDK version, and keep input files in the repository, or record where they came from.
- **Keep credentials out of everything.** Tokens belong in environment variables, never in prompts, scripts or Git history.
- **Keep client project data in Google Cloud EU regions.** FIDgate keeps client data in Google Cloud EU regions, with AES-256 encryption at rest and TLS 1.2+ in transit. Separately, follow your own company's data policy and your NDAs before pasting client data into any AI tool.

---

## Common Mistakes to Avoid

Use this as a pre-flight checklist.

- [ ] **Letting an LLM guess or approximate numbers instead of calling FIDcore.** If a figure did not come from a FIDcore output file, it does not go in the deliverable.
- [ ] **Running a large multi-site sweep before validating a single-site test case.** One wrong unit or price file multiplied by 16 sites is 16 wrong results.
- [ ] **Treating illustrative price assumptions as site-specific investment advice.** Prices are inputs. The demo's synthetic prices say nothing about a real site, and battery results are dispatched against the price series you provide, so read them as results for that series, not as a forecast.
- [ ] **Approving a plan or script you have not read.** The plan-first prompt only helps if you actually review the summary.
- [ ] **Assuming capabilities that are not there.** Today, battery dispatch is day-ahead price-based with grid limits, and wind enters as an input generation profile. Do not ask for intraday or balancing revenue stacking, or for wind sizing, and do not treat the output as if the model covered them.
- [ ] **Skipping the sanity check on outliers.** If neighboring sites differ more than expected, check the inputs (weather, prices, grid limits) before anything else.
- [ ] **Putting credentials in a prompt, a script or a commit.**

---

## Get Started

The pattern in one line: **AI orchestrates. Engineers decide. FIDcore does the math.**

Describe the study in plain English, read the plan, review the script, validate one site, then let the batch run. You keep control of every assumption, and every number traces back to FIDcore.

The FIDgate Python SDK and API are live today, and the **Early Adopter Program is open now**. If you design or evaluate utility-scale solar, storage or hybrid projects and want to try this workflow on your own cases, join the program at **[https://fidgate.com](https://fidgate.com)**.

*FIDgate develops techno-economic optimization software for utility-scale energy projects.*

Desbloquea el Artículo Completo

Ya has leído una vista previa gratuita. Introduce tu nombre y correo profesional para seguir leyendo el post completo.

Usamos tu correo solo para conocer nuestra audiencia. Sin spam, nunca.

¿Quieres hablar de tu próximo proyecto?

Habla con nuestro equipo sobre cómo FIDgate apoya tu camino al FID.

Contactar