원클릭으로
migrate-to-shoehorn
将测试文件从 `as` 类型断言迁移到 @total-typescript/shoehorn。适用于用户提到 shoehorn、想替换测试中的 `as`,或需要局部测试数据时。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
将测试文件从 `as` 类型断言迁移到 @total-typescript/shoehorn。适用于用户提到 shoehorn、想替换测试中的 `as`,或需要局部测试数据时。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
使用并行子代理为模块生成多个显著不同的接口设计。适用于用户想设计 API、探索接口选项、比较模块形状,或提到 “design it twice” 时。
交互式 QA 会话,用户以对话方式报告缺陷或问题,代理创建 GitHub issues。后台探索代码库以获取上下文和领域语言。适用于用户想报告缺陷、执行 QA、以对话方式提交 issues,或提到 “QA session” 时。
通过用户访谈创建带小提交的详细重构计划,然后作为 GitHub issue 提交。适用于用户想规划重构、创建重构 RFC,或把重构拆成安全的增量步骤时。
从当前对话提取 DDD 风格的 ubiquitous language glossary,标记歧义并提出标准术语。保存到 UBIQUITOUS_LANGUAGE.md。适用于用户想定义领域术语、构建词汇表、收紧术语、创建通用语言,或提到 “domain model” / “DDD” 时。
询问当前情境适合哪个技能或流程;它是本仓库所有 skills 的路由器。
从固定点(commit、branch、tag 或 merge-base)开始,按 Standards(代码是否符合本仓库记录的编码标准?)和 Spec(代码是否符合来源 issue/PRD 的要求?)两个轴线审查变更。两个审查会在并行子代理中运行,并并排报告。适用于用户想审查 branch、PR、进行中的变更,或要求 “review since X” 时。
| name | migrate-to-shoehorn |
| description | 将测试文件从 `as` 类型断言迁移到 @total-typescript/shoehorn。适用于用户提到 shoehorn、想替换测试中的 `as`,或需要局部测试数据时。 |
shoehorn 允许你在 tests 中传入 partial data,同时保持 TypeScript 满意。它用 type-safe alternatives 替换 as assertions。
只用于 test code。 永远不要在 production code 中使用 shoehorn。
Tests 中 as 的问题:
as unknown as Type)npm i @total-typescript/shoehorn
Before:
type Request = {
body: { id: string };
headers: Record<string, string>;
cookies: Record<string, string>;
// ...20 more properties
};
it("gets user by id", () => {
// Only care about body.id but must fake entire Request
getUser({
body: { id: "123" },
headers: {},
cookies: {},
// ...fake all 20 properties
});
});
After:
import { fromPartial } from "@total-typescript/shoehorn";
it("gets user by id", () => {
getUser(
fromPartial({
body: { id: "123" },
}),
);
});
as Type → fromPartial()Before:
getUser({ body: { id: "123" } } as Request);
After:
import { fromPartial } from "@total-typescript/shoehorn";
getUser(fromPartial({ body: { id: "123" } }));
as unknown as Type → fromAny()Before:
getUser({ body: { id: 123 } } as unknown as Request); // wrong type on purpose
After:
import { fromAny } from "@total-typescript/shoehorn";
getUser(fromAny({ body: { id: 123 } }));
| Function | Use case |
|---|---|
fromPartial() | 传入仍能 type-check 的 partial data |
fromAny() | 传入故意错误的数据(保留 autocomplete) |
fromExact() | 强制 full object(之后可换成 fromPartial) |
Gather requirements — 询问用户:
as assertions 造成问题?Install and migrate:
npm i @total-typescript/shoehornas assertions: grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"fromPartial() 替换 as TypefromAny() 替换 as unknown as Type@total-typescript/shoehorn 的 imports