Agent SkillsRemocn/remocn › migrate-to-shoehorn

migrate-to-shoehorn

GitHub

将测试文件中的 as 类型断言迁移至 @total-typescript/shoehorn,支持使用 fromPartial 处理部分数据、fromAny 处理故意错误数据,提升测试代码的类型安全性与可维护性。

agent/skills/migrate-to-shoehorn/SKILL.md Remocn/remocn

Trigger Scenarios

用户提到 shoehorn 用户希望替换测试中的 as 断言 用户需要生成部分测试数据

Install

npx skills add Remocn/remocn --skill migrate-to-shoehorn -g -y
More Options

Non-standard path

npx skills add https://github.com/Remocn/remocn/tree/main/agent/skills/migrate-to-shoehorn -g -y

Use without installing

npx skills use Remocn/remocn@migrate-to-shoehorn

指定 Agent (Claude Code)

npx skills add Remocn/remocn --skill migrate-to-shoehorn -a claude-code -g -y

安装 repo 全部 skill

npx skills add Remocn/remocn --all -g -y

预览 repo 内 skill

npx skills add Remocn/remocn --list

SKILL.md

Frontmatter
{
    "name": "migrate-to-shoehorn",
    "description": "Migrate test files from `as` type assertions to @total-typescript\/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data."
}

Migrate to Shoehorn

Why shoehorn?

shoehorn lets you pass partial data in tests while keeping TypeScript happy. It replaces as assertions with type-safe alternatives.

Test code only. Never use shoehorn in production code.

Problems with as in tests:

  • Trained not to use it
  • Must manually specify target type
  • Double-as (as unknown as Type) for intentionally wrong data

Install

npm i @total-typescript/shoehorn

Migration patterns

Large objects with few needed properties

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 TypefromPartial()

Before:

getUser({ body: { id: "123" } } as Request);

After:

import { fromPartial } from "@total-typescript/shoehorn";

getUser(fromPartial({ body: { id: "123" } }));

as unknown as TypefromAny()

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 } }));

When to use each

Function Use case
fromPartial() Pass partial data that still type-checks
fromAny() Pass intentionally wrong data (keeps autocomplete)
fromExact() Force full object (swap with fromPartial later)

Workflow

  1. Gather requirements - ask user:

    • What test files have as assertions causing problems?
    • Are they dealing with large objects where only some properties matter?
    • Do they need to pass intentionally wrong data for error testing?
  2. Install and migrate:

    • Install: npm i @total-typescript/shoehorn
    • Find test files with as assertions: grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"
    • Replace as Type with fromPartial()
    • Replace as unknown as Type with fromAny()
    • Add imports from @total-typescript/shoehorn
    • Run type check to verify

Version History

  • f77e19e Current 2026-07-19 22:36

Same Skill Collection

.agents/skills/ask-matt/SKILL.md
.agents/skills/claude-handoff/SKILL.md
.agents/skills/code-review/SKILL.md
.agents/skills/codebase-design/SKILL.md
.agents/skills/design-an-interface/SKILL.md
.agents/skills/diagnosing-bugs/SKILL.md
.agents/skills/domain-modeling/SKILL.md
.agents/skills/edit-article/SKILL.md
.agents/skills/git-guardrails-claude-code/SKILL.md
.agents/skills/grilling/SKILL.md
.agents/skills/handoff/SKILL.md
.agents/skills/implement/SKILL.md
.agents/skills/improve-codebase-architecture/SKILL.md
.agents/skills/loop-me/SKILL.md
.agents/skills/migrate-to-shoehorn/SKILL.md
.agents/skills/obsidian-vault/SKILL.md
.agents/skills/prototype/SKILL.md
.agents/skills/qa/SKILL.md
.agents/skills/request-refactor-plan/SKILL.md
.agents/skills/research/SKILL.md
.agents/skills/resolving-merge-conflicts/SKILL.md
.agents/skills/scaffold-exercises/SKILL.md
.agents/skills/setup-matt-pocock-skills/SKILL.md
.agents/skills/setup-pre-commit/SKILL.md
.agents/skills/tdd/SKILL.md
.agents/skills/teach/SKILL.md
.agents/skills/to-spec/SKILL.md
.agents/skills/to-tickets/SKILL.md
.agents/skills/triage/SKILL.md
.agents/skills/ubiquitous-language/SKILL.md
.agents/skills/wayfinder/SKILL.md
.agents/skills/wizard/SKILL.md
.agents/skills/writing-beats/SKILL.md
.agents/skills/writing-fragments/SKILL.md
.agents/skills/writing-great-skills/SKILL.md
.agents/skills/writing-shape/SKILL.md
.claude/skills/interactivity-best-practices/SKILL.md
agent/skills/ask-matt/SKILL.md
agent/skills/claude-handoff/SKILL.md
agent/skills/code-review/SKILL.md
agent/skills/codebase-design/SKILL.md
agent/skills/design-an-interface/SKILL.md
agent/skills/diagnosing-bugs/SKILL.md
agent/skills/domain-modeling/SKILL.md
agent/skills/edit-article/SKILL.md
agent/skills/git-guardrails-claude-code/SKILL.md
agent/skills/grilling/SKILL.md
agent/skills/handoff/SKILL.md
agent/skills/implement/SKILL.md
agent/skills/improve-codebase-architecture/SKILL.md
agent/skills/loop-me/SKILL.md
agent/skills/obsidian-vault/SKILL.md
agent/skills/prototype/SKILL.md
agent/skills/qa/SKILL.md
agent/skills/request-refactor-plan/SKILL.md
agent/skills/research/SKILL.md
agent/skills/resolving-merge-conflicts/SKILL.md
agent/skills/scaffold-exercises/SKILL.md
agent/skills/setup-matt-pocock-skills/SKILL.md
agent/skills/setup-pre-commit/SKILL.md
agent/skills/tdd/SKILL.md
agent/skills/teach/SKILL.md
agent/skills/to-spec/SKILL.md
agent/skills/to-tickets/SKILL.md
agent/skills/triage/SKILL.md
agent/skills/ubiquitous-language/SKILL.md
agent/skills/wayfinder/SKILL.md
agent/skills/wizard/SKILL.md
agent/skills/writing-beats/SKILL.md
agent/skills/writing-fragments/SKILL.md
agent/skills/writing-great-skills/SKILL.md
agent/skills/writing-shape/SKILL.md
skills/remocn/SKILL.md
.agents/skills/grill-me/SKILL.md
.agents/skills/grill-with-docs/SKILL.md
agent/skills/grill-me/SKILL.md
agent/skills/grill-with-docs/SKILL.md

Metadata

Files
0
Version
f77e19e
Hash
e25035c5
Indexed
2026-07-19 22:36

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-22 14:03
浙ICP备14020137号-1 $お客様$