AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Postgis Query Patterns

skill-buildmoonshot-skillpacks-postgis-query-patterns · by buildmoonshot

Use when writing PostGIS or spatial SQL — distance, proximity, intersection, or geometry storage queries. Makes the agent use correct SRIDs, spatial indexes, and the right ST_ functions, so spatial SQL is both correct and fast instead of silently slow or wrong.

No reviews yet
0 installs
23 views
0.0% view→install

Install

$ agentstack add skill-buildmoonshot-skillpacks-postgis-query-patterns

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-buildmoonshot-skillpacks-postgis-query-patterns)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
3mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Postgis Query Patterns? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

PostGIS Query Patterns

PostGIS rewards correct spatial SQL and quietly punishes the rest with wrong answers or full table scans. Follow the patterns.

Storage & SRID

  • Store geometry with a known SRID (typmod like geometry(Point, 4326) or ST_SetSRID). Operations between different SRIDs error or mislead — ST_Transform to align.
  • Choose geography for accurate distances over large/global areas (meters on a sphere); geometry in an appropriate projected CRS for fast planar math.

Make queries use the index

  • Put a GiST index on every geometry column you query.
  • Use index-assisted operators/functions: &&, ST_Intersects, ST_DWithin. These hit the index.
  • Avoid ST_Distance(a, b) < x in a WHERE clause — it can't use the index and forces a full scan. Use ST_DWithin(a, b, x) instead.

Correctness gotchas

  • && is bounding-box only — fast but approximate. Use it as a prefilter, then ST_Intersects for the exact test.
  • Validate geometry before overlays (ST_IsValid / ST_MakeValid) — see validate-geometry.
  • ST_DWithin distance units follow the type: meters for geography, CRS units for geometry (degrees if you left it in 4326 — usually not what you want for a distance).

Why this matters

Spatial SQL fails quietly in two directions: wrong SRID or wrong function gives a confident wrong answer, and a missing index turns a sub-second query into a minutes-long table scan that still "works" in testing and falls over in production. The patterns above keep queries both correct and fast.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.