- name
SKILL.md
Tệp skill vẫn nằm trong kho mã của nhà phát hành.
Dán lệnh đã sao chép vào terminal. Lệnh sẽ cài đặt tệp SKILL.md này vào agent đó.
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-rules -a cursor -yDán lệnh đã sao chép vào terminal. Lệnh sẽ cài đặt tệp SKILL.md này vào agent đó.
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-rules -a claude-code -yDán lệnh đã sao chép vào terminal. Lệnh sẽ cài đặt tệp SKILL.md này vào agent đó.
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-rules -a codex -yDán lệnh đã sao chép vào terminal. Lệnh sẽ cài đặt tệp SKILL.md này vào agent đó.
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-rules -a grok -yGửi tin nhắn đã sao chép trong cuộc trò chuyện Grok Bot. Bot sẽ lấy tệp SKILL.md này từ GitHub và thêm vào bộ skill mà mọi Bot của bạn dùng chung.
Install this skill: https://github.com/shinpr/ai-coding-project-boilerplate/tree/HEAD/.claude/skills-en/frontend-typescript-rulesTừ nhà phát hành
Frontend-specific React/TypeScript rules for implementation: review signals, boundary type safety, component/state design, error handling, and project conventions.
Inspect TypeScript, bundler/framework, lint/format, path-alias, React compiler, and representative component configuration before applying a project convention. Treat a convention as observed when configuration or an established repository pattern supports it; label a conclusion from limited examples as inferred. When conflicting patterns affect public behavior, compatibility, or component boundaries, stop and name the required source or decision.
Use these as review prompts, not pass/fail thresholds. Existing project conventions and the component's responsibility take precedence.
Receive untrusted or unavailable types as unknown and narrow them with a type guard. Use as only when a runtime/framework invariant proves the asserted type and record that invariant in a nearby comment. Existing generated or third-party declarations that contain any are boundary inputs to wrap, not justification for spreading any into application contracts.
Inside the app, React Props/State are type-guaranteed — no unknown needed. At every external boundary, receive as unknown and narrow with a type guard before use: API responses, localStorage/sessionStorage, URL parameters, parsed JSON. Controlled-component form input stays type-safe through React synthetic events.
const raw: unknown = await (await fetch(url)).json()
if (!isUser(raw)) throw new ValidationError('invalid user')
const user = raw // narrowed to User
function UserCard({ user, onSelect }: UserCardProps). Type props directly on the function so the props contract stays explicituseReducer with a discriminated-union action type rather than many useState calls"use client" boundary at the smallest scope that needs it; keep browser-only APIs (window, localStorage, event handlers) inside client components, since calling them in a server component breaks the render. N/A for client-only SPAs (e.g. Vite) — skip when the project has no server-component runtimeResult type; reserve throw for unexpected/unrecoverable casesAppError carrying a code (e.g. ValidationError, ApiError, NotFoundError)AppError upward; an Error Boundary catches render-time errors and shows fallback UIuseEffect data fetches against out-of-order responses and post-unmount state updates — abort or ignore stale results (AbortController or a mounted flag), or use a server-state library (React Query/SWR) that cancels and dedupes. try-catch alone does not cover thistype Result<T, E> = { ok: true; value: T } | { ok: false; error: E }
class AppError extends Error {
constructor(message: string, readonly code: string, readonly statusCode = 500) {
super(message); this.name = this.constructor.name
}
}
Error Boundary — the one place a class component is required:
class ErrorBoundary extends React.Component<{ children: React.ReactNode; fallback: React.ReactNode }, { hasError: boolean }> {
state = { hasError: false }
static getDerivedStateFromError() { return { hasError: true } }
render() { return this.state.hasError ? this.props.fallback : this.props.children }
}
import.meta.env.VITE_*, Next.js public process.env.NEXT_PUBLIC_*, CRA process.env.REACT_APP_*. Frontend bundles contain public configuration; secret values remain behind a server-side boundarybuild script against the project's budget when one is configured. Apply code-splitting (React.lazy + Suspense) or re-render reduction when a configured budget regresses or a bundle or profiler report attributes the cost to the changed code; otherwise a performance change needs an accepted requirement. Memoization: when React Compiler is enabled, rely on it; reach for manual React.memo/useMemo/useCallback only as a profiler- or identity-justified escape hatch (a measured bottleneck, or stable reference identity for third-party APIs / effect dependencies)PascalCase; variables/functions camelCase; hooks use-prefixed; constants SCREAMING_SNAKE_CASEtsconfig, lint configuration, and representative files. Use src/ absolute paths only when the configured alias supports themApplies React/TypeScript type safety, component design, and state management rules. Use when implementing React components.
---name: frontend-typescript-rulesdescription: Applies React/TypeScript type safety, component design, and state management rules. Use when implementing…---# .claude/skills-en/frontend-typescript-rules/SKILL.mdCâu hỏi thường gặp
Tải .claude/skills-en/frontend-typescript-rules/SKILL.md từ nhà phát hành, hoặc sao chép đường dẫn và mở kho mã. PlugMCP chỉ liệt kê skill và không lưu trữ tệp này.
Nhà phát hành duy trì nó tại https://github.com/shinpr/ai-coding-project-boilerplate.
Claude, Cursor, Codex và Grok Build có thể đọc tệp SKILL.md mà bạn thêm từ kho mã của nhà phát hành. Grok Bot cài đặt skill khi bạn gửi liên kết thư mục GitHub của skill trong cuộc trò chuyện.