dev-typescript-patterns

dev-typescript-patterns is a skill for Claude Code from joaoguirunas/team-os. It costs 37 tokens per session (1,544 once invoked), scanned A, original, MIT.

A guide to common TypeScript patterns, including types and interfaces, generics, discriminated unions, utility types, and domain-focused designs.

In plain words
What is it for?
It is for designing TypeScript types, representing different data states, reusing type logic, and structuring application domains.
Why use it?
It helps developers model complex data clearly and catch more mistakes while writing TypeScript.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is jest.mock('../services/stripe').

Good fit It is for designing TypeScript types, representing different data states, reusing type logic, and structuring application domains.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/joaoguirunas/team-os
agentmods
npx agentmods add skills/joaoguirunas/team-os/dev-typescript-patterns

Made for: Claude Code.

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 dev-typescript-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/joaoguirunas/team-os/dev-typescript-patterns/github.svg)](https://agentmods.dev/skills/joaoguirunas/team-os/dev-typescript-patterns)
Your own site
<a href="https://agentmods.dev/skills/joaoguirunas/team-os/dev-typescript-patterns"><img src="https://agentmods.dev/badge/skills/joaoguirunas/team-os/dev-typescript-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 dev-typescript-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/joaoguirunas/team-os/dev-typescript-patterns"><img src="https://agentmods.dev/badge/skills/joaoguirunas/team-os/dev-typescript-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,544 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.00037 $0.01544
Opus 5.5 $0.00015 $0.00618
Sonnet 5.5 $0.00007 $0.00309
Haiku 4.5 $0.00004 $0.00154

Measured 27d ago against content hash 5413f6ec69c7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

dev-typescript-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 27d 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.

.claude/skills/dev-typescript-patterns/SKILL.md · 215 lines

How it starts

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

TypeScript Patterns — Software Complexo

Types vs Interfaces

// Interface: para objetos públicos e extensíveis (podem ser merged via declaration merging)
interface User {
  id: string
  email: string
  name: string
}

// Type: para unions, intersections, mapped types, e aliases
type UserRole = 'admin' | 'member' | 'viewer'
type UserWithRole = User & { role: UserRole }
type PartialUser = Partial<User>

Regra geral: Interface para contratos de API e objetos de domínio. Type para unions, aliases e tipos compostos.

Discriminated Unions

// ✅ Modelar resultados com discriminated union
type Result<T, E = Error> =
  | { success: true; data: T }
  | { success: false; error: E }

// Uso
function parseUser(raw: unknown): Result<User> {
  const parsed = userSchema.safeParse(raw)
  if (!parsed.success) return { success: false, error: parsed.error }
  return { success: true, data: parsed.data }
}

// Type narrowing automático
const result = parseUser(rawData)
if (result.success) {
  console.log(result.data.email)   // TypeScript sabe que data existe
} else {
  console.log(result.error.message) // TypeScript sabe que error existe
}

Branded Types (IDs seguros)

// Evitar confundir UserId com OrderId
type UserId = string & { readonly _brand: 'UserId' }
type OrderId = string & { readonly _brand: 'OrderId' }

function createUserId(id: string): UserId {
  return id as UserId
}

// Agora TypeScript recusa UserId onde OrderId é esperado
function getOrder(id: OrderId) { ... }
getOrder(userId)  // ✅ Erro de compilação — catching bug em compile time

Generics com Constraints

// Generic para Repository pattern
interface Repository<T extends { id: string }> {
  findById(id: string): Promise<T | null>
  findAll(filters?: Partial<T>): Promise<T[]>
  create(data: Omit<T, 'id' | 'createdAt'>): Promise<T>
  update(id: string, data: Partial<Omit<T, 'id'>>): Promise<T>
  delete(id: string): Promise<void>
}

// Generic utilitário
type PaginatedResult<T> = {
  data: T[]
  pagination: { page: number; perPage: number; total: number; hasNext: boolean }
}

Read the full file on GitHub · 215 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. 27d ago Changed 5413f6ec69c7
  2. 1mo ago First seen · 215 lines · 37 tokens per session scan A 685026878b44

Subscribe to this mod's changes

dev-typescript-patterns is a skill published in the GitHub repository joaoguirunas/team-os (5 stars, last pushed 3d ago), licensed MIT. It adds 37 tokens to every session and 1,544 once invoked, about $0.0001 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.