typescript-skills について
LlamaFarm の React Designer と Electron アプリ向けの共通 TypeScript ガイドです。厳密な型付け、実装パターン、テスト、セキュリティの実践を扱います。
主な機能
- 01厳密な型付けと null 安全性
- 02インターフェースと明示的な戻り値型
- 03React と TanStack Query のパターン
- 04テストとセキュリティの指針
活用シーン
- 01サブシステム間で TypeScript の実践を統一
- 02アプリコードの型と null 処理を確認
- 03React コンポーネントとクエリフックを作成
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ llama-farm/ llamafarm --skill typescript-skillsインストール後、Claude Code で/typescript-skillsを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
patterns.mdsecurity.mdtesting.mdtyping.md詳細
LlamaFarm 向け TypeScript スキル
Designer(React)と Electron App のサブシステムで共通して使える、TypeScript のベストプラクティスです。
概要
このスキルでは、LlamaFarm のフロントエンドアプリケーション向けに、慣用的な TypeScript のパターンを解説します。
- designer/:React 18 + TanStack Query + TailwindCSS + Radix UI
- electron-app/:Electron 28 + Electron Vite
技術スタック
| サブシステム | フレームワーク | ビルド | 主なライブラリ |
|---|---|---|---|
| designer | React 18 | Vite | TanStack Query, Radix UI, axios, react-router-dom |
| electron-app | Electron 28 | electron-vite | electron-updater, axios |
設定
両方のプロジェクトで、厳格な TypeScript を使用しています。
{
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
}
基本原則
- 常に strict モードを有効にする - 明示的な正当化なしに
anyを使用しない - interface を優先する - オブジェクトの形状には
interface、ユニオン/交差型にはtypeを使用する - 戻り値の型を明示する - 公開関数の戻り値には必ず型を指定する
- 不変性 - 適用できる箇所では
readonlyとas constを使用する - null 安全性 - null/undefined を明示的に処理し、非 null アサーションを避ける
関連ドキュメント
- patterns.md - 慣用的な TypeScript パターン
- typing.md - 厳密な型付け、ジェネリクス、ユーティリティ型
- testing.md - Vitest とテストのパターン
- security.md - XSS の防止、入力検証
クイックリファレンス
React コンポーネントのパターン
interface Props {
readonly title: string
readonly onAction?: () => void
}
function MyComponent({ title, onAction }: Props): JSX.Element {
return <button onClick={onAction}>{title}</button>
}
TanStack Query フックのパターン
export const projectKeys = {
all: ['projects'] as const,
lists: () => [...projectKeys.all, 'list'] as const,
detail: (id: string) => [...projectKeys.all, 'detail', id] as const,
}
export function useProject(id: string) {
return useQuery({
queryKey: projectKeys.detail(id),
queryFn: () => fetchProject(id),
enabled: !!id,
})
}
エラークラスのパターン
export class ApiError extends Error {
constructor(
message: string,
public readonly status: number,
public readonly response?: unknown
) {
super(message)
this.name = 'ApiError'
}
}
チェックリストの概要
| カテゴリ | 重大 | 高 | 中 | 低 |
|---|---|---|---|---|
| 型付け | 3 | 4 | 2 | 1 |
| パターン | 2 | 3 | 3 | 2 |
| テスト | 2 | 3 | 2 | 1 |
| セキュリティ | 4 | 2 | 1 | 0 |
コメント
Markdown 対応