33 typescript rules available
Thirty-three Claude rules match typescript, because most Claude rules list TypeScript as a technology even when their subject is Terraform, Kubernetes or system design. Six are substantive (React, Next.js, Node.js, Vue, and two TypeScript rules); 27 are under 250 characters. The file below is a strict-typing rule for Claude Code, scoped to .ts and .tsx files.
Claude Code loads persistent project instructions from CLAUDE.md files and from Markdown rules in .claude/rules/. Rules can be scoped to file paths with a paths frontmatter field, and CLAUDE.md can import other files with @path syntax. The rules in this directory are written as plain instruction prompts: in Claude Code, save them as CLAUDE.md or .claude/rules/ content; in Claude.ai or the Claude API, use the same text as project instructions or a system prompt instead.
.claude/rules/typescript.mdStarting point, not a tested configuration for your repository. Loaded when Claude Code works with files matching paths. Review the instructions, adapt the file paths and run your project's existing checks.
--- paths: - "**/*.ts" - "**/*.tsx" --- # TypeScript instructions for Claude Code ## Focus for this project - Replace any at trust boundaries with a schema (zod or the project's validator) and infer the type from it. - Run npx tsc --noEmit in the shell before and after the change and report the error counts. - Do not loosen tsconfig.json options to make errors disappear. ## TypeScript conventions - Keep "strict": true. Note that noUncheckedIndexedAccess is a separate flag that strict does not enable; respect whichever setting tsconfig.json has. - Use unknown, not any, for untrusted data and narrow it with type guards or a schema validator before use. - Model variants as discriminated unions and end switch statements with an exhaustive never check. - Do not add non-null assertions (!) or as casts to silence an error; fix the type instead and explain any cast that remains. ## Before you finish - Run npx tsc --noEmit plus the project's lint and test scripts and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - You have shell access: run the checks yourself instead of asking the user to, unless a command needs credentials or would deploy.
Create your own Claude rules for TypeScript and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Imports with @path can nest up to four hops deep, according to the docs. Claude Code can read AGENTS.md as project instructions without extra configuration, but by default only when there is no CLAUDE.md in the working directory or above it. The docs list this behavior for version 2.1.277 and later and describe a setting (claude-md-and-agents-md) that loads both files. If you maintain AGENTS.md for other tools, you can also import it from CLAUDE.md with @AGENTS.md.
Documentation checked 2026-11-05: Claude Code docs: Manage Claude's memory
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You ask Claude Code to type an API response that is currently any and want runtime validation, not just a cast.
fetchUser() in src/api/users.ts returns Promise<any>. Give it a real type.
A User schema, fetchUser parsing the JSON with it and returning the inferred type, call sites fixed, and real before/after tsc output.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.