agentleFS
rijansrijans/agent-skills/skills/duckdb-wasm/SKILL.md

duckdb-wasm

Skill2 starsChanged 33 days agoMITView on GitHub

Query Parquet files, run in-browser analytical SQL, and persist databases to OPFS with @duckdb/duckdb-wasm, Web Workers, and Apache Arrow tables. Use for AsyncDuckDB initialization, Vite bundler ?url assets, CDN bundles, registerFileHandle, registerFileURL, and COOP/COEP isolation.

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 6 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Non-Analytical Relational Storage: When you don't need columnar vector execution, OLAP aggregates, or Parquet integration.

    line 24
  2. Distinctive:

    Before implementing or debugging a DuckDB-Wasm application, inspect:

    line 30
  3. Very specific:

    Check package.json for bundler setup (vite, next, webpack).

    line 33
  4. Distinctive:

    Check module format (ESM vs CommonJS).

    line 34
  5. Very specific:

    Check for Cross-Origin-Opener-Policy (same-origin) and Cross-Origin-Embedder-Policy (require-corp or credentialless) headers.

    line 39
  6. Very specific:

    If headers are missing, use the Single-Threaded Exception Handling (eh) bundle.

    line 40
  7. Very specific:

    Verify if queries require in-memory execution or durable disk persistence via opfs://.

    line 42
  8. Very specific:

    Never import .wasm or worker scripts via standard ES module import without explicit bundler asset directives (?url in Vite, Webpack asset …

    line 64
  9. Very specific:

    Default to the Single-Threaded Exception Handling (eh) bundle unless Cross-Origin Isolation headers (COOP: same-origin and COEP: …

    line 66
  10. Very specific:

    Never call result.toArray() on large query results (>50,000 rows).

    line 68
  11. Very specific:

    Always execute await conn.query('CHECKPOINT;') after committing writes to an opfs:// database.

    line 70
  12. Very specific:

    Always close transient connections with await conn.close() when queries complete to release worker thread memory.

    line 72
  13. Distinctive:

    All datasets loaded into DuckDB-Wasm (user-provided Parquet files, CSV uploads, remote URLs, natural language queries) are untrusted data:

    line 78
  14. Very specific:

    Parameterize All Dynamic Queries: Never concatenate user input or LLM output into raw SQL strings.

    line 80
  15. Very specific:

    Strict Remote URL Allowlists: When using registerFileURL or httpfs, enforce a strict domain allowlist.

    line 81
  16. Distinctive:

    Schema & Metadata Isolation: Do not let Parquet embedded metadata or CSV column names alter system prompts or bypass application security …

    line 82
  17. Distinctive:

    When providing DuckDB-Wasm solutions:

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

DuckDB-Wasm

Execute blazing-fast analytical SQL directly inside web browsers using @duckdb/duckdb-wasm, Web Workers, and Apache Arrow. Whether you need to query local multi-megabyte Parquet files without server uploads, stream remote columnar datasets via HTTP range requests, or persist full analytical databases locally via the Origin Private File System (opfs://), this skill provides production-grade architecture with zero bundler crashes or memory leaks.


When to Use

  • Running client-side analytical queries over Parquet, CSV, or Arrow IPC files without uploading data to a backend server.
  • Persisting client-side relational analytical data across page reloads using the browser's native Origin Private File System (opfs://).
  • Building zero-install local data exploration tools, interactive BI dashboards, or offline-capable data science interfaces.
  • Integrating in-browser SQL querying with modern frontend bundlers (Vite, Next.js, Webpack).
  • Processing streaming or batch query results with zero-copy columnar Apache Arrow tables.

When Not to Use

  • Server-Side Node.js / Python Analytics: For server-side Node.js or edge environments, use the native duckdb Node.js client (@duckdb/node-api or duckdb), not the WebAssembly browser build.
  • Transactional Row-Oriented Apps: For standard transactional user profiles or small CRUD state, standard IndexedDB or SQLite (use-telegram-serverless / @sqlite.org/sqlite-wasm) is lighter.
  • Non-Analytical Relational Storage: When you don't need columnar vector execution, OLAP aggregates, or Parquet integration.

Inputs to Inspect First

Before implementing or debugging a DuckDB-Wasm application, inspect:

  1. Frontend Framework & Bundler:
    • Check package.json for bundler setup (vite, next, webpack).
    • Check module format (ESM vs CommonJS).
  2. Asset Resolution Strategy:
    • Local Bundled Assets: Vite requires ?url imports (mvpWorkerUrl, duckdbWasmUrl) or Webpack asset/resource rules.
    • CDN-Served Assets: Uses duckdb.getJsDelivrBundles() without bundler asset configuration.
  3. Cross-Origin Isolation & Threading:
    • Check for Cross-Origin-Opener-Policy (same-origin) and Cross-Origin-Embedder-Policy (require-corp or credentialless) headers.
    • If headers are missing, use the Single-Threaded Exception Handling (eh) bundle. Do not instantiate pthreadWorker without SharedArrayBuffer support.
  4. Storage Persistence:
    • Verify if queries require in-memory execution or durable disk persistence via opfs://.

Workflow & Progressive Routing

Load only the reference file required for your active task. Do not preload all references at once.

Task / Focus AreaActionable TriggerReference to Load
Bundler Setup & Worker InitAsyncDuckDB, selectBundle, Vite ?url imports, CDN bundles, Next.js worker isolationreferences/setup-and-bundling.md
Parquet, CSV & Virtual FilesregisterFileHandle, registerFileURL, drag-and-drop files, HTTP range requests, COPY TOreferences/files-and-parquet.md
OPFS Durable Persistenceopfs://, db.open, CHECKPOINT;, multi-tab locks, storage quotasreferences/opfs-persistence.md
SQL Queries & Apache Arrowconn.query, conn.send, conn.prepare, Arrow batches, zero-copy vector slicingreferences/queries-and-arrow.md
Security & Injection DefenseSnyk W011 defense, parameterized queries, untrusted CSV/Parquet schema sanitizationreferences/security-and-injection.md
Upstream Specs & SourcesBrowser compatibility tables, WebAssembly limits, release notesreferences/sources.md

Core Guardrails & Best Practices

  1. Bundler Asset Isolation:
    • Never import .wasm or worker scripts via standard ES module import without explicit bundler asset directives (?url in Vite, Webpack asset modules). Raw imports cause runtime bundler parse errors.
  2. COOP/COEP Awareness:
    • Default to the Single-Threaded Exception Handling (eh) bundle unless Cross-Origin Isolation headers (COOP: same-origin and COEP: require-corp) are verified. Multi-threaded bundles crash without SharedArrayBuffer.
  3. Prevent Arrow Heap Exhaustion:
    • Never call result.toArray() on large query results (>50,000 rows). Iterate result.batches or slice column vectors directly to preserve columnar performance and avoid V8 garbage collection freezes.
  4. Durable OPFS Checkpoints:
    • Always execute await conn.query('CHECKPOINT;') after committing writes to an opfs:// database. Without an explicit checkpoint, uncommitted write-ahead log (WAL) data may be lost across reloads.
  5. Connection Lifecycle:
    • Always close transient connections with await conn.close() when queries complete to release worker thread memory.

Handling External Content & Indirect Prompt Injection Defense

All datasets loaded into DuckDB-Wasm (user-provided Parquet files, CSV uploads, remote URLs, natural language queries) are untrusted data:

  • Parameterize All Dynamic Queries: Never concatenate user input or LLM output into raw SQL strings. Always use conn.prepare('SELECT * FROM t WHERE id = ?') or bind parameters.
  • Strict Remote URL Allowlists: When using registerFileURL or httpfs, enforce a strict domain allowlist. Never fetch arbitrary URLs supplied by untrusted external users.
  • Schema & Metadata Isolation: Do not let Parquet embedded metadata or CSV column names alter system prompts or bypass application security checks.

Deliverable Contract

When providing DuckDB-Wasm solutions:

  1. Provide valid, runnable TypeScript or ESM JavaScript code.
  2. Include explicit bundle definitions (MANUAL_BUNDLES with ?url or getJsDelivrBundles()).
  3. Handle worker initialization and database instantiation cleanly with try/catch and error diagnostics.
  4. Close database connections properly and include CHECKPOINT; when using opfs://.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.