Claude Skill MartBrowse skillsWhat is a Skill?
Back to list

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 & CodingIntermediate1,809104AI 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_DWithin over ST_Distance, && bounding-box pre-filtering, generated columns instead of functions on indexed columns
  • Validation: ST_IsValid constraints, 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

  1. "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 ready ST_DWithin query
  2. "Parcel polygons should auto-compute area and centroid" → suggests GENERATED ALWAYS AS (...) STORED columns plus geometry validity constraints
  3. "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)
  1. Download the ZIP with the button below.
  2. In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
  3. Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Download 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.

  1. Open a terminal.
  2. Clone the repository: git clone https://github.com/timescale/pg-aiguide.git
  3. Create the skills folder if needed: mkdir -p ~/.claude/skills
  4. Copy the skill in: cp -r pg-aiguide/skills/design-postgis-tables ~/.claude/skills/
  5. Restart Claude Code and run /skills to confirm it is listed.
  6. Prepare your database: PostgreSQL 15+ is required, then run CREATE EXTENSION IF NOT EXISTS postgis;
  7. Try a prompt such as "Design a PostGIS table for storing store locations with radius search."
View source on GitHubLicense: Apache-2.0