Token导航 LogoToken导航TokenDH.com
前端设计敏感数据github未标认证来源可访问许可证需确认审计通过

typescript-rulesTypeScript rules 命令行

Agent Skill

typescript-rules 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

917

周安装

39

GitHub Stars

323

下载量

321
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:typescript-rules(TypeScript rules 命令行)
来源仓库:https://github.com/shinpr/claude-code-workflows
仓库路径:skills/typescript-rules
安装命令:
npx skills add https://github.com/shinpr/claude-code-workflows --skill typescript-rules
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/shinpr/claude-code-workflows --skill typescript-rules

简介

typescript-rules 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理时使用。
  • 可结合来源仓库、安装命令和原始 README 继续核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 当前尚无详细功能描述,需查阅原始 SKILL.md 获取更多信息。

SKILL.md

TypeScript Development Rules (Frontend)

Basic Principles

  • Aggressive Refactoring - Prevent technical debt and maintain health
  • Delete code when no current caller exists - YAGNI principle (Kent Beck)

Comment Writing Rules

  • Function Description Focus: Describe what the code "does"
  • Timeless content only: Record decisions and rationale; leave chronological history to version control
  • Conciseness: Keep explanations to necessary minimum

Type Safety

Absolute Rule: Replace every any with unknown, generics, or union types. any disables type checking and causes runtime errors.

any Type Alternatives (Priority Order)

  1. unknown Type + Type Guards: Use for validating external input (API responses, localStorage, URL parameters)
  2. Generics: When type flexibility is needed
  3. Union Types・Intersection Types: Combinations of multiple types
  4. Type Assertions (Last Resort): Only when type is certain

Type Guard Implementation Pattern

function isUser(value: unknown): value is User {
  return typeof value === 'object' && value !== null && 'id' in value && 'name' in value
}

Modern Type Features

  • satisfies Operator: const config = {apiUrl: '/api'} satisfies Config - Preserves inference
  • const Assertion: const ROUTES = {HOME: '/'} as const satisfies Routes - Immutable and type-safe
  • Branded Types: type UserId = string & {__brand: 'UserId'} - Distinguish meaning
  • Template Literal Types: type EventName = \on${Capitalize}`` - Express string patterns with types

Type Safety in Frontend Implementation

  • React Props/State: TypeScript manages types, unknown unnecessary
  • External API Responses: Always receive as unknown, validate with type guards
  • localStorage/sessionStorage: Treat as unknown, validate
  • URL Parameters: Treat as unknown, validate
  • Form Input (Controlled Components): Type-safe with React synthetic events

Type Safety in Data Flow

  • Frontend → Backend: Props/State (Type Guaranteed) → API Request (Serialization)
  • Backend → Frontend: API Response (unknown) → Type Guard → State (Type Guaranteed)

Type Complexity Management

  • Props Design:

- Props count: 3-7 props ideal (consider component splitting if exceeds 10) - Optional Props: 50% or less (consider default values or Context if excessive) - Nesting: Up to 2 levels (flatten deeper structures)

  • Type Assertions: Review design if used 3+ times
  • External API Types: Relax constraints and define according to reality (convert appropriately internally)

Coding Conventions

Component Design Criteria

  • Function components only: Official React recommendation, optimizable by modern tooling (Exception: Error Boundary requires class component)
  • Custom Hooks: Standard pattern for logic reuse and dependency injection
  • Component Hierarchy: Atoms → Molecules → Organisms → Templates → Pages
  • Co-location: Place tests, styles, and related files alongside components

State Management Patterns

  • Local State: useState for component-specific state
  • Context API: For sharing state across component tree (theme, auth, etc.)
  • Custom Hooks: Encapsulate state logic and side effects
  • Server State: React Query or SWR for API data caching

Data Flow Principles

  • Single Source of Truth: Each piece of state has one authoritative source
  • Unidirectional Flow: Data flows top-down via props
  • Immutable Updates: Use immutable patterns for state updates
// Immutable state update — always create new arrays/objects
setUsers(prev => [...prev, newUser])

Function Design

  • 0-2 parameters maximum: Use object for 3+ parameters function createUser({name, email, role}: CreateUserParams) {}

Props Design (Props-driven Approach)

  • Props are the interface: Define all necessary information as props
  • Pass all data dependencies as props; use Context only for cross-cutting concerns (theme, auth, locale)
  • Type-safe: Always define Props type explicitly

Environment Variables

  • Use build tool's environment variable system: process.env does not work in browsers
  • Centrally manage environment variables through configuration layer
  • Define a typed config object with defaults for every environment variable
// Use import.meta.env (not process.env — unavailable in browser bundles)
const config = {
  apiUrl: import.meta.env.API_URL || 'http://localhost:3000',
  appName: import.meta.env.APP_NAME || 'My App'
}

Security (Client-side Constraints)

  • CRITICAL: All frontend code is public and visible in browser
  • All secrets stay server-side: Store API keys, tokens, and secrets on the backend only
  • Exclude .env files via .gitignore
  • Limit error messages to non-sensitive context
// Backend manages secrets, frontend accesses via proxy
const response = await fetch('/api/data') // Backend handles API key authentication

Dependency Injection

  • Custom Hooks for dependency injection: Ensure testability and modularity

Asynchronous Processing

  • Promise Handling: Always use async/await
  • Error Handling: Always handle with try-catch or Error Boundary
  • Type Definition: Explicitly define return value types (e.g., Promise<Result>)

Format Rules

  • Semicolon omission (follow Biome settings)
  • Types in PascalCase, variables/functions in camelCase
  • Imports use absolute paths (src/)

Clean Code Principles

  • Delete unused code immediately
  • Delete debug console.log()
  • Delete commented-out code (retrieve from version control when needed)
  • Comments explain "why" (not "what")

Error Handling

Absolute Rule: Every caught error must be logged with context and either re-thrown to Error Boundary, returned as a Result error variant, or displayed as user-facing error state.

Fail-Fast Principle: Fail quickly on errors to prevent continued processing in invalid states

catch (error) {
  logger.error('Processing failed', error)
  throw error // Handle with Error Boundary or higher layer
}

Result Type Pattern: Express errors with types for explicit handling

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

// Example: Express error possibility with types
function parseUser(data: unknown): Result<User, ValidationError> {
  if (!isValid(data)) return { ok: false, error: new ValidationError() }
  return { ok: true, value: data as User }
}

Custom Error Classes

export class AppError extends Error {
  constructor(message: string, public readonly code: string, public readonly statusCode = 500) {
    super(message)
    this.name = this.constructor.name
  }
}
// Purpose-specific: ValidationError(400), ApiError(502), NotFoundError(404)

Layer-Specific Error Handling (React)

  • Error Boundary: Catch React component errors, display fallback UI
  • Custom Hook: Detect business rule violations, propagate AppError as-is
  • API Layer: Convert fetch errors to domain errors

Structured Logging and Sensitive Information Protection Redact sensitive fields (password, token, apiKey, secret, creditCard) before logging

Asynchronous Error Handling in React

  • Error Boundary setup mandatory: Catch rendering errors
  • Use try-catch with all async/await in event handlers
  • Always log and re-throw errors or display error state

Refactoring Techniques

Basic Policy

  • Small Steps: Maintain always-working state through gradual improvements
  • Safe Changes: Minimize the scope of changes at once
  • Behavior Guarantee: Ensure existing behavior remains unchanged while proceeding

Implementation Procedure: Understand Current State → Gradual Changes → Behavior Verification → Final Validation

Priority: Duplicate Code Removal > Large Function Division > Complex Conditional Branch Simplification > Type Safety Improvement

Performance Optimization

  • Component Memoization: Use React.memo for expensive components
  • State Optimization: Minimize re-renders with proper state structure
  • Lazy Loading: Use React.lazy and Suspense for code splitting
  • Bundle Size: Monitor with the build script and keep under 500KB

Non-functional Requirements

  • Browser Compatibility: Chrome/Firefox/Safari/Edge (latest 2 versions)
  • Rendering Time: Within 5 seconds for major pages

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.94%
按下载量换算119

Claude

26.88%
按下载量换算86

Cursor

18.82%
按下载量换算60

Gemini CLI

9.11%
按下载量换算29

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills