Создаёт Convex компоненты с изолированными таблицами и чистыми границами между приложением и переиспользуемой логикой. Правильная структура компонентов.
npx -y skills add get-convex/agent-skills --skill convex-create-component --agent claude-codeСоздание переиспользуемых компонентов Convex с чёткими границами и минималистичным публичным API.
convex.config.ts, schema.ts и файлами функций../_generated/server компонента, а не сгенерированных файлов приложения.app.use(...).components.<name> с помощью ctx.runQuery, ctx.runMutation, ctx.runAction.npx convex dev и исправьте проблемы codegen, типов или границ.| Цель | Форма | Справочник |
|---|---|---|
| Компонент только для этого приложения | Local | references/local-components.md |
| Публикация или общий доступ из нескольких приложений | Packaged | references/packaged-components.md |
| Явно нужен local + shared library код | Hybrid | references/hybrid-components.md |
| Не уверен | Local (по умолчанию) | references/local-components.md |
Если нет явного требования npm-пакета — используйте локальный компонент:
convex/components/<componentName>/defineComponent(...) в собственном convex.config.tsconvex/convex.config.ts приложения через app.use(...)// convex/components/notifications/convex.config.ts
import { defineComponent } from "convex/server";
export default defineComponent("notifications");
// convex/components/notifications/schema.ts
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
export default defineSchema({
notifications: defineTable({
userId: v.string(),
message: v.string(),
read: v.boolean(),
}).index("by_user_read", ["userId", "read"]),
});
// convex/components/notifications/lib.ts
import { v } from "convex/values";
import { mutation, query } from "./_generated/server.js";
export const send = mutation({
args: { userId: v.string(), message: v.string() },
returns: v.id("notifications"),
handler: async (ctx, args) => {
return await ctx.db.insert("notifications", {
userId: args.userId,
message: args.message,
read: false,
});
},
});
// convex/convex.config.ts
import { defineApp } from "convex/server";
import notifications from "./components/notifications/convex.config";
const app = defineApp();
app.use(notifications);
export default app;
_generated/server импорты, не импорты приложения.npx convex dev и исправляйте проблемы codegen и типов перед завершением.