Agent skill
typescript-patterns
TypeScript best practices and patterns. Use when writing TypeScript, fixing type errors, or working with generics.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/typescript-patterns-tibsfox-gsd-skill-creator-3
SKILL.md
TypeScript Patterns
Type vs Interface
| Use Case | Prefer |
|---|---|
| Object shape | interface |
| Union types | type |
| Extending shapes | interface |
| Intersection | type |
| Tuple/primitives | type |
Key Patterns
Discriminated Unions — model state with tagged types:
type Result<T> = { ok: true; value: T } | { ok: false; error: Error };
Type Guards — narrow at runtime:
function isUser(obj: unknown): obj is User {
return typeof obj === 'object' && obj !== null && 'id' in obj;
}
Generic Constraints:
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] { return obj[key]; }
Utility Types
| Type | Purpose |
|---|---|
| Partial<T> | All optional |
| Required<T> | All required |
| Pick<T,K> | Select properties |
| Omit<T,K> | Remove properties |
| Record<K,V> | Key-value map |
| ReturnType<T> | Function return type |
Avoid
any— useunknownand narrow- Type assertions (
as) — use type guards !operator — handle null properly- Missing return types on complex functions
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?