Migrate To Shoehorn
Matt PocockCommunityCreated by Matt Pocock
- Skill
- Workflow
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow for replacing unsafe TypeScript type assertions (as) in test files with the @total-typescript/shoehorn library. It helps developers manage partial test data and intentionally incorrect data structures without resorting to dangerous type casting, ensuring better type safety and maintainability in test suites.
What it does
- Identifies existing as-assertions within test files.
- Replaces standard as-casting with fromPartial for partial object definitions.
- Replaces double-as casting with fromAny for intentionally invalid test data.
- Guides the installation and integration of the shoehorn library.
- Provides a systematic approach to cleaning up test codebases.
When to use it
- When test files are cluttered with unsafe as-assertions.
- When dealing with large objects where only a few properties are relevant for a test.
- When you need to pass intentionally incorrect data to test error handling.
- When you want to improve type safety in your test suite without manual casting.
Advantages
- Eliminates the need for manual type casting in tests.
- Maintains type safety even when passing partial data.
- Improves readability by removing verbose as-assertions.
- Supports intentionally wrong data while preserving IDE autocomplete.
Usage examples
- “Migrate my test files to use shoehorn instead of as-assertions.”
- The agent will scan your test files, install the necessary package, and replace your existing as-assertions with fromPartial or fromAny as appropriate.
- “How do I handle large objects in my tests without using as?”
- The agent will guide you to use fromPartial from the shoehorn library to define only the necessary properties while keeping the test type-safe.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/mattpocock/migrate-to-shoehorn/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip migrate-to-shoehorn.zip -d .agents/skills
Documentation by Matt Pocock
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/shoehornMigration 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 purposeAfter:
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
Gather requirements - ask user:
What test files have
asassertions causing problems?Are they dealing with large objects where only some properties matter?
Do they need to pass intentionally wrong data for error testing?
Install and migrate:
[ ] Install:
npm i @total-typescript/shoehorn[ ] Find test files with
asassertions:grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"[ ] Replace
as TypewithfromPartial()[ ] Replace
as unknown as TypewithfromAny()[ ] Add imports from
@total-typescript/shoehorn[ ] Run type check to verify
Files
- ATTRIBUTION.mdAdded by AutoGineer872 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md2.7 KiB
- agents/openai.yaml110 B
ATTRIBUTION.md
Attribution
This folder is an unmodified copy of the Agent Skill "migrate-to-shoehorn", distributed by AutoGineer (https://autogineer.com/agent-skills).
Commit: 4ae2317ddb22b046e26455e4f9c9b3aaaf62212d
Created by: Matt Pocock (https://github.com/mattpocock)
Publisher: Matt Pocock (https://github.com/mattpocock)
Licence: MIT License (https://github.com/mattpocock/skills/blob/4ae2317ddb22b046e26455e4f9c9b3aaaf62212d/LICENSE)
Licence evidence: repository licence LICENSE
Retrieved: 2026-11-07
The skill's own files are unmodified copies. AutoGineer is not affiliated with or endorsed by the author or the publisher.
Files added by AutoGineer
ATTRIBUTION.md: this file, written by AutoGineer
LICENSE: copied from LICENSE
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Matt Pocock
- Publisher
- Matt Pocock (Community)
- Source
- mattpocock/skills · skills/misc/migrate-to-shoehorn · commit 4ae2317
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Matt Pocock.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download migrate-to-shoehorn.zip