migrate-to-shoehorn

द्वारा mattpocock

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.

npx skills add https://github.com/mattpocock/skills --skill migrate-to-shoehorn

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 TypefromPartial()

Before:

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

After:

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

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

as unknown as TypefromAny()

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

mattpocock की और Skills

improve-codebase-architecture
mattpocock
कोडबेस में गहन अवसर खोजें, जो CONTEXT.md में डोमेन भाषा और docs/adr/ में निर्णयों से प्रेरित हो। इसका उपयोग तब करें जब उपयोगकर्ता आर्किटेक्चर में सुधार करना चाहता हो, रीफैक्टरिंग के अवसर खोजना चाहता हो, कसकर जुड़े मॉड्यूल को समेकित करना चाहता हो, या कोडबेस को अधिक परीक्षण योग्य और AI-नेविगेट करने योग्य बनाना चाहता हो।
developmentcode-reviewapi
tdd
mattpocock
लाल-हरा-पुनर्संरचना चक्र के साथ परीक्षण-संचालित विकास। इसका उपयोग तब करें जब उपयोगकर्ता TDD का उपयोग करके सुविधाएँ बनाना या बग ठीक करना चाहता है, "लाल-हरा-पुनर्संरचना" का उल्लेख करता है, एकीकरण परीक्षण चाहता है, या परीक्षण-प्रथम विकास के लिए पूछता है।
developmenttesting
handoff
mattpocock
वर्तमान वार्तालाप को संक्षिप्त करके एक हैंडऑफ दस्तावेज़ तैयार करें, जिसे कोई अन्य एजेंट आगे ले सके।
communicationproject-managementdocument
prototype
mattpocock
एक प्रयोगात्मक प्रोटोटाइप बनाएं ताकि डिज़ाइन को अंतिम रूप देने से पहले उसे विकसित किया जा सके। दो शाखाओं के बीच मार्ग बनाएं — एक चलाने योग्य टर्मिनल ऐप जो स्थिति/व्यावसायिक-तर्क प्रश्नों के लिए हो, या एक मार्ग से टॉगल करने योग्य कई मौलिक रूप से भिन्न UI विविधताएँ। इसका उपयोग तब करें जब उपयोगकर्ता प्रोटोटाइप बनाना चाहता है, डेटा मॉडल या स्टेट मशीन की जाँच करना चाहता है,
developmentdesigncreative
triage
mattpocock
ट्राइएज भूमिकाओं द्वारा संचालित स्टेट मशीन के माध्यम से मुद्दों का ट्राइएज करें। उपयोग तब करें जब उपयोगकर्ता कोई मुद्दा बनाना चाहता हो, मुद्दों का ट्राइएज करना चाहता हो, आने वाले बग या फीचर अनुरोधों की समीक्षा करनी हो, AFK एजेंट के लिए मुद्दे तैयार करने हों, या मुद्दा वर्कफ़्लो प्रबंधित करना हो।
developmentproject-managementcommunication
obsidian-vault
mattpocock
ऑब्सिडियन वॉल्ट में विकिलिंक और इंडेक्स नोट्स के साथ नोट्स खोजें, बनाएं और प्रबंधित करें। जब उपयोगकर्ता ऑब्सिडियन में नोट्स ढूंढना, बनाना या व्यवस्थित करना चाहे तब उपयोग करें।
productivitydocument
edit-article
mattpocock
लेखों के अनुभागों को पुनर्गठित करके, स्पष्टता में सुधार करके और गद्य को संक्षिप्त बनाकर उन्हें संपादित और बेहतर बनाएं। इसका उपयोग तब करें जब उपयोगकर्ता किसी लेख के मसौदे को संपादित, संशोधित या बेहतर बनाना चाहता हो।
documentcreative
writing-great-skills
mattpocock
कौशल को अच्छी तरह लिखने और संपादित करने का संदर्भ — वह शब्दावली और सिद्धांत जो कौशल को पूर्वानुमेय बनाते हैं।
documentdevelopment