← Matt Skills CuratedCONTENT HISTORY

Update to Matt Skills Curated

Snapshot Sep 30, 2026 · 23:14 UTC · version 1.1.0

Collection source: not recorded for this historical snapshot.

WHAT CHANGED · RULE-BASED ANALYSIS

First saved snapshot

No earlier snapshot is available to establish a change.

Compare saved observations

Download comparison JSON
Full technical diff · 0 changed fields
Full snapshot data
{
  "description": "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.",
  "included_files": [
    {
      "relative_path": "agents/openai.yaml",
      "size_in_bytes": 110
    }
  ],
  "name": "migrate-to-shoehorn",
  "skill_md_contents": "---\nname: migrate-to-shoehorn\ndescription: \"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.\"\n---\n\n# Migrate to Shoehorn\n\nSafely migrate unsafe, brittle TypeScript test-fixture typecasts (`as Type`, `as unknown as Type`) to intention-revealing, type-safe helpers from `@total-typescript/shoehorn`.\n\n---\n\n## Core Invariants\n\n1. **Test-Code Isolation Strictly**: `@total-typescript/shoehorn` is strictly for test suites and test fixtures; NEVER import or use shoehorn helpers in production application code.\n2. **Intent-Specific Helper Mapping**:\n   - Partial objects where only some keys matter $\\rightarrow$ `fromPartial(obj)`\n   - Intentionally invalid/wrong types for error testing $\\rightarrow$ `fromAny(obj)`\n   - Fully populated mocks $\\rightarrow$ `fromExact(obj)`\n3. **Preserve Autocomplete & Refactor Safety**: Maintain TypeScript type inference and IDE autocompletion across all migrated test fixtures.\n4. **Automated Discovery & Regex Caution**: Discover test casts via targeted grep (`as [A-Z]`); avoid blind global replacements that might alter production code.\n5. **Mandatory Typecheck Green**: Every migration pass must conclude with a green `tsc --noEmit` or equivalent repository typecheck command.\n\n---\n\n## Architecture & Map of Content (MOC)\n\n```\n[ Unsafe Test Casts (`as Type`, `as unknown as`) ] ──► [ Intent Classification ] ──► [ Replace with Shoehorn Helper ] ──► [ Verify Typecheck ]\n```\n\n| Unsafe Pattern | Shoehorn Replacement | Target Scenario |\n|---|---|---|\n| `{ id: \"123\" } as User` | `fromPartial<User>({ id: \"123\" })` | Test cares only about `id` in large type |\n| `{ id: 123 } as unknown as User` | `fromAny<User>({ id: 123 })` | Testing runtime validation on bad input |\n| `completeMock as User` | `fromExact<User>(completeMock)` | Explicit complete mock structure |\n\n---\n\n## Step-by-Step Procedure (TWI)\n\n### Step 1: Install Dependency with Detected Package Manager\n- **Action**: Install `@total-typescript/shoehorn` as a devDependency (`bun add -d`, `pnpm add -D`, `npm i -D`).\n- **Key Point**: Check that it is added strictly to `devDependencies`.\n- **Why**: Prevent bundling test-helper utilities into production builds.\n\n### Step 2: Locate Unsafe Casts in Test Files\n- **Action**: Search test files for type assertion smells:\n  ```bash\n  grep -rnE \" as [A-Z]| as unknown as \" --include=\"*.test.ts\" --include=\"*.spec.ts\" src/\n  ```\n- **Key Point**: Inspect surrounding context to determine whether the fixture is a partial mock or an intentionally invalid payload.\n- **Inline Checklist**:\n  - [ ] Only test files (`*.test.ts`, `*.spec.ts`) targeted\n  - [ ] Zero production source files modified\n  - [ ] Intent classified per fixture (`fromPartial` vs. `fromAny`)\n\n### Step 3: Replace Casts and Import Helpers\n- **Action**: Replace `as Type` with `fromPartial(...)` and `as unknown as Type` with `fromAny(...)`, adding `import { fromPartial, fromAny } from \"@total-typescript/shoehorn\"`.\n- **Why**: `fromPartial` documents that missing fields are deliberate, avoiding false compiler errors while retaining type intelligence.\n\n### Step 4: Run Typecheck & Test Suite\n- **Action**: Execute the project's typecheck command (e.g. `bun run typecheck`, `pnpm check`, `tsc --noEmit`) and run the test suite.\n- **Key Point**: Verify that tests pass and TypeScript emits 0 errors.\n- **Why**: Ensures no subtle type contract regressions were introduced during migration.\n\n---\n\n## Anti-Rationalization Guardrails\n\n| Tempting Rationalization | Binding Rule | Engineering Rationale |\n|---|---|---|\n| *\"Use shoehorn in production helpers to bypass strict types.\"* | **Forbidden. Test code only.** | Bypassing types in production creates silent runtime TypeError crashes. |\n| *\"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. |\n| *\"Skip running typecheck after updating test files.\"* | **Mandatory green typecheck verification.** | Minor syntax errors or missing generic arguments break CI builds. |\n\n"
}

SHA-256 of public snapshot: 5e0a615c8b7e7c368952e62967694cddaaa9e688b38fde7e3332228bc08bcb15