Skip to content

Type-safe partial test data helpers that replace as assertions in test files only.

CCM score
66 of 100
skills.sh installs
5.8K
GitHub stars
6.2K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers migrating as Type, as unknown as Type, and large partial objects in tests to fromPartial(), fromAny(), and fromExact()
  • Provides a decision table mapping each helper to its case: type-checked partials, intentionally wrong data, or full objects
  • Includes a migration workflow with a grep command to locate as assertions in *.test.ts and *.spec.ts files
  • Designed for test code only; production code must never use shoehorn, and the package installs via npm i @total-typescript/shoehorn

Install

$ npx -y skills add vinvcn/mattpocock-skills-zh-cn --skill migrate-to-shoehorn -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

迁移到 Shoehorn

为什么用 shoehorn?

shoehorn 允许你在 tests 中传入 partial data,同时保持 TypeScript 满意。它用 type-safe alternatives 替换 as assertions。

只用于 test code。 永远不要在 production code 中使用 shoehorn。

Tests 中 as 的问题:

  • 经过训练,不去使用它
  • 必须手动指定 target type
  • 对故意错误的数据需要 double-as(as unknown as Type)

安装

npm i @total-typescript/shoehorn

迁移模式

只需要少数属性的大型 objects

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:

Details

Repository
github.com/vinvcn/mattpocock-skills-zh-cn
Categories
Testing & QA, Frontend & UI Code
First seen
Jun 3, 2026

Questions

What is migrate-to-shoehorn?

migrate-to-shoehorn is an agent skill listed on Claude Marketplaces in the Testing & QA category. Its page on Claude Marketplaces links to the migrate-to-shoehorn source on GitHub.

How do I install migrate-to-shoehorn?

Run npx -y skills add vinvcn/mattpocock-skills-zh-cn --skill migrate-to-shoehorn -y in a project to install migrate-to-shoehorn. After that, the agent can use migrate-to-shoehorn in that project.

Which category is migrate-to-shoehorn in?

migrate-to-shoehorn is in the Testing & QA category on Claude Marketplaces. Other listings in that category next to migrate-to-shoehorn include tdd, migrate-to-shoehorn and test-driven-development.

Where is the source code of migrate-to-shoehorn?

The source code of migrate-to-shoehorn is on GitHub at https://github.com/vinvcn/mattpocock-skills-zh-cn. The vinvcn account on GitHub publishes migrate-to-shoehorn.

More from vinvcn/mattpocock-skills-zh-cn

All 24

Similar to Migrate To Shoehorn

More Testing & QA