CtrlK
BlogDocsLog inGet started
Tessl Logo

mcollina/typescript-magician

Designs complex generic types, refactors `any` types to strict alternatives, creates type guards and utility types, and resolves TypeScript compiler errors. Use when the user asks about TypeScript (TS) types, generics, type inference, type guards, removing `any` types, strict typing, type errors, `infer`, `extends`, conditional types, mapped types, template literal types, branded/opaque types, or utility types like `Partial`, `Record`, `ReturnType`, and `Awaited`.

87

1.16x
Quality

95%

Does it follow best practices?

Impact

76%

1.16x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

Type-Safe Feature Flag System

Problem/Feature Description

A SaaS product team manages a growing list of feature flags used to control which features are visible to which customer tiers. Currently, the flag registry is a plain JavaScript object and the lookup function returns boolean | undefined, giving no compile-time safety — developers frequently misspell flag names or look up flags that don't exist. The team wants a TypeScript-native flag system where:

  1. The flag registry is defined once at startup, and the valid flag names are automatically derived from whatever is registered — no manual union type to maintain.
  2. Looking up a flag by a valid name returns the correct type for that flag's value; looking up a nonexistent name is a compile-time error.
  3. The system also needs to support "flag groups" — arrays of related flag names — where downstream code can work with the group's element types as a union, and where the group's membership is preserved as literal types rather than widened to string[].

The team's TypeScript toolchain is on version 5.2, so modern language features are available. However, they would also like the implementation documented with a fallback approach that works on older TypeScript versions, for the benefit of other teams that haven't upgraded.

Output Specification

Produce the following files:

  • feature-flags.ts — the flag registry and lookup implementation
  • type-tests.ts — compile-time tests verifying:
    • That valid flag names are accepted and return correctly typed values
    • That invalid flag names produce type errors (use @ts-expect-error)
    • That literal element types are preserved in flag groups (not widened to string)
  • README.md — explains the two approaches (modern and fallback), the type-level mechanisms used, and when each technique applies

evals

scenario-1

criteria.json

task.md

SKILL.md

tile.json