Dragonfly

A safe way to let agents audit your Redis

Find the code behind your Redis problems today, and see what breaks first as traffic grows. A read-only audit your coding agent can run safely.

December 1, 2026

Dragoinfly Agents scanning in-memeory datastores

redis-audit is an open-source (Apache-2.0) skill that lets a coding agent audit how your code uses Redis, Valkey or Dragonfly and, if you approve, read the running instance with read-only commands. It ties each symptom to the file that causes it and says what breaks first as traffic grows. It needs Node 22 or newer, has no other dependencies, and is pre-release (0.1.0).

Here is the report it produced for a six-shard Redis cluster we pushed until it filled up, with one finding next to the code that causes it:

screenshot of the agent's final report with the connection-limit finding and its `redis.js:3-7` entry side by side.

And this is how a run gets there: a code review first, one question, then an optional read of the running instance.

FIGURE: flow diagram. Code review → findings shown → one question "check the running instance?" → allowlisted read → sanitized snapshot → rules → report with next steps. A dotted line from the Prometheus box into the snapshot, labelled "optional: 14 days".

When we pushed a six-shard Redis 7.4 cluster until it filled up, it was serving about 2 million operations per second. Every shard sat at its memory limit and was evicting around 335,000 keys a second, every command thread was at roughly 86% of a core, and none of the 57 million keys had a TTL. The audit reported that memory would break first and pointed at the code that writes every key without a TTL. Its own commands cost about 1.3 milliseconds of server time per shard for the whole run. That is one setup, so measure it on yours.

A dashboard shows you those numbers. It does not tell you that the cache can never stop growing because the code writes every key without a TTL. A code review catches that kind of mistake, but it can't see the instance. Most of the time you only learn how the two connect during an incident, which is the most expensive time to find out. We wanted one tool that reads both and says which file causes which symptom.

If we were starting over, we would copy one design decision: decide early which parts of an audit must not change between runs, and write those parts as code.

Fair questions first

"Isn't this just a prompt in a folder?" Partly, and the smaller part. redis-audit is a coding-agent skill: one folder of markdown instructions plus plain JavaScript scripts (Node 22+, no dependencies, no build step). The markdown tells the agent when to run the scripts and how to explain what they return. The checks and the verdicts live in the scripts. A prompt can ask a model to be careful. It can't enforce a command allowlist, strip a hostname out of a file before the agent reads it, or do the arithmetic the same way twice.

"Is this an ad?" We work at DragonflyDB and the repo lives in our GitHub organization, so it is a fair question. The tool is Apache-2.0, and the rules and the command allowlist are plain code you can read. It is not a migration tool, and it won't tell you to move. The one place it will mention Dragonfly is when its measurements say your Redis command thread is the bottleneck, memory has room, the CPU isn't being burned by your own code, and nothing you run is unsupported there. That rule is a single short file, and "tune your Redis" or saying nothing are the normal outcomes. If you ever find it steering you somewhere the numbers don't support, open an issue and we'll treat it as a bug.

A checklist that outgrew itself

The first version was not software. It was a checklist we kept from reading Redis incident write-ups and from watching the same mistakes appear in different codebases: cache writes with no TTL, a client created inside a request handler, one GET per item in a loop, KEYS on a hot path, a Celery broker sharing an instance with a cache that can evict. We turned it into instructions for a coding agent and kept adjusting them until they found real problems in real code.

The code review half worked quickly. Every finding comes with a file, a line, why it matters and a fix. The instance half did not, and it kept running into the same three walls:

  • A review can't see the instance. It can tell you a client is built per request. It can't tell you whether that is costing you anything. The same mistake in a service that handles ten requests a minute is harmless; at 500,000 operations a second it exhausts every connection. Only the instance knows which one you have.
  • A model's opinion of INFO varies. Paste the same INFO output into a model twice and you can get two different diagnoses. That is fine in a conversation. It is a poor property for an audit, where you want to fix something, run it again, and watch the finding go away because you fixed it and not because the model phrased itself differently.
  • A live database changes the rules. An agent reading production needs guarantees: no key names or values leaving the server, no password in a chat, nothing that can write.
If you build one, start with the instructions alone and get the code review good. Add scripts only for the parts where "usually right" isn't acceptable: anything that touches a live system, and anything whose answer should be identical on every run. Keep the model for the part that needs language.

Putting the checklist into code

Turning the checklist into a tool was mostly a matter of deciding which pieces were allowed to vary. Each wall pushed one piece out of the instructions and into a script, and the mapping was close to one-to-one:

Part of the audit

Where it lives

Which code patterns to look for, and how to report them

Instructions (markdown)

Which commands may touch the instance

An allowlist, checked before anything is sent

What leaves the instance

A snapshot builder, plus a check that deletes the file if it contains a secret

Whether something is a problem

About 30 rules, each a tested function

Explaining it and tying it to a file

The agent

The whole thing is one folder. There is nothing to install beyond Node, no database and no build, and nothing in the folder is specific to one agent: it is markdown plus a script that any agent able to run a shell command can use. The instructions are plain markdown; the scripts are a single entry point with three jobs: login (save a connection), doctor (read the instance and run the rules) and instructions (print what the agent should follow).

Two stages, one report

A run has two stages, with a deliberate pause between them, and a report that joins them. The difference between the stages is who decides:

Stage

What it does

Who decides

1. Code review

Reads the repository, finds usage mistakes, reports file and line

The agent, following written checks

2. Instance read

Reads the running instance read-only, builds a snapshot, runs about 30 rules

Scripts

3. Report

Ties each instance finding to the code behind it and ends with next steps

The agent, explaining the scripts' result

After the code review the agent shows its findings and asks once whether to check the running instance. It touches nothing until you say yes. It works the same way on self-hosted Redis, Valkey and Dragonfly, on Redis Cloud and Upstash, and on a datastore run by another team and scraped by Prometheus. Where a service doesn't expose something, such as CPU on Redis Cloud's free tier or on Upstash, the report says so in that section and doesn't guess.

Stage 1: The code review

The code review never connects to anything. It needs no account, no key and no password. It searches the repository for Redis clients and their configuration, judges each use, and reports it with a file, a line, the pattern, why it matters and a specific fix.

Classifying each use before judging it

The same line of code is a bug in one role and correct in another, so before judging a pattern the review classifies what the Redis is being used for: cache, session, queue or job store, lock, rate limiter or counter, pub/sub, or primary store. Cache writes with no TTL are a bug in a cache and normal in a leaderboard. noeviction is wrong for a cache and required for a queue. A cache and a queue that share one Redis URL is a finding by itself, because the eviction policy can't suit both.

Checks drawn from real incidents

The checks come from published incident write-ups and from our own experience.

The list the review works through: cache writes with no TTL or a very long one, a client created per request, one round trip per item, missing timeouts and pool limits, KEYS and other O(N) commands on hot paths, oversized values, cache stampedes and synchronised expiry, eviction policy against role, cluster and failover mistakes, Lua scripts, a Celery broker that can be evicted, and settings in config files that make a background save dangerous. Where a check can't be sure, because a client version isn't pinned for example, the report says "depends on the version in use" and doesn't call it a confirmed bug.

If you build one, pair every code check with the measurement that shows whether it matters. A finding that says "this client is built per request" is an opinion until the instance says how many connections it is costing.

Each check is paired with the instance rule that would show its cost: a missing TTL with the TTL-coverage rule, a client per request with the connection-churn and connection-limit rules, an O(N) command with the slow-command rule. That pairing is what lets the final report join the two stages.

Stage 2: The instance read

If you say yes, the instance read starts. It takes about a minute, and the agent never sees your password.

The commands it will never send

The live read uses a fixed allowlist: INFO, PING, DBSIZE, a few CONFIG GET settings, LATENCY, SLOWLOG LEN, the cluster and Sentinel discovery calls, and the sizes of Celery's default queue keys (LLEN, ZCARD, HLEN on three fixed names). KEYS, SCAN, SLOWLOG GET, CLIENT LIST, MONITOR, OBJECT, DEBUG, FLUSH and every write are refused before they reach the socket. The list is short enough to read in a minute: allowlist.mjs.

We kept the allowlist narrow on purpose. A safety claim with an asterisk is worth little, so we would rather offer a guarantee that is short and easy to check, even though it costs features. It is also why the tool cannot find hot keys or big keys: that needs SCAN or MEMORY USAGE, and we are not willing to loosen the list for it.

If you build one, refuse by default. An allowlist short enough to read in a minute can be checked. A denylist only covers the commands someone thought of.

A snapshot with nothing to leak

The snapshot it builds has no key names, values, hosts or passwords. Before the file is kept, the tool searches it for your password, host and port, and deletes it if any of them appear. The agent never sees your password either. You run a login command in your own terminal, with a hidden prompt, and the credentials stay there. If your agent's own permission system blocks the read, the tool doesn't try to get around it: it hands you the exact command to run yourself and reads the file afterwards.

Optionally, it also reads 14 days of history from the Prometheus that already scrapes your Redis (redis_exporter, or Redis Cloud Pro's own endpoint), so one minute of a server that may have just restarted is not the whole picture.

What reading costs the server

On the six-shard cluster, with every shard at about 86% of a core, the audit's commands took about 1.3 milliseconds of server time per shard for the whole run: two INFO reads at about 160 microseconds each, two LATENCY HISTOGRAM calls at about 95 microseconds each, one CLUSTER SHARDS at about 725 microseconds, and around twenty calls that took a few microseconds apiece. The load generator held about 2.8 million operations per second throughout. That is server time, not network or client time, and it is one version (Redis 7.4) on one setup, so check it on yours before you rely on it.

Why the verdicts are code, not an LLM's opinion

The thresholds, the arithmetic and the verdicts are in scripts with tests, so the same instance gets the same answer every time. The model never decides whether something is a problem. It takes the result, says it in plain language, and connects each instance finding to the code that causes it.

This matters more than it sounds, because instance data is full of traps that a confident explanation can walk straight into. Redis Cloud's free tier answers INFO with a CPU of 0.00, which a naive reading takes as an idle server. Upstash answers with used_memory:0. A counter that resets in the middle of a sample makes a rate meaningless. Each of those is handled once, in code, with a test beside it.

The rules cover throughput against its ceiling, what breaks first as traffic grows, latency, memory against maxmemory, evictions, hit rate, TTL coverage, connections, CPU, replication, persistence settings and shard skew.

Saying how sure it is

Every finding carries one of four labels: measured now, true of one sample, needs history, or measured over 14 days. A guess is never presented as a fact.

Some of the most useful lines in the report are the ones that stop a wrong conclusion. On the app, mean server time per command was about 1.5 microseconds, which looks excellent. It was also a server with its command thread pinned at 100%. Mean engine time leaves out the time commands spend waiting in the queue, so a saturated server can look fast on that number while every client waits. The report says exactly that next to the number, because the number alone would mislead.

Findings also carry the reason they might be wrong. A hit rate or a TTL count measured minutes after a restart reflects the restart. When an instance is under an hour old, the tool marks those findings as unconfirmed and says to run it again later.

Joining the two

The report ties each instance finding to the code that causes it, in one entry per finding: the rule, the file and line, what the code does, and the fix. Here is the code behind one of them, from the app:

// app/src/redis.js:3-7, called at the top of every route
function getClient() {
  return new Redis(process.env.REDIS_URL || "redis://localhost:6379/1", {
    maxRetriesPerRequest: null,
  });
}

On the instance, that shows up as 20,000 of 20,000 client connections in use, with thousands rejected in the sample. Neither half explains the other alone. Together, the report reads:

CONN-NEAR-MAX -> app/src/redis.js:3-7   a new client on every request, never closed   -> create one shared client at startup
TTL-COVERAGE  -> app/src/server.js:32   r.set(key, JSON.stringify(ev)) with no EX      -> set EX, with jitter
LAT-COMMANDS  -> app/src/server.js:61   r.keys("session:*") in the /admin route        -> SCAN off the request path

The report ends with next steps: the concrete fixes, in order, each tied to the finding it resolves.

How we check it's working

On the six-shard cluster, the report looked like this (trimmed):

cluster: 6 primaries, 0 replicas
memory:
  used_mb_total: 5400.1
  fullest_node: node-2 at 100% of its maxmemory
ops_per_sec: 2001835.8
evictions_per_sec: 2001933.11
cpu_main_pct: "85.9 (hottest: node-3)"
firing[7]{rule,severity,confidence,summary}:
  HEADROOM,high,snapshot_only,"memory breaks first: memory is already at its limit and evicting"
  MEM-NEAR-MAX,warn,confirmed_now,memory is at 100% of maxmemory (6 nodes; node-0 shown)
  MEM-EVICTING,warn,confirmed_now,336023.57 keys/s evicted during the sample (6 nodes; node-0 shown)
  TTL-COVERAGE,warn,snapshot_only,100% of 9604004 keys have no TTL (6 nodes; node-0 shown)
  CPU-MAIN,warn,confirmed_now,main thread at 86% of a core (6 nodes; node-0 shown)

The most useful line is the first one. With the command threads at 86%, the obvious guess is that the cluster needs more CPU. The report says memory breaks first, and the keys never expire. More shards would only have given it more to fill. The same finding appears on every node, so the report groups it into one row with the number of nodes, and --full shows each one.

A tool like this is only worth running if it stays quiet when nothing is wrong. On a healthy instance, one with a memory limit, a TTL on every key, about 65,000 operations per second, 42% CPU and a 100% hit rate, it reported nothing: 0 of 30 checks firing. Our first attempt at that baseline flagged two slow commands, which fit, because we were running a second load test on the same machine at the time. It also showed us two bugs in the audit itself. Run against the cluster, its own Celery queue reads came back as MOVED errors that it then reported as a finding, and the same finding repeated once per node. We fixed both before writing this.

Underneath that, 329 tests run with node --test and no install step. The tool has been run against real servers: local Redis, the six-shard cluster above (about 57 million keys and 5.4 GB), Valkey and Dragonfly in Docker, Redis Cloud's free tier and an Upstash free database.

We don't claim a detection rate. There's no labelled set of every real Redis mistake in a codebase, so any recall number we gave you would be a guess. What we can tell you is what happens on setups where we know the answer: it finds the problems that are there, ties them to the right lines, and stays quiet when nothing is wrong.

Next steps

Along with this post, we're releasing the skill under Apache-2.0: github.com/dragonflydb/redis-audit-skill. In Claude Code, install it as a plugin:

/plugin marketplace add dragonflydb/redis-audit-skill
/plugin install redis-audit@redis-audit

For other agents, use the Skills CLI:

npx skills add https://github.com/dragonflydb/redis-audit-skill --skill redis-audit

Then ask in plain words: "is our Redis OK?", "our Redis is slow", "review how we use the cache".

If you run it, we would like to hear what it got wrong as much as what it got right. And one question we'd like your help with: what would you refuse to let an agent run on a production Redis, even in read-only mode? We'd like to check that list against the allowlist.

If your team is working on the same problem and wants to compare notes, reach us at support@dragonflydb.io.

Dragonfly Wings

Stay up to date on all things Dragonfly

Join our community for unparalleled support and insights

Join

Switch & save up to 80%

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost