agent-security-hardening
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
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.
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.
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:
npx convex-doctor@latest
This project has a convex-doctor.toml at the repo root with intentional suppressions. Always check it before working on findings.
| 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 |
convex/_generated/** (generated code)convex/authComponent.ts (thin auth component forwarders)When convex-doctor reports findings, fix them in this order:
Security errors (highest priority)
api.* server-to-server calls to internal.*Correctness errors
Date.now() from queries (breaks caching and reactivity).first() to .unique() only where the index enforces uniquenesscollect then filter patterns with indexed queriesPerformance warnings
.collect() with .take(n) or paginationctx.run* calls into single internal queriesSchema warnings
by_field snake_case conventionArchitecture warnings
throw new Error(...) with ConvexError in user-facing handlersInstead of calling a public action from the browser, create a job table and mutation-scheduled internal action:
convex/schema.ts with status, result, and error fieldsinternalAction that updates the job record on completion or failureThis pattern was used for: AI image generation, AI chat responses, URL imports.
When a Convex function calls another Convex function on the server side:
internal* version if only a public version existsapi.module.fn with internal.module.fn in the callerWhen an action makes multiple ctx.runQuery calls for independent data:
ctx.runQuery to the batched querysequential-run-calls warningQueries must be deterministic. Replace Date.now() with a timestamp argument:
now: v.number() argument to the queryDate.now() from the frontend or from the action/mutation that calls the queryWhen components.auth.public.* triggers direct-function-ref warnings:
convex/authComponent.ts that call the component APIctx.runQuery(internal.authComponent.*)convex/authComponent.ts to the [ignore] section of convex-doctor.tomlAfter every fix pass:
npx convex codegen passesnpx tsc --noEmit passes (or npx convex codegen covers this)npm run build succeedsnpx convex-doctor@latest shows improved score or fewer findings| 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 |
Fix it when:
Suppress it when:
Always document suppressions with rationale in convex-doctor.toml.
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.mdconvex-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)AFaffaan-m/ECC315k4,381 new stars in the last 7 days
Audit the whole repo: find bugs, security holes and performance bottlenecks. Get a ranked report in plain English.
DIDietrichGebert/ponytail203k4,904 new stars in the last 7 days
GAgarrytan/gstack143k598 new stars in the last 7 days
Harden code against the OWASP Top 10: input handling, authentication, sessions and dependencies.
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
RUruvnet/RuView106k596 new stars in the last 7 days