jgamaraalv/ts-dev-kit/typescript-conventions
Claude Code and agent skill by jgamaraalv/ts-dev-kit
- community
Checking that the SKILL.md file is still in the repository.
TypeScript coding conventions for strict, type-safe projects. Use when: (1) writing or reviewing TypeScript code, (2) choosing between `any` and `unknown`, (3) structuring imports with verbatimModuleSyntax, (4) defining types, interfaces, unions, or generics, (5) naming functions, booleans, queries, and commands, (6) handling errors with guard clauses and early returns, (7) narrowing types with guards and discriminated unions, or (8) avoiding common anti-patterns like primitive obsession, magic…
Install
npx vskill@latest install jgamaraalv/ts-dev-kit/typescript-conventionsSKILL.md
The same SKILL.md was published earlier as jgamaraalv/ts-dev-kit/typescript-conventions.
TypeScript Conventions
Project-wide TypeScript standards that complement agent-specific instructions.
<rules>
Type Safety
- No `any`: Use
unknownif the type is truly dynamic, then narrow. - Strict config:
strict: true,noUncheckedIndexedAccess,verbatimModuleSyntax. - Use
Readonly<T>,Pick,Omit, andRecordfor precise types. - Use branded types for entity IDs (e.g.,
UserId,OrderId) to prevent mixing. - Prefer
z.infer<typeof schema>over hand-written types when a Zod schema exists.
Interface vs Type
- Interfaces for object shapes that may grow — they support
extendsand declaration merging. - Type aliases for unions, intersections, mapped types, and complex compositions.
- Simple rule:
interfacefor plain objects,typefor everything else.
Unions and Literal Types
- Prefer literal unions over enums — zero runtime cost, better tree-shaking, full autocomplete.
- Use enums only when you need a runtime object (iteration, reverse lookup).
Discriminated Unions
Add a type (or kind) literal field to each variant. Always handle exhaustiveness with assertNever.
Type Narrowing
Always narrow before accessing type-specific properties.
typeoffor primitives:typeof x === "string"infor object shapes:"swim" in pet- Custom type guards for reusable checks:
function isBook(item): item is Book
Generics
- Constrain with
extends— never assume properties exist on unconstrainedT. - Use defaults (
T = unknown) when callers often use a single type. - Keep generics to one or two parameters; more suggests the function is too broad.
Mapped & Template Literal Types
Use mapped types to derive variants from a base — never duplicate type definitions.
Intersection Types
- Use
&to compose smaller interfaces into richer types. - If two intersected types define the same key with incompatible types, the result collapses to
never— check for this.
Imports
Error Handling
- Handle errors at the beginning of functions with early returns / guard clauses.
- Avoid deep nesting — use if-return pattern instead of else chains.
- In Fastify routes, throw
httpErrorsor usereply.status().send()— the centralizedsetErrorHandlerformats the response. - Custom error classes for domain-specific errors (e.g.,
NotFoundError,ConflictError).
Naming
- Functions:
getUserById,createReport,isActive,hasPermission - Booleans:
is/has/can/shouldprefix - Query (returns data):
get,find,list,fetch - Command (changes state):
create,update,delete,add,remove
</rules>
<anti_patterns>
Anti-Patterns
- Primitive obsession: Use branded types or Zod enums, not raw strings for IDs and statuses.
- Magic numbers/strings: Use constants from a shared package (e.g.,
RATE_LIMITS,PAGINATION,CACHE). - Long parameter lists: Use an options object or a Zod schema.
- Premature abstraction: Three similar lines > one premature helper. Abstract on the third repetition.
- Using union values without narrowing: Accessing
.lengthonstring | numberfails at runtime if it's a number. - Unions too broad: A dozen options may suggest generics or a different pattern.
- `readonly` is shallow:
readonlyprevents reassignment but doesn't freeze nested objects. - Enums for simple sets: Prefer literal unions when you don't need runtime iteration.
- Unconstrained generics:
<T>with noextendsloses type info — constrain or use a concrete type. - Conflicting intersections:
{ status: string } & { status: number }silently collapses tonever. - Forgetting exhaustiveness: Always add a
default: return assertNever(x)in discriminated union switches.
</anti_patterns>
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/typescript-conventions/SKILL.md
Popularity
- Repository stars
- 15
- Repository npm downloads, 7 days
- 28
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 5 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jgamaraalv/ts-dev-kit/typescript-conventions)