convex-retention

Classify Convex tables and implement bounded TTL cleanup jobs for ClawHub retention policies.

9.4k|1.5k|Updated Jan 3, 2026
One-click install
npx skills add https://github.com/openclaw/clawhub --skill convex-retention
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: convex-retention
Source: https://github.com/openclaw/clawhub/tree/main/.agents/skills/convex-retention
Command: npx skills add https://github.com/openclaw/clawhub --skill convex-retention

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

ClawHub's Convex database accumulates ephemeral data such as auth sessions, refresh tokens, and metric events, and without enforced retention policies these tables grow unbounded. This Skill ensures every table is classified in a central retention policy file and that ephemeral tables get indexed, bounded cleanup paths.

Core Features & Use Cases

  • Policy Enforcement: Requires every new schema table to be registered in RETENTION_POLICIES in convex/lib/retentionPolicy.ts, with the Record<TableNames, RetentionPolicy> type acting as a compile-time gate.
  • Bounded Cleanup Jobs: Guides creation of TTL fields, indexes, and cron-scheduled cleanup entrypoints that prune with .withIndex() and .take(...) using RETENTION_STANDARD_BATCH_SIZE.
  • Auth and Metrics Retention: Covers pruning of expired authSessions and authRefreshTokens via convex/retention.ts, plus documented special cases like skillStatEvents.
  • Use Case: When adding a new Convex table for rate-limit events, use this Skill to classify the table, add an expirationTime field with an index, wire a bounded cron cleanup, and verify with focused Vitest tests and bunx convex codegen.

Quick Start

Ask the agent to add a retention policy and bounded cleanup cron for a new ephemeral Convex table following the ClawHub retention checklist.

Frequently Asked Questions about convex-retention

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a retention policy for a new Convex table in ClawHub?

Register the table in the RETENTION_POLICIES record inside convex/lib/retentionPolicy.ts. The Record<TableNames, RetentionPolicy> type enforces classification at compile time, so the build fails until every table is covered.

How do I set up TTL cleanup for ephemeral Convex tables?

Add an explicit expiration field with an index, then prune using .withIndex() and .take(...) in a bounded cleanup entrypoint scheduled by a cron job. For new generic TTL tables, use the expirationTime field name to match Convex Auth conventions.

Does this handle expired Convex Auth sessions and refresh tokens?

Yes, expired authSessions and authRefreshTokens are pruned by convex/retention.ts. The Skill explicitly warns against bulk-clearing active auth state, limiting cleanup to expired records only.

When should I use a migration instead of a retention cron job?

Cron jobs should only schedule bounded cleanup entrypoints. Large one-off production migrations or destructive backfills should start with the convex-migration-helper instead of a retention cron.

How do I verify Convex retention changes work correctly?

Add focused Vitest tests for policy classification and cleanup behavior, run the focused test slice for touched modules, run bunx convex codegen after schema changes, and validate with a real runtime check like bunx convex dev --once --typecheck=disable.