Works with the AI Agents you already use
postgis copilot pro
A specialist PostGIS engineering assistant for safe spatial SQL, CRS decisions, troubleshooting, query-plan analysis, and production guidance.
Free
postgis copilot pro
Example session with this skill installed
I have a table 'parcels' with geometry(Polygon, 4326) and 'flood_zones'. I need a query to find all parcels that are at least 50% inside a flood zone.
- Read your context and instructions
- Compiled the postgis copilot pro
I will provide a query to calculate the intersection area ratio between your parcels and flood zones. I am assuming 'flood_zones' also uses SRID 4326; if not, a transform will be required.
Spatial Intersection Analysis
-- Use ST_Area on geography for meter-based calculations if high precision is needed,
-- or stick to geometry if the local CRS distortion is acceptable.
SELECT
p.id AS parcel_id,
ST_Area(ST_Intersection(p.geom, f.geom)) / ST_Area(p.geom) AS coverage_ratio
FROM
parcels p
JOIN
flood_zones f ON ST_Intersects(p.geom, f.geom)
WHERE
ST_Area(ST_Intersection(p.geom, f.geom)) > 0.5 * ST_Area(p.geom);
Why it is spatially correct
- Predicate:
ST_Intersectsis used in the join to leverage spatial indexes before performing the expensiveST_Intersectioncalculation. - Logic: The query calculates the area of the overlapping region and divides it by the original parcel area to determine the 50% threshold.
- SRID: Assumes both tables are in WGS84 (4326). Note that
ST_Areain 4326 returns results in square degrees. For meters, cast togeography.
Validation
- Run a count of
parcelsversus the result set to ensure the join isn't creating unexpected cartesian products. - Check a few
parcel_idresults visually to confirm the intersection matches the 50% criteria.
Next steps
- Confirm the SRID of the
flood_zonestable usingSELECT ST_SRID(geom) FROM flood_zones LIMIT 1;. - If performance is slow, ensure GiST indexes exist on both
p.geomandf.geom. - If you require area in square meters, cast the geometries:
ST_Area(p.geom::geography).
Connects securely to your tools. The creator never sees your data.
About this skill
Writing correct spatial SQL is error-prone and debugging coordinate system mismatches can halt production pipelines. This skill provides expert-level PostGIS guidance to ensure your queries are performant, spatially accurate, and safe for execution.
What it does
- SQL Generation produces parameterized, read-only spatial queries with explicit aliases and qualified names.
- Error Diagnosis troubleshoots common failures like mixed SRIDs, invalid topologies, and function signature mismatches.
- CRS Management handles coordinate transformations versus metadata assignments using
ST_TransformandST_SetSRIDcorrectly. - Performance Review analyzes query plans and recommends GiST indexing or spatial predicate optimizations.
- Schema Advice provides geometry typmod recommendations and constraints based on your specific data model.
How it works
- Provide a natural language description of your spatial task or a snippet of your existing schema.
- The agent identifies the relevant predicates, units, and SRID requirements, asking clarifying questions where the schema is ambiguous.
- Review the generated SQL block, which includes explanations of spatial choices and validation checks.
- For performance issues, provide an
EXPLAINoutput for a detailed analysis of index usage and bounding-box tests.
Frameworks & tools
PostgreSQL and PostGIS.
Why this beats prompting it yourself
Generic LLMs often confuse geometry and geography types or hallucinate SRID units. This skill follows a strict operating contract that prioritizes read-only safety, spatial correctness, and explicit assumption-labeling to prevent silent data corruption or slow table scans.
Use cases
- Convert complex spatial business logic into optimized SQL joins and predicates.
- Fix "geometry contains mixed SRIDs" errors without guessing coordinate systems.
- Optimize slow spatial queries by identifying missing GiST indexes or inefficient predicates.
- Design production-ready schemas with proper geometry constraints and typmods.
Known limitations
Does not connect to or execute queries on your live database directly. Performance claims are theoretical until verified by your specific hardware and dataset via EXPLAIN ANALYZE.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 13 days ago
- Free with an Agensi account
Permissions
What's inside
Creator
Yacine Mohamed
Frequently Asked Questions
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.