create-ai-project 1.11.2 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/acceptance-test-generator.md +179 -245
- package/.claude/agents/code-reviewer.md +3 -9
- package/.claude/agents/design-sync.md +221 -0
- package/.claude/agents/document-reviewer.md +15 -10
- package/.claude/agents/integration-test-reviewer.md +192 -0
- package/.claude/agents/prd-creator.md +10 -6
- package/.claude/agents/quality-fixer-frontend.md +324 -0
- package/.claude/agents/quality-fixer.md +48 -62
- package/.claude/agents/requirement-analyzer.md +8 -8
- package/.claude/agents/rule-advisor.md +84 -103
- package/.claude/agents/task-decomposer.md +21 -27
- package/.claude/agents/task-executor-frontend.md +264 -0
- package/.claude/agents/task-executor.md +4 -16
- package/.claude/agents/technical-designer-frontend.md +444 -0
- package/.claude/agents/technical-designer.md +52 -27
- package/.claude/agents/work-planner.md +41 -14
- package/.claude/agents-en/acceptance-test-generator.md +13 -13
- package/.claude/agents-en/code-reviewer.md +8 -10
- package/.claude/agents-en/design-sync.md +6 -5
- package/.claude/agents-en/document-reviewer.md +8 -7
- package/.claude/agents-en/integration-test-reviewer.md +5 -4
- package/.claude/agents-en/prd-creator.md +7 -6
- package/.claude/agents-en/quality-fixer-frontend.md +3 -14
- package/.claude/agents-en/quality-fixer.md +9 -20
- package/.claude/agents-en/requirement-analyzer.md +8 -7
- package/.claude/agents-en/rule-advisor.md +57 -128
- package/.claude/agents-en/task-decomposer.md +4 -10
- package/.claude/agents-en/task-executor-frontend.md +4 -16
- package/.claude/agents-en/task-executor.md +5 -16
- package/.claude/agents-en/technical-designer-frontend.md +17 -15
- package/.claude/agents-en/technical-designer.md +13 -15
- package/.claude/agents-en/work-planner.md +9 -14
- package/.claude/agents-ja/acceptance-test-generator.md +9 -15
- package/.claude/agents-ja/code-reviewer.md +3 -11
- package/.claude/agents-ja/design-sync.md +2 -6
- package/.claude/agents-ja/document-reviewer.md +4 -9
- package/.claude/agents-ja/integration-test-reviewer.md +2 -5
- package/.claude/agents-ja/prd-creator.md +3 -7
- package/.claude/agents-ja/quality-fixer-frontend.md +2 -13
- package/.claude/agents-ja/quality-fixer.md +7 -18
- package/.claude/agents-ja/requirement-analyzer.md +5 -8
- package/.claude/agents-ja/rule-advisor.md +57 -128
- package/.claude/agents-ja/task-decomposer.md +4 -10
- package/.claude/agents-ja/task-executor-frontend.md +3 -15
- package/.claude/agents-ja/task-executor.md +3 -17
- package/.claude/agents-ja/technical-designer-frontend.md +17 -15
- package/.claude/agents-ja/technical-designer.md +13 -15
- package/.claude/agents-ja/work-planner.md +9 -14
- package/.claude/commands/build.md +7 -10
- package/.claude/commands/design.md +15 -5
- package/.claude/commands/front-build.md +103 -0
- package/.claude/commands/front-design.md +42 -0
- package/.claude/commands/front-plan.md +40 -0
- package/.claude/commands/implement.md +23 -29
- package/.claude/commands/plan.md +4 -4
- package/.claude/commands/project-inject.md +4 -4
- package/.claude/{commands-ja/refine-rule.md → commands/refine-skill.md} +25 -25
- package/.claude/{commands-ja/sync-rules.md → commands/sync-skills.md} +28 -28
- package/.claude/commands/task.md +1 -1
- package/.claude/commands-en/build.md +2 -2
- package/.claude/commands-en/design.md +1 -1
- package/.claude/commands-en/implement.md +8 -8
- package/.claude/commands-en/plan.md +3 -3
- package/.claude/commands-en/project-inject.md +4 -4
- package/.claude/commands-en/{refine-rule.md → refine-skill.md} +47 -48
- package/.claude/commands-en/{sync-rules.md → sync-skills.md} +29 -29
- package/.claude/commands-ja/build.md +2 -2
- package/.claude/commands-ja/design.md +1 -1
- package/.claude/commands-ja/implement.md +8 -8
- package/.claude/commands-ja/plan.md +3 -3
- package/.claude/commands-ja/project-inject.md +4 -4
- package/.claude/{commands/refine-rule.md → commands-ja/refine-skill.md} +25 -25
- package/.claude/{commands/sync-rules.md → commands-ja/sync-skills.md} +28 -28
- package/.claude/settings.local.json +21 -1
- package/{docs/rules/ai-development-guide.md → .claude/skills/coding-standards/SKILL.md} +94 -108
- package/{docs/rules/documentation-criteria.md → .claude/skills/documentation-criteria/SKILL.md} +19 -6
- package/.claude/skills/documentation-criteria/references/adr-template.md +64 -0
- package/.claude/skills/documentation-criteria/references/design-template.md +242 -0
- package/.claude/skills/documentation-criteria/references/plan-template.md +130 -0
- package/.claude/skills/documentation-criteria/references/prd-template.md +109 -0
- package/.claude/skills/frontend/technical-spec/SKILL.md +147 -0
- package/.claude/skills/frontend/typescript-rules/SKILL.md +315 -0
- package/.claude/skills/frontend/typescript-testing/SKILL.md +212 -0
- package/{docs/rules-ja/architecture/implementation-approach.md → .claude/skills/implementation-approach/SKILL.md} +10 -5
- package/.claude/skills/integration-e2e-testing/SKILL.md +146 -0
- package/{docs/rules-ja/project-context.md → .claude/skills/project-context/SKILL.md} +7 -3
- package/.claude/skills/subagents-orchestration-guide/SKILL.md +212 -0
- package/.claude/skills/task-analyzer/SKILL.md +142 -0
- package/.claude/skills/task-analyzer/references/skills-index.yaml +211 -0
- package/.claude/skills/technical-spec/SKILL.md +86 -0
- package/{docs/rules/typescript.md → .claude/skills/typescript-rules/SKILL.md} +22 -67
- package/.claude/skills/typescript-testing/SKILL.md +155 -0
- package/{docs/rules-en/coding-standards.md → .claude/skills-en/coding-standards/SKILL.md} +21 -108
- package/{docs/rules-en/documentation-criteria.md → .claude/skills-en/documentation-criteria/SKILL.md} +40 -42
- package/{docs/adr/template-en.md → .claude/skills-en/documentation-criteria/references/adr-template.md} +1 -1
- package/{docs/design/template-en.md → .claude/skills-en/documentation-criteria/references/design-template.md} +11 -31
- package/{docs/plans/template-en.md → .claude/skills-en/documentation-criteria/references/plan-template.md} +4 -4
- package/{docs/prd/template-en.md → .claude/skills-en/documentation-criteria/references/prd-template.md} +1 -1
- package/{docs/rules-en/frontend/technical-spec.md → .claude/skills-en/frontend/technical-spec/SKILL.md} +17 -13
- package/{docs/rules-en/frontend/typescript.md → .claude/skills-en/frontend/typescript-rules/SKILL.md} +17 -12
- package/{docs/rules-en/frontend/typescript-testing.md → .claude/skills-en/frontend/typescript-testing/SKILL.md} +11 -6
- package/{docs/rules-en/architecture/implementation-approach.md → .claude/skills-en/implementation-approach/SKILL.md} +7 -2
- package/{docs/rules-en/integration-e2e-testing.md → .claude/skills-en/integration-e2e-testing/SKILL.md} +15 -18
- package/{docs/rules-en/project-context.md → .claude/skills-en/project-context/SKILL.md} +7 -3
- package/.claude/skills-en/subagents-orchestration-guide/SKILL.md +224 -0
- package/.claude/skills-en/task-analyzer/SKILL.md +131 -0
- package/{docs/rules-en/rules-index.yaml → .claude/skills-en/task-analyzer/references/skills-index.yaml} +34 -20
- package/{docs/rules-en/technical-spec.md → .claude/skills-en/technical-spec/SKILL.md} +6 -6
- package/{docs/rules-en/typescript.md → .claude/skills-en/typescript-rules/SKILL.md} +15 -10
- package/{docs/rules-en/typescript-testing.md → .claude/skills-en/typescript-testing/SKILL.md} +10 -4
- package/{docs/rules-ja/coding-standards.md → .claude/skills-ja/coding-standards/SKILL.md} +12 -99
- package/{docs/rules-ja/documentation-criteria.md → .claude/skills-ja/documentation-criteria/SKILL.md} +18 -5
- package/.claude/skills-ja/documentation-criteria/references/adr-template.md +64 -0
- package/.claude/skills-ja/documentation-criteria/references/design-template.md +261 -0
- package/{docs/plans/template-ja.md → .claude/skills-ja/documentation-criteria/references/plan-template.md} +38 -38
- package/{docs/prd/template-ja.md → .claude/skills-ja/documentation-criteria/references/prd-template.md} +33 -33
- package/{docs/rules-ja/frontend/technical-spec.md → .claude/skills-ja/frontend/technical-spec/SKILL.md} +13 -9
- package/.claude/skills-ja/frontend/typescript-rules/SKILL.md +315 -0
- package/{docs/rules-ja/frontend/typescript-testing.md → .claude/skills-ja/frontend/typescript-testing/SKILL.md} +93 -5
- package/{docs/rules/architecture/implementation-approach.md → .claude/skills-ja/implementation-approach/SKILL.md} +10 -5
- package/{docs/rules-ja/integration-e2e-testing.md → .claude/skills-ja/integration-e2e-testing/SKILL.md} +5 -8
- package/{docs/rules/project-context.md → .claude/skills-ja/project-context/SKILL.md} +7 -3
- package/.claude/skills-ja/subagents-orchestration-guide/SKILL.md +212 -0
- package/.claude/skills-ja/task-analyzer/SKILL.md +131 -0
- package/{docs/rules-ja/rules-index.yaml → .claude/skills-ja/task-analyzer/references/skills-index.yaml} +34 -19
- package/{docs/rules-ja/technical-spec.md → .claude/skills-ja/technical-spec/SKILL.md} +6 -6
- package/{docs/rules-ja/typescript.md → .claude/skills-ja/typescript-rules/SKILL.md} +16 -11
- package/{docs/rules-ja/typescript-testing.md → .claude/skills-ja/typescript-testing/SKILL.md} +11 -5
- package/CLAUDE.en.md +6 -6
- package/CLAUDE.ja.md +6 -6
- package/CLAUDE.md +19 -28
- package/README.ja.md +39 -10
- package/README.md +39 -10
- package/package.json +1 -1
- package/scripts/set-language.js +35 -53
- package/scripts/setup-project.js +4 -1
- package/docs/adr/template-ja.md +0 -64
- package/docs/design/template-ja.md +0 -285
- package/docs/guides/en/sub-agents.md +0 -343
- package/docs/guides/ja/sub-agents.md +0 -343
- package/docs/guides/sub-agents.md +0 -306
- package/docs/plans/20250123-integration-test-improvement.md +0 -993
- package/docs/rules/rules-index.yaml +0 -137
- package/docs/rules/technical-spec.md +0 -47
- package/docs/rules/typescript-testing.md +0 -188
- package/docs/rules-ja/frontend/typescript.md +0 -131
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# 各ルールファイルのメタデータ
|
|
2
|
-
# 各ルールの概要、タグ、典型的な使用場面、サイズを管理
|
|
3
|
-
|
|
4
|
-
rules:
|
|
5
|
-
typescript:
|
|
6
|
-
file: "typescript.md"
|
|
7
|
-
tags: [implementation, type-safety, async, refactoring, coding-style, functional-programming, dependency-injection, branded-types]
|
|
8
|
-
typical-use: "TypeScriptコードの作成・修正・リファクタリング、モダンな型機能活用"
|
|
9
|
-
size: medium
|
|
10
|
-
key-references:
|
|
11
|
-
- "YAGNI原則 - Kent Beck"
|
|
12
|
-
- "Clean Code - Robert C. Martin"
|
|
13
|
-
- "DRY原則 - The Pragmatic Programmer"
|
|
14
|
-
- "Refactoring - Martin Fowler"
|
|
15
|
-
- "TypeScript 4.9 satisfies演算子 - Microsoft"
|
|
16
|
-
- "Branded Types - TypeScript Community"
|
|
17
|
-
- "Effect-TS / fp-ts - 関数型プログラミング"
|
|
18
|
-
- "Dependency Injection - Martin Fowler"
|
|
19
|
-
- "Avoiding fallback in distributed systems - AWS Builders' Library"
|
|
20
|
-
sections:
|
|
21
|
-
- "基本原則"
|
|
22
|
-
- "コメント記述ルール"
|
|
23
|
-
- "型安全性"
|
|
24
|
-
- "コーディング規約"
|
|
25
|
-
- "エラーハンドリング"
|
|
26
|
-
- "リファクタリング手法"
|
|
27
|
-
- "パフォーマンス最適化"
|
|
28
|
-
|
|
29
|
-
typescript-testing:
|
|
30
|
-
file: "typescript-testing.md"
|
|
31
|
-
tags: [quality, testing, tdd, coverage, vitest, implementation, debugging, refactoring]
|
|
32
|
-
typical-use: "テスト作成、品質チェック、コード修正・バグ修正・リファクタリング・新機能実装時の開発ステップ"
|
|
33
|
-
size: medium
|
|
34
|
-
key-references:
|
|
35
|
-
- "Test-Driven Development - Kent Beck"
|
|
36
|
-
- "Rule of Three - Martin Fowler"
|
|
37
|
-
- "Red-Green-Refactor - Kent Beck"
|
|
38
|
-
- "AAAパターン - Arrange-Act-Assert"
|
|
39
|
-
sections:
|
|
40
|
-
- "テストフレームワーク"
|
|
41
|
-
- "テストの基本方針"
|
|
42
|
-
- "Red-Green-Refactorプロセス(テストファースト開発)"
|
|
43
|
-
- "テストの設計原則"
|
|
44
|
-
- "テストヘルパーの活用ルール"
|
|
45
|
-
- "テストの実装規約"
|
|
46
|
-
- "テストの粒度"
|
|
47
|
-
- "モックの型安全性"
|
|
48
|
-
- "継続性テストの範囲"
|
|
49
|
-
- "Vitestの基本例"
|
|
50
|
-
|
|
51
|
-
ai-development-guide:
|
|
52
|
-
file: "ai-development-guide.md"
|
|
53
|
-
tags: [anti-patterns, technical-judgment, debugging, quality-commands, rule-of-three, implementation, type-safety, refactoring, code-reading, best-practices, impact-analysis, unused-code, code-deletion]
|
|
54
|
-
typical-use: "技術的判断基準、アンチパターン検出、デバッグ手法、品質チェックコマンド、実装時のベストプラクティス、影響範囲調査、未使用コード削除"
|
|
55
|
-
size: medium
|
|
56
|
-
key-references:
|
|
57
|
-
- "Rule of Three - Martin Fowler"
|
|
58
|
-
- "5 Whys - トヨタ生産方式"
|
|
59
|
-
- "DRY原則 - The Pragmatic Programmer"
|
|
60
|
-
- "単一責任原則(SRP) - Clean Code"
|
|
61
|
-
- "YAGNI原則 - Extreme Programming"
|
|
62
|
-
- "Avoiding fallback in distributed systems - AWS Builders' Library"
|
|
63
|
-
sections:
|
|
64
|
-
- "技術的アンチパターン(赤信号パターン)"
|
|
65
|
-
- "フォールバック処理に関する設計原則"
|
|
66
|
-
- "Rule of Three - コード重複の判断基準"
|
|
67
|
-
- "よくある失敗パターンと回避方法"
|
|
68
|
-
- "デバッグ手法"
|
|
69
|
-
- "品質チェックコマンドリファレンス"
|
|
70
|
-
- "技術的判断が必要な場面"
|
|
71
|
-
- "継続的改善のマインドセット"
|
|
72
|
-
- "実装作業の完全性担保"
|
|
73
|
-
|
|
74
|
-
technical-spec:
|
|
75
|
-
file: "technical-spec.md"
|
|
76
|
-
tags: [architecture, design, documentation, environment, data-flow, implementation]
|
|
77
|
-
typical-use: "技術設計、環境設定、ドキュメント作成プロセス、実装方針決定"
|
|
78
|
-
size: medium
|
|
79
|
-
key-references:
|
|
80
|
-
- "ADRフォーマット - Michael Nygard"
|
|
81
|
-
- "単一データソース原則 - Single Source of Truth"
|
|
82
|
-
sections:
|
|
83
|
-
- "技術スタックの基本方針"
|
|
84
|
-
- "環境変数管理とセキュリティ"
|
|
85
|
-
- "アーキテクチャ設計"
|
|
86
|
-
- "パターン適用の一貫性"
|
|
87
|
-
- "データフロー統一原則"
|
|
88
|
-
- "ビルドとテスト"
|
|
89
|
-
|
|
90
|
-
project-context:
|
|
91
|
-
file: "project-context.md"
|
|
92
|
-
tags: [context, project-specific, implementation]
|
|
93
|
-
typical-use: "プロジェクト固有情報、実装原則の理解"
|
|
94
|
-
size: small
|
|
95
|
-
key-references:
|
|
96
|
-
- "プロジェクト固有(経験則)"
|
|
97
|
-
sections:
|
|
98
|
-
- "基本設定"
|
|
99
|
-
- "実装原則"
|
|
100
|
-
- "カスタマイズガイド"
|
|
101
|
-
|
|
102
|
-
documentation-criteria:
|
|
103
|
-
file: "documentation-criteria.md"
|
|
104
|
-
tags: [documentation, decision-making, adr, prd, design-doc, planning, process]
|
|
105
|
-
typical-use: "実装開始時の規模判定、ドキュメント作成判定、ADR/PRD/Design Doc/作業計画書の作成基準"
|
|
106
|
-
size: medium
|
|
107
|
-
key-references:
|
|
108
|
-
- "ADR手法 - Michael Nygard"
|
|
109
|
-
- "Design Doc文化 - Google Engineering Practices"
|
|
110
|
-
- "Single Source of Truth"
|
|
111
|
-
sections:
|
|
112
|
-
- "作成判定マトリクス"
|
|
113
|
-
- "ADR作成条件(いずれか該当で必須)"
|
|
114
|
-
- "各ドキュメントの詳細定義"
|
|
115
|
-
- "作成プロセス"
|
|
116
|
-
- "保存場所"
|
|
117
|
-
- "ADRステータス"
|
|
118
|
-
- "AI自動化ルール"
|
|
119
|
-
- "図表作成要件"
|
|
120
|
-
- "共通ADRとの関係性"
|
|
121
|
-
|
|
122
|
-
implementation-approach:
|
|
123
|
-
file: "architecture/implementation-approach.md"
|
|
124
|
-
tags: [architecture, implementation, task-decomposition, strategy-patterns, strangler-pattern, facade-pattern, design, planning, confirmation-levels]
|
|
125
|
-
typical-use: "実装戦略の選択、タスク分解、設計判断、大規模変更の計画"
|
|
126
|
-
size: medium
|
|
127
|
-
key-references:
|
|
128
|
-
- "Strangler Fig Pattern - Martin Fowler"
|
|
129
|
-
- "Feature Slicing - Martin Fowler"
|
|
130
|
-
- "Walking Skeleton - Alistair Cockburn"
|
|
131
|
-
- "Facade Pattern - Gang of Four"
|
|
132
|
-
sections:
|
|
133
|
-
- "メタ認知的戦略選択プロセス"
|
|
134
|
-
- "確認レベル定義"
|
|
135
|
-
- "統合ポイントの定義"
|
|
136
|
-
- "アンチパターン"
|
|
137
|
-
- "メタ認知的実行のための指針"
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# 技術設計ルール
|
|
2
|
-
|
|
3
|
-
## 技術スタックの基本方針
|
|
4
|
-
TypeScriptをベースとしたアプリケーション実装。アーキテクチャパターンはプロジェクトの要件と規模に応じて選択すること。
|
|
5
|
-
|
|
6
|
-
## 環境変数管理とセキュリティ
|
|
7
|
-
|
|
8
|
-
### 環境変数管理
|
|
9
|
-
- 環境変数は一元管理し、型安全性を確保する仕組みを構築すること
|
|
10
|
-
- `process.env` の直接参照は避け、設定管理層を通じて取得すること
|
|
11
|
-
- デフォルト値の設定や必須チェックを適切に実装すること
|
|
12
|
-
|
|
13
|
-
### セキュリティ
|
|
14
|
-
- `.env`ファイルはGitに含めない
|
|
15
|
-
- APIキーやシークレットは必ず環境変数として管理
|
|
16
|
-
- 機密情報のログ出力は禁止
|
|
17
|
-
- エラーメッセージに機密情報を含めない
|
|
18
|
-
|
|
19
|
-
## アーキテクチャ設計
|
|
20
|
-
|
|
21
|
-
### アーキテクチャ設計の原則
|
|
22
|
-
プロジェクトごとに適切なアーキテクチャを選択し、明確に定義すること:
|
|
23
|
-
|
|
24
|
-
- **明確な定義**: プロジェクトのアーキテクチャは`docs/rules/architecture/`配下に専用ファイルで定義
|
|
25
|
-
- **責務の分離**: 各層やモジュールの責務を明確に定義し、境界を守ること
|
|
26
|
-
|
|
27
|
-
## パターン適用の一貫性
|
|
28
|
-
|
|
29
|
-
選択したアーキテクチャパターンに厳密に従う。プロジェクト固有詳細は`docs/rules/architecture/`参照。
|
|
30
|
-
|
|
31
|
-
## データフロー統一原則
|
|
32
|
-
|
|
33
|
-
#### 基本原則
|
|
34
|
-
1. **単一データソース**: 同じ情報は1箇所にのみ保存する
|
|
35
|
-
2. **構造化データ優先**: JSON文字列ではなくパース済みオブジェクトを使用
|
|
36
|
-
3. **明確な責務分離**: 各層の責務を明確に定義
|
|
37
|
-
|
|
38
|
-
#### データフローのベストプラクティス
|
|
39
|
-
- **入力時点での検証**: データは入力層で検証し、型安全な形で内部に渡す
|
|
40
|
-
- **変換の一元化**: データ変換ロジックは専用のユーティリティに集約
|
|
41
|
-
- **ログの構造化**: データフローの各段階で構造化ログを出力
|
|
42
|
-
|
|
43
|
-
## ビルドとテスト
|
|
44
|
-
|
|
45
|
-
プロジェクトごとにビルドコマンドとテスト実行方法を定義。
|
|
46
|
-
|
|
47
|
-
品質チェックは実装完了時に必須。
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# TypeScript テストルール
|
|
2
|
-
|
|
3
|
-
## テストフレームワーク
|
|
4
|
-
- **Vitest**: このプロジェクトではVitestを使用
|
|
5
|
-
- テストのインポート: `import { describe, it, expect, beforeEach, vi } from 'vitest'`
|
|
6
|
-
- モックの作成: `vi.mock()` を使用
|
|
7
|
-
|
|
8
|
-
## テストの基本方針
|
|
9
|
-
|
|
10
|
-
### 品質要件
|
|
11
|
-
- **カバレッジ**: 単体テストのカバレッジは70%以上を必須
|
|
12
|
-
- **独立性**: 各テストは他のテストに依存せず実行可能
|
|
13
|
-
- **再現性**: テストは環境に依存せず、常に同じ結果を返す
|
|
14
|
-
- **可読性**: テストコードも製品コードと同様の品質を維持
|
|
15
|
-
|
|
16
|
-
### カバレッジ要件
|
|
17
|
-
**必須**: 単体テストのカバレッジは70%以上
|
|
18
|
-
**指標**: Statements(文)、Branches(分岐)、Functions(関数)、Lines(行)
|
|
19
|
-
|
|
20
|
-
### テストの種類と範囲
|
|
21
|
-
1. **単体テスト(Unit Tests)**
|
|
22
|
-
- 個々の関数やクラスの動作を検証
|
|
23
|
-
- 外部依存はすべてモック化
|
|
24
|
-
- 最も数が多く、細かい粒度で実施
|
|
25
|
-
|
|
26
|
-
2. **統合テスト(Integration Tests)**
|
|
27
|
-
- 複数のコンポーネントの連携を検証
|
|
28
|
-
- 実際の依存関係を使用(DBやAPI等)
|
|
29
|
-
- 主要な機能フローの検証
|
|
30
|
-
|
|
31
|
-
3. **E2Eテストでの機能横断検証**
|
|
32
|
-
- 新機能追加時、既存機能への影響を必ず検証
|
|
33
|
-
- Design Docの「統合ポイントマップ」で影響度「高」「中」の箇所をカバー
|
|
34
|
-
- 検証パターン: 既存機能動作 → 新機能有効化 → 既存機能の継続性確認
|
|
35
|
-
- 判定基準: レスポンス内容の変化なし、処理時間5秒以内
|
|
36
|
-
- CI/CDでの自動実行を前提とした設計
|
|
37
|
-
|
|
38
|
-
## Red-Green-Refactorプロセス(テストファースト開発)
|
|
39
|
-
|
|
40
|
-
**推奨原則**: コード変更は必ずテストから始める
|
|
41
|
-
|
|
42
|
-
**背景**:
|
|
43
|
-
- 変更前の動作を保証し、リグレッションを防止
|
|
44
|
-
- 期待する動作を明確化してから実装
|
|
45
|
-
- リファクタリング時の安全性を確保
|
|
46
|
-
|
|
47
|
-
**開発ステップ**:
|
|
48
|
-
1. **Red**: 期待する動作のテストを書く(失敗する)
|
|
49
|
-
2. **Green**: 最小限の実装でテストを通す
|
|
50
|
-
3. **Refactor**: テストが通る状態を維持しながらコード改善
|
|
51
|
-
|
|
52
|
-
**NGケース(テストファースト不要)**:
|
|
53
|
-
- 純粋な設定ファイル変更(.env、config等)
|
|
54
|
-
- ドキュメントのみの更新(README、コメント等)
|
|
55
|
-
- 緊急本番障害対応(ただし事後テスト必須)
|
|
56
|
-
|
|
57
|
-
## テストの設計原則
|
|
58
|
-
|
|
59
|
-
### テストケースの構造
|
|
60
|
-
- テストは「準備(Arrange)」「実行(Act)」「検証(Assert)」の3段階で構成
|
|
61
|
-
- 各テストの目的が明確に分かる命名
|
|
62
|
-
- 1つのテストケースでは1つの振る舞いのみを検証
|
|
63
|
-
|
|
64
|
-
### テストデータ管理
|
|
65
|
-
- テストデータは専用ディレクトリで管理
|
|
66
|
-
- 環境変数はテスト用の値を定義
|
|
67
|
-
- 機密情報は必ずモック化
|
|
68
|
-
- テストデータは最小限に保ち、テストケースの検証目的に直接関連するデータのみ使用
|
|
69
|
-
|
|
70
|
-
### モックとスタブの使用方針
|
|
71
|
-
|
|
72
|
-
✅ **推奨: 単体テストでの外部依存モック化**
|
|
73
|
-
- メリット: テストの独立性と再現性を確保
|
|
74
|
-
- 実践: DB、API、ファイルシステム等の外部依存をモック化
|
|
75
|
-
|
|
76
|
-
❌ **避けるべき: 単体テストでの実際の外部接続**
|
|
77
|
-
- 理由: テスト速度が遅くなり、環境依存の問題が発生するため
|
|
78
|
-
|
|
79
|
-
### テスト失敗時の対応判断基準
|
|
80
|
-
|
|
81
|
-
**テストを修正**: 間違った期待値、存在しない機能参照、実装詳細への依存、テストのためだけの実装
|
|
82
|
-
**実装を修正**: 妥当な仕様、ビジネスロジック、重要なエッジケース
|
|
83
|
-
**判断に迷ったら**: ユーザーに確認
|
|
84
|
-
|
|
85
|
-
## テストヘルパーの活用ルール
|
|
86
|
-
|
|
87
|
-
### 基本原則
|
|
88
|
-
テストヘルパーは、テストコードの重複を減らし、保守性を高めるために活用します。
|
|
89
|
-
|
|
90
|
-
### 判断基準
|
|
91
|
-
| モックの特性 | 対応方針 |
|
|
92
|
-
|-------------|---------|
|
|
93
|
-
| **単純で安定** | 共通ヘルパーに集約 |
|
|
94
|
-
| **複雑または変更頻度高** | 個別実装 |
|
|
95
|
-
| **3箇所以上で重複** | 共通化を検討 |
|
|
96
|
-
| **テスト固有ロジック** | 個別実装 |
|
|
97
|
-
|
|
98
|
-
### テストヘルパー活用例
|
|
99
|
-
```typescript
|
|
100
|
-
// ✅ ビルダーパターン
|
|
101
|
-
const testData = new TestDataBuilder().withDefaults().withName('Test User').build()
|
|
102
|
-
|
|
103
|
-
// ✅ カスタムアサーション
|
|
104
|
-
function assertValidUser(user: unknown): asserts user is User {}
|
|
105
|
-
|
|
106
|
-
// ❌ 重複する複雑なモックの個別実装
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## テストの実装規約
|
|
110
|
-
|
|
111
|
-
### ディレクトリ構造
|
|
112
|
-
```
|
|
113
|
-
src/
|
|
114
|
-
└── application/
|
|
115
|
-
└── services/
|
|
116
|
-
├── __tests__/
|
|
117
|
-
│ ├── service.test.ts # 単体テスト
|
|
118
|
-
│ └── service.int.test.ts # 統合テスト
|
|
119
|
-
└── service.ts
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### 命名規則
|
|
123
|
-
- テストファイル: `{対象ファイル名}.test.ts`
|
|
124
|
-
- 統合テストファイル: `{対象ファイル名}.int.test.ts`
|
|
125
|
-
- テストスイート: 対象の機能や状況を説明する名前
|
|
126
|
-
- テストケース: 期待される動作を説明する名前
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
### テストコードの品質ルール
|
|
130
|
-
|
|
131
|
-
✅ **推奨: すべてのテストを常に有効に保つ**
|
|
132
|
-
- メリット: テストスイートの完全性を保証
|
|
133
|
-
- 実践: 問題があるテストは修正して有効化
|
|
134
|
-
|
|
135
|
-
❌ **避けるべき: test.skip()やコメントアウト**
|
|
136
|
-
- 理由: テストの穴が生まれ、品質チェックが不完全になる
|
|
137
|
-
- 対処: 不要なテストは完全に削除する
|
|
138
|
-
|
|
139
|
-
## テストの粒度
|
|
140
|
-
|
|
141
|
-
### 原則:観測可能な振る舞いのみ
|
|
142
|
-
**テスト対象**:公開API、戻り値、例外、外部呼び出し、永続化された状態
|
|
143
|
-
**テスト対象外**:privateメソッド、内部状態、アルゴリズム詳細
|
|
144
|
-
|
|
145
|
-
```typescript
|
|
146
|
-
// ✅ 振る舞いをテスト
|
|
147
|
-
expect(calculatePrice(100, 0.1)).toBe(110)
|
|
148
|
-
|
|
149
|
-
// ❌ 実装詳細をテスト
|
|
150
|
-
expect((calculator as any).taxRate).toBe(0.1)
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## モックの型安全性
|
|
154
|
-
|
|
155
|
-
### 必要最小限の型定義
|
|
156
|
-
```typescript
|
|
157
|
-
// ✅ 必要な部分のみ
|
|
158
|
-
type TestRepo = Pick<Repository, 'find' | 'save'>
|
|
159
|
-
const mock: TestRepo = { find: vi.fn(), save: vi.fn() }
|
|
160
|
-
|
|
161
|
-
// やむを得ない場合のみ、理由明記
|
|
162
|
-
const sdkMock = {
|
|
163
|
-
call: vi.fn()
|
|
164
|
-
} as unknown as ExternalSDK // 外部SDKの複雑な型のため
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## 継続性テストの範囲
|
|
168
|
-
|
|
169
|
-
新機能追加時の既存機能への影響確認に限定。長時間運用・負荷テストはインフラ層の責務のため対象外。
|
|
170
|
-
|
|
171
|
-
## Vitestの基本例
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
import { describe, it, expect, vi } from 'vitest'
|
|
175
|
-
|
|
176
|
-
vi.mock('./userService', () => ({
|
|
177
|
-
getUserById: vi.fn(),
|
|
178
|
-
updateUser: vi.fn()
|
|
179
|
-
}))
|
|
180
|
-
|
|
181
|
-
describe('ComponentName', () => {
|
|
182
|
-
it('should follow AAA pattern', () => {
|
|
183
|
-
const input = 'test'
|
|
184
|
-
const result = someFunction(input)
|
|
185
|
-
expect(result).toBe('expected')
|
|
186
|
-
})
|
|
187
|
-
})
|
|
188
|
-
```
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# TypeScript開発ルール
|
|
2
|
-
|
|
3
|
-
## フロントエンド固有のアンチパターン
|
|
4
|
-
|
|
5
|
-
coding-standards.mdの普遍的アンチパターンに加え、以下のフロントエンド固有の問題に注意:
|
|
6
|
-
|
|
7
|
-
- **3階層以上のProp drilling** - Context APIまたは状態管理を使用すべき
|
|
8
|
-
- **巨大なコンポーネント(300行以上)** - 小さなコンポーネントに分割
|
|
9
|
-
|
|
10
|
-
## Frontend実装における型安全性
|
|
11
|
-
|
|
12
|
-
**データフローにおける型安全性**
|
|
13
|
-
- **Frontend → Backend**: Props/State(型保証済み) → APIリクエスト(シリアライゼーション)
|
|
14
|
-
- **Backend → Frontend**: APIレスポンス(`unknown`) → 型ガード → State(型保証済み)
|
|
15
|
-
|
|
16
|
-
**Frontend固有の型シナリオ**:
|
|
17
|
-
- **React Props/State**: TypeScriptが型管理、unknown不要
|
|
18
|
-
- **外部APIレスポンス**: 常に`unknown`として受け取り、型ガードで検証
|
|
19
|
-
- **localStorage/sessionStorage**: `unknown`として扱い、検証
|
|
20
|
-
- **URLパラメータ**: `unknown`として扱い、検証
|
|
21
|
-
- **Form入力(Controlled Components)**: React合成イベントで型安全
|
|
22
|
-
|
|
23
|
-
**型の複雑性管理(Frontend)**
|
|
24
|
-
- **Props設計**:
|
|
25
|
-
- Props数: 3-7個が理想(10個超えたらコンポーネント分割検討)
|
|
26
|
-
- Optional Props: 50%以下(多すぎる場合はデフォルト値やContext使用検討)
|
|
27
|
-
- ネスト: 2レベルまで(深いネストはFlatten推奨)
|
|
28
|
-
- 型アサーション: 3回以上使用で設計見直し
|
|
29
|
-
- **外部API型**: 制約を緩和し実態に応じて定義(内部で適切に変換)
|
|
30
|
-
|
|
31
|
-
## コーディング規約
|
|
32
|
-
|
|
33
|
-
**コンポーネント設計基準**
|
|
34
|
-
- **Function Components(必須)**: React公式推奨、モダンツールで最適化可能
|
|
35
|
-
- **Classes禁止**: Class componentsは完全非推奨(例外: Error Boundary)
|
|
36
|
-
- **Custom Hooks**: ロジック再利用の標準パターン
|
|
37
|
-
|
|
38
|
-
**関数設計**
|
|
39
|
-
- **0-2パラメータまで**: 3個以上はオブジェクト使用
|
|
40
|
-
```typescript
|
|
41
|
-
// ✅ オブジェクトパラメータ
|
|
42
|
-
function createUser({ name, email, role }: CreateUserParams) {}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
**Props設計(Props-drivenアプローチ)**
|
|
46
|
-
- Propsはインターフェース: 必要な情報を全てPropsとして定義
|
|
47
|
-
- 暗黙的依存を避ける: 必要なくグローバルstateやcontextに依存しない
|
|
48
|
-
- 型安全性: Props型を常に明示的に定義
|
|
49
|
-
|
|
50
|
-
**環境変数**
|
|
51
|
-
- **ビルドツールの環境変数システムを使用**: `process.env`はブラウザで動作しない
|
|
52
|
-
- **クライアントサイドに秘密情報なし**: フロントエンドコードは全て公開、秘密情報はバックエンドで管理
|
|
53
|
-
|
|
54
|
-
**依存性注入**
|
|
55
|
-
- **カスタムフックで依存性注入**: テスト可能性とモジュール性を確保
|
|
56
|
-
|
|
57
|
-
**非同期処理**
|
|
58
|
-
- Promise処理: 常に`async/await`使用
|
|
59
|
-
- エラーハンドリング: 常に`try-catch`またはError Boundaryで処理
|
|
60
|
-
- 型定義: 戻り値の型を明示的に定義(例: `Promise<Result>`)
|
|
61
|
-
|
|
62
|
-
**フォーマットルール**
|
|
63
|
-
- セミコロン省略(Biome設定に従う)
|
|
64
|
-
- 型は`PascalCase`、変数・関数は`camelCase`
|
|
65
|
-
- importは絶対パス使用(`src/`)
|
|
66
|
-
|
|
67
|
-
**Clean Code原則**
|
|
68
|
-
- ✅ 未使用コードは即座に削除
|
|
69
|
-
- ✅ デバッグ用`console.log()`削除
|
|
70
|
-
- ❌ コメントアウトされたコード(履歴はバージョン管理で)
|
|
71
|
-
- ✅ コメントは「理由」を説明(「何を」ではない)
|
|
72
|
-
|
|
73
|
-
## エラーハンドリング
|
|
74
|
-
|
|
75
|
-
**絶対ルール**: エラー抑制禁止。全てのエラーはログ出力と適切な処理が必須。
|
|
76
|
-
|
|
77
|
-
**Fail-Fast原則**: エラー時は速やかに失敗し、無効な状態での処理継続を防ぐ
|
|
78
|
-
```typescript
|
|
79
|
-
// ❌ 禁止: 無条件フォールバック
|
|
80
|
-
catch (error) {
|
|
81
|
-
return defaultValue // エラーを隠蔽
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// ✅ 必須: 明示的な失敗
|
|
85
|
-
catch (error) {
|
|
86
|
-
logger.error('処理失敗', error)
|
|
87
|
-
throw error // Error Boundaryまたは上位層で処理
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Result型パターン**: エラーを型で表現し明示的にハンドリング
|
|
92
|
-
```typescript
|
|
93
|
-
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E }
|
|
94
|
-
|
|
95
|
-
// 例: エラーの可能性を型で表現
|
|
96
|
-
function parseUser(data: unknown): Result<User, ValidationError> {
|
|
97
|
-
if (!isValid(data)) return { ok: false, error: new ValidationError() }
|
|
98
|
-
return { ok: true, value: data as User }
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**カスタムエラークラス**
|
|
103
|
-
```typescript
|
|
104
|
-
export class AppError extends Error {
|
|
105
|
-
constructor(message: string, public readonly code: string, public readonly statusCode = 500) {
|
|
106
|
-
super(message)
|
|
107
|
-
this.name = this.constructor.name
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// 目的別: ValidationError(400), ApiError(502), NotFoundError(404)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
**レイヤー別エラーハンドリング(React)**
|
|
114
|
-
- Error Boundary: Reactコンポーネントエラーをキャッチ、フォールバックUI表示
|
|
115
|
-
- Custom Hook: ビジネスルール違反を検出、AppErrorをそのまま伝播
|
|
116
|
-
- API層: fetchエラーをドメインエラーに変換
|
|
117
|
-
|
|
118
|
-
**構造化ロギングと機密情報保護**
|
|
119
|
-
ログに機密情報(password、token、apiKey、secret、creditCard)を絶対含めない
|
|
120
|
-
|
|
121
|
-
**Reactでの非同期エラーハンドリング**
|
|
122
|
-
- Error Boundaryセットアップ必須: レンダリングエラーをキャッチ
|
|
123
|
-
- イベントハンドラ内の全async/awaitでtry-catch使用
|
|
124
|
-
- エラーは常にログ記録し、再スローまたはerror stateで表示
|
|
125
|
-
|
|
126
|
-
## パフォーマンス最適化
|
|
127
|
-
|
|
128
|
-
- コンポーネントメモ化: 高コストコンポーネントにReact.memo使用
|
|
129
|
-
- State最適化: 適切なstate構造で再レンダリングを最小化
|
|
130
|
-
- 遅延読み込み: React.lazyとSuspenseでコード分割
|
|
131
|
-
- バンドルサイズ: `build`スクリプト(package.jsonの`packageManager`フィールドに応じた実行コマンドを使用)で監視し最適化
|