[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M758T4C05G48QH68885CEFC0":3,"skill-same:01M758T4C05G48QH68885CEFC0":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":28,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M758T4C05G48QH68885CEFC0","factory-method-pattern",null,"Implement the functional factory method pattern used across all service layers — the single most important architectural convention in this project","CliqRelay\u002Fcliqrelay","CliqRelay","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F290753656?v=4","01M758RPDEB11FEYA2XK17DSHA","01M758RPEKP0NKH6P43GD2FBDG",41,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ffrontend\u002Ffactory-method-pattern\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: factory-method-pattern\ndescription: Implement the functional factory method pattern used across all service layers — the single most important architectural convention in this project\n---\n\n# Factory Method Pattern\n\nThis project uses a **pure functional factory method pattern** for service layers where `@repo\u002Fapi-client` is not used. For domains covered by `@repo\u002Fapi-client`, server functions (web) or auto-generated hooks (extension) replace factories entirely.\n\nTypes are NEVER defined in service files. All types come from the project's `models\u002F` folder or from `@repo\u002Fapi-client`. See the **[type-contract-architecture](..\u002Ftype-contract-architecture\u002FSKILL.md)** skill.\n\n---\n\n## When to Use Each Pattern\n\n| Scenario | Pattern | Location |\n|----------|---------|----------|\n| Web app, api-client covers the domain | Server functions wrapping `api.*` calls | `server-fns\u002F{domain}.ts` |\n| Extension app, api-client covers the domain | Auto-generated hooks (`use*`) | Directly in components |\n| Neither app has api-client coverage | Factory method pattern | `services\u002F{domain}\u002F{domain}.service.ts` |\n\n---\n\n## Pattern A: Server Functions with api-client (Web App — Preferred)\n\nWhen `@repo\u002Fapi-client` covers a domain, use **TanStack Start server functions** that wrap the SDK calls. No factory functions needed.\n\n```typescript\n\u002F\u002F server-fns\u002Fguides.ts\nimport { createServerFn } from \"@tanstack\u002Freact-start\";\nimport { api } from \"@repo\u002Fapi-client\";\n\nexport const getAllGuides = createServerFn({\n  method: \"GET\",\n}).handler(async () => {\n  const { data, status } = await api.guides.getAllGuides();\n  if (status !== 200) {\n    console.error(\"Failed to fetch guides:\", data);\n    throw new Error(\"Failed to fetch guides\");\n  }\n  return data.guides;\n});\n\nexport const createGuide = createServerFn({ method: \"POST\" })\n  .inputValidator((input: { title: string; description?: string }) => input)\n  .handler(async ({ data }) => {\n    const response = await api.guides.createGuide({\n      title: data.title,\n      description: data.description ?? null,\n    });\n    if (response.status !== 201 || !response.data?.guide) {\n      console.error(\"Failed to create guide:\", response.data);\n      return null;\n    }\n    return response.data.guide;\n  });\n```\n\n**Rules:**\n- One function per API operation\n- Import `api` from `@repo\u002Fapi-client`\n- Check `response.status` and `response.data` for error handling\n- Return typed data (types come from `@repo\u002Fapi-client`)\n- Server functions are consumed by route loaders\n\n---\n\n## Pattern B: Use `@repo\u002Fapi-client` Directly (Extension App — Preferred)\n\nThe extension app uses `@repo\u002Fapi-client` directly. The SDK's `api.*` methods use `fetch` under the hood, so no manual HTTP implementations are needed. For React components, auto-generated hooks handle caching and re-fetching:\n\n```typescript\n\u002F\u002F ✅ DO — Use api.* directly for programmatic calls (background scripts, etc.)\nimport { api } from \"@repo\u002Fapi-client\";\n\nasync function handleCreateGuide(title: string) {\n  const response = await api.guides.createGuide({ title, description: null });\n  if (response.status >= 400 || !response.data?.guide) {\n    throw new Error(\"Failed to create guide\");\n  }\n  return response.data.guide;\n}\n\n\u002F\u002F ✅ DO — Use auto-generated hooks for React components\nimport { useGetAllGuides, useCreateGuide } from \"@repo\u002Fapi-client\";\n\nfunction GuideList() {\n  const { data, isLoading } = useGetAllGuides();\n  const createGuideMutation = useCreateGuide({\n    mutation: {\n      onSuccess: (data) => {\n        console.log(\"Guide created:\", data);\n      },\n    },\n  });\n  \u002F\u002F ...\n}\n```\n\n**Rules:**\n- Import `api` from `@repo\u002Fapi-client` for programmatic HTTP calls\n- Import hooks from `@repo\u002Fapi-client` for React components\n- No manual HTTP implementation files needed (`http-{domain}.service.ts` is no longer used)\n- No factory functions needed\n- No `http-{Verb}{Noun}` type contracts in `models\u002F` — types come from the SDK\n\n---\n\n## Pattern C: Traditional Factory Method (Fallback)\n\nThis is NOT the Gang of Four class-based factory. This is a functional TypeScript pattern where factories are exported standalone functions that return closures.\n\n### Two Variations\n\n#### Variation C1: Web App (Drizzle\u002FServer-side)\n\nFactories take a single function-type dependency (no URL parameter):\n\n```typescript\n\u002F\u002F services\u002Fguides\u002Fguides.service.ts\nimport type { CreateGuide, GuideCreateInput } from \"@\u002Fmodels\";\n\nexport const createGuideFactory = (createGuide: CreateGuide) => {\n  return async (\n    input: GuideCreateInput,\n  ): Promise\u003CAwaited\u003CReturnType\u003CCreateGuide>>> => createGuide(input);\n};\n\nexport type CreateGuide = ReturnType\u003Ctypeof createGuideFactory>;\n```\n\n#### Variation C2: Extension App (Client-side\u002FHTTP)\n\nFactories take a URL string AND an HTTP function as dependencies:\n\n```typescript\n\u002F\u002F services\u002Fguides\u002Fguides.service.ts\nimport type { CreateGuideInput, Guide } from \"@repo\u002Fdata-commons\";\nimport type { HttpCreateGuide } from \"@\u002Fmodels\";\n\nexport const createGuideFactory = (\n  url: string,\n  httpCreateGuide: HttpCreateGuide,\n) => {\n  return async (data: CreateGuideInput): Promise\u003CGuide> => {\n    const response = await httpCreateGuide(url, data);\n    return response.data;\n  };\n};\n```\n\n### Pattern Structure\n\n```typescript\n\u002F\u002F ✅ CORRECT — Web app fallback pattern (function-only DI)\nexport const {verb}{Noun}Factory = (\n  fn: {Verb}{Noun}\n) => {\n  return async (\n    \u002F* operation-specific params *\u002F\n  ): Promise\u003CResultType> => fn(\u002F* params *\u002F);\n};\n```\n\n```typescript\n\u002F\u002F ✅ CORRECT — Extension app fallback pattern (URL + HTTP function DI)\nexport const {verb}{Noun}Factory = (\n  url: string,\n  httpFn: Http{Verb}{Noun}\n) => {\n  return async (\n    \u002F* operation-specific params *\u002F\n  ): Promise\u003CResultType> => {\n    const result = await httpFn(url, { \u002F* params *\u002F });\n    return result;\n  };\n};\n```\n\n### Naming Rules\n\n| Pattern | Example |\n|---------|---------|\n| `{verb}{Noun}Factory` | `createGuideFactory`, `getGuideByIdFactory`, `updateStepFactory` |\n| Handler returned | No special name — it's the return value of the factory |\n| File name | `{domain}.service.ts` — e.g. `guides.service.ts`, `steps.service.ts` |\n| Export | Named export (not default) for each factory function |\n| Dependency type | Matches the type contract defined in `models\u002F{domain}.ts` |\n| Service type | `export type {Verb}{Noun} = ReturnType\u003Ctypeof {verb}{Noun}Factory>` — always in the service file |\n\n## Where Factories Are Wired (Fallback Pattern Only)\n\nFor the wiring of factories in the fallback pattern, see the [Service Layer Composition](.\u002Fservice-layer-composition\u002FSKILL.md) and [Functional Dependency Injection](.\u002Ffunctional-dependency-injection\u002FSKILL.md) skills.\n\n## Rules\n\n### ✅ DO\n- Use server functions + `@repo\u002Fapi-client` as the primary pattern (web app)\n- Use auto-generated hooks from `@repo\u002Fapi-client` as the primary pattern (extension)\n- Fall back to factory functions only for domains NOT covered by `@repo\u002Fapi-client`\n- One factory = one operation (fallback only)\n- Factories are pure — they do not make HTTP\u002FDB calls, they compose them\n\n### ❌ DON'T\n- Don't use classes for services\n- Don't define types in service files — types belong in `models\u002F` or come from `@repo\u002Fapi-client`\n- Don't use factories in parallel with api-client for the same domain\n- Don't import HTTP implementations inside factory functions — receive them via DI\n","# Factory Method Pattern\n\nThis project uses a **pure functional factory method pattern** for service layers where `@repo\u002Fapi-client` is not used. For domains covered by `@repo\u002Fapi-client`, server functions (web) or auto-generated hooks (extension) replace factories entirely.\n\nTypes are NEVER defined in service files. All types come from the project's `models\u002F` folder or from `@repo\u002Fapi-client`. See the **[type-contract-architecture](..\u002Ftype-contract-architecture\u002FSKILL.md)** skill.\n\n---\n\n## When to Use Each Pattern\n\n| Scenario | Pattern | Location |\n|----------|---------|----------|\n| Web app, api-client covers the domain | Server functions wrapping `api.*` calls | `server-fns\u002F{domain}.ts` |\n| Extension app, api-client covers the domain | Auto-generated hooks (`use*`) | Directly in components |\n| Neither app has api-client coverage | Factory method pattern | `services\u002F{domain}\u002F{domain}.service.ts` |\n\n---\n\n## Pattern A: Server Functions with api-client (Web App — Preferred)\n\nWhen `@repo\u002Fapi-client` covers a domain, use **TanStack Start server functions** that wrap the SDK calls. No factory functions needed.\n\n```typescript\n\u002F\u002F server-fns\u002Fguides.ts\nimport { createServerFn } from \"@tanstack\u002Freact-start\";\nimport { api } from \"@repo\u002Fapi-client\";\n\nexport const getAllGuides = createServerFn({\n  method: \"GET\",\n}).handler(async () => {\n  const { data, status } = await api.guides.getAllGuides();\n  if (status !== 200) {\n    console.error(\"Failed to fetch guides:\", data);\n    throw new Error(\"Failed to fetch guides\");\n  }\n  return data.guides;\n});\n\nexport const createGuide = createServerFn({ method: \"POST\" })\n  .inputValidator((input: { title: string; description?: string }) => input)\n  .handler(async ({ data }) => {\n    const response = await api.guides.createGuide({\n      title: data.title,\n      description: data.description ?? null,\n    });\n    if (response.status !== 201 || !response.data?.guide) {\n      console.error(\"Failed to create guide:\", response.data);\n      return null;\n    }\n    return response.data.guide;\n  });\n```\n\n**Rules:**\n- One function per API operation\n- Import `api` from `@repo\u002Fapi-client`\n- Check `response.status` and `response.data` for error handling\n- Return typed data (types come from `@repo\u002Fapi-client`)\n- Server functions are consumed by route loaders\n\n---\n\n## Pattern B: Use `@repo\u002Fapi-client` Directly (Extension App — Preferred)\n\nThe extension app uses `@repo\u002Fapi-client` directly. The SDK's `api.*` methods use `fetch` under the hood, so no manual HTTP implementations are needed. For React components, auto-generated hooks handle caching and re-fetching:\n\n```typescript\n\u002F\u002F ✅ DO — Use api.* directly for programmatic calls (background scripts, etc.)\nimport { api } from \"@repo\u002Fapi-client\";\n\nasync function handleCreateGuide(title: string) {\n  const response = await api.guides.createGuide({ title, description: null });\n  if (response.status >= 400 || !response.data?.guide) {\n    throw new Error(\"Failed to create guide\");\n  }\n  return response.data.guide;\n}\n\n\u002F\u002F ✅ DO — Use auto-generated hooks for React components\nimport { useGetAllGuides, useCreateGuide } from \"@repo\u002Fapi-client\";\n\nfunction GuideList() {\n  const { data, isLoading } = useGetAllGuides();\n  const createGuideMutation = useCreateGuide({\n    mutation: {\n      onSuccess: (data) => {\n        console.log(\"Guide created:\", data);\n      },\n    },\n  });\n  \u002F\u002F ...\n}\n```\n\n**Rules:**\n- Import `api` from `@repo\u002Fapi-client` for programmatic HTTP calls\n- Import hooks from `@repo\u002Fapi-client` for React components\n- No manual HTTP implementation files needed (`http-{domain}.service.ts` is no longer used)\n- No factory functions needed\n- No `http-{Verb}{Noun}` type contracts in `models\u002F` — types come from the SDK\n\n---\n\n## Pattern C: Traditional Factory Method (Fallback)\n\nThis is NOT the Gang of Four class-based factory. This is a functional TypeScript pattern where factories are exported standalone functions that return closures.\n\n### Two Variations\n\n#### Variation C1: Web App (Drizzle\u002FServer-side)\n\nFactories take a single function-type dependency (no URL parameter):\n\n```typescript\n\u002F\u002F services\u002Fguides\u002Fguides.service.ts\nimport type { CreateGuide, GuideCreateInput } from \"@\u002Fmodels\";\n\nexport const createGuideFactory = (createGuide: CreateGuide) => {\n  return async (\n    input: GuideCreateInput,\n  ): Promise\u003CAwaited\u003CReturnType\u003CCreateGuide>>> => createGuide(input);\n};\n\nexport type CreateGuide = ReturnType\u003Ctypeof createGuideFactory>;\n```\n\n#### Variation C2: Extension App (Client-side\u002FHTTP)\n\nFactories take a URL string AND an HTTP function as dependencies:\n\n```typescript\n\u002F\u002F services\u002Fguides\u002Fguides.service.ts\nimport type { CreateGuideInput, Guide } from \"@repo\u002Fdata-commons\";\nimport type { HttpCreateGuide } from \"@\u002Fmodels\";\n\nexport const createGuideFactory = (\n  url: string,\n  httpCreateGuide: HttpCreateGuide,\n) => {\n  return async (data: CreateGuideInput): Promise\u003CGuide> => {\n    const response = await httpCreateGuide(url, data);\n    return response.data;\n  };\n};\n```\n\n### Pattern Structure\n\n```typescript\n\u002F\u002F ✅ CORRECT — Web app fallback pattern (function-only DI)\nexport const {verb}{Noun}Factory = (\n  fn: {Verb}{Noun}\n) => {\n  return async (\n    \u002F* operation-specific params *\u002F\n  ): Promise\u003CResultType> => fn(\u002F* params *\u002F);\n};\n```\n\n```typescript\n\u002F\u002F ✅ CORRECT — Extension app fallback pattern (URL + HTTP function DI)\nexport const {verb}{Noun}Factory = (\n  url: string,\n  httpFn: Http{Verb}{Noun}\n) => {\n  return async (\n    \u002F* operation-specific params *\u002F\n  ): Promise\u003CResultType> => {\n    const result = await httpFn(url, { \u002F* params *\u002F });\n    return result;\n  };\n};\n```\n\n### Naming Rules\n\n| Pattern | Example |\n|---------|---------|\n| `{verb}{Noun}Factory` | `createGuideFactory`, `getGuideByIdFactory`, `updateStepFactory` |\n| Handler returned | No special name — it's the return value of the factory |\n| File name | `{domain}.service.ts` — e.g. `guides.service.ts`, `steps.service.ts` |\n| Export | Named export (not default) for each factory function |\n| Dependency type | Matches the type contract defined in `models\u002F{domain}.ts` |\n| Service type | `export type {Verb}{Noun} = ReturnType\u003Ctypeof {verb}{Noun}Factory>` — always in the service file |\n\n## Where Factories Are Wired (Fallback Pattern Only)\n\nFor the wiring of factories in the fallback pattern, see the [Service Layer Composition](.\u002Fservice-layer-composition\u002FSKILL.md) and [Functional Dependency Injection](.\u002Ffunctional-dependency-injection\u002FSKILL.md) skills.\n\n## Rules\n\n### ✅ DO\n- Use server functions + `@repo\u002Fapi-client` as the primary pattern (web app)\n- Use auto-generated hooks from `@repo\u002Fapi-client` as the primary pattern (extension)\n- Fall back to factory functions only for domains NOT covered by `@repo\u002Fapi-client`\n- One factory = one operation (fallback only)\n- Factories are pure — they do not make HTTP\u002FDB calls, they compose them\n\n### ❌ DON'T\n- Don't use classes for services\n- Don't define types in service files — types belong in `models\u002F` or come from `@repo\u002Fapi-client`\n- Don't use factories in parallel with api-client for the same domain\n- Don't import HTTP implementations inside factory functions — receive them via DI\n",{"name":5,"description":7},"main","f06510bcaf955afc66bbbc1606871e1a1576492e",".agents\u002Fskills\u002Ffrontend\u002Ffactory-method-pattern",0,"https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay","https:\u002F\u002Fcliqrelay.com","https:\u002F\u002Fgithub.com\u002FCliqRelay","Capture and refine workflows instantly to help your teams and AI agents perform at their best.","2026-11-04 22:56:05",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add CliqRelay\u002Fcliqrelay --skill factory-method-pattern",{"tool":38,"command":39},"bunx","bunx skills add CliqRelay\u002Fcliqrelay --skill factory-method-pattern",{"tool":41,"command":42},"pnpm","pnpm dlx skills add CliqRelay\u002Fcliqrelay --skill factory-method-pattern","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ffrontend\u002Ffactory-method-pattern\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":18},"01M758WG0JG18W5MZD6ZPM6PGG","typst","Typst document creation and package development. Use when: (1) Working with .typ files, (2) User mentions typst, typst.toml, or typst-cli, (3) Creating or using Typst packages, (4) Developing document templates, (5) Converting Markdown\u002FLaTeX to Typst","https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftypst\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M758WACKQMHG2BFF7T758J12","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", or \"switch to --preset\".","https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M758W82G2QQ5Q14FKYNHRXQW","handoff","Compact the current conversation into a handoff document for another agent to pick up.","https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fproductivity\u002Fhandoff\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M758W63H60EK55A93199B6NR","grilling","Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.","https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fproductivity\u002Fgrilling\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M758W4HD4PF66929V7MDGKW8","grill-me","A relentless interview to sharpen a plan or design.","https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fproductivity\u002Fgrill-me\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M758VYC5CCTP7EA5VKE7YWM5","dont-waffle","Use this skill when answering questions, explaining concepts, writing technical responses, reviewing code, or helping with development tasks. Communicate in clear, simple, standard English. Keep answers concise and focused, remove unnecessary filler and repetition, explain technical ideas in plain language, and structure information so it is easy to read and understand. When showing code, present it clearly with enough context for the developer to understand what it does and where it belongs.","https:\u002F\u002Fgithub.com\u002FCliqRelay\u002Fcliqrelay\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fproductivity\u002Fdont-waffle\u002FSKILL.md",[],[]]