migrate-to-shoehorn
Skill8 starsChanged 2 months agoMITView on GitHub
Migrate unsafe TypeScript test assertions to @total-typescript/shoehorn with explicit fixture intent. Use when test files contain unsafe `as` or `as unknown as` typecasts, when mock fixtures break under typechecking, or when modernizing test typing — even if the user says \"fix test type assertions\". Do NOT use for production code types.
- Installs packages
We split this skill into the rules it gives an agent
4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 75 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Mandatory Typecheck Green: Every migration pass must conclude with a green tsc --noEmit or equivalent repository typecheck command.
- Very specific: line 43
Key Point: Check that it is added strictly to devDependencies.
- Distinctive: line 47
Action: Search test files for type assertion smells:
- Distinctive: line 63
Key Point: Verify that tests pass and TypeScript emits 0 errors.
“Common” is measured: kept by at least 6 in 10 of the 75 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Migrate to Shoehorn
Safely migrate unsafe, brittle TypeScript test-fixture typecasts (as Type, as unknown as Type) to intention-revealing, type-safe helpers from @total-typescript/shoehorn.
Core Invariants
- Test-Code Isolation Strictly:
@total-typescript/shoehornis strictly for test suites and test fixtures; NEVER import or use shoehorn helpers in production application code. - Intent-Specific Helper Mapping:
- Partial objects where only some keys matter $\rightarrow$
fromPartial(obj) - Intentionally invalid/wrong types for error testing $\rightarrow$
fromAny(obj) - Fully populated mocks $\rightarrow$
fromExact(obj)
- Partial objects where only some keys matter $\rightarrow$
- Preserve Autocomplete & Refactor Safety: Maintain TypeScript type inference and IDE autocompletion across all migrated test fixtures.
- Automated Discovery & Regex Caution: Discover test casts via targeted grep (
as [A-Z]); avoid blind global replacements that might alter production code. - Mandatory Typecheck Green: Every migration pass must conclude with a green
tsc --noEmitor equivalent repository typecheck command.
Architecture & Map of Content (MOC)
[ Unsafe Test Casts (`as Type`, `as unknown as`) ] ──► [ Intent Classification ] ──► [ Replace with Shoehorn Helper ] ──► [ Verify Typecheck ]| Unsafe Pattern | Shoehorn Replacement | Target Scenario |
{ id: "123" } as User | fromPartial<User>({ id: "123" }) | Test cares only about id in large type |
{ id: 123 } as unknown as User | fromAny<User>({ id: 123 }) | Testing runtime validation on bad input |
completeMock as User | fromExact<User>(completeMock) | Explicit complete mock structure |
Step-by-Step Procedure (TWI)
Step 1: Install Dependency with Detected Package Manager
- Action: Install
@total-typescript/shoehornas a devDependency (bun add -d,pnpm add -D,npm i -D). - Key Point: Check that it is added strictly to
devDependencies. - Why: Prevent bundling test-helper utilities into production builds.
Step 2: Locate Unsafe Casts in Test Files
- Action: Search test files for type assertion smells:
grep -rnE " as [A-Z]| as unknown as " --include="*.test.ts" --include="*.spec.ts" src/ - Key Point: Inspect surrounding context to determine whether the fixture is a partial mock or an intentionally invalid payload.
- Inline Checklist:
- Only test files (
*.test.ts,*.spec.ts) targeted - Zero production source files modified
- Intent classified per fixture (
fromPartialvs.fromAny)
- Only test files (
Step 3: Replace Casts and Import Helpers
- Action: Replace
as TypewithfromPartial(...)andas unknown as TypewithfromAny(...), addingimport { fromPartial, fromAny } from "@total-typescript/shoehorn". - Why:
fromPartialdocuments that missing fields are deliberate, avoiding false compiler errors while retaining type intelligence.
Step 4: Run Typecheck & Test Suite
- Action: Execute the project's typecheck command (e.g.
bun run typecheck,pnpm check,tsc --noEmit) and run the test suite. - Key Point: Verify that tests pass and TypeScript emits 0 errors.
- Why: Ensures no subtle type contract regressions were introduced during migration.
Anti-Rationalization Guardrails
| Tempting Rationalization | Binding Rule | Engineering Rationale |
| "Use shoehorn in production helpers to bypass strict types." | Forbidden. Test code only. | Bypassing types in production creates silent runtime TypeError crashes. |
"Use fromAny everywhere because it's easier than fromPartial." | Use fromPartial for valid partials; fromAny only for invalid types. | Overusing fromAny disables autocomplete and typechecking benefits. |
| "Skip running typecheck after updating test files." | Mandatory green typecheck verification. | Minor syntax errors or missing generic arguments break CI builds. |
Other versions84 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 84
- mattpocock/skills★ 309ksame name
- vinvcn/mattpocock-skills-zh-CN★ 5.5ksame name
- devcxl/mattpocock-skills-zh★ 522same name
- mxyhi/ok-skills★ 509same name
- amazingloft999-droid/mattpocock-skills★ 422same name
- InditexTech/weavejs★ 266same name
- loulanyue/skills★ 231same name
- tt-a1i/matt-skills-with-to-goal★ 192same name
- aurorasoft2/Matt_Pocock_Skills★ 133same name
- VisualxIntelligence/mattpocok-skills★ 55same name
74 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use loop-me, claude-handoff and 5 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
RoentekSkillloop-me
Grill me about specs for the workflows I want to build, within this workspace.
Also in 46 projects that use this
ryotaroh180105Skillclaude-handoff
Hand the current conversation off to a fresh background agent that picks up the work immediately.
Also in 35 projects that use this
kennethkeimSkillubiquitous-language
Extract a DDD-style ubiquitous language glossary from the current conversation, flagging ambiguities and proposing canonical terms. Saves to UBIQUITOUS_LANGUAGE.md. Use when user wants to define domain terms, build a glossary, harden terminology, create a ubiquitous language, or mentions "domain model" or "DDD".
Also in 31 projects that use this
boyingliu01Skillbatch-grill-me
A relentless interview that asks every frontier question at once, round by round. Thin alias of `grilling` (#540) — upstream mattpocock/skills absorbed this protocol into grilling; XP-Gate keeps this name as the sprint-flow Phase 2 entry point so orchestration docs stay stable.
Also in 6 projects that use this
FabienDehopreSkilldecision-mapping
Turn a loose idea into a sequenced map of investigation tickets, then drive them to resolution one at a time.
Also in 4 projects that use this
GoogleSkillask-matt
Ask which skill or flow fits your situation. A router over the skills in this repo.
Also in 33 projects that use this
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ai-data-remediationSkill
- ai-engineeringSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- engineering-workflow-guideSkill
- git-safety-guardrailsSkill
- goalSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- j-spaceSkill
- ml-best-practicesSkill
- prototypeSkill
- researchSkill
- resolving-merge-conflictsSkill
- retroSkill
- scaffold-exercisesSkill
- setup-engineering-workflowsSkill
- setup-pre-commitSkill
- setup-ts-deep-modulesSkill
- skill-conductorSkill
- tddSkill
- teachSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- wait-whatSkill
- wayfinderSkill
- wizardSkill
- workflow-designerSkill
- writing-beatsSkill
- writing-for-agentsSkill
- writing-fragmentsSkill
- writing-shapeSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

