coding-rules
TypeScript/React コーディング規約、インポート順序、Server/Client Components使い分け、コミット規約。コード実装、レビュー、リファクタリング時に使用。
When & Why to Use This Skill
This Claude skill provides a comprehensive set of coding standards and best practices for TypeScript and React development, specifically tailored for modern web architectures like Next.js. It enforces strict typing, functional component patterns, and clear separation of concerns between UI and logic. By standardizing import sequences, file structures, and commit conventions (Conventional Commits), it ensures high maintainability, consistent code quality, and streamlined collaboration during implementation, peer reviews, and refactoring.
Use Cases
- Automated Code Review: Use the skill to verify that pull requests adhere to TypeScript strict mode, proper Hook usage, and naming conventions.
- Project Architecture Setup: Establish a consistent file structure and component organization (1-component-per-file rule) for new or existing React projects.
- Next.js Performance Optimization: Guide the correct implementation of Server and Client Components to ensure optimal data fetching and rendering strategies.
- Workflow Standardization: Implement Conventional Commits and PR checklists (linting, type-checking, testing) to maintain a clean and professional version control history.
- Refactoring Guidance: Assist in breaking down large components (over 200 lines) and separating business logic from UI layers to improve code readability.
| name | coding-rules |
|---|---|
| description | TypeScript/React コーディング規約、インポート順序、Server/Client Components使い分け、コミット規約。コード実装、レビュー、リファクタリング時に使用。 |
コーディング規約 (MUED LMS v2)
TypeScript/React
- Strict mode 有効
- 関数コンポーネント + Hooks
- Props 型定義必須
any禁止(やむを得ない場合はコメント必須)
ファイル構成
- 1ファイル1コンポーネント
- 200行超えたら分割検討
- UI層とロジックを分離
インポート順序
// 1. React/Next.js
import { useState } from 'react';
import { useRouter } from 'next/navigation';
// 2. 外部ライブラリ
import { clsx } from 'clsx';
// 3. 内部モジュール
import { Button } from '@/components/ui/button';
// 4. 型定義
import type { User } from '@/types';
Server Components vs Client Components
// デフォルト: Server Component(use client なし)
// データフェッチ、静的レンダリングに使用
// Client Component が必要な場合のみ
'use client';
// useState, useEffect, イベントハンドラ, ブラウザAPI使用時
コミット規約
Conventional Commits 形式を使用:
feat: 新機能追加
fix: バグ修正
docs: ドキュメント
refactor: リファクタリング
test: テスト
chore: その他
PR 作成時の確認事項
npm run typecheckパスnpm run lintパスnpm run testパス- 必要に応じて E2E テスト