npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fadhilp/stateql

v0.13.3

Published

Stateful, agent-oriented database CLI for safe result reuse

Readme

StateQL

StateQL is a stateful database CLI and TypeScript library for AI agents and automation. Query, change, and inspect databases while keeping results reusable and operations traceable across commands.

  • SQL: SQLite, PostgreSQL, and MySQL.
  • Native commands: MongoDB (EJSON) and Redis (JSON).
  • Durable handles: reuse, filter, page, count, alias, or export stored results without rerunning the original query.
  • Tracked writes: inspect operations, review plans, and stage transactions where supported by the database.

Requires Node.js 22.16 or newer for the required node:sqlite APIs.

Quick start

Install the CLI:

npm install -g @fadhilp/stateql

Connect to an existing SQLite database containing a users table. These shell examples use Bash; see the usage guide for connection options and SQL parameter handling.

export STQL_SESSION=audit
stql profile add local ./app.sqlite --read-only
stql connect local

stql query \
  "SELECT id, name, email FROM users WHERE status = ? AND created_at >= ? ORDER BY id LIMIT 50" \
  --param active \
  --param 2026-01-01

Parameters keep values separate from SQL. ORDER BY makes paging stable, and LIMIT bounds work at the database. The default agent output is compact, one-line JSON. An example response:

{"ok":true,"handle":"q_k7m2v5x9c3d6f8h4j2n7p5r9tw","rows":[{"id":7,"name":"Ada","email":"[email protected]"}],"truncated":false,"cached":false,"total":1,"next_offset":null}

Use the handle returned by your query in place of the example handle below. Give the snapshot a readable alias, then work with the stored data:

stql alias set active-users q_k7m2v5x9c3d6f8h4j2n7p5r9tw
stql rows active-users --offset 0 --limit 10
stql count active-users
stql export active-users --output active-users.csv --format csv
stql filter active-users "email LIKE ?" --param "%@example.com"

These commands do not access the original database. filter creates a new snapshot with its own handle. Repeating a query can reuse a valid cached result; use --cache bypass when a fresh database read is required.

Safety and state

  • Connections are read-only by default. Writes require a read-write connection.
  • Destructive and unbounded SQL/MongoDB operations require independent --allow-destructive and --allow-unbounded approvals, respectively.
  • plan stores a write for review; apply never adds authorization. Use idempotency keys to protect retryable writes from duplicate execution.
  • A write reported as OUTCOME_UNKNOWN must be inspected at the database before replaying it. Transactions are staged locally, not live interactive SQL transactions.
  • Supply credential-bearing URLs through environment variables or a trusted library credential resolver, not literal command arguments or profiles.
  • Results and history persist under STQL_HOME (or the platform data directory). Treat that state as database data; retention and size limits are configurable.

See write safety, credentials, and database restrictions before using production data.

Documentation

| Guide | Contents | | --- | --- | | Usage | Connections, CLI reference, results, sessions, limits, writes, transactions, batch and pipes | | Database support | SQL dialects, diagnostics, maintenance, native MongoDB and Redis commands | | TypeScript library | Connection setup, response handling, cleanup, actors, workspaces, and credential resolution |

Run stql --help for command syntax or stql capabilities for capability details.

TypeScript installation

npm install @fadhilp/stateql

The package exports StateQL and public TypeScript types. Start with the connected, cleanup-safe example.