Skip to main content
Back to Prompt Library
implementation

Build the application

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Build a Crop Portfolio Drought Contingency Allocator

Format
Code-aware
Lines
99
Sections
11
Linked challenge
Build a Crop Portfolio Drought Contingency Allocator

Prompt source

Original prompt text with formatting preserved for inspection.

99 lines
11 sections
No variables
1 code block
## Build
Evaluate agricultural parcel soil moisture deficits using simulated ERA5 volumetric water layer indicators. Formulate operational drought contingency plans allocating secondary irrigation rations across crop varieties.

## User
Agricultural Risk Officer

## Workflow
1. Ingest crop portfolio parcel acreage, crop water thresholds, and baseline yield valuations.
2. Retrieve ERA5 soil moisture layer indicators across target growing months via CDS API queries.
3. Calculate parcel-level soil moisture deficit anomalies against 10-year baseline historical quantiles.
4. Generate a prioritized irrigation allocation plan and crop contingency schedule for human sign-off.

## Interface
Streamlit operational dashboard displaying parcel risk rankings, soil moisture anomaly plots, and editable irrigation contingency tables.

## Data
Execute ECMWF CDS API client calls with local mock fallback fixtures storing reanalysis-era5-single-levels volumetric soil water layer parameters.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Copernicus Climate Data Store client](https://raw.githubusercontent.com/ecmwf/cdsapi/master/README.rst)
Uses the cdsapi.Client query format for ERA5 reanalysis parameters, retrieving soil moisture layers across defined temporal ranges.

## Tools
pydantic-ai, cdsapi, pandas.
Enforces strict type safety and schema validation over multi-parcel drought contingency models and allocation schedules.
Local or cloud LLM supporting structured function calling and JSON schema extraction.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Calculates volumetric soil moisture anomaly scores for each parcel relative to baseline historical norms.
- Produces a deterministic irrigation rationing priority table ranking crops by drought susceptibility.
- Outputs contingency recommendations flagged for agronomist approval without automated operational execution.

## Starter Examples
```json
[
  {
    "input": {
      "portfolio_id": "PORT-IA-2024",
      "parcels": [
        {
          "parcel_id": "P-01",
          "crop": "corn",
          "acres": 300,
          "moisture_threshold": 0.22,
          "current_layer1_moisture": 0.16
        },
        {
          "parcel_id": "P-02",
          "crop": "soybean",
          "acres": 250,
          "moisture_threshold": 0.18,
          "current_layer1_moisture": 0.19
        }
      ],
      "available_reserve_m3": 15000
    },
    "expected_output": {
      "portfolio_id": "PORT-IA-2024",
      "deficit_detected": true,
      "allocations": [
        {
          "parcel_id": "P-01",
          "crop": "corn",
          "deficit": -0.06,
          "allocated_reserve_m3": 15000,
          "status": "critical_ration"
        },
        {
          "parcel_id": "P-02",
          "crop": "soybean",
          "deficit": 0.01,
          "allocated_reserve_m3": 0,
          "status": "sufficient"
        }
      ],
      "contingency_summary": "Corn parcel P-01 breached soil moisture threshold by 0.06 m3/m3; reserved water directed to mitigate yield loss."
    }
  },
  {
    "input": {
      "portfolio_id": "PORT-CA-2024",
      "parcels": [
        {
          "parcel_id": "P-03",
          "crop": "almond",
          "acres": 120,
          "moisture_threshold": 0.25,
          "current_layer1_moisture": null
        }
      ],
      "available_reserve_m3": 5000
    },
    "expected_output": {
      "portfolio_id": "PORT-CA-2024",
      "deficit_detected": false,
      "allocations": [],
      "contingency_summary": "Incomplete moisture data for parcel P-03; contingency plan halted pending valid telemetry."
    }
  }
]
```

## Safety
Simulates water allocation suggestions only. No physical control systems or commercial irrigation gates are actuated.
Use mock external writes. Require human review before any real deployment.

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.