Communitygithub.com

ComeOnOliver/skillshub

すべてのTypeScript型は `frontend/types/index.ts` で定義されています。型はバックエンドAPIのレスポンス構造と一致し、フロントエンドアプリケーション全体で型安全性を提供します。

skillshub とは?

このスキルは、フロントエンドTypeScript型定義を作成するためのガイダンスを提供します。`frontend/types/index.ts` ファイルに既存のパターンに従って、一貫性のある型定義を生成する方法を開発者に示します。主なユースケースは、APIレスポンス構造と一致する型、フォームデータ用の型、クエリパラメータ用の型、および再利用可能なジェネリック型の作成です。スキルは、オブジェクト型には `interface`、ユニオン型(文字列リテラル)には `type`、再利用可能な構造にはジェネリック型 `<T>` の使用を推奨します。また、APIレスポンス型ではバックエンドのスネークケースフィールド名を維持し、フォームデータ型ではキャメルケースを使用するという命名規則も強調しています。このスキルは、Claude CodeやCursorなどのTypeScriptをサポートする任意のAIエージェントプラットフォームで使用でき、開発者が型安全なフロントエンドコードを効率的に作成するのに役立ちます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/asmayaseen/frontend-types

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

フロントエンド TypeScript 型定義スキル

目的: frontend/types/index.ts の既存パターンに従ったTypeScript型定義を作成するためのガイダンス。

概要

すべてのTypeScript型は frontend/types/index.ts で定義されています。型はバックエンドAPIのレスポンス構造と一致し、フロントエンドアプリケーション全体で型安全性を提供します。

frontend/types/index.ts の型パターン

1. ユーザー型

export interface User {
  id: string;
  email: string;
  name: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface UserCredentials {
  email: string;
  password: string;
}

export interface UserSignupData extends UserCredentials {
  name: string;
}

パターン:

  • オブジェクト型には interface を使用
  • オプションフィールドには ? を付与
  • 型の継承には extends を使用
  • フロントエンドの型にはキャメルケースを使用(バックエンドがスネークケースでも)

2. タスク型

export type TaskStatus = "pending" | "completed";
export type TaskPriority = "low" | "medium" | "high";

export interface Task {
  id: number;
  user_id: string;
  title: string;
  description?: string;
  completed: boolean;
  priority: TaskPriority;
  due_date?: string;
  tags: string[];
  created_at: string;
  updated_at: string;
}

export interface TaskFormData {
  title: string;
  description?: string;
  priority?: TaskPriority;
  due_date?: string;
  tags?: string[];
}

export interface TaskQueryParams {
  status?: "all" | "pending" | "completed";
  sort?: "created" | "title" | "updated" | "priority" | "due_date";
  search?: string;
  page?: number;
  limit?: number;
}

パターン:

  • ユニオン型(文字列リテラル)には type を使用
  • オブジェクト型には interface を使用
  • バックエンドのフィールド名と一致させる(APIフィールドにはスネークケース例: user_id、due_date、created_at)
  • フォームデータ用に個別の型を作成(必須フィールド以外はすべてオプション)
  • クエリパラメータ用に個別の型を作成(すべてオプション)

3. APIレスポンス型

export interface ApiResponse<T = unknown> {
  data?: T;
  success: boolean;
  message?: string;
  error?: {
    code: string;
    message: string;
    details?: unknown;
  };
}

export interface PaginatedResponse<T> {
  data: T[];
  meta: {
    total: number;
    page: number;
    limit: number;
    totalPages: number;
  };
}

パターン:

  • 再利用可能な構造にはジェネリック型 <T> を使用
  • デフォルト型パラメータを指定(<T = unknown>)
  • success ブール値フラグを含める
  • オプションの data、message、error フィールドを含める
  • ページネーション対応レスポンス用に個別の型を作成(meta オブジェクトを含む)

4. 認証型

export interface AuthResponse {
  success: boolean;
  token: string;
  user: User;
}

export interface Session {
  user: User;
  token: string;
  expiresAt: number;
}

パターン:

  • success ブール値を含める
  • token 文字列を含める
  • user オブジェクト(User型)を含める
  • セッションに expiresAt タイムスタンプを含める

5. エラー型

export interface AppError {
  message: string;
  code?: string;
  statusCode?: number;
  field?: string;
}

export interface FormErrors {
  [key: string]: string | undefined;
}

パターン:

  • エラーオブジェクトには interface を使用
  • オプションフィールドには ? を付与
  • 動的なオブジェクト型(FormErrors)にはインデックスシグネチャ [key: string] を使用

6. UI型

export type LoadingState = "idle" | "loading" | "success" | "error";

export type ToastType = "success" | "error" | "warning" | "info";

export interface ToastMessage {
  id: string;
  type: ToastType;
  message: string;
  duration?: number;
}

パターン:

  • ユニオン型(文字列リテラル)には type を使用
  • オブジェクト型には interface を使用
  • 一意な識別のために id を含める
  • オプションフィールドには ? を付与

7. エクスポート/インポート型

export type ExportFormat = "csv" | "json";

export interface ImportResult {
  imported: number;
  errors: number;
  errorDetails?: string[];
}

パターン:

  • ユニオン型(文字列リテラル)には type を使用
  • 結果オブジェクトには interface を使用
  • 成功/エラー追跡用にカウントを含める
  • オプションのエラー詳細配列を含める

型命名規則

インターフェース

  • パスカルケース: User、Task、ApiResponse
  • 説明的な名前: TaskFormData、UserSignupData

型(ユニオン型)

  • パスカルケース: TaskStatus、TaskPriority、LoadingState
  • 説明的な名前: ToastType、ExportFormat

Props型

  • コンポーネント名 + Props: TaskItemProps、ProtectedRouteProps
  • 例: interface TaskItemProps { task: Task; }

フォームデータ型

  • エンティティ名 + FormData: TaskFormData、UserSignupData
  • 例: interface TaskFormData { title: string; description?: string; }

クエリパラメータ型

  • エンティティ名 + QueryParams: TaskQueryParams
  • 例: interface TaskQueryParams { status?: "all" | "pending" | "completed"; }

バックエンドスキーマとの一致

フィールド名マッピング

バックエンド(スネークケース) → フロントエンド(フォームデータはキャメルケース、APIレスポンスはスネークケース)

// バックエンドAPIレスポンス(バックエンドと完全一致)
export interface Task {
  id: number;
  user_id: string;        // バックエンドからのスネークケース
  title: string;
  due_date?: string;     // バックエンドからのスネークケース
  created_at: string;    // バックエンドからのスネークケース
  updated_at: string;    // バックエンドからのスネークケース
}

// フロントエンドフォームデータ(使いやすさのためキャメルケース)
export interface TaskFormData {
  title: string;
  dueDate?: string;      // フロントエンド用キャメルケース
  tags?: string[];
}

パターン:

  • APIレスポンス型はバックエンドと完全一致(スネークケース)
  • フォームデータ型はフロントエンドでの使いやすさのためキャメルケースを使用
  • APIとの送受信時に形式を変換する

必須フィールドとオプションフィールド

// バックエンドAPIレスポンス(バックエンドからのすべてのフィールド)
export interface Task {
  id: number;              // 必須(バックエンドから)
  user_id: string;         // 必須(バックエンドから)
  title: string;           // 必須(バックエンドから)
  description?: string;    // オプション(バックエンドから)
  completed: boolean;      // 必須(バックエンドから)
  priority: TaskPriority;  // 必須(バックエンドから)
  due_date?: string;       // オプション(バックエンドから)
  tags: string[];          // 必須(バックエンドから、空配列可)
  created_at: string;      // 必須(バックエンドから)
  updated_at: string;      // 必須(バックエンドから)
}

// フロントエンドフォームデータ(ユーザーが編集できるフィールドのみ)
export interface TaskFormData {
  title: string;           // 必須(ユーザーが提供必須)
  description?: string;    // オプション
  priority?: TaskPriority;  // オプション(デフォルトあり)
  due_date?: string;       // オプション
  tags?: string[];         // オプション(空配列可)
}

パターン:

  • APIレスポンス型はバックエンドからのすべてのフィールドを含める
  • フォームデータ型はユーザーが編集できるフィールドのみを含める
  • オプションフィールドには ? を付与
  • 必須フィールドには ? を付与しない

型構造パターン

1. オブジェクトには interface を使用

export interface User {
  id: string;
  email: string;
}

使用する場合: プロパティを持つオブジェクト型

2. ユニオン、インターセクション、またはエイリアスには type を使用

export type TaskStatus = "pending" | "completed";
export type TaskPriority = "low" | "medium" | "high";

使用する場合: ユニオン型、インターセクション、または型エイリアス

3. 再利用可能な構造にはジェネリック型を使用

export interface ApiResponse<T = unknown> {
  data?: T;
  success: boolean;
}

使用する場合: 異なる型で動作する再利用可能な構造

4. オプションプロパティには ? を付与

export interface Task {
  title: string;        // 必須
  description?: string; // オプション
}

使用する場合: 存在しない可能性のあるフィールド

新しい型追加の完全な例

ステップ 1: エンティティ型の定義(バックエンドと一致)

export interface Category {
  id: number;
  user_id: string;
  name: string;
  color?: string;
  created_at: string;
  updated_at: string;
}

ステップ 2: フォームデータ型の定義(ユーザー入力用)

export interface CategoryFormData {
  name: string;
  color?: string;
}

ステップ 3: クエリパラメータ型の定義(APIクエリ用)

export interface CategoryQueryParams {
  search?: string;
  page?: number;
  limit?: number;
}

ステップ 4: APIクライアントで使用

async getCategories(
  userId: string,
  queryParams?: CategoryQueryParams
): Promise<ApiResponse<PaginatedResponse<Category>>> {
  // 実装
}

憲法要件

  • FR-030: すべてのAPI呼び出しに対する型付きTypeScriptインターフェース ✅
  • FR-037: TypeScript strict モード ✅

参考資料

  • 仕様: specs/002-frontend-todo-app/spec.md - エンティティ定義
  • 計画: specs/002-frontend-todo-app/plan.md - 型付きAPIコントラクト
  • 型ファイル: frontend/types/index.ts - 完全な型定義

共通パターンまとめ

  1. ✅ オブジェクト型には interface を使用
  2. ✅ ユニオン型(文字列リテラル)には type を使用
  3. ✅ 再利用可能な構造にはジェネリック型 <T> を使用
  4. ✅ オプションフィールドには ? を付与
  5. ✅ バックエンドのフィールド名と一致させる(APIレスポンスはスネークケース)
  6. ✅ フォームデータ型にはキャメルケースを使用
  7. ✅ フォームデータとクエリパラメータ用に個別の型を作成
  8. ✅ 説明的な名前を使用(EntityFormData、EntityQueryParams)
  9. ✅ バックエンドからのすべての必須フィールドを含める
  10. ✅ ジェネリックのデフォルト型パラメータを指定(<T = unknown>)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル