SkillAgentSearch skills...

migrate-to-shoehorn

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

Install / Use

npx skills add mattpocock/skills --skill migrate-to-shoehorn

Installs into whichever agent you are using.

About this skill
📄

SKILL.md

Installable skill definition

Quality Score

87/100

Supported Platforms

Universal

Our assessment of migrate-to-shoehorn

migrate-to-shoehorn scores 87/100 on our quality scale, 367th of 1,751 Development & Engineering skills we index (top 21%).

Its SKILL.md is 2.7 KB long, well organised into 9 sections with 7 code examples: a solid amount of guidance for an agent.

With 268,790 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
26/30
Structure
20/20
Description
12/15
Adoption
20/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated yesterday, so migrate-to-shoehorn is actively maintained.
  • It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

migrate-to-shoehorn compared with similar skills

All 4 of these similar skills score higher than migrate-to-shoehorn; compare them before choosing.

SkillScoreStarsUpdatedFormat
migrate-to-shoehorn (this skill)by mattpocock87268.8k1d agoSKILL.md
headroomby headroomlabs-ai10073.8ktodayCLAUDE.md
rufloby ruvnet10073.2ktodayCLAUDE.md
ai-job-searchby MadsLorentzen10043.9k4d agoCLAUDE.md
claude-howtoby luongnv8910041.7k5d agoCLAUDE.md

Frequently asked questions

How do I install migrate-to-shoehorn?
Run npx skills add mattpocock/skills --skill migrate-to-shoehorn. The install tabs above show the steps for each supported agent.
Which AI agents does migrate-to-shoehorn work with?
It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
Is migrate-to-shoehorn safe to use?
It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is migrate-to-shoehorn still maintained?
The repository was last updated yesterday, so migrate-to-shoehorn is actively maintained.

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

Related Skills

View on GitHub
GitHub Stars268.8k
CategoryDevelopment
Updated1d ago
Forks22.7k

Languages

Shell

Trust signals

100/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

No cautions