본문으로 건너뛰기
cccskills
무료GitHub에 공개

convex-cost-optimizer

Use when optimizing Convex database read bandwidth, documents-read cost, query indexes, full-table scans, function-level usage dashboard findings, or code that uses .filter(), unbounded .collect(), N+1 reads, or expensive reactive Convex queries.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(3)

  • SKILL.md5.0 KB
  • agents/openai.yaml386 B
  • assets/icon.svg605 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Convex Cost Optimizer

Reduce Convex database bandwidth and read amplification while preserving query correctness. This skill is narrower than convex-performance-audit: use it when the signal is specifically high database read bandwidth, high documents read, full-table scans, index design, or expensive query syntax.

Required Context

  • Before editing convex/**/*.ts, read convex/_generated/ai/guidelines.md.
  • Read .agents/rules/convex.md and .agents/rules/development-commands.md before changing schema or Convex functions.
  • If the user has dashboard data, treat it as the strongest signal.
  • If no dashboard data is available, use npx convex insights --details when supported, or audit the code directly and state that the ranking is code-derived rather than usage-derived.

Dashboard Triage

Start from the Convex usage dashboard database bandwidth section:

  1. Sort by database read bandwidth or documents read.
  2. Open the function-level breakdown.
  3. Prioritize functions where "Documents Read" is much higher than "Documents Returned".
  4. Map each hot function name to the matching file under convex/.
  5. Inspect client callsites using useQuery, usePaginatedQuery, fetchAuthQuery, or route loaders so you understand call frequency.

A high documents-read/documents-returned ratio usually means a full-table scan, unbounded read, or read-after-filter pattern.

Code Audit Patterns

Search for these first:

rg -n "\\.filter\\(|\\.collect\\(\\)|collect\\(\\)\\.length|for \\(.*await ctx\\.db\\.get|ctx\\.db\\.query" convex

Flag these patterns:

  • ctx.db.query("table").filter(...)
  • ctx.db.query("table").collect() followed by JavaScript .filter(...)
  • collect().length for counts
  • unbounded .collect() on user-facing or reactive paths
  • ctx.db.get(...) inside loops when the loop can grow
  • repeated helper calls that each do their own query
  • list screens returning full documents when the UI only needs summaries
  • reactive useQuery data that only needs a point-in-time server read

Fix Order

Apply the smallest high-impact fix first.

  1. Replace full scans with indexes.
  2. Bound result sets with .take(n) or .paginate(...).
  3. Replace collect().length with maintained counters or aggregate documents.
  4. Batch foreign-key lookups and avoid N+1 query loops.
  5. Return smaller DTOs from hot list functions.
  6. Denormalize or introduce digest/summary tables only when measured cost, row size, or call frequency justifies the migration complexity.

When an index or denormalized field depends on old data being backfilled, use the migration helper workflow instead of assuming old documents have the new shape.

Index Syntax

Schema:

messages: defineTable({
  channelId: v.id("channels"),
  body: v.string(),
}).index("by_channelId", ["channelId"]),

Query:

const messages = await ctx.db
  .query("messages")
  .withIndex("by_channelId", (q) => q.eq("channelId", channelId))
  .take(50);

Use Convex index syntax exactly:

  • In schema, define .index("by_fieldName", ["fieldName"]).
  • For compound indexes, include all fields in the name, for example .index("by_organizationId_and_status", ["organizationId", "status"]).
  • In .withIndex(), compare indexed fields with q.eq("fieldName", value), not q.eq(q.field("fieldName"), value).
  • Put equality fields first in compound indexes. Add range or ordering fields only when the query needs them.
  • One compound index can serve a prefix query. Do not add both by_org and by_org_and_status unless the single-field index is needed for _creationTime ordering.
  • Use .withSearchIndex(...) for text search instead of scanning and filtering.

Correctness Checks

For every rewritten query, verify:

  • The new index returns the same records as the old filter.
  • Optional or newly-added fields do not exclude older documents unexpectedly.
  • Sorting remains correct after switching to the index.
  • Authorization checks still happen before returning data.
  • Pagination cursors and limits still match the UI contract.
  • Sibling functions over the same table are inspected for the same pattern.

Verification

Run the smallest checks that cover the change:

  • npx convex dev --once for schema and generated API changes.
  • cd web-app && npm run typecheck for TypeScript correctness.
  • cd mobile-app && npx tsc --noEmit when mobile imports generated APIs.
  • cd mobile-app && npm run lint when mobile style-sensitive files changed.
  • Re-check dashboard/insights after deploy when the user is validating real cost reduction; local checks prove syntax and behavior, not production bandwidth savings.

Update docs or release notes only when this repo already has a matching changelog/release-note convention for the touched area.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Complete guide for building beautiful apps with Expo Router. Covers fundamentals, styling, components, navigation, animations, patterns, and native tabs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Melvynx/saveit.now322026년 10월 19일 업데이트

convex

무료

Routes general Convex requests to the right project skill. Use when the user asks which Convex skill to use or gives an underspecified Convex app task.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Melvynx/saveit.now322026년 10월 19일 업데이트

Build reusable Convex components with isolated tables and app-facing wrappers. Use for defineComponent, app.use, ComponentApi, or shared backend modules.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Melvynx/saveit.now322026년 10월 19일 업데이트

Plan safe Convex schema and data migrations. Use for widen-migrate-narrow rollouts, backfills, breaking field changes, table splits, or failed schema deploys.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Melvynx/saveit.now322026년 10월 19일 업데이트

Audit Convex performance for hot reads, write contention, subscriptions, function limits, OCC conflicts, latency, read amplification, and expensive reactive queries.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Melvynx/saveit.now322026년 10월 19일 업데이트

Creates or adds Convex to an app. Use for new Convex projects, npm create convex@latest, frontend setup, env vars, or the first npx convex dev run.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Melvynx/saveit.now322026년 10월 19일 업데이트

Melvynx의 스킬 모두 보기

이 스킬의 문제 신고