Typescript Rules logo

Typescript Rules

Community
shinpr
typescript-rules

React/TypeScript frontend development rules including type safety, component design, state management, and error handling. Use when implementing React components, TypeScript code, or frontend features.

Overview

Publishershinpr
Repositoryclaude-code-workflows
Skill nametypescript-rules
Stars
682
Forks
103
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by shinpr on GitHub. Read the source before you install it.

Installation

Install the Typescript Rules AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/shinpr/claude-code-workflows.git /tmp/claude-code-workflows
mkdir -p .claude/skills
cp -r /tmp/claude-code-workflows/dev-skills/skills/typescript-rules .claude/skills/typescript-rules
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Typescript Rules in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Typescript Rules on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Typescript Rules is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

Coding Conventions

Component and File Decisions

  • Prefer function components and Hooks for new code. Preserve working class components unless the accepted work requires migration; a class remains valid for an Error Boundary implementation.
  • Reuse logic through the repository's established component, hook, or module pattern.
  • Follow the project's adopted component architecture and file layout. Co-locate files only when it is established or approved as a new structure.

Server/Client Boundary — only for RSC frameworks

  • Fetch and render on the server by default; isolate interactivity behind the smallest "use client" boundary that needs it.
  • Keep browser-only APIs and event handlers inside client components.
  • Skip these rules when the project has no server-component runtime.

State Ownership

  • Preserve the repository's existing local, shared, and server-state ownership boundaries.
  • Introduce Context, a shared-state layer, or a server-state dependency only when the accepted design requires ownership or lifecycle that the existing boundary cannot represent.
  • Keep one authoritative owner for each state value and use immutable updates required by React change detection.

Function and Props Boundaries

  • Prefer 0-2 parameters. For 3+ related values, use an object when it clarifies names or represents one domain input; preserve positional parameters when the repository convention or external API requires them.
  • Declare component dependencies through typed props, hooks, Context, or injected modules according to the repository's established state and dependency boundaries.

Environment Variables

  • Read client-side environment variables through the project's bundler accessor and public prefix.
  • Validate required values through the repository's typed config layer; add a default only for an optional value or an explicitly defined local-development mode.

Client Security

  • Keep credentials and secrets on the server; browser-delivered code and public environment variables are observable by clients.
  • Exclude local environment files from version control and keep error output free of sensitive values.

Asynchronous Processing

  • Follow the repository's promise style; use async/await when it clarifies sequencing and error propagation.
  • Handle event-handler and asynchronous failures at their owning boundary. Error Boundaries cover descendant rendering failures, not ordinary callbacks or asynchronous work.
  • Guard effect-driven requests against stale or post-unmount updates through the repository's cancellation or server-state mechanism.

Formatting

  • Follow the repository's formatter, naming, module-resolution, and package-boundary configuration.
  • Use an import alias only when the project configuration resolves it.

Error Handling

Every caught error has one intentional outcome: propagate it, convert it to the repository's typed boundary result, or represent it as user-facing error state. Preserve context and log once at the boundary that owns diagnosis or recovery, with sensitive data redacted.

  • Error Boundary: place it where descendant render failures have a defined UI recovery outcome.
  • Custom Hook: preserve the application's existing error contract.
  • API Layer: convert transport failures to the repository's established domain or boundary representation.
  • Event handlers and async workflows: use the owning layer's exception, result, or UI-state contract.

Performance Optimization

  • When React Compiler is enabled, rely on it. Add manual React.memo, useMemo, or useCallback only for a measured bottleneck or a required stable identity at an external API/effect boundary.
  • Apply code splitting or import changes when a configured bundle budget regresses, or when the accepted task names bundle size as an outcome and a repository bundle report attributes the relevant increase to the changed import. Follow the repository's existing loading pattern and verify the same signal after the change.

Non-functional Requirements

  • Browser Compatibility: Implement against the support policy in the PRD, Design Doc, Browserslist, or build configuration. When none is defined, preserve the repository's current transpilation/polyfill baseline and surface any new browser-dependent API as an unresolved compatibility decision.
  • Performance: Verify against project-defined budgets and the metric representing the affected experience. When no budget exists, measure the changed path and report the observed result instead of inventing a threshold.

Frequently asked questions

What does the Typescript Rules AI skill do?

React/TypeScript frontend development rules including type safety, component design, state management, and error handling. Use when implementing React components, TypeScript code, or frontend features.

Why use Typescript Rules on TypingMind?

Because you install it once and use it with any model. Typescript Rules is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Typescript Rules in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/shinpr/claude-code-workflows/tree/main/dev-skills/skills/typescript-rules. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Typescript Rules?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Typescript Rules?

As many as you like. As long as a model supports skills, you can use Typescript Rules with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Typescript Rules AI skill free?

Yes. It is published on GitHub by shinpr under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇