/quality-gates:typescript-typesfrom quality-gates
Provides rules and patterns for writing correct TypeScript types: deriving from sources of truth, avoiding unsafe casts, and fixing type errors properly.
Ships in quality-gates. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A type is correct when it is derived from the source of truth and checked by the compiler. A type that is asserted (as, !, any) is a claim nobody checked.
tsconfig.json: strict, noUncheckedIndexedAccess, exactOptionalPropertyTypes, verbatimModuleSyntax, and the TypeScript version in the lockfile.| Situation | Do | Not |
|---|---|---|
Data from outside (HTTP, JSON.parse, storage, env, catch) | Type it unknown, parse with the repo's schema library, use the inferred type (z.infer). No library: write a type guard | as User, any |
| Checking a value fits a type | satisfies (keeps the literal type) | as |
| Value may be null or undefined | Narrow with a check or early return | ! |
| A type that follows another | typeof, keyof, T['key'], ReturnType, Parameters, Awaited, Pick, Omit | A second hand-written copy |
| A value with several states | Discriminated union on one literal field | Optional fields and boolean flags |
switch over a union | default: assigns the value to never | A silent default |
| Fixed set of strings | Union of literals or an as const object, whichever the repo uses | A new enum in a repo that has none |
| Exported function | Explicit return type | Inferred return leaking internals |
| Generic | A type parameter that links two positions, with extends | A parameter used once |
| Array or object parameter you do not change | readonly T[], Readonly<T> | Mutable by default |
| Suppressing an error is truly needed | @ts-expect-error with the reason on the same line | @ts-ignore |
as const and as directly after a runtime check are the only casts that need no comment.
JSON.parse, response.json() and any-typed library results return any. Assign them to unknown at once.obj[key] on a Record<string, T> or array is typed T, not T | undefined, unless noUncheckedIndexedAccess is on. Check before use.Object.keys(x) is string[], not (keyof T)[]. Do not cast it; iterate a known key list..filter(Boolean) narrows only on TypeScript 5.5 or newer. Older: write a type predicate.catch (e) is unknown. Narrow with instanceof Error.undefined are different under exactOptionalPropertyTypes.any, or cast to make the error go away. If the types say the code is wrong, the code may be wrong.Run the project's type check (its script, else tsc --noEmit) and the linter on the files changed. For type-level logic, add an expectTypeOf or @ts-expect-error test. Report:
Types from: <schema or generated source used>
Check: <command> -> <result>
Casts added: <file:line and the runtime check that justifies each, or "none">
Key decisions in this skill: a new shared type, generic or discriminated union that shapes a module's public API, a schema at a trust boundary, and any cast or any you cannot avoid.
Before acting on one, get a second opinion: call the Agent tool with model: "opus" (subagent_type Plan, read-only). Give it the decision, each option in one line, the evidence (file:line, measurements, the diff) and the constraints. Ask for a pick, the main risk of that pick, and what would change its mind. Do not send secrets or .env contents.
Advisor: <decision> -> <pick> (<agreed | overruled because ...>).Spend the strong models on judgment and the cheap ones on volume. When this skill spawns subagents with the Agent tool, set model by role:
| Role | Model | Use for |
|---|---|---|
| Think | fable (Fable 5.2), or opus when limits are tight | Plan, decompose, pick an approach. One call, read-only (subagent_type: "Plan"). |
| Execute | sonnet (Sonnet 5.5) | Write and edit code, run checks, produce the deliverable. |
| Review | opus (Opus 5.5) | Check the finished work before reporting: correctness, security, money, data loss. |
| Swarm | haiku (Haiku 5.5) | Many small parallel jobs: search, read, extract, classify, per-file scans. |
mcp__ccd_session_mgmt__get_usage (load it with ToolSearch if deferred). Use fable only when every window has room: 5-hour limit under 70% used, "Weekly · all models" under 80%, and "Weekly · Fable" (if listed) under 80%. Otherwise use opus. If the tool is missing, or its status is unavailable or not_applicable (API key, Bedrock, Vertex), use opus. Say the pick in one line: Think: <model> (5h <n>%, weekly <n>%, Fable <n>%).Lessons from earlier runs live in two files: ~/.claude/skill-lessons/typescript-types.md (any repo) and .claude/skill-lessons/typescript-types.md at the repo root (this repo only).
- <YYYY-MM-DD>: <do or avoid X> because <Y>. (seen: 1). When a line already says the same thing, raise its seen count and date instead of adding one. Facts about this repo go in the repo file, everything else in the user file. Keep each file under 30 lines by merging or dropping stale lessons.seen: 3: if the ashish-claude-skills source repo is open, propose the edit to plugins/quality-gates/skills/typescript-types/SKILL.md as a diff and wait for a yes, then delete the lesson once it lands; otherwise say Lesson ready to promote: <line> in the report.Learned: <the line written | nothing>.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ashishyd/ashish-claude-skills --plugin quality-gates10 skills in this plugin
/claude-md-syncUse after changing business logic, domain rules, data models, APIs, architecture, commands, config or dependencies, before calling the work done, to keep CLAUDE.md true to the code. Also when the user says "update CLAUDE.md", "sync the docs" or "is CLAUDE.md still right"./design-auditUse when a UI component, page or stylesheet has just been built or changed and its visual quality needs checking, when the user asks whether a screen looks right, consistent or polished, or before shipping front-end work./login-and-accessUse when writing, changing or reviewing sign-in, sign-up, logout, password reset, magic links, OAuth or SSO, MFA, sessions, cookies, JWTs, refresh tokens, roles, permissions, admin areas, multi-tenant data or any route that must know who the caller is and what they may see./personal-dataUse when writing, changing or reviewing code that stores, reads, sends, logs, exports or deletes information about people (users, customers, clients, patients, children, employees), including new database columns or tables, migrations, forms, analytics or tracking events, error reporting, third-party APIs, AI prompts, data exports, account deletion, consent, cookie banners, retention jobs, or questions about GDPR, CCPA, LGPD, DPDP or other privacy laws./playwright-testsUse when writing, generating or fixing Playwright end-to-end tests, covering a user journey in a real browser, choosing locators, handling login state or test data, or when an e2e test is flaky, slow or times out./security-code-auditUse when writing, changing or reviewing code that handles user input, forms, auth, passwords, sessions, tokens, API keys, secrets, env vars, permissions, database queries, file uploads, webhooks, payments or a new API route, or when the user asks for a security review of a diff, a file or a feature.Other plugins' skills for the same job