typescript-rules

A set of rules for building React user interfaces with TypeScript, a programming language that checks data types before the code runs. It covers component structure, application data, error handling, and comments.

In plain words
What is it for?
Use it when creating or changing React components, TypeScript code, or frontend features, especially when handling component data, application state, API responses, or errors.
Why use it?
It helps prevent type-related mistakes and keeps frontend code easier to understand and maintain. It also clarifies when external data needs checking before the application uses it.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/shinpr/claude-code-workflows/typescript-rules
Any agent
npx skills add shinpr/claude-code-workflows --skill typescript-rules
Clone the repo
git clone --depth 1 https://github.com/shinpr/claude-code-workflows

Made for: Claude Code, Codex.

Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,300 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00039 $0.01300
Opus 5 $0.00019 $0.00650
Sonnet 5 $0.00008 $0.00260
Haiku 4.5 $0.00004 $0.00130

Measured 2d ago against content hash 132fcc9ed782, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

typescript-rules 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 2d 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.

dev-skills/skills/typescript-rules/SKILL.md · 101 lines

How it starts

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

TypeScript Development Rules (Frontend)

Comment Writing Rules

Code first: names and types carry meaning; a comment must add what code cannot, and one comment per decision is enough.

  • Explain why a component memoizes, guards, or re-renders, not what the JSX renders.
  • Record decisions and rationale; leave chronological history to version control.

Type Safety

Default Rule: Prefer unknown, generics, or union types over any. Retain any only when an existing external, generated, or legacy public signature requires it, or when replacing it prevents the project type check from expressing a safe generic relationship. Record the declaration path or type-check result that proves the constraint. When a local adapter can preserve compatibility and expose a safer type within the user request or current task/design artifact, implement the adapter; otherwise confine any to the smallest adapter or public-signature boundary, document the reason, and validate untrusted data before it enters typed application code.

Frontend Boundaries

  • React Props/State: use the declared application types.
  • External API responses: treat unvalidated payloads as unknown and validate at the boundary. A generated client may retain its declared type when it also enforces the contract at runtime.
  • localStorage / sessionStorage: handle string | null; treat parsed data as unknown until validated.
  • URL parameters: handle the router or platform's nullable string shape, then parse and validate before converting to a domain type.
  • Exported APIs and important boundaries: declare return types; allow inference for local implementations when the contract remains clear.

Type Complexity Review Signals

Use these as review prompts, not pass/fail thresholds. Existing project conventions and the component's responsibility take precedence.

  • Props count: review ownership or splitting above 10.
  • Optional props: review defaults or ownership when more than half are optional.
  • Nested prop structures: review flattening beyond 2 levels.
  • Type assertions: review the boundary when 3+ assertions are required.
  • External API types: represent the actual external shape and convert at the application boundary.

Read the full file on GitHub · 101 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. 2d ago First seen · 101 lines · 39 tokens per session scan A 132fcc9ed782

Subscribe to this mod's changes

typescript-rules is a skill published in the GitHub repository shinpr/claude-code-workflows (675 stars, last pushed 4d ago), licensed MIT. It adds 39 tokens to every session and 1,300 once invoked, about $0.0002 per session on Opus 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-08-30.

Related

Other skills, from other repositories