Convex performance audit

From get-convex/templates · View interactive version

Convex performance audit is an AI agent skill from the GitHub repository get-convex/templates. Audits Convex performance for reads, subscriptions, write contention, and function limits. Use for slow features, insights findings, OCC conflicts, or read amplification.

How to use this skill

Skill file

Convex Performance Audit

Diagnose and fix performance problems in Convex applications, one problem class

at a time.

When to Use

OCC conflicts

do

When Not to Use

problem

Guardrails

signals are weak

migration-heavy rollouts unless there is a measured signal, a clearly

unbounded path, or a known hot read/write path

structural work just because a pattern is not ideal at large scale

First Step: Gather Signals

Start with the strongest signal available:

  1. If deployment Health insights are already available from the user or the

current context, treat them as a first-class source of performance signals.

  1. If CLI insights are available, run npx convex insights --details. Use

--prod, --preview-name, or --deployment-name when needed.

npx -y convex@latest insights --details before giving up.

  1. If the repo already uses convex-doctor, you may treat its findings as

hints. Do not require it, and do not treat it as the source of truth.

  1. If runtime signals are unavailable, audit from code anyway, but keep the

guardrails above in mind. Lack of insights is not proof of health, but it is

also not proof that a large refactor is warranted.

Signal Routing

After gathering signals, identify the problem class and read the matching

reference file.

| Signal | Reference |

| -------------------------------------------------------------- | ----------------------------------------- |

| High bytes or documents read, JS filtering, unnecessary joins | references/hot-path-rules.md |

| OCC conflict errors, write contention, mutation retries | references/occ-conflicts.md |

| High subscription count, slow UI updates, excessive re-renders | references/subscription-cost.md |

| Function timeouts, transaction size errors, large payloads | references/function-budget.md |

| General "it's slow" with no specific signal | Start with references/hot-path-rules.md |

Multiple problem classes can overlap. Read the most relevant reference first,

then check the others if symptoms remain.

Escalate Larger Fixes

If the likely fix is invasive, cross-cutting, or migration-heavy, stop and

present options before editing.

Examples:

rollout

When correctness depends on handling old and new states during a rollout,

consult the convex-migration-helper skill for the migration workflow.

Workflow

1. Scope the problem

Pick one concrete user flow from the actual project. Look at the codebase,

client pages, and API surface to find the flow that matches the symptom.

Write down:

2. Trace the full read and write set

For each function in the path:

  1. Trace every ctx.db.get() and ctx.db.query()
  2. Trace every ctx.db.patch(), ctx.db.replace(), and ctx.db.insert()
  3. Note foreign-key lookups, JS-side filtering, and full-document reads
  4. Identify all sibling functions touching the same tables
  5. Identify reactive stats, aggregates, or widgets rendered on the same page

In Convex, every extra read increases transaction work, and every write can

invalidate reactive subscribers. Treat read amplification and invalidation

amplification as first-class problems.

3. Apply fixes from the relevant reference

Read the reference file matching your problem class. Each reference includes

specific patterns, code examples, and a recommended fix order.

Do not stop at the single function named by an insight. Trace sibling readers

and writers touching the same tables.

4. Fix sibling functions together

When one function touching a table has a performance bug, audit sibling

functions for the same pattern.

After finding one problem, inspect both sibling readers and sibling writers for

the same table family, including companion digest or summary tables.

Examples:

list queries for that table

inspect the other writers to the same table

inspect sibling reads for the same rollout risk

Do not leave one path fixed and another path on the old pattern unless there is

a clear product reason.

5. Verify before finishing

Confirm all of these:

  1. Results are the same as before, no dropped records
  2. Eliminated reads or writes are no longer in the path where expected
  3. Fallback behavior works when denormalized or indexed fields are missing
  4. Frequently-updated fields are isolated from widely-read documents where

needed

  1. Every relevant sibling reader and writer was inspected, not just the original

function

Reference Files

denormalization, indexes, digest tables

splitting

granularity, point-in-time reads

documents, payload size

Also check the official

Convex Best Practices

page for additional patterns covering argument validation, access control, and

code organization that may surface during the audit.

Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.