/geosql:geosqlfrom GeoSQL
Builds cost-safe geospatial SQL across BigQuery, DuckDB, Snowflake, Wherobots, and Postgres, and renders results on interactive Dekart maps.
Ships in GeoSQL. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Dekart runs BigQuery, DuckDB, Snowflake, Wherobots and Postgres SQL and renders maps. This skill names its tools (list_connections, create_report, update_query, run_query, create_report_snapshot, ...). Two ways to call them; decide once per task:
dekart CLI: dekart call --name <tool> --args '<json>' --json, plus its own commands for run, snapshot, upload and report URL.Read references/dekart-access.md before the first Dekart call: availability check, each tool over MCP and CLI, differences (result files, uploads, timeouts, errors, setup, tokens).
Warehouse CLIs, for SQL-only answers (no map asked) or when Dekart has no connection for the warehouse; they need a shell:
bq for BigQuery.snow for Snowflake.Nothing available: offer the setup options from that reference.
Then check connections with list_connections.
Use the matching reference for per-database SQL, examples, and engine-specific caveats:
references/bigquery.mdreferences/duckdb.mdreferences/snowflake.mdreferences/postgres.mdreferences/wherobots.mdDekart references:
references/dekart-access.mdupdate_report_map_config): references/map-config.mdreferences/widgets.mdreferences/map-styling.mdFollow these steps in order. Do NOT write a final query until steps 1-3 are complete. Combine each step with examples in matching dialect reference.
Discover available data objects before writing any query: start with database/share availability (where applicable), then confirm schemas, tables, and columns. Always verify exact object names and column types from the warehouse metadata; do not assume from general knowledge.
When multiple tables match the entity, sample each candidate for attribute density and prefer the richer source. Richer attributes enable stronger visual encoding in Step 5 and a stronger map validation case.
When the user asks about a named area (city, district, country), query division_area first to discover how it is actually stored (subtype, class, naming conventions). Do not assume from general knowledge.
Use the dialect reference for target-area SQL and fallbacks. Extract the exact bbox constants from the result. Use the full precision values returned by the query, do not round or truncate them.
When the prompt asks where to act (move, close, prioritise, allocate):
ST_INTERSECTS against the real geometry from division_area for geographic correctness. bbox alone is rectangular and overshoots.ST_INTERSECTS.SELECT *.LIMIT for exploration.bbox overlap filter direction. The scan gate must use the OVERLAP pattern, not containment. The feature's bbox must overlap the target area:
-- CORRECT (overlap): feature extends into our area
AND bbox.xmax >= <area_xmin> -- feature's right edge is east of area's left
AND bbox.xmin <= <area_xmax> -- feature's left edge is west of area's right
AND bbox.ymax >= <area_ymin> -- feature's top edge is above area's bottom
AND bbox.ymin <= <area_ymax> -- feature's bottom edge is below area's top
-- WRONG (containment): do NOT use this
AND bbox.xmin >= <area_xmin> -- WRONG
AND bbox.xmax <= <area_xmax> -- WRONG
Use the dialect reference for draft query examples and engine-specific syntax. For map output, select a geometry column aliased exactly as lowercase geometry.
cast 64-bit integer fields to 32-bit int or double. Any numeric column bound to a Kepler visual channel (color, stroke width, size, height) must NOT be a 64-bit integer.
Do NOT present the query to the user without validating it first.
update_query prepare step is also the dry-run gate; read dry_run.valid and dry_run.estimated_bytes_processed from that response before running the query with run_query.
With the bq CLI, run the query with bq query --use_legacy_sql=false --dry_run --format=json '<SQL>' and parse the JSON output for totalBytesProcessed.COUNT(*) (or equivalent) to confirm count is reasonable. If count is zero, debug before presenting.GEOGRAPHY, compute total area (for example SUM(ST_AREA(geometry))) and return units in square meters (and optionally km²).GEOGRAPHY, compute total length (for example SUM(ST_LENGTH(geometry))) and return units in meters (and optionally km).geometry, measurements are CRS units. For EPSG:4326 geometry, do not report meters; transform/cast first or label the result as CRS units.ST_Distance_Sphere expects latitude first, the opposite of ST_Point for the geometry column; a swapped order gives plausible but wrong distances (see references/duckdb.md).Iterate. Fix issues in small steps. Do not run broad or full extraction queries unless explicitly requested. All validation must be done in SQL.
Maps catch what rows cannot: misplaced points, duplicates, coverage gaps.
If Dekart tools are available (MCP tools, or the dekart CLI installed and initialized), use map-in-the-loop flow by default: validate each step using map snapshot, when applicable.
If Dekart tools are not available but bq or snow is, answer first (SQL + results + cost), then propose creating a map as a "Next step" section with 2-3 map benefits for this specific question.
Do not claim visual insights until the styled snapshot is rendered and inspected; never dress row-derived facts as map observations.
Make sure maps are beautifully styled and communicate a clear insight. Always set the map title (update_report_title), dataset names (update_dataset_name) and layer labels, and add a README (add_report_readme) when the user asks for insight.
If Dekart is missing or its token is rejected, ask the user for the setup fix and wait until the user confirms with ready, done, or ok.
Run when this task created a new report and its map layer (query or file-upload flow) and the widget tool is detected (detection in references/widgets.md). If the tool is absent, skip silently: no mention, no upsell.
Add charts by default, without asking, bound to the map-layer dataset only:
number: count of rows.number: distinct of the map color/category field (the raw field, not the top-N group), or sum/avg of the main metric for aggregates.count-plot on the map color field, maxBars 10, sort value-desc (doubles as legend and click filter). For aggregates colored by a numeric metric, use a histogram of that metric instead.histogram or time count-plot on the most relevant other numeric or month field; skip it on aggregates when item 3 already charts the only metric.Any stat you would otherwise report in chat (totals, top categories, rates, ranges) becomes a chart; chat gives a one-line summary and the link.
On existing reports, add charts only on request, append-only. Verify with a snapshot that includes widgets (create_report_snapshot with include_widgets) and fix every error card on a geosql- chart before the final answer.
bq CLIUse bq CLI directly. Always use standard SQL and enforce a budget. Full command examples and guardrails: references/bigquery.md.
snow CLIUse snow sql directly for Snowflake data and keep queries bounded. Full command examples and guardrails: references/snowflake.md.
Use this when Dekart tools are available.
Write map styling with update_report_map_config; its map_config argument is a JSON string. Load references/map-config.md before writing or editing a map config.
Dekart stores map artifacts in this hierarchy:
report: top-level map container.dataset: one data layer slot inside a report, may contain a SQL query or uploaded file.file: uploaded data artifact attached to a dataset.query: SQL attached to a dataset/connection and executed asynchronously.job: execution instance for a query (run_query handles run -> wait -> fetch after the query has already been prepared).Important IDs:
create_report returns the canonical report_id at result.report.id, result.report_id, or result.idcreate_dataset returns the dataset id at result.id.run_query returns job_id and the result (row_count, schema and rows over MCP; dataset_id, query_id, status and result_file over the CLI).report_url fields returned directly by tools may miss host name; resolve the user-facing URL with get_report_url.config.dataId, filter dataId, and tooltip key in map_config, and every widget dataId in widgets_config, must use the report dataset_id, not query_id, file_id, source table name, or dataset label. Dataset ids are at result.datasets[].id in get_report_properties.SQL goes to update_query as the query_text argument, full text, before the query runs:
{
"query_id": "<query_id>",
"query_text": "<full SQL text>"
}
Over the CLI, save the SQL to a file and build this object into an --args-file; inline JSON is fragile because SQL contains quotes and newlines.
Choose exactly one flow based on whether SQL still needs to run:
report -> dataset -> file -> upload_file.run_query.Do not create both a raw-file map layer and a derived query layer unless the user explicitly asks. Query mode may upload a source file before running DuckDB.
dekart tools --schema <tool> --json and dekart run-query|snapshot|upload-file|report-url --help over the CLI).ready, done, or ok. If user declines or is silent, stop; do not export CSV, do not create reports.--max_rows is mandatory because BigQuery CLI defaults to 100 rows when omitted.
2>&1 when output is redirected to .csv.bq query --use_legacy_sql=false --format=csv --max_rows=50000 'SELECT ...'snow sql --format CSV --silent --query "<SQL with LIMIT 50000>"upload_file, which fits small results only (a few thousand rows). For larger results use query mode when Dekart has a connection for the warehouse; otherwise ask the user to upload with the dekart CLI, or say the map is limited to a sample.create_report -> create_dataset (requires report_id, returns the dataset id as result.id) -> create_file (requires dataset_id).upload_file.completed.create_report_snapshot for the target reportreport_url, and image (when available) in final response.For DuckDB, follow references/duckdb.md; its same-report source and query instructions replace the generic report and connection_id examples below.
dekart tools --schema <tool> --json and dekart run-query|snapshot|report-url --help over the CLI).list_connections (no arguments)create_report with {} -> capture report_id from result.report.id, result.report_id, or result.id.create_dataset with {"report_id":"<report_id>"} -> capture dataset_id from result.id, result.dataset_id, or result.dataset.id. Note that datasets are single slot, re-running query owerwrites prevoise data."geometry" for the final map query.create_query with {"dataset_id":"<scratch_dataset_id>","connection_id":"<id>"}update_query and {"query_id":"<scratch_query_id>","query_text":"<full SQL text>"}; for BigQuery, this response is the dry-run cost gate.dry_run.valid is true and cost is acceptable, execute and fetch with run_query and {"query_id":"<scratch_query_id>"}.schema from the response over MCP; result_file then dekart preview over the CLI. Preview 20 rows; inspect columns and types.run_query returns job_id and the result (row_count, schema, rows over MCP; dataset_id, query_id, status and result_file over the CLI).row_count 0 over MCP, empty result (metadata/SHOW statement?) over the CLI), rewrite discovery SQL to return rows.run_query waits for the job itself (over MCP about 45 s, then the "still running" handling). Do not hand-roll a poller or use temporary scripts for run/wait/fetch.check_job_status, the canonical tool payload status path is result.query_job.job_status.create_query with {"dataset_id":"<map_layer_dataset_id>","connection_id":"<id>"}update_query and {"query_id":"<map_layer_query_id>","query_text":"<full SQL text>"}; apply the BigQuery dry-run gate when applicable.run_query and {"query_id":"<map_layer_query_id>"}.update_query or run_query it again. Run any later validation (area, length, counts, previews) on the scratch query from step 4 — re-running the map-layer query overwrites the layer with the new result and blanks the map.create_report_snapshot with {"report_id":"<report_id>"}zoom, lat, lon; derive lat/lon from target area or bbox center, pass lat and lon together, and preserve the same arguments on retryreport_url, and image (when available) in final response:
report_id, dataset_id, query_id, job_id, terminal status (when available), and report_url.dekart init or dekart config on your own.create_report or create_dataset returns 404 it is likely a token or auth issue. Ask the user for the token fix and confirm before retrying.run_query waits for the job; never | tail, | head or background tasks on CLI commands.snapshot timeout), follow the timeout entry and retry the snapshot.layer.config.dataId points to the report dataset idfieldsToShow keys and filter dataId values also use the report dataset idreport_path as a Map URL or user-facing link or manually user facing report URL.get_report_url; do not treat report_url or report_path fields of other tools as canonical.dekart CLI.After upload, review the map snapshot and tune the layer. These rules override Claude's default styling instincts. Full reference: references/map-styling.md.
Non-obvious rules:
0.5-4 px, lines stroke 0.5-1.5 px, polygon borders 0.5-1 px hairline. Do not clamp LIMIT below 50k unless cost forces it.When uncertain about a specific pixel value or palette, read the styling reference.
Use H3 when the user requests spatial aggregation, heatmaps, density, or cell-based rollups.
Confirm the function exists before using it. Use the dialect reference for engine-specific H3 functions.
Cost rules:
WHERE + hardcoded bbox first, then compute H3.h3 + aggregate metrics before adding boundaries.COUNT(*) previews before geometry-heavy ST_H3_BOUNDARY output.7-9 for city scale.bq query unavailable or auth fails: return exact fix commands only, no auto-install.snow sql unavailable or auth fails: ask user to install/configure snow, then retry using snow sql.SHOW DATABASES LIKE 'OVERTURE_MAPS__%' returns no rows): ask user to install Overture data from Snowflake Marketplace, then continue.geometry_columns errors): ask the user to run CREATE EXTENSION postgis;, then continue.update_query dry-run for BigQuery, COUNT(*)/bounded preview for Snowflake, tightly bounded COUNT(*)/preview execution through a Dekart connection for Wherobots).references/bigquery.md (opens in a new tab)references/dekart-access.md (opens in a new tab)references/duckdb.md (opens in a new tab)references/map-config.md (opens in a new tab)references/map-styling.md (opens in a new tab)references/postgres.md (opens in a new tab)references/snowflake.md (opens in a new tab)references/wherobots.md (opens in a new tab)references/widgets.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub dekart-xyz/geosql --plugin geosql2 skills in this plugin
Other plugins' skills for the same job