.claude/skills-en/frontend-typescript-rules/SKILL.md
Applies React/TypeScript type safety, component design, and state management rules. Use when implementing React components.
npx skillsauth add shinpr/ai-coding-project-boilerplate frontend-typescript-rulesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
In addition to universal anti-patterns, watch for these Frontend-specific issues:
Type Safety in Data Flow
unknown) -> Type Guard -> State (Type Guaranteed)Frontend-Specific Type Scenarios:
unknown, validate with type guardsunknown, validateunknown, validateType Complexity Management (Frontend)
Component Design Criteria
Function Design
// Object parameter
function createUser({ name, email, role }: CreateUserParams) {}
Props Design (Props-driven Approach)
Environment Variables
process.env does not work in browsersDependency Injection
Asynchronous Processing
async/awaittry-catch or Error BoundaryPromise<Result>)Format Rules
PascalCase, variables/functions in camelCasesrc/)Clean Code Principles
console.log()Absolute Rule: Error suppression prohibited. All errors must have log output and appropriate handling.
Fail-Fast Principle: Fail quickly on errors to prevent continued processing in invalid states
// Prohibited: Unconditional fallback
catch (error) {
return defaultValue // Hides error
}
// Required: Explicit failure
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)
Structured Logging and Sensitive Information Protection Never include sensitive information (password, token, apiKey, secret, creditCard) in logs
Asynchronous Error Handling in React
build script and keep under 500KBdevelopment
Vitestテスト設計と品質基準を適用。カバレッジ要件とモック使用ガイドを提供。ユニットテスト作成時に使用。
development
型安全性とエラーハンドリングルールを適用。any禁止、型ガード必須。TypeScript実装、型定義レビュー時に使用。
tools
環境変数、アーキテクチャ設計、ビルド・テストコマンドを定義。環境設定、アーキテクチャ設計時に使用。
tools
タスクの本質を分析し適切なスキルを選択。規模見積もりとメタデータを返却。タスク開始時、スキル選択時に使用。