Borrowing it
Nothing to install: this file belongs to cohen-liel/hivemind. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/cohen-liel/hivemind/main/.claude/skills/typescript-patterns/SKILL.mdgit clone --depth 1 https://github.com/cohen-liel/hivemindWrote 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.
[](https://agentmods.dev/skills/cohen-liel/hivemind/typescript-patterns)<a href="https://agentmods.dev/skills/cohen-liel/hivemind/typescript-patterns"><img src="https://agentmods.dev/badge/skills/cohen-liel/hivemind/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.
<a href="https://agentmods.dev/skills/cohen-liel/hivemind/typescript-patterns"><img src="https://agentmods.dev/badge/skills/cohen-liel/hivemind/typescript-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00034 | $0.00850 |
| Opus 5.5 | $0.00014 | $0.00340 |
| Sonnet 5.5 | $0.00007 | $0.00170 |
| Haiku 4.5 | $0.00003 | $0.00085 |
Grade A, and why
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 1mo 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.
How it starts
The opening of the file, as written. The whole thing — 119 lines — stays where its author put it; the contents beside it link to each section on GitHub.
TypeScript Patterns
Strict Config (tsconfig.json)
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitReturns": true,
"exactOptionalPropertyTypes": true,
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"baseUrl": ".",
"paths": { "@/*": ["src/*"] }
}
}
Type Patterns
Discriminated Union (never use string + optional fields)
// BAD
type ApiResponse = { success: boolean; data?: User; error?: string }
// GOOD
type ApiResponse =
| { success: true; data: User }
| { success: false; error: string }
function handle(res: ApiResponse) {
if (res.success) {
console.log(res.data.email) // TypeScript knows data exists
} else {
console.error(res.error) // TypeScript knows error exists
}
}
Generic Repository
interface Repository<T, ID> {
findById(id: ID): Promise<T | null>
findAll(): Promise<T[]>
create(data: Omit<T, 'id' | 'createdAt'>): Promise<T>
update(id: ID, data: Partial<T>): Promise<T>
delete(id: ID): Promise<void>
}
Branded Types (prevent mixing IDs)
type UserId = number & { readonly _brand: 'UserId' }
type PostId = number & { readonly _brand: 'PostId' }
const userId = 123 as UserId
const postId = 456 as PostId
function getUser(id: UserId): Promise<User> { ... }
getUser(postId) // TypeScript error! Can't pass PostId as UserId
Utility Types
// Pick only what you need
type UserSummary = Pick<User, 'id' | 'name' | 'email'>
// Make all optional for updates
type UserUpdate = Partial<Pick<User, 'name' | 'email'>>
// Require specific fields
type UserCreate = Required<Pick<User, 'email' | 'password'>> & Partial<Pick<User, 'name'>>
// Readonly for immutable data
type Config = Readonly<{ apiUrl: string; timeout: number }>
// Record for maps
const rolePermissions: Record<UserRole, Permission[]> = { ... }
Result Type (instead of throwing everywhere)
type Result<T, E = Error> =
| { ok: true; value: T }
| { ok: false; error: E }
async function safeParseJson<T>(text: string): Promise<Result<T>> {
try {
return { ok: true, value: JSON.parse(text) as T }
} catch (e) {
return { ok: false, error: e as Error }
}
}
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.
- 1mo ago First seen · 119 lines · 34 tokens per session scan A 20211f9e4c09
typescript-patterns is a skill published in the GitHub repository cohen-liel/hivemind (112 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 34 tokens to every session and 850 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.
Other skills, from other repositories
coding-standards
Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.
claude-api
Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.
typescript
TypeScript strict mode with eslint and jest.
widen-return-type
When delegating a task affected by this skill, include.
angular
Use when building, refactoring, or debugging Angular (v20/21+): standalone components, signals, zoneless change detection, @if/@for/@defer control flow, inject() DI, resource()/httpResource(), RxJS interop, NgRx SignalStore, ng CLI. NOT React (that is react), NOT Next.js (that is nextjs), NOT a TypeScript language…
prisma-orm
Use when modeling data or writing type-safe queries with Prisma ORM in TypeScript — schema.prisma, prisma.config.ts, the generated Prisma Client, and Prisma Migrate, including the v6 to v7 upgrade. NOT schema-as-TS with a SQL builder (that is drizzle-orm), NOT ORM-agnostic zero-downtime migration (that is…