ワンクリックで
tdd
TDD(テスト駆動開発)のワークフロー。 新機能やバグ修正の実装時に適用する。 Red → Green → Refactor のサイクルを必ず守る。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
TDD(テスト駆動開発)のワークフロー。 新機能やバグ修正の実装時に適用する。 Red → Green → Refactor のサイクルを必ず守る。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Git コミットメッセージの規約。Conventional Commits 形式、日本語。 Apply when creating git commits, reviewing commit messages, or when the user asks to commit changes.
React / Next.js の TypeScript 規約。 コンポーネント(.tsx)、hooks、Server Components、Client Components、 Server Actions の実装時に適用する。
コミット前のセルフレビュー。プロジェクトの規約に沿っているかチェックする。 Apply when the user asks to review code, check conventions, or requests a self-review before committing.
スタイリング規約。Tailwind CSS v4 と inline styles の使い分け。 UI コンポーネントやプレビュー領域のスタイリング時に適用する。 Tailwind はアプリ UI に、inline styles はプレビュー領域に使い、混在させない。
Vitest を使った TypeScript テスト規約。 テスト(.test.ts, .test.tsx)の作成・レビュー時に適用する。 純関数テスト、Result 型テスト、React コンポーネントテスト、モックを規定。
関数型プログラミングベースのTypeScriptコーディング規約。 TypeScriptコード(.ts/.tsx)の実装時に適用する。 型、アロー関数、Result型エラーハンドリング、不変性、命名、import、async、pipe/合成を規定。
| name | tdd |
| description | TDD(テスト駆動開発)のワークフロー。 新機能やバグ修正の実装時に適用する。 Red → Green → Refactor のサイクルを必ず守る。 |
実装より先にテストを書く。テストが失敗することを確認する。
// まずテストを書く
describe("buildAppliedStyles", () => {
it("kebab-case の CSS プロパティを camelCase に変換して返す", () => {
const result = buildAppliedStyles({ "font-size": "16px", "line-height": "1.5" })
expect(result).toEqual({ fontSize: "16px", lineHeight: "1.5" })
})
it("undefined の値を除外する", () => {
const result = buildAppliedStyles({ "font-size": "16px", color: undefined })
expect(result).toEqual({ fontSize: "16px" })
})
})
npx vitest run src/shared/utils/css.test.ts # → FAIL(まだ実装がない)
テストを通すためだけのコードを書く。完璧を目指さない。
export const buildAppliedStyles = (
properties: Readonly<Record<string, string | undefined>>,
): React.CSSProperties => {
const styles: Record<string, string> = {}
for (const [key, value] of Object.entries(properties)) {
if (value !== undefined) {
styles[kebabToCamel(key)] = value
}
}
return styles
}
npx vitest run src/shared/utils/css.test.ts # → PASS
テストが緑のまま、コードを改善する。
export const buildAppliedStyles = (
properties: Readonly<Record<string, string | undefined>>,
): React.CSSProperties =>
Object.entries(properties).reduce<Record<string, string>>(
(acc, [key, value]) => (value !== undefined ? { ...acc, [kebabToCamel(key)]: value } : acc),
{},
)
npx vitest run src/shared/utils/css.test.ts # → まだ PASS
| 種類 | 何をテストするか | 例 |
|---|---|---|
| ユーティリティ関数 | 入出力 | kebabToCamel, buildAppliedStyles |
| カスタム hooks | 状態遷移 | useTypographyState の dispatch 結果 |
| コンポーネント | ユーザー操作 → UI 変化 | スライダー操作 → プレビュー更新 |
| データ定義 | 構造の整合性 | 全 PropertyDefinition が必須フィールドを持つか |
npx vitest # ウォッチモード(開発中はこれ)
npx vitest run # 全テスト1回実行
npx vitest <path> # 特定ファイルのみ