kendrick-oppong/geoskills/embedded-spatial-sqlite
Claude Code and agent skill by kendrick-oppong/geoskills
- community
Checking that the SKILL.md file is still in the repository.
Use when adding geospatial capability to an embedded/local SQLite database — SpatiaLite, or plain SQLite (e.g. better-sqlite3 in an Electron app) without a full spatial extension. Covers when embedded spatial storage is appropriate and how to approximate spatial queries without PostGIS.
Install
npx vskill@latest install kendrick-oppong/geoskills/embedded-spatial-sqliteSKILL.md
The same SKILL.md was published earlier as kendrick-oppong/geoskills/embedded-spatial-sqlite.
Embedded Spatial SQLite (SpatiaLite / better-sqlite3)
When to use this skill
- An Electron/desktop app storing local geospatial data (offline-first tools, field data collection apps)
- Deciding whether a local SQLite file needs full SpatiaLite or can get by with plain columns + application-level geometry handling
- "How do I do a bounding-box or nearest-neighbor query without a spatial index in SQLite"
Decision framework
| Situation | Approach | |
|---|---|---|
| Need real geometry types, spatial functions, spatial index, inside SQLite | Load the SpatiaLite extension (mod_spatialite) — gives ST_* functions and an R*Tree index, PostGIS-like semantics in an embedded file | |
| Simple point data, bbox-style filtering only, no complex geometry ops | Plain better-sqlite3 with lat/lon REAL columns + SQLite's built-in R*Tree virtual table module for indexed bbox queries — no native extension binary dependency | |
| Storing complex vector geometry but only ever reading it back for display (no server-side spatial queries) | Store geometry as a GeoJSON/WKB blob column; do spatial filtering client-side or via a lightweight JS geometry library (e.g. Turf.js) after a coarse bbox pre-filter from SQLite | |
| Electron app that needs to sync with a PostGIS backend | Keep the local schema geometry-representation-compatible (WKB or GeoJSON) so sync logic doesn't need translation |
Practical note for Electron + better-sqlite3: better-sqlite3 is a synchronous native binding; loading SpatiaLite as a runtime extension requires the platform-specific mod_spatialite shared library to be present and loadable via db.loadExtension() — this adds packaging/cross-platform build complexity (separate binaries per OS/arch) that plain RTree + JS-side geometry avoids entirely. Default to the RTree + Turf.js approach unless the app genuinely needs SpatiaLite's full spatial SQL surface.
Checklist
- [ ] Do you actually need spatial SQL (joins,
ST_Intersectsin a query), or just indexed nearby-lookup + JS-side rendering? Most Electron map apps only need the latter. - [ ] If using SQLite R*Tree: create the virtual table alongside a regular table holding the full record, keyed by rowid
- [ ] If using SpatiaLite: verify
mod_spatialiteships correctly for every target OS/architecture in the Electron build (this is the main source of "works on my machine" packaging bugs) - [ ] Store geometry in a stable interchange format (GeoJSON or WKB) so it's portable if the app later syncs to PostGIS
- [ ] For large local datasets, benchmark cold-start query time — embedded DBs have no connection pooling/caching layer to hide slow scans
Common pitfalls
- Shipping `mod_spatialite` cross-platform: forgetting Windows/macOS/Linux all need their own compiled extension binary, and Electron's packaging (electron-builder/forge) needs explicit
extraResourcesconfig to include it. - Using R*Tree without a companion data table: the R*Tree virtual table only stores bounding boxes and a rowid — always pair it with a regular table for the actual attributes/geometry.
- Assuming better-sqlite3 handles geometry types natively: it doesn't — geometry is just bytes/text unless SpatiaLite is loaded; plan the encoding (WKB/WKT/GeoJSON) deliberately.
- Blocking the Electron main process with large synchronous spatial queries —
better-sqlite3is synchronous by design; move heavy queries to a worker thread or the renderer's background work to avoid freezing the UI.
Reference snippets
Related skills
offline-and-mobile-gis— broader offline-first architecture this often feeds intospatial-indexing-strategy— R-tree fundamentals shared with server-side databases
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/embedded-spatial-sqlite/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kendrick-oppong/geoskills/embedded-spatial-sqlite)