agentleFS
PolarCoding85PolarCoding85/convex-agent-skillz/.claude/skills/convex-components-skill/SKILL.md

convex-components

Skill16 starsChanged 10 months agoMITView on GitHub

Universal patterns for Convex components including installation, configuration, and usage. Use when working with Rate Limiter, Aggregate, Workpool, Workflow, or any Convex component from the ecosystem.

  • Installs packages

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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. Distinctive:

    All components follow the same installation pattern:

    line 12
  2. Very specific:

    Run npx convex dev to generate code.

    line 32
  3. Distinctive:

    Use triggers for sync: - Keep aggregates in sync automatically

    line 174

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

Convex Components

Components are sandboxed packages with their own database tables, functions, and isolated execution.

Universal Installation Pattern

All components follow the same installation pattern:

npm install @convex-dev/<component-name>
// convex/convex.config.ts
import { defineApp } from 'convex/server';
import componentName from '@convex-dev/<component-name>/convex.config';

const app = defineApp();
app.use(componentName);

// Multiple instances with different names
app.use(componentName, { name: 'instance2' });

export default app;

Run npx convex dev to generate code.

Accessing Components

import { components } from './_generated/api';

// Default instance
const instance = new ComponentClass(components.componentName, {
  /* config */
});

// Named instance
const instance2 = new ComponentClass(components.instance2, {
  /* config */
});

Transaction Semantics

Component mutations participate in the parent transaction:

export const doWork = mutation({
  handler: async (ctx) => {
    await ctx.db.insert('myTable', { data: 'value' });
    await component.doSomething(ctx); // Same transaction

    // If mutation throws, BOTH writes roll back
  }
});

Component exceptions can be caught:

try {
  await rateLimiter.limit(ctx, 'myLimit', { throws: true });
} catch (e) {
  // Only component's writes roll back
  // Parent mutation can continue
}

Available Components

Durable Functions

  • Workflow - Long-running, durable code flows with retries
  • Workpool - Queue actions with parallelism limits
  • Action Retrier - Retry failed actions with backoff

Backend Utilities

  • Rate Limiter - Application-layer rate limiting
  • Aggregate - Efficient COUNT, SUM, MAX operations
  • Sharded Counter - High-throughput counting
  • Presence - Real-time user presence tracking
  • Action Cache - Cache expensive action results
  • Migrations - Stateful online data migrations

Payments

  • Stripe - Payments, subscriptions, and billing

Integrations

  • ProseMirror Sync - Collaborative text editing (Tiptap/BlockNote)
  • Resend - Transactional email with queuing and webhooks

AI Components

  • Agent - AI agents with persistent threads (separate skill)

Quick Reference

ComponentPackagePrimary Use
Rate Limiter@convex-dev/rate-limiterControl action frequency
Aggregate@convex-dev/aggregateFast count/sum queries
Sharded Counter@convex-dev/sharded-counterHigh-throughput counting
Presence@convex-dev/presenceReal-time user tracking
Action Cache@convex-dev/action-cacheCache expensive results
Migrations@convex-dev/migrationsOnline data migrations
Workpool@convex-dev/workpoolQueue work with limits
Workflow@convex-dev/workflowDurable multi-step flows
Action Retrier@convex-dev/action-retrierRetry failed actions
ProseMirror Sync@convex-dev/prosemirror-syncCollaborative text editing
Resend@convex-dev/resendTransactional email
Stripe@convex-dev/stripePayments & subscriptions
Agent@convex-dev/agentAI chat with history

Common Patterns

Component + Triggers

Auto-sync components with table changes using convex-helpers triggers:

import { Triggers } from 'convex-helpers/server/triggers';
import {
  customCtx,
  customMutation
} from 'convex-helpers/server/customFunctions';

const triggers = new Triggers<DataModel>();

// Register component trigger
triggers.register('myTable', aggregate.trigger());

// Wrap mutation to use triggers
const mutation = customMutation(mutationRaw, customCtx(triggers.wrapDB));

Testing Components

import componentTest from '@convex-dev/<component>/test';
import { convexTest } from 'convex-test';

function initTest() {
  const t = convexTest();
  componentTest.register(t);
  return t;
}

test('component test', async () => {
  const t = initTest();
  await t.run(async (ctx) => {
    // Test with component
  });
});

Dashboard Access

View component data in dashboard via component dropdown. Each component has isolated tables.

Best Practices

  1. Name instances descriptively - emailWorkpool, scrapeWorkpool vs generic workpool1
  2. Configure once - Set options when creating instance, not per-call
  3. Use triggers for sync - Keep aggregates in sync automatically
  4. Handle component errors - Catch and handle gracefully when appropriate
  5. Check limits - Respect parallelism limits on free tier (20 concurrent functions)

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.