@k2works/claude-code-booster 1.10.0 → 1.11.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.
Files changed (93) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +42 -42
  3. package/bin/claude-code-booster +79 -79
  4. package/lib/assets/.claude/README.md +162 -162
  5. package/lib/assets/.claude/SKILLS_TEMPLATE.md +100 -100
  6. package/lib/assets/.claude/scripts/generate-inception-deck.mjs +911 -911
  7. package/lib/assets/.claude/settings.json +11 -11
  8. package/lib/assets/.claude/skills/ai-agent-guidelines/SKILL.md +119 -119
  9. package/lib/assets/.claude/skills/analyzing-architecture/SKILL.md +87 -87
  10. package/lib/assets/.claude/skills/analyzing-business/SKILL.md +117 -117
  11. package/lib/assets/.claude/skills/analyzing-data-model/SKILL.md +80 -80
  12. package/lib/assets/.claude/skills/analyzing-domain-model/SKILL.md +88 -88
  13. package/lib/assets/.claude/skills/analyzing-inception-deck/SKILL.md +137 -137
  14. package/lib/assets/.claude/skills/analyzing-non-functional/SKILL.md +91 -91
  15. package/lib/assets/.claude/skills/analyzing-operation/SKILL.md +91 -91
  16. package/lib/assets/.claude/skills/analyzing-requirements/SKILL.md +89 -87
  17. package/lib/assets/.claude/skills/analyzing-tech-stack/SKILL.md +102 -102
  18. package/lib/assets/.claude/skills/analyzing-test-strategy/SKILL.md +87 -87
  19. package/lib/assets/.claude/skills/analyzing-ui-design/SKILL.md +86 -86
  20. package/lib/assets/.claude/skills/analyzing-usecases/SKILL.md +87 -87
  21. package/lib/assets/.claude/skills/creating-adr/SKILL.md +115 -115
  22. package/lib/assets/.claude/skills/developing-backend/SKILL.md +106 -106
  23. package/lib/assets/.claude/skills/developing-frontend/SKILL.md +96 -96
  24. package/lib/assets/.claude/skills/developing-release/SKILL.md +154 -154
  25. package/lib/assets/.claude/skills/generating-slides/SKILL.md +136 -136
  26. package/lib/assets/.claude/skills/git-commit/SKILL.md +106 -106
  27. package/lib/assets/.claude/skills/killing-processes/SKILL.md +98 -98
  28. package/lib/assets/.claude/skills/managing-docs/SKILL.md +200 -200
  29. package/lib/assets/.claude/skills/managing-operations/DEPLOY.md +77 -77
  30. package/lib/assets/.claude/skills/managing-operations/SETUP_CSHARP.md +80 -80
  31. package/lib/assets/.claude/skills/managing-operations/SETUP_FRONTEND.md +84 -84
  32. package/lib/assets/.claude/skills/managing-operations/SETUP_JAVA.md +75 -75
  33. package/lib/assets/.claude/skills/managing-operations/SKILL.md +156 -156
  34. package/lib/assets/.claude/skills/orchestrating-analysis/SKILL.md +134 -134
  35. package/lib/assets/.claude/skills/orchestrating-development/SKILL.md +243 -243
  36. package/lib/assets/.claude/skills/orchestrating-project/SKILL.md +193 -193
  37. package/lib/assets/.claude/skills/planning-releases/SKILL.md +222 -222
  38. package/lib/assets/.claude/skills/tracking-progress/SKILL.md +164 -164
  39. package/lib/assets/.devcontainer/devcontainer.json +34 -34
  40. package/lib/assets/.env.example +17 -17
  41. package/lib/assets/.gitattributes +4 -4
  42. package/lib/assets/.github/workflows/docker-publish.yml +77 -77
  43. package/lib/assets/.github/workflows/mkdocs.yml +39 -39
  44. package/lib/assets/AGENTS.md +94 -94
  45. package/lib/assets/CLAUDE.md +162 -162
  46. package/lib/assets/README.md +285 -269
  47. package/lib/assets/docker-compose.yml +33 -33
  48. package/lib/assets/docs/assets/css/extra.css +29 -29
  49. package/lib/assets/docs/assets/js/extra.js +44 -44
  50. package/lib/assets/docs/index.md +14 -14
  51. package/lib/assets/docs/reference/CodexCLIMCP/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/343/203/225/343/203/255/343/203/274.md +532 -532
  52. package/lib/assets/docs/reference/CodexCLIMCP/343/202/265/343/203/274/343/203/220/343/203/274/350/250/255/345/256/232/346/211/213/351/240/206.md +341 -341
  53. package/lib/assets/docs/reference/Java/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +578 -578
  54. package/lib/assets/docs/reference/TypeScript/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +465 -465
  55. package/lib/assets/docs/reference/UI/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +448 -448
  56. package/lib/assets/docs/reference//343/202/210/343/201/204/343/202/275/343/203/225/343/203/210/343/202/246/343/202/247/343/202/242/343/201/250/343/201/257.md +242 -242
  57. package/lib/assets/docs/reference//343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +2216 -2216
  58. package/lib/assets/docs/reference//343/202/244/343/203/263/343/203/225/343/203/251/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +1878 -1878
  59. package/lib/assets/docs/reference//343/202/250/343/202/257/343/202/271/343/203/210/343/203/252/343/203/274/343/203/240/343/203/227/343/203/255/343/202/260/343/203/251/343/203/237/343/203/263/343/202/260.md +554 -554
  60. package/lib/assets/docs/reference//343/202/263/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/343/201/250/343/203/206/343/202/271/343/203/210/343/202/254/343/202/244/343/203/211.md +705 -705
  61. package/lib/assets/docs/reference//343/203/206/343/202/271/343/203/210/346/210/246/347/225/245/343/202/254/343/202/244/343/203/211.md +1313 -1313
  62. package/lib/assets/docs/reference//343/203/207/343/203/274/343/202/277/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +311 -311
  63. package/lib/assets/docs/reference//343/203/211/343/203/241/343/202/244/343/203/263/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +599 -599
  64. package/lib/assets/docs/reference//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/345/210/206/346/236/220/343/202/254/343/202/244/343/203/211.md +528 -528
  65. package/lib/assets/docs/reference//343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +682 -682
  66. package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/202/254/343/202/244/343/203/211.md +442 -442
  67. package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/203/273/343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/350/250/210/347/224/273/343/202/254/343/202/244/343/203/211.md +558 -558
  68. package/lib/assets/docs/reference//347/222/260/345/242/203/345/244/211/346/225/260/347/256/241/347/220/206/343/202/254/343/202/244/343/203/211.md +663 -663
  69. package/lib/assets/docs/reference//350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1248 -1248
  70. package/lib/assets/docs/reference//351/201/213/347/224/250/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +392 -392
  71. package/lib/assets/docs/reference//351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +235 -235
  72. package/lib/assets/docs/reference//351/235/236/346/251/237/350/203/275/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1236 -1236
  73. package/lib/assets/docs/template/ADR.md +30 -30
  74. package/lib/assets/docs/template/README.md +50 -50
  75. package/lib/assets/docs/template//343/201/276/343/201/232/343/201/223/343/202/214/343/202/222/350/252/255/343/202/202/343/201/206/343/203/252/343/202/271/343/203/210.md +12 -12
  76. package/lib/assets/docs/template//343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/345/256/214/344/272/206/345/240/261/345/221/212/346/233/270.md +58 -58
  77. package/lib/assets/docs/template//343/202/244/343/203/263/343/202/273/343/203/227/343/202/267/343/203/247/343/203/263/343/203/207/343/203/203/343/202/255.md +13 -13
  78. package/lib/assets/docs/template//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243.md +379 -379
  79. package/lib/assets/docs/template//345/256/214/345/205/250/345/275/242/345/274/217/343/201/256/343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271.md +68 -68
  80. package/lib/assets/docs/template//350/246/201/344/273/266/345/256/232/347/276/251.md +669 -669
  81. package/lib/assets/docs/template//350/250/255/350/250/210.md +163 -163
  82. package/lib/assets/gulpfile.js +23 -23
  83. package/lib/assets/mkdocs.yml +65 -65
  84. package/lib/assets/ops/docker/mkdoc/Dockerfile +19 -19
  85. package/lib/assets/ops/scripts/journal.js +180 -180
  86. package/lib/assets/ops/scripts/mkdocs.js +82 -82
  87. package/lib/assets/ops/scripts/release.js +431 -431
  88. package/lib/assets/ops/scripts/ssh.js +190 -190
  89. package/lib/assets/ops/scripts/vault.js +299 -299
  90. package/lib/assets/package-lock.json +1653 -1653
  91. package/lib/assets/package.json +40 -40
  92. package/lib/gulpfile.js +37 -37
  93. package/package.json +41 -41
@@ -1,466 +1,466 @@
1
- # TypeScript アプリケーション環境構築ガイド
2
-
3
- ## 概要
4
-
5
- 本ガイドは、TypeScript アプリケーション開発環境をゼロから構築し、ソフトウェア開発の三種の神器(バージョン管理、テスティング、自動化)を実践するための手順書です。テスト駆動開発(TDD)により「動作するきれいなコード」を継続的に作成できる開発環境を整備します。
6
-
7
- ## 前提条件
8
-
9
- - Node.js 18 以降がインストールされていること
10
- - npm または yarn がインストールされていること
11
- - Git がインストールされていること
12
- - VS Code または WebStorm がインストールされていること(推奨)
13
-
14
- ## ソフトウェア開発の三種の神器
15
-
16
- ### 1. バージョン管理
17
-
18
- #### Git の基本設定
19
-
20
- ```bash
21
- # ユーザー設定
22
- git config --global user.name "Your Name"
23
- git config --global user.email "your.email@example.com"
24
-
25
- # リポジトリの初期化
26
- git init
27
-
28
- # .gitignore の作成
29
- echo "node_modules/" >> .gitignore
30
- echo "dist/" >> .gitignore
31
- echo "coverage/" >> .gitignore
32
- echo ".env" >> .gitignore
33
- echo ".DS_Store" >> .gitignore
34
- ```
35
-
36
- #### コミットメッセージ規約(Conventional Commits)
37
-
38
- ```text
39
- <タイプ>(<スコープ>): <タイトル>
40
- <空行>
41
- <ボディ>
42
- <空行>
43
- <フッタ>
44
- ```
45
-
46
- **タイプの種類:**
47
-
48
- - `feat`: 新機能の追加
49
- - `fix`: バグ修正
50
- - `docs`: ドキュメント変更のみ
51
- - `style`: コードに影響を与えない変更(フォーマット等)
52
- - `refactor`: 機能追加でもバグ修正でもないコード変更
53
- - `perf`: パフォーマンスを改善するコード変更
54
- - `test`: テストの追加や修正
55
- - `chore`: ビルドプロセスやツール、ライブラリの変更
56
-
57
- **例:**
58
- ```bash
59
- git commit -m 'feat: ユーザー認証機能を追加'
60
- git commit -m 'fix: ログイン時のバリデーションエラーを修正'
61
- git commit -m 'refactor: FizzBuzz クラスのメソッド抽出'
62
- ```
63
-
64
- ### 2. テスティング
65
-
66
- #### プロジェクトの初期化
67
-
68
- ```bash
69
- # プロジェクトの初期化
70
- npm init -y
71
-
72
- # TypeScript の設定
73
- npm install -D typescript @types/node
74
- npx tsc --init
75
- ```
76
-
77
- #### テストフレームワークのセットアップ
78
-
79
- ```bash
80
- # Vitest とテスト関連パッケージのインストール
81
- npm install -D vitest @vitest/coverage-v8 @types/node
82
- ```
83
-
84
- #### package.json の設定
85
-
86
- ```json
87
- {
88
- "name": "typescript-app",
89
- "private": true,
90
- "version": "0.0.0",
91
- "type": "module",
92
- "scripts": {
93
- "dev": "vite",
94
- "build": "tsc && vite build",
95
- "preview": "vite preview",
96
- "test": "vitest run",
97
- "test:watch": "vitest",
98
- "test:coverage": "vitest run --coverage",
99
- "lint": "eslint . --ext .ts,.tsx",
100
- "lint:fix": "eslint . --ext .ts,.tsx --fix",
101
- "format": "prettier --write .",
102
- "format:check": "prettier --check .",
103
- "gulp": "gulp",
104
- "watch": "gulp watch",
105
- "guard": "gulp guard",
106
- "check": "gulp checkAndFix",
107
- "commit": "git add . && git commit",
108
- "setup": "npm install && npm run check"
109
- }
110
- }
111
- ```
112
-
113
- #### テストの基本構造
114
-
115
- ```typescript
116
- // src/fizz-buzz.ts
117
- export class FizzBuzz {
118
- private static readonly MAX_NUMBER = 100
119
-
120
- public static generate(number: number): string {
121
- const isFizz = number % 3 === 0
122
- const isBuzz = number % 5 === 0
123
-
124
- if (isFizz && isBuzz) return 'FizzBuzz'
125
- if (isFizz) return 'Fizz'
126
- if (isBuzz) return 'Buzz'
127
-
128
- return number.toString()
129
- }
130
-
131
- public static generateList(): string[] {
132
- return Array.from({ length: this.MAX_NUMBER }, (_, i) => this.generate(i + 1))
133
- }
134
- }
135
- ```
136
-
137
- ```typescript
138
- // src/fizz-buzz.test.ts
139
- import { describe, it, expect } from 'vitest'
140
- import { FizzBuzz } from './fizz-buzz'
141
-
142
- describe('FizzBuzz', () => {
143
- describe('三の倍数の場合', () => {
144
- it('3を渡したら文字列Fizzを返す', () => {
145
- expect(FizzBuzz.generate(3)).toBe('Fizz')
146
- })
147
- })
148
-
149
- describe('五の倍数の場合', () => {
150
- it('5を渡したら文字列Buzzを返す', () => {
151
- expect(FizzBuzz.generate(5)).toBe('Buzz')
152
- })
153
- })
154
-
155
- describe('三と五の倍数の場合', () => {
156
- it('15を渡したら文字列FizzBuzzを返す', () => {
157
- expect(FizzBuzz.generate(15)).toBe('FizzBuzz')
158
- })
159
- })
160
- })
161
- ```
162
-
163
- #### TDD のサイクル
164
-
165
- ```bash
166
- # Red: 失敗するテストを書く
167
- npm run test
168
-
169
- # Green: テストを通す最小限の実装
170
- # コードを修正
171
-
172
- # Refactor: リファクタリング
173
- npm run test
174
-
175
- # コミット
176
- git add .
177
- git commit -m 'feat: FizzBuzz 基本機能を実装'
178
- ```
179
-
180
- ### 3. 自動化
181
-
182
- #### 静的コード解析(ESLint)
183
-
184
- ```bash
185
- # ESLint のインストール
186
- npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-prettier eslint-plugin-prettier
187
- ```
188
-
189
- #### eslint.config.js の設定
190
-
191
- ```javascript
192
- export default [
193
- {
194
- files: ['**/*.ts', '**/*.tsx'],
195
- languageOptions: {
196
- parser: '@typescript-eslint/parser',
197
- parserOptions: {
198
- ecmaVersion: 2020,
199
- sourceType: 'module'
200
- }
201
- },
202
- plugins: {
203
- '@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
204
- 'prettier': require('eslint-plugin-prettier')
205
- },
206
- rules: {
207
- // 基本的なルール
208
- '@typescript-eslint/no-unused-vars': 'error',
209
- '@typescript-eslint/no-explicit-any': 'warn',
210
-
211
- // 循環的複雑度の制限(7以下を推奨)
212
- 'complexity': ['error', { max: 7 }],
213
-
214
- // Prettier 統合
215
- 'prettier/prettier': 'error'
216
- }
217
- },
218
- {
219
- files: ['**/*.test.{ts,tsx}'],
220
- rules: {
221
- '@typescript-eslint/no-unused-expressions': 'off',
222
- '@typescript-eslint/no-unused-vars': 'warn'
223
- }
224
- }
225
- ]
226
- ```
227
-
228
- #### コードフォーマッタ(Prettier)
229
-
230
- ```bash
231
- # Prettier のインストール
232
- npm install -D prettier eslint-config-prettier eslint-plugin-prettier
233
- ```
234
-
235
- #### .prettierrc の設定
236
-
237
- ```json
238
- {
239
- "semi": false,
240
- "singleQuote": true,
241
- "tabWidth": 2,
242
- "trailingComma": "es5",
243
- "printWidth": 100,
244
- "endOfLine": "lf"
245
- }
246
- ```
247
-
248
- #### コードカバレッジ
249
-
250
- Vitest に組み込まれたカバレッジ機能を使用:
251
-
252
- ```bash
253
- # カバレッジの実行
254
- npm run test:coverage
255
- ```
256
-
257
- #### vitest.config.ts の設定
258
-
259
- ```typescript
260
- import { defineConfig } from 'vitest/config'
261
-
262
- export default defineConfig({
263
- test: {
264
- coverage: {
265
- reporter: ['text', 'html', 'json'],
266
- reportsDirectory: 'coverage',
267
- exclude: [
268
- 'node_modules/**',
269
- 'dist/**',
270
- '**/*.test.ts',
271
- '**/*.config.js',
272
- '**/*.config.ts',
273
- 'src/main.ts'
274
- ],
275
- all: true,
276
- thresholds: {
277
- global: {
278
- branches: 80,
279
- functions: 80,
280
- lines: 80,
281
- statements: 80
282
- }
283
- }
284
- }
285
- }
286
- })
287
- ```
288
-
289
- #### タスクランナー(Gulp)
290
-
291
- ```bash
292
- # Gulp のインストール
293
- npm install -D gulp gulp-shell
294
- ```
295
-
296
- #### gulpfile.js の設定
297
-
298
- ```javascript
299
- import { watch, series } from 'gulp'
300
- import shell from 'gulp-shell'
301
-
302
- // 基本タスク
303
- export const test = shell.task(['npm run test'])
304
- export const coverage = shell.task(['npm run test:coverage'])
305
- export const lint = shell.task(['npm run lint'])
306
- export const lintFix = shell.task(['npm run lint:fix'])
307
- export const format = shell.task(['npm run format'])
308
- export const formatCheck = shell.task(['npm run format:check'])
309
- export const build = shell.task(['npm run build'])
310
- export const dev = shell.task(['npm run dev'])
311
-
312
- // 複合タスク
313
- export const checkAndFix = series(lintFix, format, test)
314
-
315
- // ファイル監視タスク(Guard機能)
316
- export function guard() {
317
- console.log('🔍 Guard is watching for file changes...')
318
- console.log('Files will be automatically linted, formatted, and tested on change.')
319
- watch('src/**/*.ts', series(lintFix, format, test))
320
- watch('**/*.test.ts', series(test))
321
- }
322
-
323
- // ファイル監視タスク
324
- export function watchFiles() {
325
- watch('src/**/*.ts', series(formatCheck, lint, test))
326
- watch('**/*.test.ts', series(test))
327
- }
328
-
329
- // デフォルトタスク
330
- export default series(checkAndFix, guard)
331
-
332
- // ウォッチタスクのエイリアス
333
- export { watchFiles as watch }
334
- ```
335
-
336
- ## 開発ワークフロー
337
-
338
- ### 1. 環境のセットアップ
339
-
340
- ```bash
341
- # プロジェクトの初期化
342
- npm init -y
343
-
344
- # 依存関係のインストール
345
- npm install
346
-
347
- # 初期チェック実行
348
- npm run setup
349
- ```
350
-
351
- ### 2. 開発の開始
352
-
353
- ```bash
354
- # Guard を起動(自動テスト・リント・フォーマット)
355
- npm run guard
356
-
357
- # 別ターミナルで開発サーバーを起動
358
- npm run dev
359
- ```
360
-
361
- ### 3. TDD サイクルの実践
362
-
363
- 1. **Red**: 失敗するテストを作成
364
- ```bash
365
- # テストファイル作成・編集
366
- # Guard が自動でテスト実行し、失敗を確認
367
- ```
368
-
369
- 2. **Green**: テストを通す最小限の実装
370
- ```bash
371
- # 実装コードを作成
372
- # Guard が自動でテスト実行し、成功を確認
373
- ```
374
-
375
- 3. **Refactor**: コードをリファクタリング
376
- ```bash
377
- # コードを改善
378
- # Guard が自動でリント・フォーマット・テスト実行
379
- ```
380
-
381
- 4. **Commit**: 作業をコミット
382
- ```bash
383
- git add .
384
- git commit -m 'feat: 新機能を実装'
385
- ```
386
-
387
- ### 4. 品質チェック
388
-
389
- ```bash
390
- # 全体的な品質チェック
391
- npm run check
392
-
393
- # カバレッジ確認
394
- npm run test:coverage
395
-
396
- # 静的解析
397
- npm run lint
398
-
399
- # フォーマットチェック
400
- npm run format:check
401
- ```
402
-
403
- ## ベストプラクティス
404
-
405
- ### 1. テスト戦略
406
-
407
- - **単体テスト**: 各機能の動作を検証
408
- - **統合テスト**: 複数のコンポーネント間の協調を検証
409
- - **E2E テスト**: ユーザーの視点から全体的な動作を検証
410
-
411
- ### 2. コード品質
412
-
413
- - **循環的複雑度**: 7以下を維持
414
- - **テストカバレッジ**: 80%以上を目標
415
- - **ESLint ルール**: プロジェクトに応じてカスタマイズ
416
-
417
- ### 3. 継続的改善
418
-
419
- - **定期的なリファクタリング**: 技術的負債の蓄積を防ぐ
420
- - **コードレビュー**: チーム全体のコード品質向上
421
- - **ツールのアップデート**: セキュリティと性能の維持
422
-
423
- ## トラブルシューティング
424
-
425
- ### よくある問題と解決法
426
-
427
- #### 1. テストが実行されない
428
-
429
- ```bash
430
- # node_modules を再インストール
431
- rm -rf node_modules package-lock.json
432
- npm install
433
-
434
- # キャッシュをクリア
435
- npm cache clean --force
436
- ```
437
-
438
- #### 2. ESLint エラーが発生
439
-
440
- ```bash
441
- # 自動修正を試行
442
- npm run lint:fix
443
-
444
- # 設定ファイルを確認
445
- cat eslint.config.js
446
- ```
447
-
448
- #### 3. TypeScript コンパイルエラー
449
-
450
- ```bash
451
- # TypeScript 設定を確認
452
- cat tsconfig.json
453
-
454
- # 型定義を再インストール
455
- npm install -D @types/node
456
- ```
457
-
458
- ## 参考資料
459
-
460
- - [Conventional Commits](https://www.conventionalcommits.org/ja/)
461
- - [Vitest 公式ドキュメント](https://vitest.dev/)
462
- - [ESLint 公式ドキュメント](https://eslint.org/)
463
- - [Prettier 公式ドキュメント](https://prettier.io/)
464
- - [TypeScript 公式ドキュメント](https://www.typescriptlang.org/)
465
-
1
+ # TypeScript アプリケーション環境構築ガイド
2
+
3
+ ## 概要
4
+
5
+ 本ガイドは、TypeScript アプリケーション開発環境をゼロから構築し、ソフトウェア開発の三種の神器(バージョン管理、テスティング、自動化)を実践するための手順書です。テスト駆動開発(TDD)により「動作するきれいなコード」を継続的に作成できる開発環境を整備します。
6
+
7
+ ## 前提条件
8
+
9
+ - Node.js 18 以降がインストールされていること
10
+ - npm または yarn がインストールされていること
11
+ - Git がインストールされていること
12
+ - VS Code または WebStorm がインストールされていること(推奨)
13
+
14
+ ## ソフトウェア開発の三種の神器
15
+
16
+ ### 1. バージョン管理
17
+
18
+ #### Git の基本設定
19
+
20
+ ```bash
21
+ # ユーザー設定
22
+ git config --global user.name "Your Name"
23
+ git config --global user.email "your.email@example.com"
24
+
25
+ # リポジトリの初期化
26
+ git init
27
+
28
+ # .gitignore の作成
29
+ echo "node_modules/" >> .gitignore
30
+ echo "dist/" >> .gitignore
31
+ echo "coverage/" >> .gitignore
32
+ echo ".env" >> .gitignore
33
+ echo ".DS_Store" >> .gitignore
34
+ ```
35
+
36
+ #### コミットメッセージ規約(Conventional Commits)
37
+
38
+ ```text
39
+ <タイプ>(<スコープ>): <タイトル>
40
+ <空行>
41
+ <ボディ>
42
+ <空行>
43
+ <フッタ>
44
+ ```
45
+
46
+ **タイプの種類:**
47
+
48
+ - `feat`: 新機能の追加
49
+ - `fix`: バグ修正
50
+ - `docs`: ドキュメント変更のみ
51
+ - `style`: コードに影響を与えない変更(フォーマット等)
52
+ - `refactor`: 機能追加でもバグ修正でもないコード変更
53
+ - `perf`: パフォーマンスを改善するコード変更
54
+ - `test`: テストの追加や修正
55
+ - `chore`: ビルドプロセスやツール、ライブラリの変更
56
+
57
+ **例:**
58
+ ```bash
59
+ git commit -m 'feat: ユーザー認証機能を追加'
60
+ git commit -m 'fix: ログイン時のバリデーションエラーを修正'
61
+ git commit -m 'refactor: FizzBuzz クラスのメソッド抽出'
62
+ ```
63
+
64
+ ### 2. テスティング
65
+
66
+ #### プロジェクトの初期化
67
+
68
+ ```bash
69
+ # プロジェクトの初期化
70
+ npm init -y
71
+
72
+ # TypeScript の設定
73
+ npm install -D typescript @types/node
74
+ npx tsc --init
75
+ ```
76
+
77
+ #### テストフレームワークのセットアップ
78
+
79
+ ```bash
80
+ # Vitest とテスト関連パッケージのインストール
81
+ npm install -D vitest @vitest/coverage-v8 @types/node
82
+ ```
83
+
84
+ #### package.json の設定
85
+
86
+ ```json
87
+ {
88
+ "name": "typescript-app",
89
+ "private": true,
90
+ "version": "0.0.0",
91
+ "type": "module",
92
+ "scripts": {
93
+ "dev": "vite",
94
+ "build": "tsc && vite build",
95
+ "preview": "vite preview",
96
+ "test": "vitest run",
97
+ "test:watch": "vitest",
98
+ "test:coverage": "vitest run --coverage",
99
+ "lint": "eslint . --ext .ts,.tsx",
100
+ "lint:fix": "eslint . --ext .ts,.tsx --fix",
101
+ "format": "prettier --write .",
102
+ "format:check": "prettier --check .",
103
+ "gulp": "gulp",
104
+ "watch": "gulp watch",
105
+ "guard": "gulp guard",
106
+ "check": "gulp checkAndFix",
107
+ "commit": "git add . && git commit",
108
+ "setup": "npm install && npm run check"
109
+ }
110
+ }
111
+ ```
112
+
113
+ #### テストの基本構造
114
+
115
+ ```typescript
116
+ // src/fizz-buzz.ts
117
+ export class FizzBuzz {
118
+ private static readonly MAX_NUMBER = 100
119
+
120
+ public static generate(number: number): string {
121
+ const isFizz = number % 3 === 0
122
+ const isBuzz = number % 5 === 0
123
+
124
+ if (isFizz && isBuzz) return 'FizzBuzz'
125
+ if (isFizz) return 'Fizz'
126
+ if (isBuzz) return 'Buzz'
127
+
128
+ return number.toString()
129
+ }
130
+
131
+ public static generateList(): string[] {
132
+ return Array.from({ length: this.MAX_NUMBER }, (_, i) => this.generate(i + 1))
133
+ }
134
+ }
135
+ ```
136
+
137
+ ```typescript
138
+ // src/fizz-buzz.test.ts
139
+ import { describe, it, expect } from 'vitest'
140
+ import { FizzBuzz } from './fizz-buzz'
141
+
142
+ describe('FizzBuzz', () => {
143
+ describe('三の倍数の場合', () => {
144
+ it('3を渡したら文字列Fizzを返す', () => {
145
+ expect(FizzBuzz.generate(3)).toBe('Fizz')
146
+ })
147
+ })
148
+
149
+ describe('五の倍数の場合', () => {
150
+ it('5を渡したら文字列Buzzを返す', () => {
151
+ expect(FizzBuzz.generate(5)).toBe('Buzz')
152
+ })
153
+ })
154
+
155
+ describe('三と五の倍数の場合', () => {
156
+ it('15を渡したら文字列FizzBuzzを返す', () => {
157
+ expect(FizzBuzz.generate(15)).toBe('FizzBuzz')
158
+ })
159
+ })
160
+ })
161
+ ```
162
+
163
+ #### TDD のサイクル
164
+
165
+ ```bash
166
+ # Red: 失敗するテストを書く
167
+ npm run test
168
+
169
+ # Green: テストを通す最小限の実装
170
+ # コードを修正
171
+
172
+ # Refactor: リファクタリング
173
+ npm run test
174
+
175
+ # コミット
176
+ git add .
177
+ git commit -m 'feat: FizzBuzz 基本機能を実装'
178
+ ```
179
+
180
+ ### 3. 自動化
181
+
182
+ #### 静的コード解析(ESLint)
183
+
184
+ ```bash
185
+ # ESLint のインストール
186
+ npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-prettier eslint-plugin-prettier
187
+ ```
188
+
189
+ #### eslint.config.js の設定
190
+
191
+ ```javascript
192
+ export default [
193
+ {
194
+ files: ['**/*.ts', '**/*.tsx'],
195
+ languageOptions: {
196
+ parser: '@typescript-eslint/parser',
197
+ parserOptions: {
198
+ ecmaVersion: 2020,
199
+ sourceType: 'module'
200
+ }
201
+ },
202
+ plugins: {
203
+ '@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
204
+ 'prettier': require('eslint-plugin-prettier')
205
+ },
206
+ rules: {
207
+ // 基本的なルール
208
+ '@typescript-eslint/no-unused-vars': 'error',
209
+ '@typescript-eslint/no-explicit-any': 'warn',
210
+
211
+ // 循環的複雑度の制限(7以下を推奨)
212
+ 'complexity': ['error', { max: 7 }],
213
+
214
+ // Prettier 統合
215
+ 'prettier/prettier': 'error'
216
+ }
217
+ },
218
+ {
219
+ files: ['**/*.test.{ts,tsx}'],
220
+ rules: {
221
+ '@typescript-eslint/no-unused-expressions': 'off',
222
+ '@typescript-eslint/no-unused-vars': 'warn'
223
+ }
224
+ }
225
+ ]
226
+ ```
227
+
228
+ #### コードフォーマッタ(Prettier)
229
+
230
+ ```bash
231
+ # Prettier のインストール
232
+ npm install -D prettier eslint-config-prettier eslint-plugin-prettier
233
+ ```
234
+
235
+ #### .prettierrc の設定
236
+
237
+ ```json
238
+ {
239
+ "semi": false,
240
+ "singleQuote": true,
241
+ "tabWidth": 2,
242
+ "trailingComma": "es5",
243
+ "printWidth": 100,
244
+ "endOfLine": "lf"
245
+ }
246
+ ```
247
+
248
+ #### コードカバレッジ
249
+
250
+ Vitest に組み込まれたカバレッジ機能を使用:
251
+
252
+ ```bash
253
+ # カバレッジの実行
254
+ npm run test:coverage
255
+ ```
256
+
257
+ #### vitest.config.ts の設定
258
+
259
+ ```typescript
260
+ import { defineConfig } from 'vitest/config'
261
+
262
+ export default defineConfig({
263
+ test: {
264
+ coverage: {
265
+ reporter: ['text', 'html', 'json'],
266
+ reportsDirectory: 'coverage',
267
+ exclude: [
268
+ 'node_modules/**',
269
+ 'dist/**',
270
+ '**/*.test.ts',
271
+ '**/*.config.js',
272
+ '**/*.config.ts',
273
+ 'src/main.ts'
274
+ ],
275
+ all: true,
276
+ thresholds: {
277
+ global: {
278
+ branches: 80,
279
+ functions: 80,
280
+ lines: 80,
281
+ statements: 80
282
+ }
283
+ }
284
+ }
285
+ }
286
+ })
287
+ ```
288
+
289
+ #### タスクランナー(Gulp)
290
+
291
+ ```bash
292
+ # Gulp のインストール
293
+ npm install -D gulp gulp-shell
294
+ ```
295
+
296
+ #### gulpfile.js の設定
297
+
298
+ ```javascript
299
+ import { watch, series } from 'gulp'
300
+ import shell from 'gulp-shell'
301
+
302
+ // 基本タスク
303
+ export const test = shell.task(['npm run test'])
304
+ export const coverage = shell.task(['npm run test:coverage'])
305
+ export const lint = shell.task(['npm run lint'])
306
+ export const lintFix = shell.task(['npm run lint:fix'])
307
+ export const format = shell.task(['npm run format'])
308
+ export const formatCheck = shell.task(['npm run format:check'])
309
+ export const build = shell.task(['npm run build'])
310
+ export const dev = shell.task(['npm run dev'])
311
+
312
+ // 複合タスク
313
+ export const checkAndFix = series(lintFix, format, test)
314
+
315
+ // ファイル監視タスク(Guard機能)
316
+ export function guard() {
317
+ console.log('🔍 Guard is watching for file changes...')
318
+ console.log('Files will be automatically linted, formatted, and tested on change.')
319
+ watch('src/**/*.ts', series(lintFix, format, test))
320
+ watch('**/*.test.ts', series(test))
321
+ }
322
+
323
+ // ファイル監視タスク
324
+ export function watchFiles() {
325
+ watch('src/**/*.ts', series(formatCheck, lint, test))
326
+ watch('**/*.test.ts', series(test))
327
+ }
328
+
329
+ // デフォルトタスク
330
+ export default series(checkAndFix, guard)
331
+
332
+ // ウォッチタスクのエイリアス
333
+ export { watchFiles as watch }
334
+ ```
335
+
336
+ ## 開発ワークフロー
337
+
338
+ ### 1. 環境のセットアップ
339
+
340
+ ```bash
341
+ # プロジェクトの初期化
342
+ npm init -y
343
+
344
+ # 依存関係のインストール
345
+ npm install
346
+
347
+ # 初期チェック実行
348
+ npm run setup
349
+ ```
350
+
351
+ ### 2. 開発の開始
352
+
353
+ ```bash
354
+ # Guard を起動(自動テスト・リント・フォーマット)
355
+ npm run guard
356
+
357
+ # 別ターミナルで開発サーバーを起動
358
+ npm run dev
359
+ ```
360
+
361
+ ### 3. TDD サイクルの実践
362
+
363
+ 1. **Red**: 失敗するテストを作成
364
+ ```bash
365
+ # テストファイル作成・編集
366
+ # Guard が自動でテスト実行し、失敗を確認
367
+ ```
368
+
369
+ 2. **Green**: テストを通す最小限の実装
370
+ ```bash
371
+ # 実装コードを作成
372
+ # Guard が自動でテスト実行し、成功を確認
373
+ ```
374
+
375
+ 3. **Refactor**: コードをリファクタリング
376
+ ```bash
377
+ # コードを改善
378
+ # Guard が自動でリント・フォーマット・テスト実行
379
+ ```
380
+
381
+ 4. **Commit**: 作業をコミット
382
+ ```bash
383
+ git add .
384
+ git commit -m 'feat: 新機能を実装'
385
+ ```
386
+
387
+ ### 4. 品質チェック
388
+
389
+ ```bash
390
+ # 全体的な品質チェック
391
+ npm run check
392
+
393
+ # カバレッジ確認
394
+ npm run test:coverage
395
+
396
+ # 静的解析
397
+ npm run lint
398
+
399
+ # フォーマットチェック
400
+ npm run format:check
401
+ ```
402
+
403
+ ## ベストプラクティス
404
+
405
+ ### 1. テスト戦略
406
+
407
+ - **単体テスト**: 各機能の動作を検証
408
+ - **統合テスト**: 複数のコンポーネント間の協調を検証
409
+ - **E2E テスト**: ユーザーの視点から全体的な動作を検証
410
+
411
+ ### 2. コード品質
412
+
413
+ - **循環的複雑度**: 7以下を維持
414
+ - **テストカバレッジ**: 80%以上を目標
415
+ - **ESLint ルール**: プロジェクトに応じてカスタマイズ
416
+
417
+ ### 3. 継続的改善
418
+
419
+ - **定期的なリファクタリング**: 技術的負債の蓄積を防ぐ
420
+ - **コードレビュー**: チーム全体のコード品質向上
421
+ - **ツールのアップデート**: セキュリティと性能の維持
422
+
423
+ ## トラブルシューティング
424
+
425
+ ### よくある問題と解決法
426
+
427
+ #### 1. テストが実行されない
428
+
429
+ ```bash
430
+ # node_modules を再インストール
431
+ rm -rf node_modules package-lock.json
432
+ npm install
433
+
434
+ # キャッシュをクリア
435
+ npm cache clean --force
436
+ ```
437
+
438
+ #### 2. ESLint エラーが発生
439
+
440
+ ```bash
441
+ # 自動修正を試行
442
+ npm run lint:fix
443
+
444
+ # 設定ファイルを確認
445
+ cat eslint.config.js
446
+ ```
447
+
448
+ #### 3. TypeScript コンパイルエラー
449
+
450
+ ```bash
451
+ # TypeScript 設定を確認
452
+ cat tsconfig.json
453
+
454
+ # 型定義を再インストール
455
+ npm install -D @types/node
456
+ ```
457
+
458
+ ## 参考資料
459
+
460
+ - [Conventional Commits](https://www.conventionalcommits.org/ja/)
461
+ - [Vitest 公式ドキュメント](https://vitest.dev/)
462
+ - [ESLint 公式ドキュメント](https://eslint.org/)
463
+ - [Prettier 公式ドキュメント](https://prettier.io/)
464
+ - [TypeScript 公式ドキュメント](https://www.typescriptlang.org/)
465
+
466
466
  このガイドに従って環境を構築することで、効率的で品質の高い TypeScript アプリケーション開発が可能になります。