New to Claude Skills? Learn how to install them →

Mmattpocock on GitHub

Migrate to Shoehorn

Free

Easily replace `as` assertions in TypeScript tests.

by mattpocock212.7k stars on mattpocock/skills
1 views
Updated Aug 6, 2026
Get this skill

Free · Opens the source repo

What Migrate to Shoehorn does

Migrate to Shoehorn is a specialized tool designed for TypeScript developers looking to improve the way they handle type assertions in their test files. The skill facilitates the transition from using as type assertions to the more type-safe alternatives provided by the @total-typescript/shoehorn library. This is particularly useful in scenarios where developers need to pass partial data while ensuring that their TypeScript code remains valid and type-checked. By utilizing functions like fromPartial() and fromAny(), users can streamline their test code, making it cleaner and more maintainable.

The skill addresses common issues associated with as assertions in tests, such as the need to manually specify target types and the complications arising from double assertions like as unknown as Type. These practices can lead to errors and confusion in test cases, which this skill aims to eliminate. Instead of creating large mock objects with unnecessary properties, developers can focus on the specific data they need for their tests, enhancing readability and reducing boilerplate code.

This tool is particularly beneficial for teams and individual developers who frequently work with large objects in their tests. It allows for a more efficient testing process by encouraging the use of partial data structures, which can significantly reduce the amount of code needed to set up tests. Furthermore, the skill is ideal for those who are transitioning to stricter TypeScript practices and want to ensure their tests are both robust and type-safe.

In summary, Migrate to Shoehorn is a valuable addition for TypeScript developers aiming to improve their testing practices by replacing outdated type assertions with modern, type-safe alternatives. It not only simplifies the test code but also promotes better coding standards within TypeScript projects.

When to use it

Use this skill when you want to replace `as` assertions in your TypeScript test files with type-safe alternatives.

When not to use it

This skill is not suitable for production code; it is specifically designed for testing scenarios only.

What you can build with it

Migrating Large Object Tests

When testing functions that require large objects, use `fromPartial()` to create only the necessary properties instead of faking the entire object.

Replacing `as` Assertions

If your test files contain `as Type` assertions, replace them with `fromPartial()` to maintain type safety.

Handling Intentionally Wrong Data

For tests that require passing incorrect types, use `fromAny()` to keep your code type-checked while testing error handling.

How to install Migrate to Shoehorn

View source

1. Install with the skills CLI

npx skills add mattpocock/skills/migrate-to-shoehorn --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mattpocock

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

FunctionUse 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

Frequently asked questions about Migrate to Shoehorn

Similar skills