Install any skill in seconds. Free to start, no credit card required.
Get Started Free →TypeScript best practices. Use when reading or editing any .ts or .tsx file.
.claude/skills/kunanonj-cursor-plugin-pstack-typescript-best-practices/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 13% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -11% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 22% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 7% | 0% |
| case-04 | ✓→✓ | = Same ✓ | -9% | 0% |
Apply the type-system-discipline principle skill first; this skill grounds it in TypeScript syntax.
| Rule | Summary | |------|---------| | Discriminated unions | Model variants with a kind literal discriminant so impossible states can't be represented. No optional-field bags. | | Branded types | Brand primitives with & { readonly __brand: "X" } so they can't be mixed up. Validate once at creation. | | unknown over any | External data is unknown. any disables type checking everywhere it touches. | | No as casts | Every as is a runtime crash waiting. Cast only after validation. | | Narrowing hierarchy | Discriminant switch > in operator > typeof/instanceof > user-defined type guard > as. | | Type guards | Must verify the claim. A lying guard is worse than as because the bug hides behind a name that says it's safe. Name them isX or hasX. | | Exhaustiveness | Inline const _exhaustive: never = x; in default arms so the compiler errors when a new variant is added. | | satisfies over as | Validates the value without widening literal types. | | Boundary validation | Validate where data crosses in; trust types inside. See the boundary-discipline principle skill. | | Schema-derived types | Reach for Pick/Omit/Parameters/ReturnType/Awaited/typeof before declaring a new interface. | | Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |
Examples: references/patterns.md.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 14,602 | 13,626 | -7% | 1 | 1 | 0% | 3,094 | 3,484 | +13% | 0 | 0 | — |
case-02 | fail→pass | 11,320 | 7,462 | -34% | 1 | 1 | 0% | 2,235 | 1,982 | -11% | 0 | 0 | — |
case-03 | fail→pass | 9,467 | 10,933 | +15% | 1 | 1 | 0% | 1,896 | 2,304 | +22% | 0 | 0 | — |
case-04 | pass→pass | 12,843 | 8,882 | -31% | 1 | 1 | 0% | 2,222 | 2,021 | -9% | 0 | 0 | — |
case-05 | pass→pass | 9,946 | 5,133 | -48% | 1 | 1 | 0% | 1,780 | 1,386 | -22% | 0 | 0 | — |
case-06 | pass→pass | 9,195 | 9,401 | +2% | 1 | 1 | 0% | 2,092 | 2,397 | +15% | 0 | 0 | — |
case-07 | pass→pass | 8,745 | 5,986 | -32% | 1 | 1 | 0% | 1,570 | 1,486 | -5% | 0 | 0 | — |
case-08 | pass→pass | 7,787 | 9,807 | +26% | 1 | 1 | 0% | 1,677 | 2,384 | +42% | 0 | 0 | — |
case-09 | pass→pass | 6,381 | 3,877 | -39% | 1 | 1 | 0% | 1,391 | 1,145 | -18% | 0 | 0 | — |
case-10 | pass→pass | 4,776 | 3,489 | -27% | 1 | 1 | 0% | 935 | 1,108 | +19% | 0 | 0 | — |
case-11 | pass→pass | 8,189 | 5,942 | -27% | 1 | 1 | 0% | 1,696 | 1,676 | -1% | 0 | 0 | — |
case-12 | pass→pass | 13,748 | 9,901 | -28% | 1 | 1 | 0% | 2,746 | 2,296 | -16% | 0 | 0 | — |
case-13 | fail→pass | 6,763 | 4,766 | -30% | 1 | 1 | 0% | 1,278 | 1,370 | +7% | 0 | 0 | — |
case-14 | pass→pass | 4,529 | 5,196 | +15% | 1 | 1 | 0% | 918 | 1,421 | +55% | 0 | 0 | — |
case-15 | pass→pass | 14,027 | 7,023 | -50% | 1 | 1 | 0% | 2,576 | 1,667 | -35% | 0 | 0 | — |
case-16 | pass→pass | 6,247 | 2,763 | -56% | 1 | 1 | 0% | 1,275 | 926 | -27% | 0 | 0 | — |
case-17 | pass→pass | 7,398 | 4,691 | -37% | 1 | 1 | 0% | 1,582 | 1,341 | -15% | 0 | 0 | — |
case-18 | pass→pass | 10,318 | 9,191 | -11% | 1 | 1 | 0% | 1,972 | 2,142 | +9% | 0 | 0 | — |
case-19 | pass→pass | 7,411 | 4,091 | -45% | 1 | 1 | 0% | 1,477 | 1,182 | -20% | 0 | 0 | — |
case-20 | pass→pass | 4,746 | 4,698 | -1% | 1 | 1 | 0% | 911 | 1,258 | +38% | 0 | 0 | — |
case-21 | pass→pass | 10,017 | 11,221 | +12% | 1 | 1 | 0% | 1,946 | 2,594 | +33% | 0 | 0 | — |
case-22 | pass→pass | 10,597 | 10,448 | -1% | 1 | 1 | 0% | 2,154 | 2,436 | +13% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +18 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.