Skills mattpocock skills

migrate-to-shoehorn

Use it when:
Your tests use `as` assertions to pass partial or deliberately wrong data to typed functions.
It does:
Installs shoehorn and replaces `as Type` with fromPartial() and `as unknown as Type` with fromAny() in your test files.
You get:
Tests that pass only the properties they need and still type-check, confirmed by a type check at the end.
Keeps:
shoehorn out of production code: it touches test files only.
From:
Matt Pocock, who maintains shoehorn.
Runs:
By itself when you mention shoehorn, want `as` out of your tests, or need partial test data.

TL;DR

shoehorn (@total-typescript/shoehorn) is a small library for test data. A test often has to pass a large object, such as a request, when it only cares about one property, so people fake the whole object or silence TypeScript with `as`. With shoehorn, fromPartial() takes a partial object and still type-checks, fromAny() passes intentionally wrong data while keeping autocomplete, and fromExact() demands the full object until you swap it for fromPartial(). The agent first asks which test files have troublesome assertions and whether you need wrong data for error tests. It then installs the package with npm, searches .test.ts and .spec.ts files for `as` assertions, swaps each for the matching function, adds the imports and runs a type check.

Summarizes the skill at 4ae2317.

npx skills add https://github.com/mattpocock/skills --skill migrate-to-shoehorn
Total Downloads
522,700 on skills.sh, Nov 9, 2026
Repo stars
318,714 mattpocock/skills
First seen
Feb 13, 2026 on skills.sh
Weekly Downloads
20.2K
-22% over the 8 weeks to Nov 9
Weekly values
Week toInstalls
Sep 2125,997
Sep 2823,103
Oct 522,681
Oct 1228,413
Oct 1925,063
Oct 2622,748
Nov 220,924
Nov 920,179
Category

Test-first work, implementation from specs, git hygiene and scope control.

Guides for frameworks, databases and SDKs, mostly from their vendors.

Everything for building software: planning, coding, debugging, design, frameworks, cloud, agents and skills.

Type

A multi-step process the agent follows: interview, debug, run a TDD loop, review.

Effect

Its own steps create or change files, git state or local tools.

Needs

Instructions only. Works in any agent that supports skills.

Publisher

A verified publisher on skills.sh, or the company or maintainer behind the product the skill operates.

Topics
Stack

SKILL.md

From mattpocock/skills at 4ae2317. Checked daily, last changed Nov 9, 2026.

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

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