| name | sherlock |
| description | Allows read-only access to SQL databases and Redis for querying and analysis using natural language |
| allowed-tools | ["Bash(~/.claude/skills/sherlock/sherlock:*)"] |
Sherlock
Read-only database access for SQL and Redis. Binary: ~/.claude/skills/sherlock/sherlock
Ad Hoc Connections (--url)
Use --url (-u) to connect directly via a database URL without any config file setup. This is ideal when a project has a DATABASE_URL in its .env file.
sherlock -u "postgres://user:pass@localhost:5432/mydb" tables
sherlock -u "mysql://user:pass@localhost:3306/mydb" query "SELECT 1"
sherlock -u "redis://localhost:6379" info
--url and -c are mutually exclusive — use one or the other
- Database type is auto-detected from the URL prefix (
postgres://, mysql://, sqlite://, redis://)
- Schema caching and introspection work normally (cached under a synthetic name derived from the URL)
- Query logging is disabled for ad hoc connections
When to use --url vs -c: Use --url for quick one-off access, especially when the project already has a DATABASE_URL. Use -c for repeated access to the same database with config-managed credentials.
SQL Commands
All SQL commands require -c <connection> or -u <url>. Output is JSON by default, use -f markdown for tables.
sherlock connections
sherlock -c <conn> tables
sherlock -c <conn> describe <table>
sherlock -c <conn> introspect
sherlock -c <conn> introspect --refresh
sherlock -c <conn> query "SELECT ..."
sherlock -c <conn> sample <table> -n 10
sherlock -c <conn> stats <table>
sherlock -c <conn> indexes <table>
sherlock -c <conn> fk <table>
Redis Commands
All Redis commands require -c <connection> pointing to a Redis connection.
sherlock -c <conn> info
sherlock -c <conn> info --section memory
sherlock -c <conn> keys "user:*"
sherlock -c <conn> keys --limit 50
sherlock -c <conn> get <key>
sherlock -c <conn> get <key> --limit 50
sherlock -c <conn> inspect <key>
sherlock -c <conn> slowlog
sherlock -c <conn> slowlog -n 20
sherlock -c <conn> command GET mykey
Constraints
- Read-only: SQL allows SELECT, SHOW, DESCRIBE, EXPLAIN, WITH only. Redis allows read commands only (GET, HGETALL, SCAN, etc.) — mutations (SET, DEL, HSET, etc.) are blocked.
- Connection required: Always specify
-c <connection> or -u <url> (no default)
- Type-aware: SQL commands only work with SQL connections, Redis commands only work with Redis connections
- Quoting: PostgreSQL/SQLite use
"identifier", MySQL uses `identifier`
SQL Workflow
- Run
connections to see available databases
- Use
tables or introspect to understand schema (introspect is cached per-connection)
- Use
fk to understand table relationships before writing JOINs
- Use
sample to see real data examples before writing queries
- Write SQL based on user's question and schema
- Execute with
query, present results clearly
Redis Workflow
- Run
connections to see available connections
- Use
info to understand the Redis instance (version, memory, keyspace)
- Use
keys "pattern:*" to find keys of interest
- Use
get <key> to retrieve values (auto-detects string/hash/list/set/zset)
- Use
inspect <key> for metadata (TTL, memory usage, encoding)
- Use
command for any other read-only operation
Tips
- Always use LIMIT to avoid large result sets
- Use
stats for SQL data profiling (row counts, null counts, distinct values)
- Use
-f markdown for human-readable table output
- For Redis, use
keys with specific patterns rather than * on large databases
- Use
--no-types with keys for faster scanning when type info isn't needed
- Config:
~/.claude/skills/sherlock/config.json