TypeScript Patterns Enforcer
Claude writes TypeScript. TypeScript Patterns Enforcer checks every edit.

A Claude Code plugin that holds Claude's TypeScript to a written standard. It has three parts. An inline skill carries the rules. A review subagent handles large changes. A hook checks sixteen rules after every .ts or .tsx edit.
Install
/plugin marketplace add gagoar/typescript-patterns-enforcer
/plugin install typescript-patterns-enforcer@typescript-patterns-enforcer
/reload-plugins
Prefer one marketplace for all gagoar plugins? Use gago-plugins:
/plugin marketplace add gagoar/gago-plugins
/plugin install typescript-patterns-enforcer@gago-plugins
Renamed from ts-patterns
Before v0.5.0 this plugin was called ts-patterns. The plugin directory held that name as too close to other plugins, so it is now typescript-patterns-enforcer.
If you installed the old name, remove it and install the new one:
/plugin uninstall ts-patterns@gago-plugins
/plugin install typescript-patterns-enforcer@gago-plugins
The skill is now /typescript-patterns-enforcer:check and the agent is typescript-patterns-enforcer:review. Three things keep the old name, so nothing you wrote needs to change: the ts-patterns: prefix on the hook's messages, the ts-patterns/<rule> names in eslint-disable comments, and the ts-patterns: allow exhaustive switch line in a project's CLAUDE.md.
Why
- It checks the code, not only the prompt. A hook reads each file Claude edits. A violation returns to Claude as feedback, and Claude fixes it before moving on.
- Every check has a test. Each of the sixteen checks has a failing fixture and a passing fixture. The suite runs against the built hook.
- It stays out of the project's config. The engine ships its own parser and rules. It never reads or writes the repo's ESLint or
tsconfig setup.
30-second tour
Claude writes this:
export function describeStatus(status: string): string {
return status === "active" ? "Active" : status === "paused" ? "Paused" : "Unknown";
}
The hook replies to Claude:
ts-patterns: 1 mechanical violation(s) in describeStatus.ts:
L2:10 no-nested-ternary nested ternary — flatten, or convert to a Record/.find() lookup
Fix these to satisfy the TypeScript patterns before continuing.
Claude rewrites it:
const STATUS_LABELS: Record<string, string> = { active: "Active", paused: "Paused" };
export function describeStatus(status: string): string {
return STATUS_LABELS[status] ?? "Unknown";
}
The next check passes with no output.
What you get
| Component | What it does |
|---|
Skill /typescript-patterns-enforcer:check | Active while Claude writes or edits .ts and .tsx files. It gives inline guidance on type safety, patterns, and anti-patterns. |
Agent typescript-patterns-enforcer:review | Runs through the Agent tool for full PR reviews, large refactors, and JavaScript to TypeScript conversions. |
| Hook | Runs a bundled checker after every .ts or .tsx edit and backs the skill with sixteen deterministic checks. |
The core rules
- No
any. Use unknown and narrow, or write a precise type.
- Explicit return types on public functions.
interface for extendable shapes. type for unions, intersections, and mapped types.
readonly by default.
async/await only. No .then() chains.
- Typed errors. Custom classes or discriminated-union results.
- Constrained generics.
<TEntity extends BaseEntity>, not <T>.
- Composition over inheritance.
- No magic strings or numbers in comparisons or branching.
- Coerce over compare when the intent is "is it empty" or "is it zero".
- Every regex carries an example. A comment directly above it: plain words, a quoted match and reject, and a pre-filled regex101 link.
The skill covers more: data over logic, validation at the boundary, comment discipline, and a review checklist. Read skills/check/SKILL.md for the full text.
The sixteen mechanical checks