Synthèse automatique
Migre les assertions `as` des fichiers de test TypeScript vers les helpers de `@total-typescript/shoehorn` (`fromPartial`, `fromAny`, `fromExact`) sans modifier le code de production.
Points forts
- Distingue clairement les données partielles (`fromPartial`) des données volontairement invalides (`fromAny`).
- Rappelle d'installer la dépendance avec le gestionnaire de paquets déjà utilisé par le dépôt, sans en changer.
- Fournit une recherche ciblée avec ripgrep et impose une revue manuelle assertion par assertion.
- Limite explicitement la migration aux fichiers `*.test.*` et `*.spec.*`.
Limites
- Ne traite pas les assertions situées dans le code source ou de production.
- Ajoute une dépendance de développement au dépôt cible.
- Ne corrige pas les problèmes de typage sous-jacents qui ont motivé les assertions.
- Suppose un projet TypeScript et l'utilisation de ripgrep pour identifier les candidats.
À utiliser lorsqu'un fichier de test TypeScript contient des assertions `as` ou `as unknown as` pour des fixtures partielles ou des données invalides.
À éviter pour assouplir le typage du code de production ou pour migrer des assertions hors des fichiers de test.
Analyse de sécurité
PrudenceThe skill is for legitimate test-code migration and does not contain destructive, exfiltrating, or obfuscated actions. However, it does instruct the agent to install a dependency and execute package-manager and search commands, so it warrants caution rather than safe.
- •Instructs installing a third-party npm package and running shell commands (bun add, pnpm add, npm install, rg, bun test/typecheck), which involves network access and package execution.
Exemples
Migrate the `as` assertions in my TypeScript test files to @total-typescript/shoehorn. Find candidates with ripgrep, check the lockfile for the package manager, then replace them one at a time with fromPartial or fromAny based on intent.In src/user.test.ts, replace `{ body: { id: 123 } } as unknown as Request` with the appropriate @total-typescript/shoehorn helper while keeping the invalid-data intent explicit.Add @total-typescript/shoehorn as a dev dependency using the package manager indicated by the repo lockfile, then migrate only *.test.tsx files that use partial object assertions.name: migrate-to-shoehorn
description: Migrate test files from as assertions to @total-typescript/shoehorn helpers. Use when tests need partial fixtures, intentionally invalid data, or safer replacements for TypeScript assertions.
migrate-to-shoehorn
Use this skill to migrate test code only from TypeScript as assertions to @total-typescript/shoehorn helpers.
Shoehorn is for tests, fixtures, and test-only helpers. Do not recommend it for production or source files, and do not add @total-typescript/shoehorn imports outside *.test.* or *.spec.* files.
When To Use
- A test creates a large object but only needs a few properties.
- A test uses
value as Typeto satisfy a function, component, or hook signature. - A test intentionally passes invalid data and currently uses
value as unknown as Type. - A fixture needs a temporary full-shape wrapper while it is being migrated.
Do not use this skill to loosen production typing. If the assertion is in source code, fix the domain type, parser, or test boundary instead.
Install
Install Shoehorn only when the target repository does not already depend on it, and use the package manager already used by that repository:
# bun.lock or bun.lockb
bun add -d @total-typescript/shoehorn
# pnpm-lock.yaml
pnpm add -D @total-typescript/shoehorn
# yarn.lock
yarn add -D @total-typescript/shoehorn
# package-lock.json or npm-shrinkwrap.json
npm install --save-dev @total-typescript/shoehorn
Do not switch package managers. If multiple lockfiles exist, ask which package manager owns the repo before installing.
Find Candidate Tests
Search only test files and review every result manually:
rg "\bas\s+[A-Z][A-Za-z0-9_$]*(<[^>]+>)?" --glob "*.{test,spec}.{ts,tsx}"
rg "\bas\s+unknown\s+as\s+" --glob "*.{test,spec}.{ts,tsx}"
Avoid broad replacements. Migrate one assertion at a time so the new helper matches the test intent.
Migration Patterns
value as Type -> fromPartial(value)
Use fromPartial() when the test supplies a subset of a larger type and the supplied properties should still type-check.
Before:
getUser({ body: { id: "123" } } as Request);
After:
import { fromPartial } from "@total-typescript/shoehorn";
getUser(fromPartial({ body: { id: "123" } }));
If TypeScript cannot infer the target from context, provide the target type explicitly:
const request = fromPartial<Request>({
body: { id: "123" },
});
value as unknown as Type -> fromAny(value)
Use fromAny() only when the test intentionally passes invalid data, such as exercising validation or error handling paths. This replaces double assertions while keeping the intent visible.
Before:
getUser({ body: { id: 123 } } as unknown as Request);
After:
import { fromAny } from "@total-typescript/shoehorn";
getUser(fromAny({ body: { id: 123 } }));
Full-Shape Fixtures -> fromExact(value)
Use fromExact() as a temporary helper when a fixture already has the full shape and you want to keep the migration mechanical before deciding whether it can be reduced.
import { fromExact } from "@total-typescript/shoehorn";
const request = fromExact<Request>({
body: { id: "123" },
headers: {},
cookies: {},
});
Prefer fromPartial() once the test only needs a subset of the object. fromExact() should not become a dumping ground for unnecessary fixture fields.
Workflow
- Confirm the target files are tests (
*.test.ts,*.test.tsx,*.spec.ts, or*.spec.tsx). - Check whether
@total-typescript/shoehornis already installed. - If installation is needed, use the existing package manager from the repo lockfile.
- Search for candidate assertions with the
rgcommands above. - Replace
value as TypewithfromPartial(value)when the supplied data is partial but type-valid. - Replace
value as unknown as TypewithfromAny(value)when the supplied data is intentionally invalid. - Use
fromExact()only for full-shape fixtures or short-lived migration steps. - Add the narrowest import needed from
@total-typescript/shoehorn. - Run the target test file, the repo test suite, and the typecheck command.
Validation
After migrating, run the repository's normal checks. For a Bun-based repo, use:
bun run typecheck
bun test
Verify Shoehorn remains test-only:
rg "@total-typescript/shoehorn"
rg "@total-typescript/shoehorn" --glob "!*.{test,spec}.{ts,tsx}"
The first command should show only intended test imports. The second command should return no source-file imports; if it finds any, remove Shoehorn from production/source code and fix the underlying type boundary instead.
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/migrate-to-shoehorn-mrwak9lw' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/migrate-to-shoehorn-mrwak9lw/download' --output '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md.part' && mv '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md.part' '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md' && test -s '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/migrate-to-shoehorn' && cp -R '.skill-downloads/migrate-to-shoehorn-mrwak9lw' '.claude/skills/migrate-to-shoehorn'Cursor
test -f '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md' && test -s '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/migrate-to-shoehorn' && cp -R '.skill-downloads/migrate-to-shoehorn-mrwak9lw' '.cursor/skills/migrate-to-shoehorn'Codex
test -f '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md' && test -s '.skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/migrate-to-shoehorn' && cp -R '.skill-downloads/migrate-to-shoehorn-mrwak9lw' '.agents/skills/migrate-to-shoehorn'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/migrate-to-shoehorn-mrwak9lw'openskills read 'migrate-to-shoehorn-mrwak9lw'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/migrate-to-shoehorn-mrwak9lw/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Comparaison de performances ClickHouse
Testing
Évaluez les résultats de tests de performance ClickHouse, analysez les régressions de PR, comparez avec l'historique et vérifiez la fiabilité des mesures.
Analyse des rapports de performance CI
Testing
Analyse les rapports de comparaison de performance CI pour une PR ClickHouse. Recoupe l'historique master pour distinguer les vraies régressions des tests instables.
Méthode Santa
Testing
Vérification adversarial multi-agents avec deux réviseurs indépendants. La sortie est vérifiée deux fois et corrigée itérativement jusqu'à ce que les deux acceptent avant publication.