[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CCBPD0PS0B6K39P8K0V9VQ":3,"skill-same:01M6CCBPD0PS0B6K39P8K0V9VQ":92},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":15,"repositoryHtmlUrl":50,"repositoryHomepageUrl":51,"ownerHtmlUrl":52,"ownerBlogUrl":17,"ownerDescription":17,"updatedAt":53,"install":54,"resources":67},"01M6CCBPD0PS0B6K39P8K0V9VQ","convex-create-component","Convex 组件设计与构建","Design and build Convex components with clear boundaries, isolated state, and app-facing wrappers. Use when creating a new Convex component, extracting reusable backend logic into one, or packaging Convex functionality for reuse across apps.","设计并构建 Convex 组件，使其具备清晰的边界、隔离的状态以及面向应用的封装（wrapper）。适用于创建新的 Convex 组件、将可复用的后端逻辑提取为组件，或打包 Convex 功能以便跨应用复用。","baisharg\u002FASTN","baisharg","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F204916775?v=4","01M6CC8XHZYVK2DR22FZ1BESCG","BAISH","01M6CC8XP400QZ9DXAWTC8EG3X",2,"AGPL-3.0",null,"https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fconvex-create-component\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BT7QVANT4709358VEJK53E","代码实现","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41],"convex create component","convex","component","create","create component","design","components","state","packaging","use","backend","2026-11-10 10:12:30",false,"---\nname: convex-create-component\ndescription: Design and build Convex components with clear boundaries, isolated state, and app-facing wrappers. Use when creating a new Convex component, extracting reusable backend logic into one, or packaging Convex functionality for reuse across apps.\n---\n\n# Convex Create Component\n\nCreate reusable Convex components with clear boundaries and a small app-facing API.\n\n## When to Use\n\n- Creating a new Convex component in an existing app\n- Extracting reusable backend logic into a component\n- Building a third-party integration that should own its own tables and workflows\n- Packaging Convex functionality for reuse across multiple apps\n\n## When Not to Use\n\n- One-off business logic that belongs in the main app\n- Thin utilities that do not need Convex tables or functions\n- App-level orchestration that should stay in `convex\u002F`\n- Cases where a normal TypeScript library is enough\n\n## Workflow\n\n1. Ask the user what they are building and what the end goal is. If the repo already makes the answer obvious, say so and confirm before proceeding.\n2. Choose the shape using the decision tree below and read the matching reference file.\n3. Decide whether a component is justified. Prefer normal app code or a regular library if the feature does not need isolated tables, backend functions, or reusable persistent state.\n4. Make a short plan for:\n   - what tables the component owns\n   - what public functions it exposes\n   - what data must be passed in from the app (auth, env vars, parent IDs)\n   - what stays in the app as wrappers or HTTP mounts\n5. Create the component structure with `convex.config.ts`, `schema.ts`, and function files.\n6. Implement functions using the component's own `.\u002F_generated\u002Fserver` imports, not the app's generated files.\n7. Wire the component into the app with `app.use(...)`. If the app does not already have `convex\u002Fconvex.config.ts`, create it.\n8. Call the component from the app through `components.\u003Cname>` using `ctx.runQuery`, `ctx.runMutation`, or `ctx.runAction`.\n9. If React clients, HTTP callers, or public APIs need access, create wrapper functions in the app instead of exposing component functions directly.\n10. Run `npx convex dev` and fix codegen, type, or boundary issues before finishing.\n\n## Choose the Shape\n\nAsk the user, then pick one path:\n\n| Goal                                              | Shape            | Reference                           |\n| ------------------------------------------------- | ---------------- | ----------------------------------- |\n| Component for this app only                       | Local            | `references\u002Flocal-components.md`    |\n| Publish or share across apps                      | Packaged         | `references\u002Fpackaged-components.md` |\n| User explicitly needs local + shared library code | Hybrid           | `references\u002Fhybrid-components.md`   |\n| Not sure                                          | Default to local | `references\u002Flocal-components.md`    |\n\nRead exactly one reference file before proceeding.\n\n## Default Approach\n\nUnless the user explicitly wants an npm package, default to a local component:\n\n- Put it under `convex\u002Fcomponents\u002F\u003CcomponentName>\u002F`\n- Define it with `defineComponent(...)` in its own `convex.config.ts`\n- Install it from the app's `convex\u002Fconvex.config.ts` with `app.use(...)`\n- Let `npx convex dev` generate the component's own `_generated\u002F` files\n\n## Component Skeleton\n\nA minimal local component with a table and two functions, plus the app wiring.\n\n```ts\n\u002F\u002F convex\u002Fcomponents\u002Fnotifications\u002Fconvex.config.ts\nimport { defineComponent } from 'convex\u002Fserver'\n\nexport default defineComponent('notifications')\n```\n\n```ts\n\u002F\u002F convex\u002Fcomponents\u002Fnotifications\u002Fschema.ts\nimport { defineSchema, defineTable } from 'convex\u002Fserver'\nimport { v } from 'convex\u002Fvalues'\n\nexport default defineSchema({\n  notifications: defineTable({\n    userId: v.string(),\n    message: v.string(),\n    read: v.boolean(),\n  }).index('by_user', ['userId']),\n})\n```\n\n```ts\n\u002F\u002F convex\u002Fcomponents\u002Fnotifications\u002Flib.ts\nimport { v } from 'convex\u002Fvalues'\nimport { mutation, query } from '.\u002F_generated\u002Fserver.js'\n\nexport const send = mutation({\n  args: { userId: v.string(), message: v.string() },\n  returns: v.id('notifications'),\n  handler: async (ctx, args) => {\n    return await ctx.db.insert('notifications', {\n      userId: args.userId,\n      message: args.message,\n      read: false,\n    })\n  },\n})\n\nexport const listUnread = query({\n  args: { userId: v.string() },\n  returns: v.array(\n    v.object({\n      _id: v.id('notifications'),\n      _creationTime: v.number(),\n      userId: v.string(),\n      message: v.string(),\n      read: v.boolean(),\n    }),\n  ),\n  handler: async (ctx, args) => {\n    return await ctx.db\n      .query('notifications')\n      .withIndex('by_user', (q) => q.eq('userId', args.userId))\n      .filter((q) => q.eq(q.field('read'), false))\n      .collect()\n  },\n})\n```\n\n```ts\n\u002F\u002F convex\u002Fconvex.config.ts\nimport { defineApp } from 'convex\u002Fserver'\nimport notifications from '.\u002Fcomponents\u002Fnotifications\u002Fconvex.config.js'\n\nconst app = defineApp()\napp.use(notifications)\n\nexport default app\n```\n\n```ts\n\u002F\u002F convex\u002Fnotifications.ts  (app-side wrapper)\nimport { v } from 'convex\u002Fvalues'\nimport { mutation, query } from '.\u002F_generated\u002Fserver'\nimport { components } from '.\u002F_generated\u002Fapi'\nimport { getAuthUserId } from '@convex-dev\u002Fauth\u002Fserver'\n\nexport const sendNotification = mutation({\n  args: { message: v.string() },\n  returns: v.null(),\n  handler: async (ctx, args) => {\n    const userId = await getAuthUserId(ctx)\n    if (!userId) throw new Error('Not authenticated')\n\n    await ctx.runMutation(components.notifications.lib.send, {\n      userId,\n      message: args.message,\n    })\n    return null\n  },\n})\n\nexport const myUnread = query({\n  args: {},\n  handler: async (ctx) => {\n    const userId = await getAuthUserId(ctx)\n    if (!userId) throw new Error('Not authenticated')\n\n    return await ctx.runQuery(components.notifications.lib.listUnread, {\n      userId,\n    })\n  },\n})\n```\n\nNote the reference path shape: a function in `convex\u002Fcomponents\u002Fnotifications\u002Flib.ts` is called as `components.notifications.lib.send` from the app.\n\n## Critical Rules\n\n- Keep authentication in the app. `ctx.auth` is not available inside components.\n- Keep environment access in the app. Component functions cannot read `process.env`.\n- Pass parent app IDs across the boundary as strings. `Id` types become plain strings in the app-facing `ComponentApi`.\n- Do not use `v.id(\"parentTable\")` for app-owned tables inside component args or schema.\n- Import `query`, `mutation`, and `action` from the component's own `.\u002F_generated\u002Fserver`.\n- Do not expose component functions directly to clients. Create app wrappers when client access is needed.\n- If the component defines HTTP handlers, mount the routes in the app's `convex\u002Fhttp.ts`.\n- If the component needs pagination, use `paginator` from `convex-helpers` instead of built-in `.paginate()`.\n- Add `args` and `returns` validators to all public component functions.\n\n## Patterns\n\n### Authentication and environment access\n\n```ts\n\u002F\u002F Bad: component code cannot rely on app auth or env\nconst identity = await ctx.auth.getUserIdentity()\nconst apiKey = process.env.OPENAI_API_KEY\n```\n\n```ts\n\u002F\u002F Good: the app resolves auth and env, then passes explicit values\nconst userId = await getAuthUserId(ctx)\nif (!userId) throw new Error('Not authenticated')\n\nawait ctx.runAction(components.translator.translate, {\n  userId,\n  apiKey: process.env.OPENAI_API_KEY,\n  text: args.text,\n})\n```\n\n### Client-facing API\n\n```ts\n\u002F\u002F Bad: assuming a component function is directly callable by clients\nexport const send = components.notifications.send\n```\n\n```ts\n\u002F\u002F Good: re-export through an app mutation or query\nexport const sendNotification = mutation({\n  args: { message: v.string() },\n  returns: v.null(),\n  handler: async (ctx, args) => {\n    const userId = await getAuthUserId(ctx)\n    if (!userId) throw new Error('Not authenticated')\n\n    await ctx.runMutation(components.notifications.lib.send, {\n      userId,\n      message: args.message,\n    })\n    return null\n  },\n})\n```\n\n### IDs across the boundary\n\n```ts\n\u002F\u002F Bad: parent app table IDs are not valid component validators\nargs: {\n  userId: v.id('users')\n}\n```\n\n```ts\n\u002F\u002F Good: treat parent-owned IDs as strings at the boundary\nargs: {\n  userId: v.string()\n}\n```\n\n### Function Handles for callbacks\n\nWhen the app needs to pass a callback function to the component, use function handles. This is common for components that run app-defined logic on a schedule or in a workflow.\n\n```ts\n\u002F\u002F App side: create a handle and pass it to the component\nimport { createFunctionHandle } from 'convex\u002Fserver'\n\nexport const startJob = mutation({\n  handler: async (ctx) => {\n    const handle = await createFunctionHandle(internal.myModule.processItem)\n    await ctx.runMutation(components.workpool.enqueue, {\n      callback: handle,\n    })\n  },\n})\n```\n\n```ts\n\u002F\u002F Component side: accept and invoke the handle\nimport { v } from 'convex\u002Fvalues'\nimport type { FunctionHandle } from 'convex\u002Fserver'\nimport { mutation } from '.\u002F_generated\u002Fserver.js'\n\nexport const enqueue = mutation({\n  args: { callback: v.string() },\n  handler: async (ctx, args) => {\n    const handle = args.callback as FunctionHandle\u003C'mutation'>\n    await ctx.scheduler.runAfter(0, handle, {})\n  },\n})\n```\n\n### Deriving validators from schema\n\nInstead of manually repeating field types in return validators, extend the schema validator:\n\n```ts\nimport { v } from 'convex\u002Fvalues'\nimport schema from '.\u002Fschema.js'\n\nconst notificationDoc = schema.tables.notifications.validator.extend({\n  _id: v.id('notifications'),\n  _creationTime: v.number(),\n})\n\nexport const getLatest = query({\n  args: {},\n  returns: v.nullable(notificationDoc),\n  handler: async (ctx) => {\n    return await ctx.db.query('notifications').order('desc').first()\n  },\n})\n```\n\n### Static configuration with a globals table\n\nA common pattern for component configuration is a single-document \"globals\" table:\n\n```ts\n\u002F\u002F schema.ts\nexport default defineSchema({\n  globals: defineTable({\n    maxRetries: v.number(),\n    webhookUrl: v.optional(v.string()),\n  }),\n  \u002F\u002F ... other tables\n})\n```\n\n```ts\n\u002F\u002F lib.ts\nexport const configure = mutation({\n  args: { maxRetries: v.number(), webhookUrl: v.optional(v.string()) },\n  returns: v.null(),\n  handler: async (ctx, args) => {\n    const existing = await ctx.db.query('globals').first()\n    if (existing) {\n      await ctx.db.patch(existing._id, args)\n    } else {\n      await ctx.db.insert('globals', args)\n    }\n    return null\n  },\n})\n```\n\n### Class-based client wrappers\n\nFor components with many functions or configuration options, a class-based client provides a cleaner API. This pattern is common in published components.\n\n```ts\n\u002F\u002F src\u002Fclient\u002Findex.ts\nimport type { GenericMutationCtx, GenericDataModel } from 'convex\u002Fserver'\nimport type { ComponentApi } from '..\u002Fcomponent\u002F_generated\u002Fcomponent.js'\n\ntype MutationCtx = Pick\u003CGenericMutationCtx\u003CGenericDataModel>, 'runMutation'>\n\nexport class Notifications {\n  constructor(\n    private component: ComponentApi,\n    private options?: { defaultChannel?: string },\n  ) {}\n\n  async send(ctx: MutationCtx, args: { userId: string; message: string }) {\n    return await ctx.runMutation(this.component.lib.send, {\n      ...args,\n      channel: this.options?.defaultChannel ?? 'default',\n    })\n  }\n}\n```\n\n```ts\n\u002F\u002F App usage\nimport { Notifications } from '@convex-dev\u002Fnotifications'\nimport { components } from '.\u002F_generated\u002Fapi'\n\nconst notifications = new Notifications(components.notifications, {\n  defaultChannel: 'alerts',\n})\n\nexport const send = mutation({\n  args: { message: v.string() },\n  handler: async (ctx, args) => {\n    const userId = await getAuthUserId(ctx)\n    await notifications.send(ctx, { userId, message: args.message })\n  },\n})\n```\n\n## Validation\n\nTry validation in this order:\n\n1. `npx convex codegen --component-dir convex\u002Fcomponents\u002F\u003Cname>`\n2. `npx convex codegen`\n3. `npx convex dev`\n\nImportant:\n\n- Fresh repos may fail these commands until `CONVEX_DEPLOYMENT` is configured.\n- Until codegen runs, component-local `.\u002F_generated\u002F*` imports and app-side `components.\u003Cname>...` references will not typecheck.\n- If validation blocks on Convex login or deployment setup, stop and ask the user for that exact step instead of guessing.\n\n## Reference Files\n\nRead exactly one of these after the user confirms the goal:\n\n- `references\u002Flocal-components.md`\n- `references\u002Fpackaged-components.md`\n- `references\u002Fhybrid-components.md`\n\nOfficial docs: [Authoring Components](https:\u002F\u002Fdocs.convex.dev\u002Fcomponents\u002Fauthoring)\n\n## Checklist\n\n- [ ] Asked the user what they want to build and confirmed the shape\n- [ ] Read the matching reference file\n- [ ] Confirmed a component is the right abstraction\n- [ ] Planned tables, public API, boundaries, and app wrappers\n- [ ] Component lives under `convex\u002Fcomponents\u002F\u003Cname>\u002F` (or package layout if publishing)\n- [ ] Component imports from its own `.\u002F_generated\u002Fserver`\n- [ ] Auth, env access, and HTTP routes stay in the app\n- [ ] Parent app IDs cross the boundary as `v.string()`\n- [ ] Public functions have `args` and `returns` validators\n- [ ] Ran `npx convex dev` and fixed codegen or type issues\n","# Convex Create Component\n\nCreate reusable Convex components with clear boundaries and a small app-facing API.\n\n## When to Use\n\n- Creating a new Convex component in an existing app\n- Extracting reusable backend logic into a component\n- Building a third-party integration that should own its own tables and workflows\n- Packaging Convex functionality for reuse across multiple apps\n\n## When Not to Use\n\n- One-off business logic that belongs in the main app\n- Thin utilities that do not need Convex tables or functions\n- App-level orchestration that should stay in `convex\u002F`\n- Cases where a normal TypeScript library is enough\n\n## Workflow\n\n1. Ask the user what they are building and what the end goal is. If the repo already makes the answer obvious, say so and confirm before proceeding.\n2. Choose the shape using the decision tree below and read the matching reference file.\n3. Decide whether a component is justified. Prefer normal app code or a regular library if the feature does not need isolated tables, backend functions, or reusable persistent state.\n4. Make a short plan for:\n   - what tables the component owns\n   - what public functions it exposes\n   - what data must be passed in from the app (auth, env vars, parent IDs)\n   - what stays in the app as wrappers or HTTP mounts\n5. Create the component structure with `convex.config.ts`, `schema.ts`, and function files.\n6. Implement functions using the component's own `.\u002F_generated\u002Fserver` imports, not the app's generated files.\n7. Wire the component into the app with `app.use(...)`. If the app does not already have `convex\u002Fconvex.config.ts`, create it.\n8. Call the component from the app through `components.\u003Cname>` using `ctx.runQuery`, `ctx.runMutation`, or `ctx.runAction`.\n9. If React clients, HTTP callers, or public APIs need access, create wrapper functions in the app instead of exposing component functions directly.\n10. Run `npx convex dev` and fix codegen, type, or boundary issues before finishing.\n\n## Choose the Shape\n\nAsk the user, then pick one path:\n\n| Goal                                              | Shape            | Reference                           |\n| ------------------------------------------------- | ---------------- | ----------------------------------- |\n| Component for this app only                       | Local            | `references\u002Flocal-components.md`    |\n| Publish or share across apps                      | Packaged         | `references\u002Fpackaged-components.md` |\n| User explicitly needs local + shared library code | Hybrid           | `references\u002Fhybrid-components.md`   |\n| Not sure                                          | Default to local | `references\u002Flocal-components.md`    |\n\nRead exactly one reference file before proceeding.\n\n## Default Approach\n\nUnless the user explicitly wants an npm package, default to a local component:\n\n- Put it under `convex\u002Fcomponents\u002F\u003CcomponentName>\u002F`\n- Define it with `defineComponent(...)` in its own `convex.config.ts`\n- Install it from the app's `convex\u002Fconvex.config.ts` with `app.use(...)`\n- Let `npx convex dev` generate the component's own `_generated\u002F` files\n\n## Component Skeleton\n\nA minimal local component with a table and two functions, plus the app wiring.\n\n```ts\n\u002F\u002F convex\u002Fcomponents\u002Fnotifications\u002Fconvex.config.ts\nimport { defineComponent } from 'convex\u002Fserver'\n\nexport default defineComponent('notifications')\n```\n\n```ts\n\u002F\u002F convex\u002Fcomponents\u002Fnotifications\u002Fschema.ts\nimport { defineSchema, defineTable } from 'convex\u002Fserver'\nimport { v } from 'convex\u002Fvalues'\n\nexport default defineSchema({\n  notifications: defineTable({\n    userId: v.string(),\n    message: v.string(),\n    read: v.boolean(),\n  }).index('by_user', ['userId']),\n})\n```\n\n```ts\n\u002F\u002F convex\u002Fcomponents\u002Fnotifications\u002Flib.ts\nimport { v } from 'convex\u002Fvalues'\nimport { mutation, query } from '.\u002F_generated\u002Fserver.js'\n\nexport const send = mutation({\n  args: { userId: v.string(), message: v.string() },\n  returns: v.id('notifications'),\n  handler: async (ctx, args) => {\n    return await ctx.db.insert('notifications', {\n      userId: args.userId,\n      message: args.message,\n      read: false,\n    })\n  },\n})\n\nexport const listUnread = query({\n  args: { userId: v.string() },\n  returns: v.array(\n    v.object({\n      _id: v.id('notifications'),\n      _creationTime: v.number(),\n      userId: v.string(),\n      message: v.string(),\n      read: v.boolean(),\n    }),\n  ),\n  handler: async (ctx, args) => {\n    return await ctx.db\n      .query('notifications')\n      .withIndex('by_user', (q) => q.eq('userId', args.userId))\n      .filter((q) => q.eq(q.field('read'), false))\n      .collect()\n  },\n})\n```\n\n```ts\n\u002F\u002F convex\u002Fconvex.config.ts\nimport { defineApp } from 'convex\u002Fserver'\nimport notifications from '.\u002Fcomponents\u002Fnotifications\u002Fconvex.config.js'\n\nconst app = defineApp()\napp.use(notifications)\n\nexport default app\n```\n\n```ts\n\u002F\u002F convex\u002Fnotifications.ts  (app-side wrapper)\nimport { v } from 'convex\u002Fvalues'\nimport { mutation, query } from '.\u002F_generated\u002Fserver'\nimport { components } from '.\u002F_generated\u002Fapi'\nimport { getAuthUserId } from '@convex-dev\u002Fauth\u002Fserver'\n\nexport const sendNotification = mutation({\n  args: { message: v.string() },\n  returns: v.null(),\n  handler: async (ctx, args) => {\n    const userId = await getAuthUserId(ctx)\n    if (!userId) throw new Error('Not authenticated')\n\n    await ctx.runMutation(components.notifications.lib.send, {\n      userId,\n      message: args.message,\n    })\n    return null\n  },\n})\n\nexport const myUnread = query({\n  args: {},\n  handler: async (ctx) => {\n    const userId = await getAuthUserId(ctx)\n    if (!userId) throw new Error('Not authenticated')\n\n    return await ctx.runQuery(components.notifications.lib.listUnread, {\n      userId,\n    })\n  },\n})\n```\n\nNote the reference path shape: a function in `convex\u002Fcomponents\u002Fnotifications\u002Flib.ts` is called as `components.notifications.lib.send` from the app.\n\n## Critical Rules\n\n- Keep authentication in the app. `ctx.auth` is not available inside components.\n- Keep environment access in the app. Component functions cannot read `process.env`.\n- Pass parent app IDs across the boundary as strings. `Id` types become plain strings in the app-facing `ComponentApi`.\n- Do not use `v.id(\"parentTable\")` for app-owned tables inside component args or schema.\n- Import `query`, `mutation`, and `action` from the component's own `.\u002F_generated\u002Fserver`.\n- Do not expose component functions directly to clients. Create app wrappers when client access is needed.\n- If the component defines HTTP handlers, mount the routes in the app's `convex\u002Fhttp.ts`.\n- If the component needs pagination, use `paginator` from `convex-helpers` instead of built-in `.paginate()`.\n- Add `args` and `returns` validators to all public component functions.\n\n## Patterns\n\n### Authentication and environment access\n\n```ts\n\u002F\u002F Bad: component code cannot rely on app auth or env\nconst identity = await ctx.auth.getUserIdentity()\nconst apiKey = process.env.OPENAI_API_KEY\n```\n\n```ts\n\u002F\u002F Good: the app resolves auth and env, then passes explicit values\nconst userId = await getAuthUserId(ctx)\nif (!userId) throw new Error('Not authenticated')\n\nawait ctx.runAction(components.translator.translate, {\n  userId,\n  apiKey: process.env.OPENAI_API_KEY,\n  text: args.text,\n})\n```\n\n### Client-facing API\n\n```ts\n\u002F\u002F Bad: assuming a component function is directly callable by clients\nexport const send = components.notifications.send\n```\n\n```ts\n\u002F\u002F Good: re-export through an app mutation or query\nexport const sendNotification = mutation({\n  args: { message: v.string() },\n  returns: v.null(),\n  handler: async (ctx, args) => {\n    const userId = await getAuthUserId(ctx)\n    if (!userId) throw new Error('Not authenticated')\n\n    await ctx.runMutation(components.notifications.lib.send, {\n      userId,\n      message: args.message,\n    })\n    return null\n  },\n})\n```\n\n### IDs across the boundary\n\n```ts\n\u002F\u002F Bad: parent app table IDs are not valid component validators\nargs: {\n  userId: v.id('users')\n}\n```\n\n```ts\n\u002F\u002F Good: treat parent-owned IDs as strings at the boundary\nargs: {\n  userId: v.string()\n}\n```\n\n### Function Handles for callbacks\n\nWhen the app needs to pass a callback function to the component, use function handles. This is common for components that run app-defined logic on a schedule or in a workflow.\n\n```ts\n\u002F\u002F App side: create a handle and pass it to the component\nimport { createFunctionHandle } from 'convex\u002Fserver'\n\nexport const startJob = mutation({\n  handler: async (ctx) => {\n    const handle = await createFunctionHandle(internal.myModule.processItem)\n    await ctx.runMutation(components.workpool.enqueue, {\n      callback: handle,\n    })\n  },\n})\n```\n\n```ts\n\u002F\u002F Component side: accept and invoke the handle\nimport { v } from 'convex\u002Fvalues'\nimport type { FunctionHandle } from 'convex\u002Fserver'\nimport { mutation } from '.\u002F_generated\u002Fserver.js'\n\nexport const enqueue = mutation({\n  args: { callback: v.string() },\n  handler: async (ctx, args) => {\n    const handle = args.callback as FunctionHandle\u003C'mutation'>\n    await ctx.scheduler.runAfter(0, handle, {})\n  },\n})\n```\n\n### Deriving validators from schema\n\nInstead of manually repeating field types in return validators, extend the schema validator:\n\n```ts\nimport { v } from 'convex\u002Fvalues'\nimport schema from '.\u002Fschema.js'\n\nconst notificationDoc = schema.tables.notifications.validator.extend({\n  _id: v.id('notifications'),\n  _creationTime: v.number(),\n})\n\nexport const getLatest = query({\n  args: {},\n  returns: v.nullable(notificationDoc),\n  handler: async (ctx) => {\n    return await ctx.db.query('notifications').order('desc').first()\n  },\n})\n```\n\n### Static configuration with a globals table\n\nA common pattern for component configuration is a single-document \"globals\" table:\n\n```ts\n\u002F\u002F schema.ts\nexport default defineSchema({\n  globals: defineTable({\n    maxRetries: v.number(),\n    webhookUrl: v.optional(v.string()),\n  }),\n  \u002F\u002F ... other tables\n})\n```\n\n```ts\n\u002F\u002F lib.ts\nexport const configure = mutation({\n  args: { maxRetries: v.number(), webhookUrl: v.optional(v.string()) },\n  returns: v.null(),\n  handler: async (ctx, args) => {\n    const existing = await ctx.db.query('globals').first()\n    if (existing) {\n      await ctx.db.patch(existing._id, args)\n    } else {\n      await ctx.db.insert('globals', args)\n    }\n    return null\n  },\n})\n```\n\n### Class-based client wrappers\n\nFor components with many functions or configuration options, a class-based client provides a cleaner API. This pattern is common in published components.\n\n```ts\n\u002F\u002F src\u002Fclient\u002Findex.ts\nimport type { GenericMutationCtx, GenericDataModel } from 'convex\u002Fserver'\nimport type { ComponentApi } from '..\u002Fcomponent\u002F_generated\u002Fcomponent.js'\n\ntype MutationCtx = Pick\u003CGenericMutationCtx\u003CGenericDataModel>, 'runMutation'>\n\nexport class Notifications {\n  constructor(\n    private component: ComponentApi,\n    private options?: { defaultChannel?: string },\n  ) {}\n\n  async send(ctx: MutationCtx, args: { userId: string; message: string }) {\n    return await ctx.runMutation(this.component.lib.send, {\n      ...args,\n      channel: this.options?.defaultChannel ?? 'default',\n    })\n  }\n}\n```\n\n```ts\n\u002F\u002F App usage\nimport { Notifications } from '@convex-dev\u002Fnotifications'\nimport { components } from '.\u002F_generated\u002Fapi'\n\nconst notifications = new Notifications(components.notifications, {\n  defaultChannel: 'alerts',\n})\n\nexport const send = mutation({\n  args: { message: v.string() },\n  handler: async (ctx, args) => {\n    const userId = await getAuthUserId(ctx)\n    await notifications.send(ctx, { userId, message: args.message })\n  },\n})\n```\n\n## Validation\n\nTry validation in this order:\n\n1. `npx convex codegen --component-dir convex\u002Fcomponents\u002F\u003Cname>`\n2. `npx convex codegen`\n3. `npx convex dev`\n\nImportant:\n\n- Fresh repos may fail these commands until `CONVEX_DEPLOYMENT` is configured.\n- Until codegen runs, component-local `.\u002F_generated\u002F*` imports and app-side `components.\u003Cname>...` references will not typecheck.\n- If validation blocks on Convex login or deployment setup, stop and ask the user for that exact step instead of guessing.\n\n## Reference Files\n\nRead exactly one of these after the user confirms the goal:\n\n- `references\u002Flocal-components.md`\n- `references\u002Fpackaged-components.md`\n- `references\u002Fhybrid-components.md`\n\nOfficial docs: [Authoring Components](https:\u002F\u002Fdocs.convex.dev\u002Fcomponents\u002Fauthoring)\n\n## Checklist\n\n- [ ] Asked the user what they want to build and confirmed the shape\n- [ ] Read the matching reference file\n- [ ] Confirmed a component is the right abstraction\n- [ ] Planned tables, public API, boundaries, and app wrappers\n- [ ] Component lives under `convex\u002Fcomponents\u002F\u003Cname>\u002F` (or package layout if publishing)\n- [ ] Component imports from its own `.\u002F_generated\u002Fserver`\n- [ ] Auth, env access, and HTTP routes stay in the app\n- [ ] Parent app IDs cross the boundary as `v.string()`\n- [ ] Public functions have `args` and `returns` validators\n- [ ] Ran `npx convex dev` and fixed codegen or type issues\n",{"name":5,"description":7},"main","83212e6d909b6a0fe9e93fd5a3ff1723300f5b5b",".agents\u002Fskills\u002Fconvex-create-component","https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN","https:\u002F\u002Fsafetytalent.org","https:\u002F\u002Fgithub.com\u002Fbaisharg","2026-11-15 03:33:22",{"source":9,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add baisharg\u002FASTN --skill convex-create-component",{"tool":60,"command":61},"bunx","bunx skills add baisharg\u002FASTN --skill convex-create-component",{"tool":63,"command":64},"pnpm","pnpm dlx skills add baisharg\u002FASTN --skill convex-create-component","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fconvex-create-component\u002FSKILL.md",true,[68,74,80,84,88],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"agents\u002Fopenai.yaml","REFERENCE","参考文档",488,"https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fconvex-create-component\u002Fagents\u002Fopenai.yaml",{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"assets\u002Ficon.svg","ASSET","资产文件",485,"https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fconvex-create-component\u002Fassets\u002Ficon.svg",{"path":81,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fhybrid-components.md",1017,"https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fconvex-create-component\u002Freferences\u002Fhybrid-components.md",{"path":85,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":86,"sourceHtmlUrl":87},"references\u002Flocal-components.md",1100,"https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fconvex-create-component\u002Freferences\u002Flocal-components.md",{"path":89,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Fpackaged-components.md",1822,"https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fconvex-create-component\u002Freferences\u002Fpackaged-components.md",[93,114,134,148,162,179],{"skillNo":94,"name":95,"nameZh":96,"description":97,"descriptionZh":98,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":99,"categories":100,"keywords":105,"publishedAt":42},"01M6CCE5DVER8DQWJDY51HAJF7","schema-builder","Convex 数据库模式设计","Design and generate Convex database schemas with proper validation, indexes, and relationships. Use when creating schema.ts or modifying table definitions.","设计并生成 Convex 数据库模式（schema），包含完善的验证、索引和关系。在创建 schema.ts 或修改表定义时使用。","https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fschema-builder\u002FSKILL.md",[101,102],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":103,"categoryName":104,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BS1P4QM1G70C9FKMTZ88VK","数据库管理",[106,107,108,109,110,40,111,112,36,32,113],"schema builder","schema","builder","indexes","validation","table","database","generate",{"skillNo":115,"name":116,"nameZh":117,"description":118,"descriptionZh":119,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":120,"categories":121,"keywords":126,"publishedAt":42},"01M6CCE36AA57CG36R4VHKFRXV","integration-tanstack-start","TanStack Start 集成 PostHog","PostHog integration for TanStack Start full-stack applications","为 TanStack Start 全栈应用集成 PostHog","https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fposthog-integration-tanstack-start\u002FSKILL.md",[122,123],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":124,"categoryName":125,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BWDNFEHJCBZX47YY896K05","应用连接器集成",[127,128,129,130,131,132,133],"integration","start","tanstack","integration tanstack start","posthog","applications","stack",{"skillNo":135,"name":136,"nameZh":17,"description":137,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":42},"01M6CCE0FK6N8XAB093X7TTQ4F","migration-helper","Plan and execute Convex schema migrations safely, including adding fields, creating tables, and data transformations. Use when schema changes affect existing data.","https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fmigration-helper\u002FSKILL.md",[],[141,142,143,144,145,146,40,107,147,32],"migration","migration helper","schema migrations safely","data","plan","execute","migrations",{"skillNo":149,"name":150,"nameZh":17,"description":151,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":42},"01M6CCDY3644G8WXXP0BDNMZPR","gsd:sprint","Autonomous phase execution with Codex validation. Runs plan\u002Fexecute\u002Fverify cycles in a bash loop until done or halted.","https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fgsd-sprint\u002FSKILL.md",[],[150,155,156,110,128,157,158,159,160,145,161,146],"resume","codex","execution","verify","Bash","loop","autonomous",{"skillNo":163,"name":164,"nameZh":17,"description":165,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":42},"01M6CCDVTZRTFWWGREMV6FF956","gsd:second-opinion","Get a second opinion from OpenAI Codex (GPT-5.2-codex) on code, architecture, or implementation decisions. Use when you want independent verification or an alternative perspective.","https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fgsd-second-opinion\u002FSKILL.md",[],[169,170,171,156,172,173,174,175,176,177,40,178],"gsd:second opinion","second opinion","question","architecture","code","verification","openai","gpt","decisions","implementation",{"skillNo":180,"name":181,"nameZh":17,"description":182,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":183,"categories":184,"keywords":185,"publishedAt":42},"01M6CCDSDPYYNEDERHP01N30PT","gsd:milestone-sprint","Run entire milestone autonomously with Codex validation. Auto-detects current milestone, executes all phases, and runs audit.","https:\u002F\u002Fgithub.com\u002Fbaisharg\u002FASTN\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fgsd-milestone-sprint\u002FSKILL.md",[],[186,187,110,188,189,190,155,156],"gsd:milestone sprint","run","audit","interactive","auto"]