ai-check-template 0.2.0-alpha.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 (51) hide show
  1. package/LICENSE +201 -0
  2. package/README-ja.md +151 -0
  3. package/README.md +149 -0
  4. package/bin/ai-check-template.mjs +7 -0
  5. package/docs/cli.md +348 -0
  6. package/package-templates/.claude/README.md +83 -0
  7. package/package-templates/.claude/rules/test-rules.md +46 -0
  8. package/package-templates/.claude/settings.hook-fragment.json +25 -0
  9. package/package-templates/README.md +56 -0
  10. package/package-templates/ci-examples/README.md +134 -0
  11. package/package-templates/ci-examples/github-actions/ai-check-fast.yml +49 -0
  12. package/package-templates/ci-examples/github-actions/ai-check.yml +58 -0
  13. package/package-templates/ci-examples/github-actions/ai-quality-call.yml +26 -0
  14. package/package-templates/ci-examples/github-actions/ai-quality-reusable.yml +113 -0
  15. package/package-templates/docs/philosophy/formal-name-match.md +182 -0
  16. package/package-templates/docs/philosophy/given-when-then.md +206 -0
  17. package/package-templates/docs/philosophy/qa-techniques.md +235 -0
  18. package/package-templates/docs/philosophy/test-pyramid.md +171 -0
  19. package/package-templates/docs/test-design-template.md +173 -0
  20. package/package-templates/package.scripts.fragment.json +6 -0
  21. package/package-templates/profiles/README.md +89 -0
  22. package/package-templates/profiles/expo-rn/README.md +80 -0
  23. package/package-templates/profiles/node-cli/README.md +93 -0
  24. package/package-templates/profiles/react-nextjs/README.md +82 -0
  25. package/package-templates/profiles/react-vanilla/README.md +73 -0
  26. package/package-templates/profiles/supabase-rls/README.md +89 -0
  27. package/package-templates/prompts/README.md +94 -0
  28. package/package-templates/prompts/boundary-value.md +94 -0
  29. package/package-templates/prompts/decision-table.md +82 -0
  30. package/package-templates/prompts/diagnostic-repair.md +149 -0
  31. package/package-templates/prompts/plan-first.md +122 -0
  32. package/package-templates/prompts/rls-permission.md +94 -0
  33. package/package-templates/prompts/state-transition.md +81 -0
  34. package/package-templates/scripts/README.md +78 -0
  35. package/package-templates/scripts/ai-check-fast.sh +20 -0
  36. package/package-templates/scripts/ai-check.sh +22 -0
  37. package/package.json +47 -0
  38. package/src/cli/ci-workflows.mjs +104 -0
  39. package/src/cli/claude-hooks.mjs +94 -0
  40. package/src/cli/dependency-installer.mjs +164 -0
  41. package/src/cli/doctor.mjs +392 -0
  42. package/src/cli/index.mjs +80 -0
  43. package/src/cli/init.mjs +433 -0
  44. package/src/cli/install-state.mjs +242 -0
  45. package/src/cli/package-manager.mjs +78 -0
  46. package/src/cli/profile-diagnostics.mjs +160 -0
  47. package/src/cli/profile-docs.mjs +31 -0
  48. package/src/cli/profile-scripts.mjs +96 -0
  49. package/src/cli/profile.mjs +59 -0
  50. package/src/cli/update.mjs +537 -0
  51. package/src/cli/utils.mjs +75 -0
@@ -0,0 +1,173 @@
1
+ # Test Design Template
2
+
3
+ > **Status**: Draft v0.1. Copy this file into your project and fill it before asking AI to implement.
4
+
5
+ This template turns a requirement into observable tests. It is designed for AI-assisted development, where the model should not start implementation until the expected behavior, edge cases, and verification commands are explicit.
6
+
7
+ Use it between:
8
+
9
+ ```
10
+ Requirement -> Acceptance Criteria -> Test Design -> AI Implementation -> Quality Check
11
+ ```
12
+
13
+ The goal is Formal Name Match: the "name" is the declared behavior below, and the "form" is the evidence produced by tests and diagnostics.
14
+
15
+ ## How to Use
16
+
17
+ 1. Fill `Requirement` and `Acceptance Criteria` before implementation.
18
+ 2. Map each acceptance criterion to at least one test row.
19
+ 3. Assign each test to the cheapest reliable verification layer.
20
+ 4. Give this completed document to the AI along with the implementation task.
21
+ 5. After implementation, run the verification commands exactly as written.
22
+ 6. If a command fails, use [`../prompts/diagnostic-repair.md`](../prompts/diagnostic-repair.md) with redacted diagnostic output.
23
+
24
+ ## Requirement
25
+
26
+ ### Summary
27
+
28
+ Write the user-visible behavior in one or two sentences.
29
+
30
+ Example:
31
+
32
+ > Users can update their display name from the profile settings page. Empty names are rejected and successful updates are reflected immediately on the page.
33
+
34
+ ### Scope
35
+
36
+ - In scope:
37
+ - [write the files, screens, API routes, or commands that may change]
38
+ - [write the behaviors that must be implemented]
39
+ - Out of scope:
40
+ - [write adjacent behaviors that must not change]
41
+ - [write future work that should not be pulled into this task]
42
+
43
+ ### User / Actor
44
+
45
+ - Primary actor:
46
+ - Secondary actor:
47
+ - Trust boundary:
48
+
49
+ ### Inputs and Outputs
50
+
51
+ | Item | Type | Source | Expected shape | Notes |
52
+ |---|---|---|---|---|
53
+ | input_name | string | UI / API / CLI | 1-50 visible characters | Example row |
54
+ | output_state | object | API response / UI state | public fields only | Example row |
55
+
56
+ ## Acceptance Criteria
57
+
58
+ Write acceptance criteria before implementation. They should be stable even if the implementation approach changes.
59
+
60
+ | AC ID | Criterion | Verification command or test | Layer |
61
+ |---|---|---|---|
62
+ | AC-01 | Happy path behavior succeeds | `pnpm test path/to/test` | unit / integration |
63
+ | AC-02 | Invalid input is rejected | `pnpm test path/to/test` | unit |
64
+ | AC-03 | Unauthorized or out-of-scope access is blocked | `pnpm test path/to/test` | integration / security |
65
+ | AC-04 | Existing behavior does not regress | `pnpm ai:check` | full gate |
66
+
67
+ Rules:
68
+
69
+ - Each AC must have a command, test name, or explicit manual evidence.
70
+ - At least one AC should cover an error path.
71
+ - Security or trust boundary changes must have a negative test.
72
+ - Do not rewrite AC after implementation just to match the code.
73
+
74
+ ## Test Matrix
75
+
76
+ Use this table to map behavior to the cheapest reliable test layer.
77
+
78
+ | Test ID | AC ID | Scenario | Given | When | Then | Layer | Command | Owner |
79
+ |---|---|---|---|---|---|---|---|---|
80
+ | T-001 | AC-01 | valid happy path | valid precondition | user performs allowed action | expected output appears | unit | `pnpm test path/to/test` | AI |
81
+ | T-002 | AC-02 | boundary input | input at minimum / maximum | validation runs | accepted or rejected per rule | unit | `pnpm test path/to/test` | AI |
82
+ | T-003 | AC-03 | trust boundary / security | actor lacks permission or data is private | actor requests protected action | request is rejected and private data is not exposed | integration / security | `pnpm test path/to/test` | AI |
83
+ | T-004 | AC-04 | regression guard | existing fixture or workflow exists | full check runs | no unrelated failure appears | full gate | `pnpm ai:check` | human + AI |
84
+
85
+ Layer guidance:
86
+
87
+ - Static: types, lint, dependency boundaries, dead code.
88
+ - Unit: pure logic, validation, formatting, permission predicates.
89
+ - Integration: API route, database boundary, service boundary, auth context.
90
+ - E2E: core user path only; avoid using E2E for cheap unit-observable behavior.
91
+ - Security: RLS, authorization, private field exposure, injection, secret handling.
92
+
93
+ ## Given-When-Then
94
+
95
+ Convert the most important rows into Given-When-Then statements. This makes the expected behavior easier for both humans and AI to follow.
96
+
97
+ ```gherkin
98
+ Scenario: valid display name update
99
+ Given a signed-in user with an existing profile
100
+ When the user submits a display name within the allowed length
101
+ Then the profile is updated
102
+ And the updated display name is visible in the response or UI
103
+ ```
104
+
105
+ ```gherkin
106
+ Scenario: empty display name is rejected
107
+ Given a signed-in user with an existing profile
108
+ When the user submits an empty display name
109
+ Then the request is rejected
110
+ And the existing profile remains unchanged
111
+ ```
112
+
113
+ ```gherkin
114
+ Scenario: private data does not cross the trust boundary
115
+ Given a public API response for another user
116
+ When the response is serialized
117
+ Then private fields are not included
118
+ And the test asserts the exact public field allowlist
119
+ ```
120
+
121
+ ## Verification Commands
122
+
123
+ List commands in the order they should run. Prefer fast checks first.
124
+
125
+ ```bash
126
+ pnpm typecheck
127
+ pnpm lint
128
+ pnpm test path/to/changed-area
129
+ pnpm ai:check:fast
130
+ pnpm ai:check
131
+ ```
132
+
133
+ If a command is not available in your project, replace it before implementation. Do not leave placeholder commands in the final task.
134
+
135
+ ## Risks and Gaps
136
+
137
+ | Risk / Gap | Why it matters | Mitigation | Follow-up trigger |
138
+ |---|---|---|---|
139
+ | Missing negative test | AI may implement happy path only | Add an invalid input or unauthorized actor row | Any permission or validation change |
140
+ | Overusing E2E | Slow and brittle checks hide simple logic failures | Move cheap checks to unit / integration | E2E test duplicates pure logic |
141
+ | Private data exposure | AI may return full records by convenience | Use exact public allowlist assertions | API response crosses trust boundary |
142
+ | Unclear rollback | Failed implementation may spread unrelated edits | Record files in scope and rollback path | More than one layer changes |
143
+
144
+ ## AI Implementation Brief
145
+
146
+ After this template is filled, give the AI this instruction:
147
+
148
+ ```
149
+ Implement the task using the Requirement, Acceptance Criteria, Test Matrix, and Verification Commands above.
150
+
151
+ Constraints:
152
+ - Do not change the acceptance criteria.
153
+ - Do not add files outside the declared scope.
154
+ - Add or update tests before or together with implementation.
155
+ - Run the verification commands and report exact output.
156
+ - If a command fails, stop and provide the failing output instead of claiming success.
157
+ ```
158
+
159
+ ## Review Checklist
160
+
161
+ - [ ] Every AC maps to at least one test row.
162
+ - [ ] At least one error path is tested.
163
+ - [ ] Trust boundary or security behavior has a negative test when applicable.
164
+ - [ ] Verification commands are executable in this project.
165
+ - [ ] The AI is not allowed to change AC after implementation.
166
+ - [ ] Remaining gaps are explicit and assigned to follow-up work.
167
+
168
+ ## Related Philosophy
169
+
170
+ - [`./philosophy/formal-name-match.md`](./philosophy/formal-name-match.md) — Declare the expected name before comparing the actual form.
171
+ - [`./philosophy/test-pyramid.md`](./philosophy/test-pyramid.md) — Put each check at the cheapest reliable layer.
172
+ - [`./philosophy/given-when-then.md`](./philosophy/given-when-then.md) — Express behavior as Given / When / Then.
173
+ - [`./philosophy/qa-techniques.md`](./philosophy/qa-techniques.md) — Use equivalence classes, boundary values, decision tables, and state transitions.
@@ -0,0 +1,6 @@
1
+ {
2
+ "scripts": {
3
+ "ai:check": "pnpm typecheck && pnpm lint && pnpm test && pnpm test:e2e:smoke",
4
+ "ai:check:fast": "pnpm typecheck && pnpm lint && pnpm test:unit"
5
+ }
6
+ }
@@ -0,0 +1,89 @@
1
+ # profiles/
2
+
3
+ 技術スタック別の typical 構成を提供する profile ライブラリ。利用者は自プロジェクトに合う profile を 1 つ選び、必要なら addon profile(supabase-rls)と組み合わせる。
4
+
5
+ > **ステータス**: Draft v0.1(Phase 0 では README のみ配布、実体ファイルは Phase 2 で)
6
+
7
+ ## 5 profile 一覧
8
+
9
+ | profile | 対象スタック | 主な特徴 | 注意点 |
10
+ |---|---|---|---|
11
+ | [`react-nextjs/`](./react-nextjs/README.md) | Next.js App Router + TS | フル toolchain | 推奨スタート地点 |
12
+ | [`react-vanilla/`](./react-vanilla/README.md) | 純 React + TS(Vite / CRA) | Next.js なし | SSR なしのため SEO 別途 |
13
+ | [`expo-rn/`](./expo-rn/README.md) | Expo / React Native | モバイル特化 | **React Doctor 非対応**、Maestro / Detox 使用 |
14
+ | [`node-cli/`](./node-cli/README.md) | Node CLI / Library | UI なし、Static + Unit 中心 | Playwright 不要 |
15
+ | [`supabase-rls/`](./supabase-rls/README.md)(addon) | Supabase + RLS | 上記 profile に追加適用 | 単独 profile ではない、組み合わせ前提 |
16
+
17
+ ## 選び方フロー
18
+
19
+ ```
20
+ 1. UI を持つ?
21
+ ├─ Yes: Web か モバイルか?
22
+ │ ├─ Web: Next.js を使う?
23
+ │ │ ├─ Yes → react-nextjs
24
+ │ │ └─ No → react-vanilla
25
+ │ └─ モバイル → expo-rn
26
+ └─ No → node-cli
27
+
28
+ 2. Supabase + RLS を使う?
29
+ ├─ Yes → 上で選んだ profile に supabase-rls を追加
30
+ └─ No → 上で選んだ profile のみ
31
+ ```
32
+
33
+ ## 組み合わせパターン例
34
+
35
+ | 組み合わせ | 使うところ |
36
+ |---|---|
37
+ | `react-nextjs` | Next.js + 自前 API |
38
+ | `react-nextjs+supabase-rls` | Next.js + Supabase(最も多い構成) |
39
+ | `react-vanilla` | SPA + 自前 API |
40
+ | `react-vanilla+supabase-rls` | SPA + Supabase |
41
+ | `expo-rn` | モバイル + 自前 API |
42
+ | `expo-rn+supabase-rls` | モバイル + Supabase |
43
+ | `node-cli` | CLI ツール / ライブラリ |
44
+ | `node-cli+supabase-rls` | サーバー側スクリプト + Supabase |
45
+
46
+ Phase 2 の CLI 実装で `--profile react-nextjs+supabase-rls` 形式を予定。
47
+
48
+ ## Phase 0 ステータス
49
+
50
+ 本ディレクトリは Phase 0 では **README のみ配布**。実体ファイル(profile-specific な scripts / hook / 設定)は以下のフェーズで提供:
51
+
52
+ | Phase | 内容 |
53
+ |---|---|
54
+ | Phase 0(現状) | profile README のみ |
55
+ | Phase 1 | dogfooding で profile の精度を上げる(README 改訂) |
56
+ | Phase 2 | profile-specific な実体ファイルを CLI で配布(`npx ai-check-template init --profile X`) |
57
+ | Phase 3 | 多 profile / 多プロジェクトでの横展開 |
58
+
59
+ 利用者は現状 README を読んで手動で自プロジェクトを構成する。Phase 2 以降は CLI 統合される。
60
+
61
+ ## 各 profile に共通する構造
62
+
63
+ | セクション | 内容 |
64
+ |---|---|
65
+ | 目的 | 誰向け・何を解決するか |
66
+ | 対象スタック | フレームワーク・ライブラリ・バージョン |
67
+ | 推奨ツール | 必須 / 推奨 / 任意のテーブル |
68
+ | ai:check カスタマイズ案 | `package.scripts.fragment.json` の差分 |
69
+ | .claude / scripts カスタマイズ案 | hook / scripts の差分 |
70
+ | 注意事項 | profile 固有の落とし穴 |
71
+ | 隣接 profile | 他 profile への参照 |
72
+ | 隣接思想 | philosophy への相互リンク |
73
+ | 出典 | Notion / 公式 docs |
74
+
75
+ ## 新規 profile の追加
76
+
77
+ 新しいスタック(例: rust-cli, python-fastapi)への対応は新規 SPEC で行う。本 SPEC(SPEC-0005)は 5 profile に限定。
78
+
79
+ ## 隣接する思想
80
+
81
+ - [`../docs/philosophy/test-pyramid.md`](../docs/philosophy/test-pyramid.md) — 各 profile で責務分割の応用が異なる
82
+ - [`../docs/philosophy/formal-name-match.md`](../docs/philosophy/formal-name-match.md) — 形名参同(profile 別の「名」定義)
83
+ - [`../docs/philosophy/qa-techniques.md`](../docs/philosophy/qa-techniques.md) — QA 技法
84
+ - [`../docs/philosophy/given-when-then.md`](../docs/philosophy/given-when-then.md) — GWT
85
+
86
+ ## 出典
87
+
88
+ - Notion ページ: `c3e549660ca44005a20c4f6fdb54c8d5` — 無料で作る AI エージェント開発診断フロー(参照日 2026-05-13)
89
+ - Notion ページ: `7c531b165bab4b7ea2dce1782469ac52` — Supabase Testing 戦略
@@ -0,0 +1,80 @@
1
+ # expo-rn profile
2
+
3
+ > **ステータス**: Draft v0.1(Phase 1 dogfooding 後に改訂予定。実体ファイルは Phase 2 で配布)
4
+
5
+ ## 目的
6
+
7
+ Expo / React Native 環境の typical stack 向け profile。モバイル特有の制約(Native 連携、E2E ツールの違い、React Doctor の非対応)を考慮した品質ループを構築する。
8
+
9
+ ## 対象スタック
10
+
11
+ | カテゴリ | 想定 |
12
+ |---|---|
13
+ | Framework | Expo SDK 50+ または素の React Native 0.73+ |
14
+ | Language | TypeScript |
15
+ | Navigation | React Navigation / Expo Router |
16
+ | Package Manager | pnpm / npm / yarn |
17
+ | Node version | 22 LTS |
18
+ | Native | iOS / Android(必要に応じて) |
19
+ | E2E | Maestro / Detox(Playwright は使わない) |
20
+
21
+ ## 推奨ツール
22
+
23
+ | ツール | 必須/推奨/任意 | 用途 | 備考 |
24
+ |---|---|---|---|
25
+ | TypeScript | 必須 | 型チェック | |
26
+ | ESLint / oxlint | 必須 | lint | |
27
+ | **React Doctor** | **非対応** | — | React Doctor は **モバイル非対応**。代替なし(純 React コンポーネントのみ別途部分検査可) |
28
+ | Knip | 推奨 | 未使用検出 | |
29
+ | Jest / Vitest | 必須 | Unit / Integration | Jest が React Native コミュニティでは主流 |
30
+ | **Maestro** | 推奨 | E2E(モバイル UI) | Playwright の代替。YAML ベースで AI 出力と相性◯ |
31
+ | **Detox** | 任意 | E2E(より高度) | iOS / Android シミュレータ統合 |
32
+ | Semgrep | 推奨 | セキュリティ | |
33
+
34
+ ## ai:check / ai:check:fast カスタマイズ案
35
+
36
+ ```json
37
+ {
38
+ "scripts": {
39
+ "ai:check": "pnpm typecheck && pnpm lint && pnpm deadcode && pnpm test && pnpm test:e2e:smoke",
40
+ "ai:check:fast": "pnpm typecheck && pnpm lint && pnpm test:unit"
41
+ }
42
+ }
43
+ ```
44
+
45
+ - `test:e2e:smoke`: Maestro で `maestro test .maestro/smoke.yaml` 等
46
+ - React Doctor 関連の script は **入れない**
47
+
48
+ ## .claude / scripts カスタマイズ案
49
+
50
+ - `.claude/rules/test-rules.md`: Playwright Locator 優先順位の代わりに **Maestro / Detox の selector ルール**を記述
51
+ - Maestro: `id:my-button` / `text:Submit` の優先順位
52
+ - Detox: `by.id` > `by.label` > `by.text`
53
+ - hook fragment は基本構造そのまま(コマンドは `pnpm ai:check` / `pnpm ai:check:fast`)
54
+
55
+ ## 注意事項
56
+
57
+ - **React Doctor 非対応**: 本 profile の最大の特徴。診断スコアによる判定は使えない。代替として静的解析 + 手動レビューに依存
58
+ - **Native module の test 困難**: モック化必須。test:unit でカバーできない範囲は Maestro / 手動確認
59
+ - **iOS / Android 差異**: 両 OS で動かして確認。CI で両 OS を sharding するコストを考慮
60
+ - **Expo Go 制限**: 一部 Native 機能は Expo Go では動かないため、開発ビルド / プロダクションビルドでのテストが必要
61
+ - **キャッシュ問題**: Metro / Babel のキャッシュで「直したつもりが反映されない」事故あり。CI では cache クリアを明示
62
+
63
+ ## 隣接 profile
64
+
65
+ - [`../react-vanilla/README.md`](../react-vanilla/README.md) — Web の純 React
66
+ - [`../react-nextjs/README.md`](../react-nextjs/README.md) — Web の Next.js
67
+ - [`../node-cli/README.md`](../node-cli/README.md) — サーバー側ロジック
68
+
69
+ ## 隣接思想
70
+
71
+ - [`../../docs/philosophy/test-pyramid.md`](../../docs/philosophy/test-pyramid.md) — モバイルでは E2E 層のコスト構造が異なる
72
+ - [`../../docs/philosophy/formal-name-match.md`](../../docs/philosophy/formal-name-match.md) — 形名参同(React Doctor を使わない場合は他の「形」で代替)
73
+ - [`../../docs/philosophy/qa-techniques.md`](../../docs/philosophy/qa-techniques.md) — QA 技法
74
+ - [`../../docs/philosophy/given-when-then.md`](../../docs/philosophy/given-when-then.md) — GWT(Maestro / Detox にそのまま使える)
75
+
76
+ ## 出典
77
+
78
+ - Notion ページ: `c3e549660ca44005a20c4f6fdb54c8d5` — 無料で作る AI エージェント開発診断フロー(参照日 2026-05-13)
79
+ - Maestro 公式 docs
80
+ - Detox 公式 docs
@@ -0,0 +1,93 @@
1
+ # node-cli profile
2
+
3
+ > **ステータス**: Draft v0.1(Phase 1 dogfooding 後に改訂予定。実体ファイルは Phase 2 で配布)
4
+
5
+ ## 目的
6
+
7
+ UI を持たない Node.js CLI / Library / サーバー側コード向け profile。UI / E2E ツールを除外し、Static + Unit + Integration に焦点を絞った品質ループを構築する。
8
+
9
+ ## 対象スタック
10
+
11
+ | カテゴリ | 想定 |
12
+ |---|---|
13
+ | Runtime | Node.js 22 LTS(20 でも動作) |
14
+ | Language | TypeScript |
15
+ | Build | tsc / esbuild / tsup / unbuild |
16
+ | CLI Framework | commander / oclif / yargs / 自前 |
17
+ | Package Manager | pnpm / npm / yarn / bun |
18
+ | UI | **なし** |
19
+ | E2E | **なし**(必要なら integration test で代替) |
20
+
21
+ ## 推奨ツール
22
+
23
+ | ツール | 必須/推奨/任意 | 用途 | 備考 |
24
+ |---|---|---|---|
25
+ | TypeScript | 必須 | 型チェック | |
26
+ | ESLint / oxlint | 必須 | lint | |
27
+ | **React Doctor** | **非対応** | — | React なしのため |
28
+ | Knip | 必須 | 未使用検出 | Library は未使用 export の影響大、必須 |
29
+ | Vitest | 必須 | Unit / Integration | |
30
+ | **Playwright** | **不要** | — | UI なし |
31
+ | Semgrep | 推奨 | セキュリティ | 特に CLI 引数 / ファイル I/O 経路 |
32
+
33
+ ## ai:check / ai:check:fast カスタマイズ案
34
+
35
+ ```json
36
+ {
37
+ "scripts": {
38
+ "ai:check": "pnpm typecheck && pnpm lint && pnpm deadcode && pnpm test",
39
+ "ai:check:fast": "pnpm typecheck && pnpm lint && pnpm test:unit"
40
+ }
41
+ }
42
+ ```
43
+
44
+ - E2E ステップは含まない
45
+ - `test`: integration を含む全テスト
46
+ - `test:unit`: Unit のみ(fast loop 用)
47
+
48
+ ## .claude / scripts カスタマイズ案
49
+
50
+ - `.claude/rules/test-rules.md`: Playwright Locator 優先順位は **不要**。代わりに **CLI 引数 / stdin / stdout の testing ルール**を記述してもよい(カスタマイズ)
51
+ - hook fragment / scripts はそのまま使える
52
+
53
+ ## 注意事項
54
+
55
+ - **stdin / stdout**: CLI の入出力をテストする際、`spawn` / `execa` でサブプロセス化 + stdout を assert
56
+ - **環境変数**: `.env` 経由の設定は test で明示的に上書き
57
+ - **path traversal**: ファイル操作する CLI は path traversal 攻撃の検証必須(Semgrep でカバー)
58
+ - **exit code**: 「正常終了 = 0」「エラー = 非 0」を必ずテスト
59
+ - **publish 前の検査**: `npm pack` で配布物に余計なファイルが入らないか確認
60
+
61
+ ## CLI 特有のテストパターン
62
+
63
+ ```typescript
64
+ // CLI 統合テスト例(vitest + execa)
65
+ import { execa } from 'execa';
66
+
67
+ it('CLI exits 0 on valid input', async () => {
68
+ const { stdout, exitCode } = await execa('node', ['./dist/cli.js', '--input', 'foo']);
69
+ expect(exitCode).toBe(0);
70
+ expect(stdout).toContain('expected output');
71
+ });
72
+
73
+ it('CLI exits non-zero on invalid input', async () => {
74
+ await expect(execa('node', ['./dist/cli.js', '--invalid'])).rejects.toMatchObject({ exitCode: 1 });
75
+ });
76
+ ```
77
+
78
+ ## 隣接 profile
79
+
80
+ - [`../react-nextjs/README.md`](../react-nextjs/README.md) — フルスタック Web
81
+ - [`../react-vanilla/README.md`](../react-vanilla/README.md) — Web の SPA
82
+ - [`../supabase-rls/README.md`](../supabase-rls/README.md) — DB 統合がある場合に組み合わせ
83
+
84
+ ## 隣接思想
85
+
86
+ - [`../../docs/philosophy/test-pyramid.md`](../../docs/philosophy/test-pyramid.md) — E2E 層なしで Static + Unit + Integration が中心
87
+ - [`../../docs/philosophy/formal-name-match.md`](../../docs/philosophy/formal-name-match.md) — 形名参同
88
+ - [`../../docs/philosophy/qa-techniques.md`](../../docs/philosophy/qa-techniques.md) — boundary-value, decision-table が特に有効
89
+ - [`../../docs/philosophy/given-when-then.md`](../../docs/philosophy/given-when-then.md) — GWT
90
+
91
+ ## 出典
92
+
93
+ - Notion ページ: `c3e549660ca44005a20c4f6fdb54c8d5` — 無料で作る AI エージェント開発診断フロー(参照日 2026-05-13)
@@ -0,0 +1,82 @@
1
+ # react-nextjs profile
2
+
3
+ > **ステータス**: Draft v0.1(Phase 1 dogfooding 後に改訂予定。実体ファイルは Phase 2 で配布)
4
+
5
+ ## 目的
6
+
7
+ Next.js(App Router 想定)+ TypeScript の typical stack で AI 駆動開発の品質ループを構築する利用者向け profile。フル toolchain(型 / lint / 静的解析 / 未使用検出 / E2E / セキュリティ)を組み合わせて、形名参同による品質照合を実装する。
8
+
9
+ ## 対象スタック
10
+
11
+ | カテゴリ | 想定 |
12
+ |---|---|
13
+ | Framework | Next.js 14+(App Router、Pages Router でも動作するが調整必要) |
14
+ | Language | TypeScript |
15
+ | Package Manager | pnpm(npm / yarn / bun でも可、`PM` 環境変数で切り替え) |
16
+ | Node version | 22 LTS(20 でも動作) |
17
+ | UI Test | Playwright |
18
+ | Style | Tailwind / CSS Modules / styled-components いずれも可 |
19
+
20
+ ## 推奨ツール
21
+
22
+ | ツール | 必須/推奨/任意 | 用途 | 備考 |
23
+ |---|---|---|---|
24
+ | TypeScript | 必須 | 型チェック | `tsc --noEmit` を `ai:check:fast` に含める |
25
+ | ESLint / oxlint | 必須 | lint | oxlint の高速性で AI 内部ループ向き |
26
+ | React Doctor | 推奨 | React/Next.js 品質診断 | 75 以上目標、50 未満マージ不可 |
27
+ | Knip | 推奨 | 未使用検出 | 1 週間運用後に CI 強制を検討 |
28
+ | Playwright | 必須 | E2E(主要導線のみ) | smoke は PR、full は nightly |
29
+ | Semgrep | 推奨 | セキュリティ | High/Critical でマージブロック |
30
+
31
+ ## ai:check / ai:check:fast カスタマイズ案
32
+
33
+ `package.scripts.fragment.json` を以下のように調整:
34
+
35
+ ```json
36
+ {
37
+ "scripts": {
38
+ "ai:check": "pnpm typecheck && pnpm lint && pnpm doctor && pnpm deadcode && pnpm test && pnpm test:e2e:smoke",
39
+ "ai:check:fast": "pnpm typecheck && pnpm lint && pnpm test:unit"
40
+ }
41
+ }
42
+ ```
43
+
44
+ 個別ツールの npm script を別途定義:
45
+ - `typecheck`: `tsc --noEmit`
46
+ - `lint`: `next lint` または `oxlint .`
47
+ - `doctor`: `npx -y react-doctor@latest . --fail-on warning`
48
+ - `deadcode`: `knip`
49
+ - `test`: `vitest run`
50
+ - `test:unit`: `vitest run --dir tests/unit`
51
+ - `test:e2e:smoke`: `playwright test --grep smoke`
52
+
53
+ ## .claude / scripts カスタマイズ案
54
+
55
+ - `.claude/settings.hook-fragment.json`: そのまま使える(hook command が `pnpm ai:check` / `pnpm ai:check:fast`)
56
+ - `.claude/rules/test-rules.md`: Playwright Locator 優先順位を遵守
57
+ - `scripts/ai-check.sh` / `ai-check-fast.sh`: そのまま
58
+
59
+ ## 注意事項
60
+
61
+ - **Pages Router の場合**: App Router 前提の React Doctor 診断項目が一部対象外。`--ignore-pages` 等の調整を検討
62
+ - **monorepo**: workspace の場合、`pnpm -r ai:check` のような root レベルスクリプトを別途用意
63
+ - **Playwright のフレーキー**: 主要導線のみに絞り、retry 1 回まで許容
64
+ - **Server Actions**: 認可は client 側だけでなく server action 内でも検証(参照: [`../../docs/philosophy/test-pyramid.md`](../../docs/philosophy/test-pyramid.md) §3 Integration)
65
+
66
+ ## 隣接 profile
67
+
68
+ - [`../react-vanilla/README.md`](../react-vanilla/README.md) — Next.js なしの純 React
69
+ - [`../supabase-rls/README.md`](../supabase-rls/README.md) — Supabase + RLS を追加適用
70
+ - [`../expo-rn/README.md`](../expo-rn/README.md) — モバイル(React Native)
71
+
72
+ ## 隣接思想
73
+
74
+ - [`../../docs/philosophy/formal-name-match.md`](../../docs/philosophy/formal-name-match.md) — 形名参同
75
+ - [`../../docs/philosophy/test-pyramid.md`](../../docs/philosophy/test-pyramid.md) — 責務分割
76
+ - [`../../docs/philosophy/given-when-then.md`](../../docs/philosophy/given-when-then.md) — 受け入れ条件先出し
77
+ - [`../../docs/philosophy/qa-techniques.md`](../../docs/philosophy/qa-techniques.md) — QA 技法
78
+
79
+ ## 出典
80
+
81
+ - Notion ページ: `c3e549660ca44005a20c4f6fdb54c8d5` — 無料で作る AI エージェント開発診断フロー(参照日 2026-05-13)
82
+ - Next.js Testing Guide(公式)
@@ -0,0 +1,73 @@
1
+ # react-vanilla profile
2
+
3
+ > **ステータス**: Draft v0.1(Phase 1 dogfooding 後に改訂予定。実体ファイルは Phase 2 で配布)
4
+
5
+ ## 目的
6
+
7
+ 純 React + TypeScript(Next.js なし、Vite / CRA / 自前 setup)の typical stack 向け profile。Next.js 固有機能を除外し、SPA としての品質ループを構築する。
8
+
9
+ ## 対象スタック
10
+
11
+ | カテゴリ | 想定 |
12
+ |---|---|
13
+ | Framework | React 18+(Vite / Create React App / 自前 webpack 等) |
14
+ | Language | TypeScript |
15
+ | Routing | React Router / TanStack Router 等 |
16
+ | Package Manager | pnpm(npm / yarn / bun でも可) |
17
+ | Node version | 22 LTS |
18
+ | UI Test | Playwright(任意、SPA のみなら React Testing Library で代替可) |
19
+
20
+ ## 推奨ツール
21
+
22
+ | ツール | 必須/推奨/任意 | 用途 | 備考 |
23
+ |---|---|---|---|
24
+ | TypeScript | 必須 | 型チェック | |
25
+ | ESLint / oxlint | 必須 | lint | |
26
+ | React Doctor | 任意 | React 品質診断 | Next.js 固有診断項目は対象外、純 React 部分のみ有効 |
27
+ | Knip | 推奨 | 未使用検出 | |
28
+ | Vitest | 必須 | Unit / Integration | |
29
+ | Playwright | 任意 | E2E | SPA で十分な testing-library 等で代替可 |
30
+ | Semgrep | 推奨 | セキュリティ | |
31
+
32
+ ## ai:check / ai:check:fast カスタマイズ案
33
+
34
+ ```json
35
+ {
36
+ "scripts": {
37
+ "ai:check": "pnpm typecheck && pnpm lint && pnpm deadcode && pnpm test",
38
+ "ai:check:fast": "pnpm typecheck && pnpm lint && pnpm test:unit"
39
+ }
40
+ }
41
+ ```
42
+
43
+ Playwright を使う場合は `ai:check` に `pnpm test:e2e:smoke` を追加。
44
+
45
+ ## .claude / scripts カスタマイズ案
46
+
47
+ react-nextjs profile と同じ(hook fragment / test-rules / scripts はそのまま使える)。
48
+ ただし test-rules.md の Playwright Locator 優先順位は Playwright を使わない場合は不要。
49
+
50
+ ## 注意事項
51
+
52
+ - **SPA の SEO 制約**: SSR がないため、SEO 観点のテストは別途検討
53
+ - **react-router の権限制御**: `<ProtectedRoute>` 等の wrapper が server-side 認可と一致するか確認
54
+ - **localStorage / sessionStorage の漏洩**: secret を store しないか lint で検出
55
+ - **CSP**: SPA は inline script を多用しがちなので strict CSP との相性を確認
56
+
57
+ ## 隣接 profile
58
+
59
+ - [`../react-nextjs/README.md`](../react-nextjs/README.md) — Next.js(推奨:本 profile より広範囲)
60
+ - [`../node-cli/README.md`](../node-cli/README.md) — UI なしの Node
61
+ - [`../supabase-rls/README.md`](../supabase-rls/README.md) — Supabase + RLS を追加
62
+
63
+ ## 隣接思想
64
+
65
+ - [`../../docs/philosophy/test-pyramid.md`](../../docs/philosophy/test-pyramid.md) — 各層の責務分割
66
+ - [`../../docs/philosophy/formal-name-match.md`](../../docs/philosophy/formal-name-match.md) — 形名参同
67
+ - [`../../docs/philosophy/qa-techniques.md`](../../docs/philosophy/qa-techniques.md) — QA 技法
68
+ - [`../../docs/philosophy/given-when-then.md`](../../docs/philosophy/given-when-then.md) — GWT
69
+
70
+ ## 出典
71
+
72
+ - Notion ページ: `c3e549660ca44005a20c4f6fdb54c8d5` — 無料で作る AI エージェント開発診断フロー(参照日 2026-05-13)
73
+ - Testing Library Guiding Principles(公式)