migrate-to-shoehorn

migrate-to-shoehorn is a skill for Claude Code, Codex from devcxl/mattpocock-skills-zh. It costs 53 tokens per session (831 once invoked), scanned A, original, MIT.

A testing utility that replaces TypeScript's `as` type assertions with Shoehorn helpers for creating partial or intentionally invalid test data.

In plain words
What is it for?
Migrating test code from `as Type` to `fromPartial()` and from `as unknown as Type` to `fromAny()`. It is intended only for tests, not production code.
Why use it?
It lets tests provide only the fields they need while preserving type checking, without forcing developers to fabricate large objects or use double assertions.

Skill for Claude CodeCodex

Written for Claude Code and Codex: shipped in a Claude Code plugin, but also agents/openai.yaml present.

Part of the mattpocock-skills plugin — 37 skills shipped together

Good fit Migrating test code from as Type to fromPartial() and from as unknown as Type to fromAny(). It is intended only for tests, not production code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/devcxl/mattpocock-skills-zh/migrate-to-shoehorn
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add devcxl/mattpocock-skills-zh --skill migrate-to-shoehorn
Clone the repo
git clone --depth 1 https://github.com/devcxl/mattpocock-skills-zh

Made for: Claude Code, Codex.

Or install mattpocock-skills, the plugin that ships this one along with the rest of its 37 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for migrate-to-shoehorn

README.md
[![agentmods](https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/migrate-to-shoehorn/github.svg)](https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/migrate-to-shoehorn)
Your own site
<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/migrate-to-shoehorn"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/migrate-to-shoehorn/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for migrate-to-shoehorn

Your own site · 80×15
<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/migrate-to-shoehorn"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/migrate-to-shoehorn.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 831 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00053 $0.00831
Opus 5 $0.00026 $0.00415
Sonnet 5 $0.00011 $0.00166
Haiku 4.5 $0.00005 $0.00083

Measured 12d ago against content hash f62fd103c644, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

migrate-to-shoehorn scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/misc/migrate-to-shoehorn/SKILL.md · 119 lines

What it actually says

迁移到 Shoehorn

为什么使用 shoehorn?

shoehorn 让你在测试中传递部分数据,同时保持 TypeScript 类型正确。它用类型安全的替代方案取代了 as 断言。

仅限测试代码。 切勿在生产代码中使用 shoehorn。

as 在测试中的问题:

  • 习惯上被训练不要使用它
  • 必须手动指定目标类型
  • 双重 asas unknown as Type)用于传递故意错误的数据

安装

npm i @total-typescript/shoehorn

迁移模式

大型对象,只用到少数属性

迁移前:

type Request = {
  body: { id: string };
  headers: Record<string, string>;
  cookies: Record<string, string>;
  // ...还有 20 个属性
};

it("gets user by id", () => {
  // 只关心 body.id,但必须伪造整个 Request
  getUser({
    body: { id: "123" },
    headers: {},
    cookies: {},
    // ...伪造所有 20 个属性
  });
});

迁移后:

import { fromPartial } from "@total-typescript/shoehorn";

it("gets user by id", () => {
  getUser(
    fromPartial({
      body: { id: "123" },
    }),
  );
});

as TypefromPartial()

迁移前:

getUser({ body: { id: "123" } } as Request);

迁移后:

import { fromPartial } from "@total-typescript/shoehorn";

getUser(fromPartial({ body: { id: "123" } }));

as unknown as TypefromAny()

迁移前:

getUser({ body: { id: 123 } } as unknown as Request); // 故意传错类型

迁移后:

import { fromAny } from "@total-typescript/shoehorn";

getUser(fromAny({ body: { id: 123 } }));

各函数的适用场景

函数 使用场景
fromPartial() 传递部分数据,仍能通过类型检查
fromAny() 传递故意错误的数据(保留自动补全)
fromExact() 强制传入完整对象(后续可替换为 fromPartial)

工作流程

  1. 收集需求 — 询问用户:

    • 哪些测试文件中的 as 断言造成了问题?
    • 是否涉及大型对象,只有部分属性是重要的?
    • 是否需要传递故意错误的数据用于错误测试?
  2. 安装并迁移

    • 安装:npm i @total-typescript/shoehorn
    • 查找含有 as 断言的测试文件:grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"
    • as Type 替换为 fromPartial()
    • as unknown as Type 替换为 fromAny()
    • @total-typescript/shoehorn 添加 import
    • 运行类型检查以验证
Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 119 lines · 53 tokens per session scan A f62fd103c644

Subscribe to this mod's changes

migrate-to-shoehorn is a skill published in the GitHub repository devcxl/mattpocock-skills-zh (343 stars, last pushed 7d ago), licensed MIT. It adds 53 tokens to every session and 831 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

verification-before-completion

A checklist for verifying work before claiming that it is finished, fixed, built, tested, or ready to submit. It requires fresh command output and evidence for each claim.

jnMetaCode/superpowers-zh · 50 tokens

writing-skills

A guide for creating and testing reusable instructions for AI agents, called skills. It applies test-driven development, or TDD—the practice of writing tests before implementation—to instruction documents.

jnMetaCode/superpowers-zh · 23 tokens

test-driven-development

Test-driven development, or TDD, is a way to build software by writing a test that fails, adding the smallest code that makes it pass, and then cleaning up the code. These instructions require that process for features, bug fixes, refactors, and behavior changes.

jnMetaCode/superpowers-zh · 20 tokens

dsh-webapp-testing

Verify a local web application's rendered browser behavior with console, network, server, and focused regression-test evidence.

hackerFish/awesome-dsh-skills · 27 tokens

dsh-test-first

A test-first process for fixing bugs or adding features: write a failing test, make the smallest change that passes it, then improve the code.

hackerFish/awesome-dsh-skills · 28 tokens

bruno-api-testing

Create, run, and maintain API test collections using Bruno (OpenCollection YAML format and legacy Bru format). Use when the user wants to: (1) create a Bruno API test collection from scratch or from OpenAPI/Swagger specs, (2) write API request files with tests and assertions, (3) run API tests using bru CLI, (4)…

jim60105/copilot-prompt · 186 tokens