convex-doctor
Run convex-doctor static analysis, interpret findings, and fix issues across security, performance, correctness, schema, and architecture categories. Use when running convex-doctor, fixing convex-doctor warnings or errors, improving the convex-doctor score, or when asked about Convex code quality, static analysis, or linting Convex functions.
Best use case
convex-doctor is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Run convex-doctor static analysis, interpret findings, and fix issues across security, performance, correctness, schema, and architecture categories. Use when running convex-doctor, fixing convex-doctor warnings or errors, improving the convex-doctor score, or when asked about Convex code quality, static analysis, or linting Convex functions.
Teams using convex-doctor should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/convex-doctor/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How convex-doctor Compares
| Feature / Agent | convex-doctor | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Run convex-doctor static analysis, interpret findings, and fix issues across security, performance, correctness, schema, and architecture categories. Use when running convex-doctor, fixing convex-doctor warnings or errors, improving the convex-doctor score, or when asked about Convex code quality, static analysis, or linting Convex functions.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Convex doctor workflow This skill codifies the full convex-doctor remediation workflow used in this codebase (score 42 to 100 across 17 passes). Follow it whenever running convex-doctor or fixing its findings. ## What is convex-doctor [convex-doctor](https://github.com/nooesc/convex-doctor) is a static analysis tool for Convex backends. It scores your codebase 0 to 100 across five categories: security, correctness, performance, schema, and architecture. Run it with: ```bash npx convex-doctor@latest ``` ## Configuration This project has a `convex-doctor.toml` at the repo root with intentional suppressions. Always check it before working on findings. ### Current suppressions and rationale | Rule | Level | Rationale | |------|-------|-----------| | `correctness/generated-code-modified` | off | Working tree is always dirty after codegen | | `schema/optional-field-no-default-handling` | off | 94 optional fields by design for markdown frontmatter | | `correctness/missing-unique` | off | Remaining `.first()` calls are intentional ordered picks | | `schema/deep-nesting` | off | 4-level validators needed for chat attachments | | `schema/array-relationships` | off | Flagged on function args, not table columns | | `perf/missing-index-on-foreign-key` | off | Remaining FK is inside nested array (not indexable) | | `arch/duplicated-auth` | off | Auth awareness is intentional per public handler | | `arch/monolithic-file` | off | Files organized by domain | | `arch/large-handler` | off | Email templates, sync, and search are inherently multi-step | ### Ignored files - `convex/_generated/**` (generated code) - `convex/authComponent.ts` (thin auth component forwarders) ## Fix priority order When convex-doctor reports findings, fix them in this order: 1. **Security errors** (highest priority) - Add auth to HTTP actions and public endpoints - Convert `api.*` server-to-server calls to `internal.*` - Move public actions to mutation-scheduled internal actions 2. **Correctness errors** - Remove `Date.now()` from queries (breaks caching and reactivity) - Convert `.first()` to `.unique()` only where the index enforces uniqueness - Fix `collect then filter` patterns with indexed queries 3. **Performance warnings** - Replace unbounded `.collect()` with `.take(n)` or pagination - Batch sequential `ctx.run*` calls into single internal queries - Eliminate N+1 patterns in HTTP and RSS endpoints 4. **Schema warnings** - Add missing indexes for foreign keys where query patterns exist - Rename indexes to `by_field` snake_case convention - Remove redundant indexes (prefixes of compound indexes) 5. **Architecture warnings** - Extract helper functions from large handlers - Split provider modules from orchestration logic - Replace `throw new Error(...)` with `ConvexError` in user-facing handlers ## Common fix patterns ### Convert public action to queued job Instead of calling a public action from the browser, create a job table and mutation-scheduled internal action: 1. Add a job table to `convex/schema.ts` with status, result, and error fields 2. Create a public mutation that inserts a pending job and schedules the internal action 3. Create a public query that returns job status for the UI 4. Convert the action to `internalAction` that updates the job record on completion or failure 5. Update the frontend to call the mutation and poll the query This pattern was used for: AI image generation, AI chat responses, URL imports. ### Convert api.* to internal.* When a Convex function calls another Convex function on the server side: 1. Create an `internal*` version if only a public version exists 2. Replace `api.module.fn` with `internal.module.fn` in the caller 3. If the function needs both public and internal access, keep both and have the public version call the internal one ### Batch sequential ctx.run* calls When an action makes multiple `ctx.runQuery` calls for independent data: 1. Create a single internal query that returns all needed data in one object 2. Replace the sequential calls with one `ctx.runQuery` to the batched query 3. This reduces transaction overhead and eliminates the `sequential-run-calls` warning ### Remove Date.now() from queries Queries must be deterministic. Replace `Date.now()` with a timestamp argument: 1. Add a `now: v.number()` argument to the query 2. Pass `Date.now()` from the frontend or from the action/mutation that calls the query 3. For reactive subscriptions, round the timestamp (e.g., 60-second intervals) to keep reactivity stable ### Auth component helper conversion When `components.auth.public.*` triggers `direct-function-ref` warnings: 1. Create helper functions in `convex/authComponent.ts` that call the component API 2. Import helpers directly instead of using `ctx.runQuery(internal.authComponent.*)` 3. Add `convex/authComponent.ts` to the `[ignore]` section of `convex-doctor.toml` ## Verification checklist After every fix pass: - [ ] `npx convex codegen` passes - [ ] `npx tsc --noEmit` passes (or `npx convex codegen` covers this) - [ ] `npm run build` succeeds - [ ] `npx convex-doctor@latest` shows improved score or fewer findings - [ ] Existing functionality still works (AI chat, search, dashboard, RSS, stats) ## Score history | Pass | Score | Errors | Warnings | Key changes | |------|-------|--------|----------|-------------| | Initial | 42/100 | 73 | 243 | Baseline | | 1 (remediation) | ~55 | ~50 | ~221 | Security: auth on HTTP, api to internal | | 2 | ~60 | ~40 | ~200 | AI action flow, HTTP hardening | | 3 | 68/100 | - | - | collect-then-filter, auth signals | | 10 | 80/100 | 1 | 68 | Import URL queued job, unique lookups | | 15 | 91/100 | 0 | 43 | Newsletter batching, auth forwarders, toml config | | 16 | 92/100 | 0 | 39 | Semantic search batching, auth helpers | | 17 | 100/100 | 0 | 0 | Stats helpers, contact helpers, final toml tuning | ## When to suppress vs fix **Fix it** when: - The finding points to a real bug or security gap - The fix is low risk and improves code quality - The pattern can be changed without affecting product behavior **Suppress it** when: - The finding is a tool false positive (e.g., component function refs) - The pattern is intentional by design (e.g., per-handler auth checks) - The fix would add more complexity than the warning is worth - Generated code triggers the finding Always document suppressions with rationale in `convex-doctor.toml`. ## Related PRDs All remediation PRDs are in `prds/convex-doctor/`: - `convex-doctor-remediation.md` (initial plan, 5 phases) - `convex-doctor-second-pass.md` through `convex-doctor-seventeenth-pass.md` ## Related files - `convex-doctor.toml` (suppression config) - `convex/schema.ts` (indexes and table definitions) - `convex/authComponent.ts` (auth component forwarders) - `convex/importJobs.ts` (queued job pattern example) - `convex/aiImageJobs.ts` (queued job pattern example) - `convex/semanticSearchJobs.ts` (queued job pattern example)
Related Skills
convex-self-hosting
Integrate Convex static self hosting into existing apps using the latest upstream instructions from get-convex/self-hosting every time. Use when setting up upload APIs, HTTP routes, deployment scripts, migration from external hosting, or troubleshooting static deploy issues across React, Vite, Next.js, and other frontends.
convex-return-validators
Guide for when to use and when not to use return validators in Convex functions. Use this skill whenever the user is writing Convex queries, mutations, or actions and needs guidance on return value validation. Also trigger when the user asks about Convex type safety, runtime validation, AI-generated Convex code, Convex AI rules, Convex security best practices, or when they're debugging return type issues in Convex functions. Trigger this skill when users mention "validators", "returns", "return type", or "exact types" in the context of Convex development. Also trigger when writing or reviewing Convex AI rules or prompts that instruct LLMs how to write Convex code.
convex-setup-auth
Set up Convex authentication with proper user management, identity mapping, and access control patterns. Use when implementing auth flows, setting up OAuth providers, or adding role-based access control.
convex-quickstart
Initialize a new Convex project from scratch or add Convex to an existing app. Use when starting a new project with Convex, scaffolding a Convex app, or integrating Convex into an existing frontend.
Update project docs
Use this skill after completing any feature, fix, or migration to keep the three core project tracking files in sync.
robel-auth
Integrate and maintain Robelest Convex Auth in apps by always checking upstream before implementation. Use when adding auth setup, updating auth wiring, migrating between upstream patterns, or troubleshooting @robelest/convex-auth behavior across projects.
Create a PRD
Use this skill before any multi-file feature, architectural decision, or complex bug fix.
write
Writing style guide for technical content, social media, blog posts, READMEs, git commits, and developer documentation. Optimized to avoid AI detection patterns. Use when writing any content beyond code.
workflow
Project workflow for PRDs, task tracking, changelog sync, and documentation updates. Use for any non-trivial task that spans multiple steps, touches several files, changes architecture, or needs project tracking updates. Also activates with @update to sync task.md, changelog.md, and files.md after completing work.
sec-check
Security review checklist for Convex functions, auth logic, public queries, admin routes, webhooks, uploads, and AI-generated code. Use when reviewing code that touches user data, PII, or access control.
schema-builder
Design and generate Convex database schemas with proper validation, indexes, and relationships. Use when creating schema.ts or modifying table definitions.
real-time-backend
Build reactive, type-safe, production-grade backends. ALWAYS use this skill when the user asks to build, plan, design, or implement backend features, APIs, data models, server logic, database schemas, web apps, full stack apps, or mobile apps. This includes planning and architecture discussions.