sqlr is a small terminal client for SQL. Save a connection once, then run queries, describe tables and pipe results wherever you need them.
$ ● mydb postgresQuery executed in: 42ms · Rows affected: 3
The first argument is either SQL or a path to a .sql file. {{ variables }} in the file are filled from -i "key: value".
sqlr describe --compact prints tables, columns, types and foreign keys in a form that fits in a prompt.
Compact rows by default, --table for humans, -o result.json for files and scripts.
Connections belong to the git repo you are in. -g uses the global scope instead.
Every command takes flags, so pipelines and cron jobs can run it without an interactive wizard.
Add a connection once with sqlr add. From then on the agent runs sqlr and sees table names and rows, never hosts, users or passwords. sqlr skill --init turns that into a /sqlr slash command for Claude Code, Codex and Cursor.
/sqlr find users inactive for 7 dayssqlr "select id, email from users where last_login < now() - interval '7 days'"
sqlr set prod · once per repo
Store it as is. The agent can query straight away.
$ sqlr add -n dev -t postgresql -s "postgres://app@localhost:5432/app" $ sqlr set dev
Protect it with a password when adding. Before you start the agent, put that password in an environment variable. The agent inherits the variable but never sees its value, and it is gone when the terminal closes.
$ sqlr add -n prod # answer yes to "secure connection" $ export SQLR_ENCRYPTION_PASSWORD="my-prod-password" $ sqlr set prod $ claude # or codex, cursor…
curl -fsSL sobanieca.github.io/sqlr/install.sh | bash
A single binary for Linux and macOS, no runtime needed. Then sqlr help explains every command on one screen, and sqlr update keeps it up to date.