---
id: gh-convex-seed
name: "convex-seed"
url: https://skills.yangsir.net/skill/gh-convex-seed
author: convex
domain: ai-data-management-analysis
tags: ["convex", "database", "seeding", "data-import", "idempotent"]
install_count: 34800
rating: 4.60 (120 reviews)
github: https://github.com/convex/agent-skills/tree/main/skills/convex-seed
---

# convex-seed

> 将种子数据或批量数据导入 Convex 数据库的 Skill：通过可重复执行的 internalMutation 种子函数或 npx convex import 填充数据表，并严格对齐 schema 校验器。它让开发与测试环境的数据初始化变得幂等、可验证，避免重复插入与脏数据，适合本地开发、预览部署与演示数据准备场景。

**Stats**: 34,800 installs · 4.6/5 (120 reviews)

## Before / After 对比

### 种子数据准备从手工脚本到幂等函数

**Before**:

开发者手写一次性插入脚本，字段常与 schema 校验器不一致，报错后要反复改；重复运行还会插入重复行，只能手动清表重来。

**After**:

该 Skill 用可重复执行的 internalMutation 或 convex import，严格对齐 schema 校验器，先清后插或 upsert，重跑即安全。

| Metric | Before | After | Change |
|---|---|---|---|
| 种子脚本准备耗时 | 90分钟 | 10分钟 | -89% |
| 重复运行导致的脏数据率 | 35% | 2% | -94% |
| schema 校验失败次数 | 8次 | 1次 | -88% |

### 环境数据重置效率

**Before**:

每次要重建演示或测试数据时，开发者得手动连数据库、逐表清理再灌数据，几十条记录也要花上半小时，还容易漏表。

**After**:

该 Skill 提供清空再插入的幂等流程并核对行数，一条命令即可把环境恢复到干净基线，重复执行结果一致。

| Metric | Before | After | Change |
|---|---|---|---|
| 环境重置耗时 | 30分钟 | 3分钟 | -90% |
| 漏表或数据不一致概率 | 25% | 3% | -88% |

## Readme

<!-- GENERATED from convex-agents content/capabilities/seed.json — do not edit by hand. -->

# Seed / import data

Populate tables via an internalMutation seed function (re-runnable) or `npx convex import`, matching the schema.

## Workflow

1. For fixtures: write an internalMutation that inserts sample rows; run it with `npx convex run`.
2. For bulk import: shape the data to the schema and use `npx convex import`.
3. Make seeding idempotent (clear-then-insert or upsert) so re-running is safe.
4. Verify row counts.

## Rules

- Seed via internalMutation or convex import, matching validators.
- Make seeding idempotent.
- Never seed secrets/PII into a shared deployment.


---
*Source: https://skills.yangsir.net/skill/gh-convex-seed*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-convex-seed/markdown*