Create and cleanup migration

From openclaw/clawhub · View interactive version

Create and cleanup migration is an AI agent skill from the GitHub repository openclaw/clawhub. Use for end-to-end ClawHub Convex production migrations, backfills, destructive cleanups, and one-off maintenance functions that must be created, validated, shipped, run, verified, then removed after completion.

How to use this skill

Skill file

Create And Cleanup Migration

Drive a ClawHub Convex migration from implementation through production cleanup,

with explicit operator gates before destructive execution and before removing the

temporary migration code.

When To Use

narrowing, table reshaping, or one-off maintenance function is needed.

removed after it is no longer useful.

apply, verify, cleanup PR, deploy cleanup.

Required Companion Guidance

  1. Start with convex-migration-helper.
  2. Read convex/_generated/ai/guidelines.md before editing Convex code.
  3. Default to @convex-dev/migrations for production data changes.
  4. If not using @convex-dev/migrations, write down why the component is

unnecessary and provide equivalent:

  1. Use clawhub-convex for repository-specific file placement and runtime

targeting. Use clawhub-production-release for production deploy phases.

Safety Rules

results and receiving explicit user confirmation in the current thread.

code deploy, existing Convex function run, operator import/export command,

schema narrowing, data cleanup, or cleanup-code removal. Do not invent a new

Convex migration function when the issue or PR specifies an operator command

such as convex import --replace.

and receiving explicit user confirmation in the current thread.

do not rely on generic --prod if this repo's guidance says to verify the

actual deployment.

installability, or public API output, call that out before the apply gate.

handoff.

Phase 1: Design The Migration

  1. Identify the intended data change and whether it is:
  1. Choose the implementation:

case, and document the exception.

  1. Define done criteria:

Phase 2: Implement

  1. Add or update the Convex migration/maintenance code.
  2. Include argument validators for every Convex function.
  3. Include dry-run support.
  4. Include batching and resume/progress state.
  5. Include a confirmation token for destructive writes.
  6. Keep apply logic idempotent where practical.
  7. Add targeted tests for business logic and safety gates.
  8. Add real Convex runtime validation for Convex semantics such as pagination,

validators, internal/public function boundaries, scheduler behavior, and

action/query/mutation interactions.

Phase 3: Local Validation

Run the smallest meaningful set first, then broaden before PR handoff:

convex run, HTTP smoke, or local-auth Playwright, covering the changed

Convex behavior

If local real Convex validation is blocked, record the blocker and make the PR

or deployment plan explicitly compensate with an equivalent runtime proof.

Phase 4: PR, Review, Merge, Deploy

  1. Open a focused PR containing the migration implementation.
  2. Include:
  1. Run the repo's review/CI workflow required by AGENTS.md.
  2. Address actionable review findings.
  3. Merge only after required checks are green or the user explicitly accepts a

documented risk.

  1. Deploy the relevant production target from main.
  2. Wait for deployment success before running the production dry run.

Phase 5: Production Dry Run

  1. Run the production dry run with bounded batch settings.
  2. Resume until either:
  1. Present results to the user before apply:
  1. Stop and wait for explicit user confirmation before applying.

Phase 6: Production Apply

  1. Run only after explicit user confirmation of the dry-run results.
  2. Use the destructive confirmation token.
  3. Resume in bounded batches until complete or until a documented safety cap.
  4. Present apply results:
  1. Run verification:
  1. Stop and wait for explicit user confirmation before cleanup-code removal.

Phase 7: Cleanup PR

  1. Remove temporary migration functions, tests, docs, scripts, and generated API

entries that are no longer needed.

  1. Keep durable specs/docs only if they explain lasting behavior or invariants.
  2. Run targeted validation plus the repo-required gates for the touched surface.
  3. Open a cleanup PR with:
  1. Merge after checks/review.
  2. Deploy the cleanup PR if removing Convex functions or schema/code that affects

production.

Final Handoff

Report:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.