Migrate To Shoehorn skill for Claude

Migrate test files from `as` type assertions to @total-typescript/shoehorn.

When Claude uses it

Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.

Migrate To Shoehorn SKILL.md

The full skill file from mattpocock/skills (MIT).

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

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

How to install Migrate To Shoehorn

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit mattpocock/skills/skills/misc/migrate-to-shoehorn#main ~/.claude/skills/migrate-to-shoehorn

Codex

npx degit mattpocock/skills/skills/misc/migrate-to-shoehorn#main ~/.codex/skills/migrate-to-shoehorn

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+What does the Migrate To Shoehorn skill do?

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.

+How do I install Migrate To Shoehorn in Claude Code?

Copy the skill folder into ~/.claude/skills/migrate-to-shoehorn, for example with "npx degit mattpocock/skills/skills/misc/migrate-to-shoehorn#main ~/.claude/skills/migrate-to-shoehorn". Claude Code loads it automatically and uses it when a task matches.

+Does Migrate To Shoehorn work with ChatGPT or Codex?

Yes. Migrate To Shoehorn uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/migrate-to-shoehorn. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is Migrate To Shoehorn free?

Migrate To Shoehorn is published on GitHub by mattpocock under the MIT license, which allows free use.

Related testing & code review skills

  1. Agent Browser

    Official

    Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms,…

    vercel-labs/agent-browser★ 53k
  2. Playwright

    Official

    Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction,…

    openai/skills★ 29k
  3. Playwright Skill

    Complete browser automation with Playwright. Auto-detects dev servers, writes reusable test scripts, and supports screenshots, responsive…

    lackeyjb/playwright-skill★ 3.3k
  4. Scaffold Exercises

    Create exercise directory structures with sections, problems, solutions, and explainers that pass linting.

    mattpocock/skills★ 327k
  5. Finishing A Development Branch

    Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

    obra/superpowers★ 319k
  6. Verification Before Completion

    Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and…

    obra/superpowers★ 319k
  7. Cavecrew

    When to delegate to `cavecrew-investigator` (locate code), `cavecrew-builder` (1-2 file edit) or `cavecrew-reviewer` (diff review) instead…

    JuliusBrussee/caveman★ 121k
  8. Caveman Review

    Compressed code review - one line per finding with location, problem and fix.

    JuliusBrussee/caveman★ 121k
  9. Surgical Patch

    Fix bugs and small behavior changes at the narrowest responsible layer.

    JuliusBrussee/caveman★ 121k

See all testing & code review skills →

More skills from mattpocock

  1. Pr

    Use when writing a PR body.

    mattpocock/skills★ 327k
  2. Prototype

    Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels…

    mattpocock/skills★ 327k
  3. Retro

    Conduct a retrospective on a coding session.

    mattpocock/skills★ 327k

All skills by mattpocock →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.