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.
- package/LICENSE +201 -0
- package/README-ja.md +151 -0
- package/README.md +149 -0
- package/bin/ai-check-template.mjs +7 -0
- package/docs/cli.md +348 -0
- package/package-templates/.claude/README.md +83 -0
- package/package-templates/.claude/rules/test-rules.md +46 -0
- package/package-templates/.claude/settings.hook-fragment.json +25 -0
- package/package-templates/README.md +56 -0
- package/package-templates/ci-examples/README.md +134 -0
- package/package-templates/ci-examples/github-actions/ai-check-fast.yml +49 -0
- package/package-templates/ci-examples/github-actions/ai-check.yml +58 -0
- package/package-templates/ci-examples/github-actions/ai-quality-call.yml +26 -0
- package/package-templates/ci-examples/github-actions/ai-quality-reusable.yml +113 -0
- package/package-templates/docs/philosophy/formal-name-match.md +182 -0
- package/package-templates/docs/philosophy/given-when-then.md +206 -0
- package/package-templates/docs/philosophy/qa-techniques.md +235 -0
- package/package-templates/docs/philosophy/test-pyramid.md +171 -0
- package/package-templates/docs/test-design-template.md +173 -0
- package/package-templates/package.scripts.fragment.json +6 -0
- package/package-templates/profiles/README.md +89 -0
- package/package-templates/profiles/expo-rn/README.md +80 -0
- package/package-templates/profiles/node-cli/README.md +93 -0
- package/package-templates/profiles/react-nextjs/README.md +82 -0
- package/package-templates/profiles/react-vanilla/README.md +73 -0
- package/package-templates/profiles/supabase-rls/README.md +89 -0
- package/package-templates/prompts/README.md +94 -0
- package/package-templates/prompts/boundary-value.md +94 -0
- package/package-templates/prompts/decision-table.md +82 -0
- package/package-templates/prompts/diagnostic-repair.md +149 -0
- package/package-templates/prompts/plan-first.md +122 -0
- package/package-templates/prompts/rls-permission.md +94 -0
- package/package-templates/prompts/state-transition.md +81 -0
- package/package-templates/scripts/README.md +78 -0
- package/package-templates/scripts/ai-check-fast.sh +20 -0
- package/package-templates/scripts/ai-check.sh +22 -0
- package/package.json +47 -0
- package/src/cli/ci-workflows.mjs +104 -0
- package/src/cli/claude-hooks.mjs +94 -0
- package/src/cli/dependency-installer.mjs +164 -0
- package/src/cli/doctor.mjs +392 -0
- package/src/cli/index.mjs +80 -0
- package/src/cli/init.mjs +433 -0
- package/src/cli/install-state.mjs +242 -0
- package/src/cli/package-manager.mjs +78 -0
- package/src/cli/profile-diagnostics.mjs +160 -0
- package/src/cli/profile-docs.mjs +31 -0
- package/src/cli/profile-scripts.mjs +96 -0
- package/src/cli/profile.mjs +59 -0
- package/src/cli/update.mjs +537 -0
- package/src/cli/utils.mjs +75 -0
package/docs/cli.md
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# CLI alpha
|
|
2
|
+
|
|
3
|
+
`ai-check-template` now includes an alpha CLI foundation for v0.2.0. It is repository-local in this slice and is not an npm-published stable release yet.
|
|
4
|
+
|
|
5
|
+
Use it to copy the v0.1.0 templates into an existing project with safer defaults than manual copy.
|
|
6
|
+
|
|
7
|
+
## Command
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
node bin/ai-check-template.mjs init --target ../your-project --profile react-nextjs --yes
|
|
11
|
+
node bin/ai-check-template.mjs doctor --target ../your-project
|
|
12
|
+
node bin/ai-check-template.mjs update --target ../your-project --dry-run
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
From another project after cloning this repository:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
node ../ai-check-template/bin/ai-check-template.mjs init --target . --profile react-nextjs --dry-run
|
|
19
|
+
node ../ai-check-template/bin/ai-check-template.mjs init --target . --profile react-nextjs --install-deps --dry-run
|
|
20
|
+
node ../ai-check-template/bin/ai-check-template.mjs init --target . --profile react-nextjs --yes
|
|
21
|
+
node ../ai-check-template/bin/ai-check-template.mjs init --target . --profile node-cli --package-manager npm --dry-run
|
|
22
|
+
node ../ai-check-template/bin/ai-check-template.mjs doctor --target . --json
|
|
23
|
+
node ../ai-check-template/bin/ai-check-template.mjs doctor --target . --strict --json
|
|
24
|
+
node ../ai-check-template/bin/ai-check-template.mjs update --target . --yes
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Init options
|
|
28
|
+
|
|
29
|
+
| Option | Default | Description |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `--target <dir>` | current directory | Existing project directory. It must already contain `package.json`. |
|
|
32
|
+
| `--profile <name>` | `react-nextjs` | One base profile: `react-nextjs`, `react-vanilla`, `expo-rn`, or `node-cli`. Add `+supabase-rls` when needed. |
|
|
33
|
+
| `--package-manager <name>` | target detection or `pnpm` | Package manager for generated package scripts: `pnpm`, `npm`, `yarn`, or `bun`. |
|
|
34
|
+
| `--ci <mode>` | `direct` | `direct` writes package-manager-aware `ai-check.yml` and `ai-check-fast.yml`; `reusable` writes `ai-quality-reusable.yml` plus a package-manager-aware `ai-quality-call.yml`; `none` skips workflows. |
|
|
35
|
+
| `--claude-hooks` | off | Copies `.claude/rules/test-rules.md` and merges package-manager-aware hook commands into `.claude/settings.json`. |
|
|
36
|
+
| `--install-deps` | off | Installs missing npm dev dependencies for generated package scripts. With `--dry-run`, prints the command without executing it. |
|
|
37
|
+
| `--dry-run` | off | Prints planned operations without writing files. |
|
|
38
|
+
| `--yes` | off | Confirms non-interactive writes. Required unless `--dry-run` is used. |
|
|
39
|
+
| `--overwrite` | off | Replaces conflicting files or scripts. Without this flag, conflicts are skipped. |
|
|
40
|
+
|
|
41
|
+
## Doctor options
|
|
42
|
+
|
|
43
|
+
| Option | Default | Description |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `--target <dir>` | current directory | Existing project directory. It must already contain `package.json`. |
|
|
46
|
+
| `--profile <name>` | install state or `react-nextjs` | Profile to check. One base profile plus optional `+supabase-rls`. |
|
|
47
|
+
| `--package-manager <name>` | install state, target detection, or `pnpm` | Package manager used when checking package scripts: `pnpm`, `npm`, `yarn`, or `bun`. |
|
|
48
|
+
| `--ci <mode>` | `direct` | Checks `direct`, `reusable`, or no workflow files. |
|
|
49
|
+
| `--claude-hooks` | off | Checks `.claude/rules/test-rules.md` and required hook keys in `.claude/settings.json`. |
|
|
50
|
+
| `--strict` | off | Treats profile diagnostics warnings as a failing result while keeping them in `warnings`. |
|
|
51
|
+
| `--json` | off | Prints `{ status, target, strict, installation, effectiveOptions, warnings, issues }` for automation. |
|
|
52
|
+
|
|
53
|
+
## Update options
|
|
54
|
+
|
|
55
|
+
| Option | Default | Description |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `--target <dir>` | current directory | Existing project directory. It must already contain `package.json`. |
|
|
58
|
+
| `--profile <name>` | install state or `react-nextjs` | Profile to refresh in install state. One base profile plus optional `+supabase-rls`. |
|
|
59
|
+
| `--package-manager <name>` | install state, target detection, or `pnpm` | Package manager used when refreshing package scripts: `pnpm`, `npm`, `yarn`, or `bun`. |
|
|
60
|
+
| `--ci <mode>` | `direct` | Updates package-manager-aware `direct`, `reusable`, or no workflow files. |
|
|
61
|
+
| `--claude-hooks` | off | Updates `.claude/rules/test-rules.md` and managed package-manager-aware hook keys in `.claude/settings.json`. |
|
|
62
|
+
| `--install-deps` | off | Installs missing npm dev dependencies for generated package scripts. With `--dry-run`, prints the command without executing it. |
|
|
63
|
+
| `--dry-run` | off | Prints planned operations without writing files. |
|
|
64
|
+
| `--yes` | off | Confirms non-interactive writes. Required unless `--dry-run` is used. |
|
|
65
|
+
| `--json` | off | Prints `{ status, target, installation, effectiveOptions, operations }` for automation. |
|
|
66
|
+
|
|
67
|
+
## Install state
|
|
68
|
+
|
|
69
|
+
`init` writes a deterministic `.ai-check-template.json` file at the target project root. The file records schema version, package version, selected profile, package manager, CI mode, and whether Claude hooks were enabled. It intentionally does not store timestamps, absolute target paths, environment values, or secrets.
|
|
70
|
+
|
|
71
|
+
`doctor` and `update` read this file when it exists. Explicit flags still win:
|
|
72
|
+
|
|
73
|
+
1. CLI flags such as `--profile`, `--package-manager`, `--ci`, and `--claude-hooks`
|
|
74
|
+
2. `.ai-check-template.json`
|
|
75
|
+
3. target detection for package manager (`packageManager` field, then lockfiles)
|
|
76
|
+
4. legacy defaults (`react-nextjs`, `pnpm`, `direct`, no Claude hooks)
|
|
77
|
+
|
|
78
|
+
Malformed or unsupported install state is reported by `doctor` as an issue. `update` rejects malformed install state before writing any target files.
|
|
79
|
+
|
|
80
|
+
## Package manager detection
|
|
81
|
+
|
|
82
|
+
The CLI alpha generates profile-aware package scripts for `pnpm`, `npm`, `yarn`, and `bun`. Detection uses:
|
|
83
|
+
|
|
84
|
+
1. explicit `--package-manager`
|
|
85
|
+
2. install state
|
|
86
|
+
3. target `package.json` `packageManager` field
|
|
87
|
+
4. lockfiles (`pnpm-lock.yaml`, `package-lock.json`, `npm-shrinkwrap.json`, `yarn.lock`, `bun.lock`, `bun.lockb`)
|
|
88
|
+
5. `pnpm` default
|
|
89
|
+
|
|
90
|
+
Package manager detection changes generated package script invocations, Claude hook commands, and CLI-written GitHub Actions workflows. When `--install-deps` is explicitly set on `init` or `update`, it also selects the install command. It does not change the manual `package-templates/package.scripts.fragment.json` or the source templates under `package-templates/`.
|
|
91
|
+
|
|
92
|
+
## CI workflow rendering
|
|
93
|
+
|
|
94
|
+
When `--ci direct` is set, `init` and `update` write workflow commands for the effective package manager:
|
|
95
|
+
|
|
96
|
+
| Package manager | Install command | Full check | Fast check |
|
|
97
|
+
|---|---|---|---|
|
|
98
|
+
| `pnpm` | `pnpm install --frozen-lockfile` | `pnpm ai:check` | `pnpm ai:check:fast` |
|
|
99
|
+
| `npm` | `npm ci` | `npm run ai:check` | `npm run ai:check:fast` |
|
|
100
|
+
| `yarn` | `yarn install --immutable` | `yarn ai:check` | `yarn ai:check:fast` |
|
|
101
|
+
| `bun` | `bun install --frozen-lockfile` | `bun run ai:check` | `bun run ai:check:fast` |
|
|
102
|
+
|
|
103
|
+
When `--ci reusable` is set, `ai-quality-reusable.yml` remains the generic reusable workflow and `ai-quality-call.yml` receives package-manager-specific `package-manager` and `check-command` inputs. `doctor` compares selected workflows against the rendered content for the effective package manager. `update --ci none` cleans up inactive workflows only when their content exactly matches one of the managed rendered variants; custom workflow content is preserved.
|
|
104
|
+
|
|
105
|
+
## Claude hook command rendering
|
|
106
|
+
|
|
107
|
+
When `--claude-hooks` is set, `init` and `update` render the managed `.claude/settings.json` hook commands from the effective package manager:
|
|
108
|
+
|
|
109
|
+
| Package manager | Fast hook | Full hook |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `pnpm` | `pnpm ai:check:fast` | `pnpm ai:check` |
|
|
112
|
+
| `npm` | `npm run ai:check:fast` | `npm run ai:check` |
|
|
113
|
+
| `yarn` | `yarn ai:check:fast` | `yarn ai:check` |
|
|
114
|
+
| `bun` | `bun run ai:check:fast` | `bun run ai:check` |
|
|
115
|
+
|
|
116
|
+
`init` preserves existing hook groups unless `--overwrite` is passed. `update` refreshes managed hook commands to the effective package manager and preserves custom non-managed hook commands in the same group. The packaged manual hook fragment remains `pnpm`-based for copy-and-adapt users.
|
|
117
|
+
|
|
118
|
+
## Profile diagnostics
|
|
119
|
+
|
|
120
|
+
`doctor` also emits `warnings` from the effective profile, missing referenced package scripts, and stale managed CI workflow checks. These warnings use the same `{ code, path, message }` shape as issues. By default they are advisory and do not change the exit status. Add `--strict` when CI or release prep should fail on warnings without converting them into issues.
|
|
121
|
+
|
|
122
|
+
Current advisory checks cover:
|
|
123
|
+
|
|
124
|
+
- `react-nextjs`: React Doctor and Playwright smoke E2E recommendations
|
|
125
|
+
- `react-vanilla`: Next.js-specific script mismatch
|
|
126
|
+
- `expo-rn`: Playwright / React Doctor mismatch for mobile projects
|
|
127
|
+
- `node-cli`: UI E2E mismatch for CLI or library projects
|
|
128
|
+
- `supabase-rls`: missing RLS-related DB / integration test scripts
|
|
129
|
+
- `ai:check` / `ai:check:fast`: missing referenced package scripts such as `typecheck`, `lint`, or `test:unit`
|
|
130
|
+
|
|
131
|
+
Warnings remain advisory by default in this alpha. `doctor --strict` is available for stricter local or CI checks. Missing script diagnostics do not install dependencies or create scripts; profile-specific file / CI migrations remain future work.
|
|
132
|
+
|
|
133
|
+
## CI diagnostics
|
|
134
|
+
|
|
135
|
+
`doctor` reports `ci-advice` warnings when workflow files from an inactive `--ci` mode still exist and exactly match the packaged templates:
|
|
136
|
+
|
|
137
|
+
- `--ci none`: warns about managed direct and reusable workflow files
|
|
138
|
+
- `--ci direct`: warns about managed reusable workflow files
|
|
139
|
+
- `--ci reusable`: warns about managed direct workflow files
|
|
140
|
+
|
|
141
|
+
Custom workflows with the same paths are not treated as stale managed files unless their contents exactly match the packaged template. `update` can clean up exact-managed inactive workflows; custom workflows are preserved.
|
|
142
|
+
|
|
143
|
+
## Profile-aware scripts
|
|
144
|
+
|
|
145
|
+
The manual `package-templates/package.scripts.fragment.json` remains a generic copy-and-adapt fragment. The CLI alpha uses a profile-aware script resolver instead:
|
|
146
|
+
|
|
147
|
+
- `react-nextjs` adds React Doctor and dead-code checks to `ai:check`
|
|
148
|
+
- `react-vanilla` keeps SPA scripts without Next.js-specific commands
|
|
149
|
+
- `expo-rn` keeps mobile-oriented smoke E2E defaults
|
|
150
|
+
- `node-cli` excludes UI E2E from `ai:check`
|
|
151
|
+
- `supabase-rls` adds `test:db` and `test:integration:rls`
|
|
152
|
+
|
|
153
|
+
`init` merges the selected profile scripts. `doctor` checks the effective profile scripts. `update` migrates known managed package scripts to the effective profile, with explicit `--profile` and `--package-manager` taking precedence over install state.
|
|
154
|
+
|
|
155
|
+
## Profile document migrations
|
|
156
|
+
|
|
157
|
+
`init` and `update` copy profile guidance into the target project under `docs/ai-check-template/`.
|
|
158
|
+
|
|
159
|
+
The copied set includes:
|
|
160
|
+
|
|
161
|
+
- `docs/test-design-template.md`
|
|
162
|
+
- `docs/philosophy/*.md`
|
|
163
|
+
- `prompts/diagnostic-repair.md`
|
|
164
|
+
- `profiles/README.md`
|
|
165
|
+
- the selected base profile README, such as `profiles/react-nextjs/README.md` or `profiles/node-cli/README.md`
|
|
166
|
+
- selected addon profile READMEs, such as `profiles/supabase-rls/README.md`
|
|
167
|
+
|
|
168
|
+
The target layout preserves the package-template-like `docs/`, `prompts/`, and `profiles/` structure so existing relative links in the copied Markdown continue to work. `init` skips existing files by default and follows `--overwrite` for conflicts. `update` creates missing docs only and keeps existing target docs unchanged.
|
|
169
|
+
|
|
170
|
+
## Support script defaults
|
|
171
|
+
|
|
172
|
+
`init` and `update` also add missing support package scripts referenced by `ai:check` / `ai:check:fast`, such as `typecheck`, `lint`, `test`, `test:unit`, and for `react-nextjs`, `test:e2e:smoke`.
|
|
173
|
+
|
|
174
|
+
These defaults are intentionally conservative:
|
|
175
|
+
|
|
176
|
+
- Existing user scripts are kept, even with `--overwrite`
|
|
177
|
+
- Missing support scripts are added before `doctor --strict` checks for `script-advice`
|
|
178
|
+
- Dependencies are installed only when `--install-deps` is explicitly set
|
|
179
|
+
- The manual `package-templates/package.scripts.fragment.json` is not changed
|
|
180
|
+
|
|
181
|
+
## Dependency install opt-in
|
|
182
|
+
|
|
183
|
+
`init` and `update` can install missing npm dev dependencies for generated package scripts when `--install-deps` is explicitly provided. This is intentionally opt-in:
|
|
184
|
+
|
|
185
|
+
- `--install-deps --dry-run` prints the package manager command, such as `pnpm add -D typescript eslint vitest knip @playwright/test`, without requiring the package manager binary and without writing lockfiles.
|
|
186
|
+
- `--install-deps --yes` preflights the selected package manager binary before template files are written, then runs the install command after package scripts and install state are updated.
|
|
187
|
+
- Already declared packages in `dependencies`, `devDependencies`, `peerDependencies`, or `optionalDependencies` are skipped.
|
|
188
|
+
- Supported commands are `pnpm add -D`, `npm install --save-dev`, `yarn add --dev`, and `bun add --dev`.
|
|
189
|
+
- The allowlist covers npm dev dependencies for generated defaults: `typescript`, `eslint`, `vitest`, `knip`, and `@playwright/test` for `react-nextjs`.
|
|
190
|
+
- External tools such as Supabase CLI, Maestro, and React Doctor are not installed by this flag. React Doctor remains invoked through the generated `npx -y react-doctor@latest` script.
|
|
191
|
+
|
|
192
|
+
## What init changes
|
|
193
|
+
|
|
194
|
+
`init` reads from `package-templates/` and the CLI profile resolver, then may update the target project:
|
|
195
|
+
|
|
196
|
+
- Merges profile-aware package scripts for the selected `--profile`
|
|
197
|
+
- Adds missing support package scripts while preserving existing user scripts
|
|
198
|
+
- Uses the selected or detected package manager for generated package script invocations
|
|
199
|
+
- Optionally installs missing npm dev dependencies when `--install-deps` is set
|
|
200
|
+
- Copies common test design / philosophy docs and selected profile docs under `docs/ai-check-template/`
|
|
201
|
+
- Copies `package-templates/scripts/ai-check.sh` and `ai-check-fast.sh`
|
|
202
|
+
- Writes package-manager-aware GitHub Actions workflows for the selected `--ci` mode
|
|
203
|
+
- Optionally copies Claude Code rules and merges package-manager-aware hook settings when `--claude-hooks` is set
|
|
204
|
+
- Writes `.ai-check-template.json` with install metadata
|
|
205
|
+
|
|
206
|
+
It does not modify `package-templates/`, publish to npm, install dependencies without `--install-deps`, or rewrite existing project-specific tool choices.
|
|
207
|
+
|
|
208
|
+
## What doctor checks
|
|
209
|
+
|
|
210
|
+
`doctor` is read-only. It checks the target project for the files and fragments installed by `init`:
|
|
211
|
+
|
|
212
|
+
- profile-aware package scripts
|
|
213
|
+
- missing support package scripts referenced by `ai:check` / `ai:check:fast`
|
|
214
|
+
- package-manager-aware package script invocations
|
|
215
|
+
- selected profile docs under `docs/ai-check-template/`
|
|
216
|
+
- `scripts/ai-check.sh` and `scripts/ai-check-fast.sh`
|
|
217
|
+
- selected package-manager-aware GitHub Actions workflows for `--ci direct` or `--ci reusable`
|
|
218
|
+
- optional Claude Code rule and hook settings when `--claude-hooks` is set
|
|
219
|
+
- install state validity when `.ai-check-template.json` exists
|
|
220
|
+
- profile-specific advisory warnings based on package scripts
|
|
221
|
+
- missing referenced package script warnings from `ai:check` / `ai:check:fast`
|
|
222
|
+
- stale managed CI workflow warnings for inactive `--ci` modes
|
|
223
|
+
|
|
224
|
+
It exits with code `0` when no issues are found and code `1` when files are missing, drifted, or the install state is malformed. It does not repair files; use the reported paths to decide whether to run `update --dry-run` and then `update --yes`.
|
|
225
|
+
|
|
226
|
+
## What update changes
|
|
227
|
+
|
|
228
|
+
`update` writes current templates and profile scripts to known template-managed paths only:
|
|
229
|
+
|
|
230
|
+
- profile-aware package scripts
|
|
231
|
+
- package-manager-aware package script invocations
|
|
232
|
+
- `scripts/ai-check.sh` and `scripts/ai-check-fast.sh`
|
|
233
|
+
- selected package-manager-aware GitHub Actions workflows for `--ci direct` or `--ci reusable`
|
|
234
|
+
- missing profile docs under `docs/ai-check-template/`
|
|
235
|
+
- inactive exact-managed GitHub Actions workflows from other `--ci` modes
|
|
236
|
+
- optional Claude Code rule and package-manager-aware managed hook settings when `--claude-hooks` is set
|
|
237
|
+
- `.ai-check-template.json` install state
|
|
238
|
+
- missing npm dev dependencies when `--install-deps` is set
|
|
239
|
+
|
|
240
|
+
It requires `--yes` before writing. Use `--dry-run` to preview operations. It performs package-script profile migrations, missing support script creation, exact-managed workflow cleanup, and optional npm dev dependency install only; semantic merges of arbitrary custom user scripts, external toolchain install, and arbitrary workflow cleanup are still out of scope.
|
|
241
|
+
|
|
242
|
+
## Safety behavior
|
|
243
|
+
|
|
244
|
+
- During `init`, existing target files are not overwritten by default.
|
|
245
|
+
- During `init`, existing target scripts are not overwritten by default.
|
|
246
|
+
- During `init` / `update`, existing support scripts such as `lint` and `test` are preserved.
|
|
247
|
+
- During `update`, only known template-managed non-doc paths are rewritten, and `--yes` is required.
|
|
248
|
+
- During `update`, existing files under `docs/ai-check-template/` are kept instead of overwritten.
|
|
249
|
+
- During `update`, inactive workflow files are deleted only when they exactly match packaged managed templates or their package-manager-rendered variants.
|
|
250
|
+
- `--install-deps` is the explicit opt-in for dependency install; without it, no package manager install command runs.
|
|
251
|
+
- Actual `--install-deps --yes` preflights the package manager binary before target writes.
|
|
252
|
+
- `--install-deps --dry-run` prints the command without requiring the package manager binary.
|
|
253
|
+
- `--dry-run` writes nothing.
|
|
254
|
+
- Invalid profiles are rejected before any target write.
|
|
255
|
+
- Malformed install state blocks `update` before any target write.
|
|
256
|
+
- `--overwrite` is the explicit opt-in for replacing conflicts.
|
|
257
|
+
|
|
258
|
+
## Examples
|
|
259
|
+
|
|
260
|
+
Preview a Next.js setup:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
node bin/ai-check-template.mjs init --target ../app --profile react-nextjs --dry-run
|
|
264
|
+
node bin/ai-check-template.mjs init --target ../app --profile react-nextjs --install-deps --dry-run
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Preview an npm-based CLI/library setup:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
node bin/ai-check-template.mjs init --target ../app --profile node-cli --package-manager npm --dry-run
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Apply direct GitHub Actions workflows:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
node bin/ai-check-template.mjs init --target ../app --profile react-nextjs --ci direct --yes
|
|
277
|
+
node bin/ai-check-template.mjs init --target ../app --profile react-nextjs --ci direct --install-deps --yes
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Apply reusable workflow examples and Claude hooks:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
node bin/ai-check-template.mjs init --target ../app --profile react-nextjs+supabase-rls --ci reusable --claude-hooks --yes
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Overwrite known conflicts:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
node bin/ai-check-template.mjs init --target ../app --profile node-cli --ci none --yes --overwrite
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Check an installed setup:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
node bin/ai-check-template.mjs doctor --target ../app
|
|
296
|
+
node bin/ai-check-template.mjs doctor --target ../app --ci reusable --claude-hooks --json
|
|
297
|
+
node bin/ai-check-template.mjs doctor --target ../app --strict --json
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Preview and apply an update:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
node bin/ai-check-template.mjs update --target ../app --dry-run
|
|
304
|
+
node bin/ai-check-template.mjs update --target ../app --yes
|
|
305
|
+
node bin/ai-check-template.mjs update --target ../app --ci reusable --claude-hooks --json --yes
|
|
306
|
+
node bin/ai-check-template.mjs update --target ../app --ci none --dry-run --json
|
|
307
|
+
node bin/ai-check-template.mjs update --target ../app --package-manager yarn --dry-run --json
|
|
308
|
+
node bin/ai-check-template.mjs update --target ../app --install-deps --dry-run --json
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Verification
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
node bin/ai-check-template.mjs --help
|
|
315
|
+
node bin/ai-check-template.mjs doctor --help
|
|
316
|
+
node bin/ai-check-template.mjs update --help
|
|
317
|
+
node --test tests/cli/*.test.mjs
|
|
318
|
+
npm pack --dry-run --json
|
|
319
|
+
npm publish --dry-run --tag next --json
|
|
320
|
+
make validate
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Package readiness
|
|
324
|
+
|
|
325
|
+
SPEC-0016 verifies that the package can be packed and installed from a local tarball before any registry publish happens.
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
npm pack --dry-run --json
|
|
329
|
+
node --test tests/cli/package.test.mjs
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The package tests assert that runtime files are included, repository-only SAGE artifacts are excluded, and a tarball-installed `ai-check-template` binary can run both `--help` and `init`.
|
|
333
|
+
|
|
334
|
+
This still does not mean the package is published to npm. Until the publish SPEC is complete, use a local clone or local tarball for CLI trials.
|
|
335
|
+
|
|
336
|
+
## Publish preflight
|
|
337
|
+
|
|
338
|
+
Because `0.2.0-alpha.0` is a prerelease version, npm requires an explicit dist-tag. The publish preflight command is:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
npm publish --dry-run --tag next --json
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
This command validates the publish payload without writing to the registry. Actual `npm publish --tag next` requires explicit maintainer approval and npm authentication, and is not performed by repository validation.
|
|
345
|
+
|
|
346
|
+
## 日本語メモ
|
|
347
|
+
|
|
348
|
+
この CLI は v0.2.0 alpha foundation です。現時点では npm 公開済みの安定版ではありません。`npm pack` と local tarball smoke で package readiness を検証し、`npm publish --dry-run --tag next --json` で publish preflight を検証しますが、registry への actual publish は別 SPEC で扱います。まず `init --dry-run` で差分を確認し、問題なければ `init --yes` を付けて実行してください。導入後は `.ai-check-template.json` に選択した profile / package manager / CI / Claude hooks が保存され、`doctor` と `update` は明示 flag がない場合にその state を使います。CLI alpha は profile ごとの package scripts と missing support scripts を導入・診断・更新し、`pnpm` / `npm` / `yarn` / `bun` の script invocation を生成できます。`--install-deps --dry-run` は npm dev dependency install command を表示し、`--install-deps --yes` は package manager binary を preflight してから missing dev dependencies を install します。Supabase CLI、Maestro、React Doctor などの external toolchain install は対象外です。profile diagnostics warnings、missing referenced package script warnings、stale managed CI workflow warnings は通常 advisory ですが、CI や release prep では `doctor --strict` で warning を failure として扱えます。`update --dry-run` で更新予定を確認できます。inactive な exact-managed workflow は `update --yes` で cleanup できますが、custom workflow は保持されます。既存ファイルや既存 scripts は `--overwrite` を付けない限り上書きしません。既存 support scripts は `--overwrite` の有無に関係なく保持されます。
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# .claude/
|
|
2
|
+
|
|
3
|
+
Claude Code 用の設定とルールを配布する example。
|
|
4
|
+
|
|
5
|
+
> **ステータス**: Draft v0.1(Phase 1 dogfooding 後に改訂予定)
|
|
6
|
+
|
|
7
|
+
> **重要**: ここに置く `.claude/` は **配布物** として利用者のプロジェクトにコピーされる前提。本リポ自身の `.claude/`(リポジトリルート直下)は SAGE が管理しており、配布物とは別物。
|
|
8
|
+
|
|
9
|
+
## 提供物
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
.claude/
|
|
13
|
+
├── rules/
|
|
14
|
+
│ └── test-rules.md # Playwright Locator 優先順位
|
|
15
|
+
└── settings.hook-fragment.json # Edit/Stop hook の雛形
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 思想
|
|
19
|
+
|
|
20
|
+
[`../docs/philosophy/formal-name-match.md`](../docs/philosophy/formal-name-match.md) の **AI 内部ループ** を実体化するための hook 設定。
|
|
21
|
+
|
|
22
|
+
- **Edit hook**(fast): AI がコード編集するたびに `pnpm ai:check:fast` を呼ぶ。Static + Unit のみで軽量
|
|
23
|
+
- **Stop hook**(full): AI セッション終了時に `pnpm ai:check` を呼ぶ。Diagnostic + E2E まで含む完全版
|
|
24
|
+
|
|
25
|
+
これにより、AI が「実装完了しました」と言って終わる前に必ず形名照合が走る。
|
|
26
|
+
|
|
27
|
+
## 利用者の `.claude/settings.json` への組み込み
|
|
28
|
+
|
|
29
|
+
利用者は自プロジェクトの `.claude/settings.json` に hook fragment をマージする。
|
|
30
|
+
|
|
31
|
+
### 既存 settings.json がない場合
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cp .claude/settings.hook-fragment.json /your-project/.claude/settings.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 既存 settings.json に hook を追加する場合
|
|
38
|
+
|
|
39
|
+
JSON の `hooks` キーをマージ。例えば `jq` を使う場合:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
jq -s '.[0] * .[1]' \
|
|
43
|
+
/your-project/.claude/settings.json \
|
|
44
|
+
.claude/settings.hook-fragment.json \
|
|
45
|
+
> /tmp/merged.json && mv /tmp/merged.json /your-project/.claude/settings.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
または手動で `hooks` セクションを追記する。
|
|
49
|
+
|
|
50
|
+
### test-rules.md の組み込み
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cp .claude/rules/test-rules.md /your-project/.claude/rules/
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
複数の rules ファイルが既にある場合はそのままコピーで競合しない(ファイル名が衝突しない限り)。
|
|
57
|
+
|
|
58
|
+
## hook が呼ぶコマンドと package.scripts.fragment.json の対応
|
|
59
|
+
|
|
60
|
+
| Hook | コマンド | scripts エントリ |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| `PostToolUse` (Edit/Write) | `pnpm ai:check:fast` | `package.json` の `scripts."ai:check:fast"` |
|
|
63
|
+
| `Stop` | `pnpm ai:check` | `package.json` の `scripts."ai:check"` |
|
|
64
|
+
|
|
65
|
+
`scripts."ai:check"` / `"ai:check:fast"` の中身は [`../package.scripts.fragment.json`](../package.scripts.fragment.json) を参照。
|
|
66
|
+
シェル経由([`../scripts/ai-check.sh`](../scripts/ai-check.sh))でも CI 経由([`../ci-examples/github-actions/ai-check.yml`](../ci-examples/github-actions/ai-check.yml))でも同じコマンドが走る設計。
|
|
67
|
+
|
|
68
|
+
## カスタマイズ
|
|
69
|
+
|
|
70
|
+
### PM 変更
|
|
71
|
+
hook の `command` フィールドを `npm run ai:check`, `yarn ai:check`, `bun run ai:check` などに変更。
|
|
72
|
+
|
|
73
|
+
### Edit hook を無効化
|
|
74
|
+
`PostToolUse` セクションを削除すれば、Edit ごとの fast loop は走らない(Stop hook の full check のみになる)。
|
|
75
|
+
|
|
76
|
+
### blocking モード
|
|
77
|
+
本 fragment では `blocking` を指定していない(Claude Code default の非 blocking)。
|
|
78
|
+
編集を強制ブロックしたい場合は `"blocking": true` を追加。ただし誤判定でセッションが進まなくなるリスクあり。
|
|
79
|
+
|
|
80
|
+
## 出典
|
|
81
|
+
|
|
82
|
+
- Claude Code Hooks 公式 docs(参照日 2026-05-13)
|
|
83
|
+
- Notion Doc #2(`c3e549660ca44005a20c4f6fdb54c8d5`)の「## Codex / Claude Codeに渡す運用プロンプト」節
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Test Rules
|
|
2
|
+
|
|
3
|
+
このファイルはテスト記述ルールを Claude Code / Codex 等の実装エージェントに伝える。
|
|
4
|
+
配布される example。利用者が自プロジェクトの `.claude/rules/` にコピーして使う。
|
|
5
|
+
|
|
6
|
+
> **ステータス**: Draft v0.1(Phase 1 dogfooding 後に改訂予定)
|
|
7
|
+
|
|
8
|
+
## Playwright Locator 優先順位
|
|
9
|
+
|
|
10
|
+
E2E テストを書く際、locator の選択は以下の優先順位に従う。下位の選択肢を使う場合は理由をコメントで明示すること。
|
|
11
|
+
|
|
12
|
+
| 順位 | Locator | 用途 | 例 |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| 1 | `getByRole` | accessibility tree ベース。最も robust | `page.getByRole('button', { name: 'Submit' })` |
|
|
15
|
+
| 2 | `getByLabel` | フォーム入力要素 | `page.getByLabel('Email address')` |
|
|
16
|
+
| 3 | `getByText` | テキスト内容で識別 | `page.getByText('Welcome back')` |
|
|
17
|
+
| 4 | `getByTestId` | `data-testid` 属性ベース | `page.getByTestId('user-menu')` |
|
|
18
|
+
| 5 | `locator(css)` | 最後の手段。DOM 構造依存で壊れやすい | `page.locator('.user-menu > .avatar')` |
|
|
19
|
+
|
|
20
|
+
### なぜこの順位か
|
|
21
|
+
|
|
22
|
+
- `getByRole` / `getByLabel`: a11y を兼ねるため、テストが a11y 違反を検出する副作用がある
|
|
23
|
+
- `getByText`: i18n の場合は脆い。多言語プロジェクトでは `getByRole` を優先
|
|
24
|
+
- `getByTestId`: 実装詳細に依存するが、変わりにくい識別子なら許容
|
|
25
|
+
- `locator(css)`: 上記が使えない場合のみ。Refactor で容易に壊れる
|
|
26
|
+
|
|
27
|
+
### AI への指示例
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Playwright テストを書いてください。Locator は以下の優先順位で選択し、4 番以下を使う場合は理由をコメントしてください:
|
|
31
|
+
1. getByRole
|
|
32
|
+
2. getByLabel
|
|
33
|
+
3. getByText
|
|
34
|
+
4. getByTestId
|
|
35
|
+
5. locator(css)(最後の手段)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 関連思想
|
|
39
|
+
|
|
40
|
+
- [`../../docs/philosophy/test-pyramid.md`](../../docs/philosophy/test-pyramid.md) — E2E 層の責務分割
|
|
41
|
+
- [`../../docs/philosophy/given-when-then.md`](../../docs/philosophy/given-when-then.md) — GWT で E2E シナリオを書く
|
|
42
|
+
|
|
43
|
+
## 出典
|
|
44
|
+
|
|
45
|
+
- Playwright 公式 Best Practices(参照日 2026-05-13)
|
|
46
|
+
- Notion Doc #1(`35b68c677f4380bfa1ffeab248264e92`)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PostToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Edit|Write",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "pnpm ai:check:fast"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"Stop": [
|
|
15
|
+
{
|
|
16
|
+
"hooks": [
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "pnpm ai:check"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# package-templates/
|
|
2
|
+
|
|
3
|
+
このディレクトリは `ai-check-template` パッケージが **配布** する内容を格納する。
|
|
4
|
+
|
|
5
|
+
> **重要**: SAGE がインストールする `templates/` (hooks/sage/settings 等の SAGE 内部物)とは別物。
|
|
6
|
+
> 配布物は **必ずこのディレクトリ** (`package-templates/`)に置く。命名衝突を避けるため。
|
|
7
|
+
|
|
8
|
+
## 想定する構造(Phase 2 で具体化)
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
package-templates/
|
|
12
|
+
├── docs/
|
|
13
|
+
│ ├── test-design-template.md
|
|
14
|
+
│ └── philosophy/
|
|
15
|
+
│ ├── formal-name-match.md
|
|
16
|
+
│ ├── test-pyramid.md
|
|
17
|
+
│ ├── given-when-then.md
|
|
18
|
+
│ └── qa-techniques.md
|
|
19
|
+
├── scripts/
|
|
20
|
+
│ ├── ai-check.sh
|
|
21
|
+
│ └── ai-check-fast.sh
|
|
22
|
+
├── .claude/
|
|
23
|
+
│ ├── rules/
|
|
24
|
+
│ │ └── test-rules.md
|
|
25
|
+
│ └── settings.hook-fragment.json
|
|
26
|
+
├── prompts/
|
|
27
|
+
│ ├── decision-table.md
|
|
28
|
+
│ ├── state-transition.md
|
|
29
|
+
│ ├── boundary-value.md
|
|
30
|
+
│ ├── rls-permission.md
|
|
31
|
+
│ ├── diagnostic-repair.md
|
|
32
|
+
│ └── plan-first.md
|
|
33
|
+
├── ci-examples/
|
|
34
|
+
│ ├── README.md
|
|
35
|
+
│ └── github-actions/
|
|
36
|
+
│ ├── ai-check.yml
|
|
37
|
+
│ ├── ai-check-fast.yml
|
|
38
|
+
│ ├── ai-quality-reusable.yml
|
|
39
|
+
│ └── ai-quality-call.yml
|
|
40
|
+
├── profiles/
|
|
41
|
+
│ ├── react-nextjs/
|
|
42
|
+
│ ├── react-vanilla/
|
|
43
|
+
│ ├── expo-rn/
|
|
44
|
+
│ ├── node-cli/
|
|
45
|
+
│ └── supabase-rls/
|
|
46
|
+
└── package.scripts.fragment.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## ステータス
|
|
50
|
+
|
|
51
|
+
v0.1.0 — Released(2026-05-14)。手動コピーで使う template set として配布。CLI scaffolding は v0.2.0 以降。
|
|
52
|
+
|
|
53
|
+
## テスト設計と修復
|
|
54
|
+
|
|
55
|
+
- [`docs/test-design-template.md`](./docs/test-design-template.md): Requirement / Acceptance Criteria / Test Matrix / Verification Commands を実装前に固定するテンプレート。
|
|
56
|
+
- [`prompts/diagnostic-repair.md`](./prompts/diagnostic-repair.md): `ai:check` や CI の失敗後、redacted diagnostic output から修復計画・patch・再検証へ進めるプロンプト。
|