[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75MM3AJWQCD7BAYS9SHD4F5":3,"skill-same:01M75MM3AJWQCD7BAYS9SHD4F5":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M75MM3AJWQCD7BAYS9SHD4F5","migrate-to-shoehorn",null,"将测试文件从 `as` 类型断言迁移到 @total-typescript\u002Fshoehorn。当用户提到 shoehorn、想要在测试中替换 `as`、或需要部分测试数据时使用。","devcxl\u002Fmattpocock-skills-zh","devcxl","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F64475363?v=4","01M75MJ7N3BE0AK24Q83ZVY13N","半颗白菜","01M75MJ7P58635MPFAW17AG3SV",541,"MIT","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fmigrate-to-shoehorn\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: migrate-to-shoehorn\ndescription: 将测试文件从 `as` 类型断言迁移到 @total-typescript\u002Fshoehorn。当用户提到 shoehorn、想要在测试中替换 `as`、或需要部分测试数据时使用。\n---\n\n# 迁移到 Shoehorn\n\n## 为什么使用 shoehorn？\n\n`shoehorn` 让你在测试中传递部分数据，同时保持 TypeScript 类型正确。它用类型安全的替代方案取代了 `as` 断言。\n\n**仅限测试代码。** 切勿在生产代码中使用 shoehorn。\n\n`as` 在测试中的问题：\n\n- 习惯上被训练不要使用它\n- 必须手动指定目标类型\n- 双重 `as`（`as unknown as Type`）用于传递故意错误的数据\n\n## 安装\n\n```bash\nnpm i @total-typescript\u002Fshoehorn\n```\n\n## 迁移模式\n\n### 大型对象，只用到少数属性\n\n迁移前：\n\n```ts\ntype Request = {\n  body: { id: string };\n  headers: Record\u003Cstring, string>;\n  cookies: Record\u003Cstring, string>;\n  \u002F\u002F ...还有 20 个属性\n};\n\nit(\"gets user by id\", () => {\n  \u002F\u002F 只关心 body.id，但必须伪造整个 Request\n  getUser({\n    body: { id: \"123\" },\n    headers: {},\n    cookies: {},\n    \u002F\u002F ...伪造所有 20 个属性\n  });\n});\n```\n\n迁移后：\n\n```ts\nimport { fromPartial } from \"@total-typescript\u002Fshoehorn\";\n\nit(\"gets user by id\", () => {\n  getUser(\n    fromPartial({\n      body: { id: \"123\" },\n    }),\n  );\n});\n```\n\n### `as Type` → `fromPartial()`\n\n迁移前：\n\n```ts\ngetUser({ body: { id: \"123\" } } as Request);\n```\n\n迁移后：\n\n```ts\nimport { fromPartial } from \"@total-typescript\u002Fshoehorn\";\n\ngetUser(fromPartial({ body: { id: \"123\" } }));\n```\n\n### `as unknown as Type` → `fromAny()`\n\n迁移前：\n\n```ts\ngetUser({ body: { id: 123 } } as unknown as Request); \u002F\u002F 故意传错类型\n```\n\n迁移后：\n\n```ts\nimport { fromAny } from \"@total-typescript\u002Fshoehorn\";\n\ngetUser(fromAny({ body: { id: 123 } }));\n```\n\n## 各函数的适用场景\n\n| 函数            | 使用场景                                |\n| --------------- | --------------------------------------- |\n| `fromPartial()` | 传递部分数据，仍能通过类型检查          |\n| `fromAny()`     | 传递故意错误的数据（保留自动补全）      |\n| `fromExact()`   | 强制传入完整对象（后续可替换为 fromPartial） |\n\n## 工作流程\n\n1. **收集需求** — 询问用户：\n   - 哪些测试文件中的 `as` 断言造成了问题？\n   - 是否涉及大型对象，只有部分属性是重要的？\n   - 是否需要传递故意错误的数据用于错误测试？\n\n2. **安装并迁移**：\n   - [ ] 安装：`npm i @total-typescript\u002Fshoehorn`\n   - [ ] 查找含有 `as` 断言的测试文件：`grep -r \" as [A-Z]\" --include=\"*.test.ts\" --include=\"*.spec.ts\"`\n   - [ ] 将 `as Type` 替换为 `fromPartial()`\n   - [ ] 将 `as unknown as Type` 替换为 `fromAny()`\n   - [ ] 从 `@total-typescript\u002Fshoehorn` 添加 import\n   - [ ] 运行类型检查以验证\n","# 迁移到 Shoehorn\n\n## 为什么使用 shoehorn？\n\n`shoehorn` 让你在测试中传递部分数据，同时保持 TypeScript 类型正确。它用类型安全的替代方案取代了 `as` 断言。\n\n**仅限测试代码。** 切勿在生产代码中使用 shoehorn。\n\n`as` 在测试中的问题：\n\n- 习惯上被训练不要使用它\n- 必须手动指定目标类型\n- 双重 `as`（`as unknown as Type`）用于传递故意错误的数据\n\n## 安装\n\n```bash\nnpm i @total-typescript\u002Fshoehorn\n```\n\n## 迁移模式\n\n### 大型对象，只用到少数属性\n\n迁移前：\n\n```ts\ntype Request = {\n  body: { id: string };\n  headers: Record\u003Cstring, string>;\n  cookies: Record\u003Cstring, string>;\n  \u002F\u002F ...还有 20 个属性\n};\n\nit(\"gets user by id\", () => {\n  \u002F\u002F 只关心 body.id，但必须伪造整个 Request\n  getUser({\n    body: { id: \"123\" },\n    headers: {},\n    cookies: {},\n    \u002F\u002F ...伪造所有 20 个属性\n  });\n});\n```\n\n迁移后：\n\n```ts\nimport { fromPartial } from \"@total-typescript\u002Fshoehorn\";\n\nit(\"gets user by id\", () => {\n  getUser(\n    fromPartial({\n      body: { id: \"123\" },\n    }),\n  );\n});\n```\n\n### `as Type` → `fromPartial()`\n\n迁移前：\n\n```ts\ngetUser({ body: { id: \"123\" } } as Request);\n```\n\n迁移后：\n\n```ts\nimport { fromPartial } from \"@total-typescript\u002Fshoehorn\";\n\ngetUser(fromPartial({ body: { id: \"123\" } }));\n```\n\n### `as unknown as Type` → `fromAny()`\n\n迁移前：\n\n```ts\ngetUser({ body: { id: 123 } } as unknown as Request); \u002F\u002F 故意传错类型\n```\n\n迁移后：\n\n```ts\nimport { fromAny } from \"@total-typescript\u002Fshoehorn\";\n\ngetUser(fromAny({ body: { id: 123 } }));\n```\n\n## 各函数的适用场景\n\n| 函数            | 使用场景                                |\n| --------------- | --------------------------------------- |\n| `fromPartial()` | 传递部分数据，仍能通过类型检查          |\n| `fromAny()`     | 传递故意错误的数据（保留自动补全）      |\n| `fromExact()`   | 强制传入完整对象（后续可替换为 fromPartial） |\n\n## 工作流程\n\n1. **收集需求** — 询问用户：\n   - 哪些测试文件中的 `as` 断言造成了问题？\n   - 是否涉及大型对象，只有部分属性是重要的？\n   - 是否需要传递故意错误的数据用于错误测试？\n\n2. **安装并迁移**：\n   - [ ] 安装：`npm i @total-typescript\u002Fshoehorn`\n   - [ ] 查找含有 `as` 断言的测试文件：`grep -r \" as [A-Z]\" --include=\"*.test.ts\" --include=\"*.spec.ts\"`\n   - [ ] 将 `as Type` 替换为 `fromPartial()`\n   - [ ] 将 `as unknown as Type` 替换为 `fromAny()`\n   - [ ] 从 `@total-typescript\u002Fshoehorn` 添加 import\n   - [ ] 运行类型检查以验证\n",{"name":5,"description":7},"main","30fc5dbf9380144598f3593e6c1e22c713a52c2a","skills\u002Fmisc\u002Fmigrate-to-shoehorn",48,"https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh","https:\u002F\u002Fgithub.com\u002Fdevcxl","2026-11-13 04:10:40",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add devcxl\u002Fmattpocock-skills-zh --skill migrate-to-shoehorn",{"tool":37,"command":38},"bunx","bunx skills add devcxl\u002Fmattpocock-skills-zh --skill migrate-to-shoehorn",{"tool":40,"command":41},"pnpm","pnpm dlx skills add devcxl\u002Fmattpocock-skills-zh --skill migrate-to-shoehorn","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fmigrate-to-shoehorn\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"agents\u002Fopenai.yaml","REFERENCE","参考文档",104,"https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fmigrate-to-shoehorn\u002Fagents\u002Fopenai.yaml",[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M75MMJXWKRN5DFAYWKNHCG28","writing-for-agents","为智能体编写文档。当你正在创建或编辑技能，或者修改 AGENTS.md \u002F CLAUDE.md 时使用。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M75MMHVFN4B6QBPNGQ5GJSDT","wait-what","等等。上一条消息我没理解：重新解释一下。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fwait-what\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M75MMGNH9G1M7WC7NKP6100Y","to-questionnaire","将你无法完全回答的决策转化为供他人填写的问卷。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fto-questionnaire\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M75MME5PC8MBS7M6R6RH7VDH","teach","在当前工作区中教会用户一项新技能或概念。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fteach\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M75MMD05VWVMK55W6GEWJNX3","handoff","将当前对话压缩为一份交接文档，供另一个智能体继续工作。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fhandoff\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M75MMBS30DRYPMC6SADZ7ZTT","grilling","对用户的计划、决策或想法进行层层盘问。当用户想要压力测试自己的思考，或使用任何 'grill' 触发短语时使用。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fgrilling\u002FSKILL.md",[],[]]