/full-stack-hq:typescript-patternsfrom full-stack-hq
Provides TypeScript type system patterns including generics, utility types, discriminated unions, and strict mode best practices for writing and reviewing TypeScript code.
Ships in full-stack-hq. 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.
"strict": true)any — use unknown for dynamic valuesconst over let, never var// ✅ Interface for objects/classes (extensible)
interface User {
id: string
email: string
name: string
}
// ✅ Type for unions, primitives, computed
type Status = 'active' | 'inactive' | 'pending'
type UserOrAdmin = User | Admin
type ReadonlyUser = Readonly<User>
// ✅ Reusable generic types
type ApiResponse<T> = {
data: T
error: string | null
status: number
}
type PaginatedResponse<T> = {
items: T[]
total: number
page: number
limit: number
}
// ✅ Generic functions
const findById = <T extends { id: string }>(items: T[], id: string): T | undefined =>
items.find(item => item.id === id)
// Pick specific fields
type UserPreview = Pick<User, 'id' | 'name'>
// Omit sensitive fields
type PublicUser = Omit<User, 'password' | 'salt'>
// Make all optional (for partial updates)
type UpdateUserDto = Partial<User>
// Make all required
type RequiredUser = Required<User>
// Make all readonly
type FrozenUser = Readonly<User>
// Extract from union
type ActiveStatus = Extract<Status, 'active' | 'pending'>
// Record type
type UserMap = Record<string, User>
// ✅ Type-safe error handling
type Result<T> =
| { success: true; data: T }
| { success: false; error: string }
const processUser = (id: string): Result<User> => {
try {
return { success: true, data: fetchUser(id) }
} catch (e) {
return { success: false, error: 'User not found' }
}
}
// Usage — TypeScript knows the type
const result = processUser('123')
if (result.success) {
console.log(result.data.name) // User
} else {
console.log(result.error) // string
}
// ✅ Custom type guards
const isUser = (value: unknown): value is User =>
typeof value === 'object' &&
value !== null &&
'id' in value &&
'email' in value
// ✅ Assertion functions
const assertDefined = <T>(value: T | null | undefined): T => {
if (value == null) throw new Error('Value is null or undefined')
return value
}
// ✅ Always type async return values
const fetchUser = async (id: string): Promise<User> => {
const res = await fetch(`/api/users/${id}`)
if (!res.ok) throw new Error('Failed to fetch user')
return res.json() as Promise<User>
}
// ✅ Error handling with unknown
try {
await fetchUser(id)
} catch (error) {
if (error instanceof Error) {
console.error(error.message)
}
}
// ❌ Never
const data: any = fetchData()
function process(x) { return x } // implicit any
const obj = {} as User // unsafe assertion
// @ts-ignore // suppressing errors
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
28 skills in this plugin
/api-design-patternsREST API design, versioning, error responses, pagination, OpenAPI conventions. Use when designing new API endpoints, reviewing API contracts, or setting up Swagger/OpenAPI documentation./auth-patternsJWT access/refresh tokens, Passport.js strategies, session management, OAuth. Use when implementing authentication, authorization, or setting up OAuth providers in a NestJS + Next.js app./backend-dev-guidelinesBackend architecture principles, layering, error handling, logging patterns for NestJS. Use when designing NestJS modules, writing service logic, structuring error handling, or setting up structured logging./brainstormingStructured brainstorming techniques, idea generation, trade-off analysis. Use when exploring design options, choosing between architectural approaches, generating feature ideas, or making technology decisions./code-review-patternsCode review checklist, what to look for, how to give feedback, PR review flow. Use when reviewing a pull request, or when preparing code for review./deployment-guideVercel frontend + Railway/Fly.io backend deployment, env vars, health checks. Use when deploying a Next.js frontend to Vercel or a NestJS backend to Railway or Fly.io, or troubleshooting a deployment issue.npx claudepluginhub sabahattink/antigravity-fullstack-hq --plugin full-stack-hqOther plugins' skills for the same job