agentleFS
tejastn10tejastn10/workbench/skills/data/review-query/SKILL.md

review-query

Skill1 starsChanged 2 months agoMITView on GitHub

Review a database or cache access path for correctness and cost — N+1, missing index, unbounded result set, transaction scope, and the Redis/cache-key issues from the review corpus (read key ≠ write key, KEYS on a shared instance, negative tombstones, replica lag on read-your-writes). Use when reviewing a PR that adds a query, when something is slow, or when asked to "check this query".

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check EXPLAIN; a seq scan on a big table is the tell.

    line 14

≈ “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

Review a query / cache access

SQL / ORM

  • N+1 — a query inside a loop over rows already fetched. Batch it: one WHERE id IN (…), or the ORM's include / join. refreshUserCache-style helpers in a per-item loop when the rows are in hand → ~2N redundant reads.
  • Missing index — the WHERE / ORDER BY / join column has no index. Check EXPLAIN; a seq scan on a big table is the tell.
  • Unbounded result set — SELECT … with no LIMIT on a table that grows. Paginate.
  • SELECT * pulling columns (and big TEXT/JSON blobs) the caller doesn't use.
  • Transaction scope — @Transaction / a BEGIN held across a paginated loop or an external call pins a connection and holds locks. Keep transactions short; don't wrap read-only paginated work in one.
  • Write-then-read in the same request expecting to see the write — fine on primary, broken if the read goes to a replica.

Redis / cache

  • Read key ≠ write key — the key for the index lookup and the key for the loader must be derived identically. Normalize once, use for both.
  • KEYS on a shared instance — blocks Redis. Use SCAN, or drop the method.
  • Negative tombstones from a bulk loader written with a different filter than the single-item loader → real records 404. Blocking.
  • Read-your-writes on a replica — OTP verify, rate-limit counters, session — replica lag means a stale/missing read. Must hit primary.
  • multi.exec() result ignored — MULTI doesn't roll back; scan the result array for errors.
  • No TTL on a cache entry that should expire, or a TTL so long the data goes stale.

Output

Blocking (tombstone bug, replica on read-your-writes, KEYS on shared) vs non-blocking (N+1 on a cold path, missing index that's not hot yet — quantify). Show the mechanism: the query, the call volume, what happens under load.

Anti-patterns

  • ❌ "Add an index" with no EXPLAIN and no idea if the path is hot.
  • ❌ Flagging N+1 on a path called once a day as a blocker.
  • ❌ Missing that the read and write keys diverge.

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.