Agent skill

Typescript Rules

by softspark in softspark/ai-toolkit

TypeScript/JavaScript coding rules: style, patterns, security, testing.

Apache-2.0Auto-check: notesTesting & QA

Install Typescript Rules

skills CLI
$ npx skills add softspark/ai-toolkit --skill typescript-rules -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install softspark/ai-toolkit typescript-rules --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/app/skills/typescript-rules .claude/skills/typescript-rules && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
typescript-rules
GitHub stars
179
Token cost
~2.7k tokens
SKILL.md length
1,314 words
Files
1
Skills in repo
112
Repo updated
First seen
Licence
Apache-2.0

At a glance

TypeScript/JavaScript coding rules: style, patterns, security, testing.

  • Tasks that involve Unit testing
  • SKILL.md covers Strict Mode, Naming, Functions and Imports, plus 21 more sections
  • Calls npm
  • Tasks that involve React components

What it does

Typescript Rules is an agent skill from softspark/ai-toolkit. TypeScript/JavaScript coding rules: style, patterns, security, testing. Triggers: .ts, .tsx, .js, .jsx, package.json, tsconfig.json, React, Next.js, Vue, Vite, Vitest, Jest, ESLint.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Unit testing, React components and Linting and formatting. It works with TypeScript, JavaScript, Next.js and React. The repository describes itself as: Professional-grade AI coding toolkit: 94 skills, 44 agents, multi-platform (Claude, Cursor, Windsurf, Copilot, Gemini, Cline, Roo Code, Aider, Augment, Antigravity, Codex CLI… The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Unit testing
  • Tasks that involve React components
  • Tasks that involve Linting and formatting

Example prompts

  • “/typescript-rules”

Requirements

  • Node.js
  • Pre-approved tools (allowed-tools): Read

What it can do on your machine

Read from SKILL.md and the folder at commit d64db2b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Typescript Rules loads about 2.7k tokens when it runs. Until then it costs about 50 tokens; SKILL.md has 1,314 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~50
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:188
    - Never import `.env` files in production -- use platform env injection.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from softspark/ai-toolkit at commit d64db2b, republished under its Apache-2.0 licence (© softspark). 1,314 words, ~2,710 tokens.

Download SKILL.mdSave it as .claude/skills/typescript-rules/SKILL.md (or your agent's skills folder).
name
typescript-rules
description
TypeScript/JavaScript coding rules: style, patterns, security, testing. Triggers: .ts, .tsx, .js, .jsx, package.json, tsconfig.json, React, Next.js, Vue, Vite, Vitest, Jest, ESLint.
allowed-tools
Read
effort
medium
user-invocable
false

TypeScript/JavaScript Rules

These rules come from app/rules/typescript/ in ai-toolkit. They cover the project's standards for coding style, frameworks, patterns, security, and testing in TypeScript/JavaScript. Apply them when writing or reviewing TypeScript/JavaScript code.

TypeScript Coding Style

Strict Mode

  • Always use strict: true in tsconfig.json.
  • Never use any -- use unknown + type guards instead.
  • Prefer interface over type for object shapes (extendable).
  • Use as const for literal types and readonly tuples.

Naming

  • PascalCase: types, interfaces, enums, classes, components.
  • camelCase: variables, functions, methods, properties.
  • UPPER_SNAKE: constants, env vars.
  • Prefix interfaces with I only if project convention requires it.

Functions

  • Prefer arrow functions for callbacks and inline.
  • Use function declarations for hoisted, named functions.
  • Max 3 parameters -- use options object beyond that.
  • Always type return values for public/exported functions.

Imports

  • Group: node builtins, external, internal, relative.
  • Use type imports: import type { Foo } from './foo'.
  • No barrel exports unless at package boundary.
  • Prefer named exports over default exports.

Types

  • Use discriminated unions over class hierarchies for state.
  • Use readonly for arrays and objects that should not be mutated.
  • Use satisfies operator to validate types without widening.
  • Prefer unknown over any at API boundaries.
  • Use template literal types for string patterns.

Avoid

  • enum -- use as const objects or union types.
  • namespace -- use ES modules.
  • private keyword -- use # private fields.
  • Non-null assertion ! -- use proper type narrowing.
  • as type casting -- use type guards and narrowing.

Configuration

  • Enable noUncheckedIndexedAccess for safer array/object access.
  • Enable exactOptionalPropertyTypes to distinguish undefined from missing.
  • Use moduleResolution: "bundler" for modern projects.
  • Set isolatedModules: true for bundler compatibility.

TypeScript Frameworks

React

  • Use function components exclusively. No class components.
  • Colocate state with the component that owns it. Lift only when needed.
  • Use useCallback and useMemo only when profiling shows a need.
  • Use React.lazy() + Suspense for code-splitting routes.
  • Avoid prop drilling past 2 levels -- use Context or state management.

Next.js (App Router)

  • Default to Server Components. Add "use client" only when needed.
  • Use Server Actions for mutations. Never expose internal APIs to client.
  • Use loading.tsx and error.tsx for streaming and error boundaries.
  • Fetch data in Server Components, not in useEffect on client.
  • Use revalidatePath / revalidateTag for cache invalidation.

Express / Fastify / Hono

  • Use layered architecture: route -> controller -> service -> repository.
  • Validate request body/params/query with Zod middleware.
  • Centralize error handling in a single error middleware.
  • Use async route handlers with proper error forwarding.
  • Return consistent response shapes: { data } or { error }.

State Management

  • Use Zustand or Jotai for client state. Redux only for complex existing apps.
  • Use TanStack Query (React Query) for server state.
  • Separate server state (fetched data) from client state (UI state).
  • Never duplicate server data in client state stores.

ORM / Database

  • Use Drizzle for new projects (SQL-like, type-safe, lightweight).
  • Use Prisma for rapid prototyping (schema-first, great DX).
  • Always use migrations. Never modify schema manually in production.
  • Use transactions for multi-table operations.

Node.js Runtime

  • Use node: prefix for built-in modules: import { readFile } from 'node:fs/promises'.
  • Prefer fetch (built-in since Node 18) over axios/node-fetch.
  • Use structuredClone() for deep cloning.
  • Set "type": "module" in package.json for ESM.

Monorepo

  • Use Turborepo or Nx for monorepo orchestration.
  • Share types via internal packages, not copy-paste.
  • Use workspace protocols: "@org/shared": "workspace:*".

TypeScript Patterns

Error Handling

  • Use Result type pattern: { success: true; data: T } | { success: false; error: E }.
  • Use Zod .safeParse() for validation -- returns typed result, never throws.
  • Create domain-specific error classes extending Error with error codes.
  • Centralize error handling in middleware, not in each handler.
  • Never catch errors silently. Log or rethrow with context.

Discriminated Unions

  • Use discriminated unions for state machines and polymorphic data.
  • Always include a type or kind literal field as discriminant.
  • Use switch with exhaustive checking (never in default) on unions.
  • Prefer unions over optional fields for mutually exclusive states.

Async Patterns

  • Use async/await everywhere. Never use raw .then() chains.
  • Use Promise.all() for independent concurrent operations.
  • Use Promise.allSettled() when some failures are acceptable.
  • Implement cancellation with AbortController for long operations.
  • Wrap callbacks in Promises at the boundary, then use async/await.

Validation

  • Validate at API boundaries with Zod, Valibot, or ArkType.
  • Derive TypeScript types from schemas: z.infer<typeof Schema>.
  • Never trust runtime data to match TypeScript types without validation.
  • Use branded types for domain primitives: UserId, Email, Slug.

Dependency Injection

  • Use constructor injection for services and repositories.
  • Accept interfaces, not concrete classes, in constructors.
  • Use factory functions for creating configured instances.
  • Avoid service locator pattern and global singletons.

Immutability

  • Use readonly on interface properties by default.
  • Use Readonly<T>, ReadonlyArray<T> for function parameters.
  • Use Object.freeze() only for runtime safety in config objects.
  • Prefer spread/map/filter over mutating methods (push, splice).

Type Guards

  • Use is return type for custom type guards: (x: unknown): x is User.
  • Use in operator for discriminating object shapes.
  • Prefer satisfies over as for type validation without casting.
  • Use assertion functions (asserts x is T) for preconditions.

TypeScript Security

Show full SKILL.md (529 more words)Show less

Input Validation

  • Validate ALL request data with Zod/Valibot at API boundary.
  • Use .strip() / .strict() to reject unexpected fields.
  • Validate URL params and query strings, not just request bodies.
  • Never pass raw user input to eval(), Function(), or template literals in SQL.

XSS Prevention

  • Use framework auto-escaping (React JSX, Angular templates).
  • Never use dangerouslySetInnerHTML without DOMPurify sanitization.
  • Sanitize user content before storing, not just before rendering.
  • Set CSP headers: default-src 'self'; script-src 'self'.

Authentication

  • Use httpOnly, secure, sameSite: 'strict' for auth cookies.
  • Implement CSRF protection for cookie-based auth (double-submit or token).
  • Use short-lived JWTs (15min) with refresh token rotation.
  • Validate JWT signature, expiration, issuer, and audience on every request.

SQL / NoSQL Injection

  • Use parameterized queries with Drizzle/Prisma/TypeORM. Never concatenate.
  • For raw queries, use tagged template literals: sql\SELECT * FROM users WHERE id = ${id}``.
  • Validate and cast IDs to expected types (UUID, integer) before queries.
  • Use ORM query builders for dynamic filters.

Dependency Security

  • Run npm audit in CI. Fail on high/critical vulnerabilities.
  • Use npm audit signatures to verify package provenance.
  • Pin exact versions with lockfile. Review lockfile changes in PRs.
  • Avoid packages with postinstall scripts unless trusted.

Secrets

  • Use process.env with Zod validation for env vars.
  • Never import .env files in production -- use platform env injection.
  • Never log req.headers.authorization or session tokens.
  • Use crypto.timingSafeEqual() for comparing secrets.

Server Hardening

  • Set security headers: HSTS, X-Content-Type-Options, X-Frame-Options.
  • Use helmet middleware in Express, built-in security in Fastify.
  • Implement rate limiting on all endpoints (express-rate-limit, @fastify/rate-limit).
  • Disable X-Powered-By header. Do not expose server technology.

File Uploads

  • Validate file type by magic bytes, not just extension or MIME type.
  • Set maximum file size limits on the server.
  • Store uploads outside the web root. Serve through a proxy with CDN.
  • Generate random filenames. Never use user-provided filenames for storage.

TypeScript Testing

Framework

  • Use Vitest for new projects (faster, native ESM, TypeScript-first).
  • Use Jest only for existing projects already using it.
  • Use Playwright for E2E browser testing.
  • Use Supertest or built-in fetch for API integration tests.

File Naming

  • Test files: *.test.ts or *.spec.ts colocated with source.
  • Test utilities: tests/helpers/ or tests/utils/.
  • Fixtures: tests/fixtures/ with typed factory functions.

Structure

  • Use describe for grouping by function/class/feature.
  • Use it with behavior descriptions: it('returns 404 when user not found').
  • Avoid deeply nested describe blocks (max 2 levels).
  • Use beforeEach for setup, avoid beforeAll for mutable state.

Type-Safe Mocking

  • Use vi.fn() with type parameters: vi.fn<[string], Promise<User>>().
  • Use vi.mock() for module-level mocking.
  • Prefer dependency injection over module mocking for testability.
  • Use vi.spyOn() for partial mocks on existing objects.

React/Component Testing

  • Use React Testing Library. Query by role, label, text -- not test IDs.
  • Use userEvent over fireEvent for realistic user interactions.
  • Test behavior and rendered output, not component internals.
  • Use renderHook for testing custom hooks in isolation.

Assertions

  • Use expect().toBe() for primitives, expect().toEqual() for objects.
  • Use expect().toMatchInlineSnapshot() for complex output verification.
  • Avoid toBeTruthy/toBeFalsy -- use specific matchers.
  • Use expect().rejects.toThrow() for async error testing.

Async Testing

  • Always await async operations. Never use done callback.
  • Use vi.useFakeTimers() for timer-dependent code.
  • Use waitFor from Testing Library for async DOM updates.

Performance

  • Run tests in parallel (Vitest default). Isolate state to enable this.
  • Use vi.mock() for heavy dependencies (DB, network) in unit tests.
  • Keep unit test suite under 30 seconds.

© softspark, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in app/skills/typescript-rules of softspark/ai-toolkit.

Open the folder on GitHubat commit d64db2b

Compare with similar skills

Typescript Rules next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Typescript Rules compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Typescript Rules this skillsoftspark/ai-toolkit179—~2.7kAutomated safety check: NotesApache-2.0
Ultraciteagustinusnathaniel/nextarter-tailwind1252 repos~1.2kAutomated safety check: PassMIT
React Testinggetsentry/sentry45k—~2.2kAutomated safety check: PassCustom licence
Jest Skillsickn33/agentic-awesome-skills47k1 repos~1.4kAutomated safety check: PassMIT
Typescriptalinaqi/maggy707—~1.3kAutomated safety check: PassMIT
Jest Generatorsecondsky/claude-skills227—~1.1kAutomated safety check: NotesMIT

Similar skills

  • Ultracite

    agustinusnathaniel/nextarter-tailwind

    Ultracite is a zero-config linting and formatting preset for JavaScript/TypeScript projects.

    125 GitHub starsUsed in 2 repos~1.2k tokens
    DevelopmentAuto-check passed
  • React Testing

    getsentry/sentry

    Official

    Write and review React/TypeScript tests for Sentry's frontend using Jest and React Testing Library.

    45k GitHub stars~2.2k tokensUpdated today
    Testing & QAAuto-check passed
  • Jest Skill

    sickn33/agentic-awesome-skills

    Generates Jest unit and integration tests in JavaScript or TypeScript.

    47k GitHub starsUsed in 1 repo~1.4k tokens
    Testing & QAAuto-check passed
  • Typescript

    alinaqi/maggy

    TypeScript strict mode with eslint and jest. An agent skill from alinaqi/maggy.

    707 GitHub stars~1.3k tokensUpdated 13 days ago
    Testing & QAAuto-check passed
  • Jest Generator

    secondsky/claude-skills

    Generate Jest unit tests for JavaScript/TypeScript with mocking, coverage.

    227 GitHub stars~1.1k tokensUpdated 9 days ago
    Testing & QAAuto-check: notes
  • React Render Types Composition

    HorusGoul/eslint-plugin-react-render-types

    Composition patterns for building React components with @renders type annotations from eslint-plugin-react-render-types.

    111 GitHub stars~1.1k tokensUpdated 2 mo ago
    Frontend & DesignAuto-check passed

More from softspark/ai-toolkit

All 112 skills in this repo
  • Prepare Test Env

    softspark/ai-toolkit

    Prepare or verify a project QA environment with source identity, readiness, browser access, evidence paths and owned cleanup.

    179 GitHub stars~1.8k tokensUpdated today
    Auto-check: notes
  • A11y Validate

    softspark/ai-toolkit

    Accessibility validator: WCAG 2.1 AA, EN 301 549, EAA. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~3.8k tokensUpdated today
    Auto-check: notes
  • Analyze

    softspark/ai-toolkit

    Analyzes code quality, complexity, patterns across codebase.

    179 GitHub stars~1k tokensUpdated today
    Auto-check passed
  • Autonomous Dev

    softspark/ai-toolkit

    Drives a brief, specification, issue or existing PR through implementation, review, tests and QA to a ready PR.

    179 GitHub stars~2.6k tokensUpdated today
    Auto-check: notes
  • Brand Voice

    softspark/ai-toolkit

    Direct technical voice for docs, README, user-facing text. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • CI

    softspark/ai-toolkit

    Detect/generate/debug CI pipeline config (GitHub Actions, GitLab CI).

    179 GitHub stars~1.1k tokensUpdated today
    Auto-check: notes

Questions about Typescript Rules

What does Typescript Rules do?

TypeScript/JavaScript coding rules: style, patterns, security, testing. Typescript Rules is an agent skill from softspark/ai-toolkit. TypeScript/JavaScript coding rules: style, patterns, security, testing.

When should I use Typescript Rules?

Typescript Rules fits situations like: tasks that involve Unit testing; tasks that involve React components; tasks that involve Linting and formatting.

How do I install Typescript Rules in Claude Code?

Run `npx skills add softspark/ai-toolkit --skill typescript-rules -a claude-code`. Or copy the skill folder (app/skills/typescript-rules in softspark/ai-toolkit) into .claude/skills/typescript-rules in your project. Claude Code loads it when a task matches its description.

How do I install Typescript Rules in Codex?

Run `npx skills add softspark/ai-toolkit --skill typescript-rules -a codex`. Or copy the skill folder (app/skills/typescript-rules in softspark/ai-toolkit) into .agents/skills/typescript-rules in your project. Codex loads it when a task matches its description.

Can I use Typescript Rules in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add softspark/ai-toolkit --skill typescript-rules -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/typescript-rules, .gemini/skills/typescript-rules, .github/skills/typescript-rules and .opencode/skills/typescript-rules in your project.

What does Typescript Rules need to run?

Going by SKILL.md and its folder, Typescript Rules needs the command-line tools its instructions call (npm). Our summary lists: Node.js. Its frontmatter pre-approves these tools: Read.

Does Typescript Rules access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Typescript Rules safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Typescript Rules use?

Typescript Rules is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Typescript Rules use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Typescript Rules?

Skills that share tags, products or a category with Typescript Rules: Ultracite (agustinusnathaniel/nextarter-tailwind, 125 stars), React Testing (getsentry/sentry, 45k stars), Jest Skill (sickn33/agentic-awesome-skills, 47k stars) and Typescript (alinaqi/maggy, 707 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Typescript Rules?

softspark (a GitHub user) maintains it in softspark/ai-toolkit, which has 179 GitHub stars. The repository holds 112 skills in this directory. The repository was last updated on October 7, 2026.

Source: softspark/ai-toolkit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.