type-system-patterns

type-system-patterns is a skill for Claude Code, Codex from mickeyyaya/refactoring-skills. It costs 77 tokens per session (2,906 once invoked), scanned A, original, MIT.

A code-review guide for choosing safer type patterns in TypeScript and Java. It explains patterns such as tagged alternatives, distinct value types, constrained generics, and explicit success-or-error results.

In plain words
What is it for?
Use it to review APIs, state machines, validation code, and data-flow boundaries for type-system problems.
Why use it?
It helps reviewers find places where loose types, unsafe casts, or ad-hoc flags can let invalid data pass unnoticed. The compiler can catch some of these mistakes before tests run.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to review APIs, state machines, validation code, and data-flow boundaries for type-system problems.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mickeyyaya/refactoring-skills/type-system-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mickeyyaya/refactoring-skills --skill type-system-patterns
Clone the repo
git clone --depth 1 https://github.com/mickeyyaya/refactoring-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for type-system-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/type-system-patterns/github.svg)](https://agentmods.dev/skills/mickeyyaya/refactoring-skills/type-system-patterns)
Your own site
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/type-system-patterns"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/type-system-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for type-system-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/type-system-patterns"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/type-system-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 77 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,906 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00077 $0.02906
Opus 5.5 $0.00031 $0.01162
Sonnet 5.5 $0.00015 $0.00581
Haiku 4.5 $0.00008 $0.00291

Measured 2mo ago against content hash 28b714fc81df, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

type-system-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/type-system-patterns/SKILL.md · 318 lines

How it starts

The opening of the file, as written. The whole thing — 318 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Type System Patterns for Code Review

Overview

A strong type system is the first line of defense against bugs. When used well, types make illegal states unrepresentable — the compiler catches entire classes of errors before any test runs.

When to Use

  • APIs accepting raw strings where a typed value is expected
  • Functions returning null/undefined or throwing where a Result type belongs
  • Codebases with frequent any casts or type assertions
  • State machines implemented as ad-hoc string/boolean flags
  • Runtime validation that could be moved to compile time

Quick Reference

Pattern Core Idea Primary Red Flag
Discriminated Unions Tag each variant; switch exhaustively instanceof chains, stringly-typed variants
Phantom Types Compile-time info with no runtime cost Mixing validated/unvalidated data of same shape
Branded/Nominal Types Structurally identical types made distinct Passing userId where orderId required
Generic Constraints Bound type params to enforce contracts any escape hatches, unconstrained generics
Type Narrowing / Guards Runtime checks informing the type system Unsafe as casts, as unknown as T
Immutable Types readonly and const at the type level Mutable types on value objects and DTOs
Newtype Pattern Wrap primitives for semantic safety Raw strings for emails, IDs, URLs
Result / Option Types Type-safe absence and error handling null returns, exception-based control flow
Builder with Types Compile-time required-field enforcement Runtime errors from incomplete builders
Conditional Types Type-level computation and inference Untyped overloads, duplicated type logic

Patterns in Detail

1. Discriminated Unions / Tagged Unions

Represent a fixed set of mutually exclusive variants with a literal discriminant tag. Compiler enforces exhaustive handling and narrows types per branch.

Red Flags: instanceof chains or parallel boolean flags allowing impossible combinations; type/status typed as string instead of literal union; switch with no exhaustiveness guard.

Read the full file on GitHub · 318 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 318 lines · 77 tokens per session scan A 28b714fc81df

Subscribe to this mod's changes

type-system-patterns is a skill published in the GitHub repository mickeyyaya/refactoring-skills (7 stars, last pushed 8mo ago), licensed MIT. It adds 77 tokens to every session and 2,906 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

type-system-patterns compared with skills from other repositories

type-system-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
type-system-patternsmickeyyaya/refactoring-skillsSkill78mo agoMITA77Claude Code, Codex
no-bare-castsprisma/ormSkill48ktodayApache-2.0A52Claude Code, Codex
coding-standardshashgraph-online/awesome-codex-pluginsSkill1.6k2d agoApache-2.0A28Claude Code, Codex
splitting-oversized-modulesPostHog/posthogSkill41ktodaynoneA197Claude Code, Codex
best-practicesFradSer/dotclaudeSkill59824d agoMITA52Claude Code
ts-reviewliuyanghejerry/ClausuraSkill2054d agoMITA26Claude Code, Codex
effect-developmentThreadlines/threadlinesSkill52todayMITA29Claude Code, Codex