Works with the AI Agents you already use

    postgis copilot pro

    by Yacine Mohamed

    1

    A specialist PostGIS engineering assistant for safe spatial SQL, CRS decisions, troubleshooting, query-plan analysis, and production guidance.

    Free

    Security scanned
    postgis copilot pro

    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_Intersects is used in the join to leverage spatial indexes before performing the expensive ST_Intersection calculation.
    • 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_Area in 4326 returns results in square degrees. For meters, cast to geography.

    Validation

    • Run a count of parcels versus the result set to ensure the join isn't creating unexpected cartesian products.
    • Check a few parcel_id results visually to confirm the intersection matches the 50% criteria.

    Next steps

    1. Confirm the SRID of the flood_zones table using SELECT ST_SRID(geom) FROM flood_zones LIMIT 1;.
    2. If performance is slow, ensure GiST indexes exist on both p.geom and f.geom.
    3. 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_Transform and ST_SetSRID correctly.
    • 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

    1. Provide a natural language description of your spatial task or a snippet of your existing schema.
    2. The agent identifies the relevant predicates, units, and SRID requirements, asking clarifying questions where the schema is ambiguous.
    3. Review the generated SQL block, which includes explanations of spatial choices and validation checks.
    4. For performance issues, provide an EXPLAIN output 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Read Files
    Network Access
    Listed13 days ago

    What's inside

    Creator

    Yacine Mohamed

    Yacine Mohamed

    Frequently Asked Questions

    This skill helps you generate optimized spatial SQL, debug SRID mismatches, and troubleshoot performance issues. It is specifically designed to handle the nuances of PostGIS geometry vs. geography types that generic models often confuse.

    The skill is designed to work with any AI agent or platform that supports system-prompt customization or skill integration. It focuses on generating standard PostgreSQL/PostGIS syntax compatible with all modern versions of the extension.

    No, the agent operates in a sandbox environment and does not have direct access to your database. It generates and reviews SQL code based on the schema or EXPLAIN plans you provide, ensuring your data remains private and secure.

    The skill provides expert guidance on SRID transformations, helping you choose between `ST_Transform` for coordinate changes and `ST_SetSRID` for metadata fixes. It asks clarifying questions about your data's origin to ensure you use the correct projection for your geographic area.

    Upon purchase, you receive the specialized agent configuration, including its operating contract and spatial reasoning logic. You also get lifetime access to updates as new PostGIS functions and optimization techniques are released.

    Yes, you can provide the output of a PostgreSQL `EXPLAIN` or `EXPLAIN ANALYZE` command. The skill will analyze the plan to identify missing GiST indexes, inefficient spatial predicates, or unnecessary table scans.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.

    Free