Agent skill

Typescript Rules

by shinpr in shinpr/ai-coding-project-boilerplate

应用类型安全与错误处理规则。强制执行禁用 any 策略与类型守卫。在实现 TypeScript 或评审类型时使用. An agent skill from shinpr/ai-coding-project-boilerplate.

MITAuto-check passed

Install Typescript Rules

skills CLI
$ npx skills add shinpr/ai-coding-project-boilerplate --skill typescript-rules -a claude-code

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

GitHub CLI
$ gh skill install shinpr/ai-coding-project-boilerplate 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/shinpr/ai-coding-project-boilerplate.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills-zh-CN/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
232
Token cost
~791 tokens
SKILL.md length
100 words
Files
1
Skills in repo
42
Repo updated
First seen
Licence
MIT

At a glance

应用类型安全与错误处理规则。强制执行禁用 any 策略与类型守卫。在实现 TypeScript 或评审类型时使用. An agent skill from shinpr/ai-coding-project-boilerplate.

  • SKILL.md covers 前置条件检测, 后端实现中的类型安全, 编码约定 and 错误处理, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Typescript Rules is an agent skill from shinpr/ai-coding-project-boilerplate. 应用类型安全与错误处理规则。强制执行禁用 any 策略与类型守卫。在实现 TypeScript 或评审类型时使用。

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

It works with TypeScript. The repository describes itself as: Agentic coding TypeScript boilerplate for Claude Code: sub-agent workflows with built-in quality checks and context engineering. The licence is MIT.

Example prompts

  • “/typescript-rules”

What it can do on your machine

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

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

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

  • Network

    No URLs in SKILL.md.

    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 791 tokens when it runs. Until then it costs about 19 tokens; SKILL.md has 100 words of instructions outside code blocks.

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

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 passed

The automated check found no risky patterns in SKILL.md.

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 shinpr/ai-coding-project-boilerplate at commit 56913a2, republished under its MIT licence (© shinpr). 100 words, ~791 tokens.

Download SKILL.mdSave it as .claude/skills/typescript-rules/SKILL.md (or your agent's skills folder).
name
typescript-rules
description
应用类型安全与错误处理规则。强制执行禁用 any 策略与类型守卫。在实现 TypeScript 或评审类型时使用。

TypeScript 开发规则

前置条件检测

在应用项目约定之前,先检查 tsconfig、运行时/框架配置、lint/格式化配置、路径别名、package 脚本以及有代表性的模块。仅当配置或既有模式支持某条规则时,才将其视为项目特有规则。将基于有限样本得出的结论标注为推断所得。当相互竞争的约定会改变公共契约、运行时行为或错误边界时,应停下来指出所需的约束来源或用户决策。

后端实现中的类型安全

数据流中的类型安全 输入层(unknown)-> 类型守卫 -> 业务层(类型已保证)-> 输出层(序列化)

后端特有的类型场景:

  • API 通信:将响应作为 unknown 接收,并通过类型守卫进行校验
  • 表单输入:外部输入作为 unknown,校验后再确定类型
  • 遗留系统集成:将遗留边界作为 unknown 接收;将任何有依据支撑的类型断言隔离在拥有该边界的适配器内
  • 测试代码:使用配置好的测试工具定义模拟输入/输出类型;对有意为之的部分 fixture 使用 Partial<T>,仅在配置了 Vitest 时使用带类型的 vi.fn<[Args], Return>()

编码约定

类的使用标准

  • 推荐:使用函数与接口实现
    • 理由:提升可测试性与函数组合的灵活性
  • 允许使用类的情形:
    • 框架要求(NestJS Controller/Service、TypeORM Entity 等)
    • 自定义错误类定义
    • 状态与业务逻辑紧密耦合时(例如 ShoppingCart、Session、StateMachine)
  • 判断标准:若“这份数据是否具有行为?”的答案是肯定的,可考虑使用类
    typescript
    // 函数与接口
    interface UserService { create(data: UserData): User }
    const userService: UserService = { create: (data) => {...} }

函数设计

  • 最多 0-2 个参数:3 个及以上参数时使用对象
    typescript
    // 对象参数
    function createUser({ name, email, role }: CreateUserParams) {}

依赖注入

  • 将外部依赖作为参数注入:确保可测试性与模块化
    typescript
    // 将依赖作为参数接收
    function createService(repository: Repository) { return {...} }

异步处理

  • Promise 处理:遵循仓库既有风格;当能明确表达执行顺序与错误传播时使用 async/await
  • 错误处理:当当前层能够转换、丰富、恢复或记录该失败时添加 try-catch。否则应让 Promise 拒绝传播到拥有该边界的位置
  • 类型定义:明确定义返回值类型(例如 Promise<Result>)

格式规则

  • 遵循仓库配置的格式化工具,包括其分号策略
  • 类型使用 PascalCase,变量/函数使用 camelCase
  • 仅通过 tsconfig 或所配置构建工具中声明的别名使用绝对导入;否则使用相对导入

整洁代码原则

  • 在当前改动范围内移除未使用的代码
  • 删除调试用的 console.log()
  • 保持可执行源码中不含被注释掉的代码;版本控制系统会保留被移除的实现
  • 注释解释“为什么”(而非“做了什么”)

错误处理

错误结果规则:每个失败都应有唯一的责任归属结果:返回一个带类型的预期错误、按明确规定的需求恢复,或携带诊断上下文向外传播。在拥有可观测性职责的边界处记录日志,以避免同一失败被重复记录。

快速失败原则:出错时应快速失败,以防止在无效状态下继续处理

typescript
// 无效做法:回退值掩盖了调用方所需的失败信息
catch (error) {
  return defaultValue // 掩盖了错误
}

// 明确传播并附加上下文
catch (error) {
  throw new Error('Processing failed', { cause: error })
}

Result 类型模式:用类型表达错误以实现显式处理

typescript
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E }

// 示例:用类型表达错误的可能性
function parseUser(data: unknown): Result<User, ValidationError> {
  if (!isValid(data)) return { ok: false, error: new ValidationError() }
  return { ok: true, value: data as User }
}

自定义错误类

typescript
export class AppError extends Error {
  constructor(message: string, public readonly code: string, public readonly statusCode = 500) {
    super(message)
    this.name = this.constructor.name
  }
}
// 按用途区分:ValidationError(400)、BusinessRuleError(400)、DatabaseError(500)、ExternalServiceError(502)

各层特有的错误处理(后端)

  • API 层:转换为 HTTP 响应,输出日志时排除敏感信息
  • Service 层:检测业务规则违反,原样传播 AppError
  • 仓储层:将技术错误转换为领域错误

结构化日志与敏感信息保护 仅记录当前信任边界所允许的字段。记录日志前应对凭证、令牌、密钥、支付数据和个人数据进行脱敏处理。

异步错误处理

  • 当运行时暴露 unhandledRejection/uncaughtException 事件时,在应用入口处配置运行时级别的处理;库应将进程级策略留给宿主决定
  • 在能够添加带类型结果、恢复逻辑或诊断上下文的那一层捕获异步失败
  • 除非某项明确规定的需求要求在该层恢复,否则应在补充信息后继续传播失败

性能优化

  • 流式处理:当实测的输入规模可能超出可用内存预算,或需求要求增量输出时,使用流式处理或有限批次;记录触发该判断的度量数据或约束条件
  • 资源生命周期:在拥有其生命周期的边界处释放定时器、订阅、句柄及被持有的引用

© shinpr, MIT. 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 .claude/skills-zh-CN/typescript-rules of shinpr/ai-coding-project-boilerplate.

Open the folder on GitHubat commit 56913a2

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 skillshinpr/ai-coding-project-boilerplate232—~791Automated safety check: PassMIT
MCP Server Builderanthropics/skills180k64 repos~2.3kAutomated safety check: PassApache-2.0
Web Artifacts Builderanthropics/skills180k41 repos~769Automated safety check: PassApache-2.0
Typescript Advanced Typesrolling-scopes/rsschool-app10k25 repos~4.2kAutomated safety check: PassMPL-2.0
Code Review ChecklistshareAI-lab/learn-claude-code78k5 repos~1.1kAutomated safety check: PassMIT
MCP Server BuildershareAI-lab/learn-claude-code78k5 repos~1.2kAutomated safety check: PassMIT

Similar skills

  • MCP Server Builder

    anthropics/skills

    Official

    Guides the design and implementation of Model Context Protocol servers in TypeScript or Python, from tool naming and error messages to evaluation.

    180k GitHub starsUsed in 64 repos~2.3k tokens
    Agent WorkflowsAuto-check passed
  • Web Artifacts Builder

    anthropics/skills

    Official

    Builds multi-component claude.ai HTML artifacts as a small React, TypeScript and Tailwind project, then bundles it into one shareable HTML file.

    180k GitHub starsUsed in 41 repos~769 tokens
    Frontend & DesignAuto-check passed
  • Typescript Advanced Types

    rolling-scopes/rsschool-app

    Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications.

    10k GitHub starsUsed in 25 repos~4.2k tokens
    DevelopmentAuto-check passed
  • Code Review Checklist

    shareAI-lab/learn-claude-code

    Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.

    78k GitHub starsUsed in 5 repos~1.1k tokens
    DevelopmentAuto-check passed
  • MCP Server Builder

    shareAI-lab/learn-claude-code

    Walks through building MCP servers in Python or TypeScript that expose tools, resources and prompts to Claude, with templates, registration and testing.

    78k GitHub starsUsed in 5 repos~1.2k tokens
    Agent WorkflowsAuto-check passed
  • Nx Import

    nrwl/nx

    Import, merge, or combine repositories into an Nx workspace using nx import.

    29k GitHub starsUsed in 6 repos~3.5k tokens
    DevelopmentAuto-check passed

More from shinpr/ai-coding-project-boilerplate

All 42 skills in this repo
  • Integration E2E Testing

    shinpr/ai-coding-project-boilerplate

    Selects and designs the smallest integration/E2E test set that proves accepted behavior at an observable boundary.

    232 GitHub stars~2.8k tokensUpdated 4 days ago
    Auto-check passed
  • Skill Optimization

    shinpr/ai-coding-project-boilerplate

    Evaluates and optimizes skill file quality using 9 content patterns and 10 editing principles.

    232 GitHub stars~3.5k tokensUpdated 4 days ago
    Auto-check passed
  • Frontend Technical Spec

    shinpr/ai-coding-project-boilerplate

    Defines React environment, component architecture, state/data flow, build verification, and frontend non-functional criteria from repository evidence.

    232 GitHub stars~1.9k tokensUpdated 4 days ago
    Auto-check: notes
  • Frontend Typescript Rules

    shinpr/ai-coding-project-boilerplate

    Applies React/TypeScript type safety, component design, and state management rules.

    232 GitHub stars~1.7k tokensUpdated 4 days ago
    Auto-check passed
  • Implementation Approach

    shinpr/ai-coding-project-boilerplate

    Selects implementation strategy (vertical slice, horizontal, or hybrid) with risk assessment.

    232 GitHub stars~3.2k tokensUpdated 4 days ago
    Auto-check passed
  • Subagents Orchestration Guide

    shinpr/ai-coding-project-boilerplate

    Coordinates subagents through scale-based planning, approval, implementation, verification, and escalation flows.

    232 GitHub stars~8k tokensUpdated 4 days ago
    Auto-check passed

Works with

Questions about Typescript Rules

What does Typescript Rules do?

应用类型安全与错误处理规则。强制执行禁用 any 策略与类型守卫。在实现 TypeScript 或评审类型时使用. An agent skill from shinpr/ai-coding-project-boilerplate. Typescript Rules is an agent skill from shinpr/ai-coding-project-boilerplate.

How do I install Typescript Rules in Claude Code?

Run `npx skills add shinpr/ai-coding-project-boilerplate --skill typescript-rules -a claude-code`. Or copy the skill folder (.claude/skills-zh-CN/typescript-rules in shinpr/ai-coding-project-boilerplate) 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 shinpr/ai-coding-project-boilerplate --skill typescript-rules -a codex`. Or copy the skill folder (.claude/skills-zh-CN/typescript-rules in shinpr/ai-coding-project-boilerplate) 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 shinpr/ai-coding-project-boilerplate --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?

SKILL.md names no scripts, command-line tools or credentials: Typescript Rules is instructions for the agent only.

Does Typescript Rules access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Typescript Rules safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Typescript Rules use?

Typescript Rules is published under the MIT 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 791 tokens (SKILL.md is roughly 3.2k 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: MCP Server Builder (anthropics/skills, 180k stars), Web Artifacts Builder (anthropics/skills, 180k stars), Typescript Advanced Types (rolling-scopes/rsschool-app, 10k stars) and Code Review Checklist (shareAI-lab/learn-claude-code, 78k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Typescript Rules?

shinpr (a GitHub user) maintains it in shinpr/ai-coding-project-boilerplate, which has 232 GitHub stars. The repository holds 42 skills in this directory. The repository was last updated on October 4, 2026.

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