PostGIS Spatial Table Design
A reference skill that guides Claude to design PostGIS tables with the right geometry types, SRIDs, indexes and query patterns.
Dev & CodingIntermediate★ 1,809⑂ 104AI score 8/10Last updated: Jun 26, 2026
What it does
Gives Claude a decision framework for modeling location data in PostgreSQL + PostGIS.
- GEOMETRY vs GEOGRAPHY: comparison table on units, accuracy, function coverage and performance
- Coordinate systems: when to use 4326 (WGS84), 3857 (Web Mercator) or a local UTM zone
- Index strategy: GiST by default, BRIN for huge append-only geometry tables, SP-GiST for point-only data
- Performance patterns: prefer
ST_DWithinoverST_Distance,&&bounding-box pre-filtering, generated columns instead of functions on indexed columns - Validation:
ST_IsValidconstraints, SRID consistency checks, coordinate range checks - Pitfalls: (longitude, latitude) ordering, never mixing SRIDs, parameterizing SQL to avoid injection
Who it's for
- Backend engineers building delivery, mobility, real-estate or IoT features that store coordinates
- Teams already on PostGIS whose spatial queries skip the index or return confusing distance units
- Data engineers reviewing an existing spatial schema for correctness and speed
Examples
- "Create a POI table for stores; the main query is a 1km radius search" → produces a
GEOGRAPHY(POINT, 4326)column, a GiST index, and a readyST_DWithinquery - "Parcel polygons should auto-compute area and centroid" → suggests
GENERATED ALWAYS AS (...) STOREDcolumns plus geometry validity constraints - "100M rows of vehicle GPS logs and queries are slow" → recommends a (device_id, timestamp) composite index, explains the GiST vs BRIN trade-off, and rebuilds tracks with
ST_MakeLine
· · · Install guide · · ·
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/design-postgis-tables folder from the GitHub repo timescale/pg-aiguide into my ~/.claude/skills/design-postgis-tables/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/timescale/pg-aiguide.git && mkdir -p ~/.claude/skills && cp -r pg-aiguide/skills/design-postgis-tables ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal.
- Clone the repository:
git clone https://github.com/timescale/pg-aiguide.git - Create the skills folder if needed:
mkdir -p ~/.claude/skills - Copy the skill in:
cp -r pg-aiguide/skills/design-postgis-tables ~/.claude/skills/ - Restart Claude Code and run
/skillsto confirm it is listed. - Prepare your database: PostgreSQL 15+ is required, then run
CREATE EXTENSION IF NOT EXISTS postgis; - Try a prompt such as "Design a PostGIS table for storing store locations with radius search."
View source on GitHub ↗License: Apache-2.0