create-ai-project 1.23.4 → 1.24.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 (94) hide show
  1. package/.claude/agents-en/acceptance-test-generator.md +8 -32
  2. package/.claude/agents-en/code-reviewer.md +24 -25
  3. package/.claude/agents-en/code-verifier.md +3 -32
  4. package/.claude/agents-en/codebase-analyzer.md +11 -79
  5. package/.claude/agents-en/document-reviewer.md +12 -58
  6. package/.claude/agents-en/integration-test-reviewer.md +6 -37
  7. package/.claude/agents-en/investigator.md +6 -59
  8. package/.claude/agents-en/quality-fixer-frontend.md +1 -5
  9. package/.claude/agents-en/quality-fixer.md +1 -5
  10. package/.claude/agents-en/requirement-analyzer.md +3 -14
  11. package/.claude/agents-en/rule-advisor.md +3 -16
  12. package/.claude/agents-en/scope-discoverer.md +5 -29
  13. package/.claude/agents-en/security-reviewer.md +2 -13
  14. package/.claude/agents-en/skill-creator.md +3 -6
  15. package/.claude/agents-en/skill-reviewer.md +7 -43
  16. package/.claude/agents-en/solver.md +9 -24
  17. package/.claude/agents-en/task-decomposer.md +39 -8
  18. package/.claude/agents-en/task-executor-frontend.md +29 -20
  19. package/.claude/agents-en/task-executor.md +29 -20
  20. package/.claude/agents-en/technical-designer-frontend.md +7 -12
  21. package/.claude/agents-en/technical-designer.md +4 -11
  22. package/.claude/agents-en/ui-analyzer.md +16 -115
  23. package/.claude/agents-en/ui-spec-designer.md +3 -3
  24. package/.claude/agents-en/verifier.md +9 -53
  25. package/.claude/agents-en/work-planner.md +27 -22
  26. package/.claude/agents-ja/acceptance-test-generator.md +10 -34
  27. package/.claude/agents-ja/code-reviewer.md +24 -25
  28. package/.claude/agents-ja/code-verifier.md +5 -34
  29. package/.claude/agents-ja/codebase-analyzer.md +11 -79
  30. package/.claude/agents-ja/document-reviewer.md +16 -62
  31. package/.claude/agents-ja/integration-test-reviewer.md +6 -37
  32. package/.claude/agents-ja/investigator.md +6 -59
  33. package/.claude/agents-ja/prd-creator.md +3 -3
  34. package/.claude/agents-ja/quality-fixer-frontend.md +2 -6
  35. package/.claude/agents-ja/quality-fixer.md +2 -6
  36. package/.claude/agents-ja/requirement-analyzer.md +3 -14
  37. package/.claude/agents-ja/rule-advisor.md +4 -17
  38. package/.claude/agents-ja/scope-discoverer.md +5 -29
  39. package/.claude/agents-ja/security-reviewer.md +3 -14
  40. package/.claude/agents-ja/skill-creator.md +3 -6
  41. package/.claude/agents-ja/skill-reviewer.md +7 -43
  42. package/.claude/agents-ja/solver.md +11 -26
  43. package/.claude/agents-ja/task-decomposer.md +40 -9
  44. package/.claude/agents-ja/task-executor-frontend.md +29 -20
  45. package/.claude/agents-ja/task-executor.md +29 -20
  46. package/.claude/agents-ja/technical-designer-frontend.md +8 -13
  47. package/.claude/agents-ja/technical-designer.md +5 -12
  48. package/.claude/agents-ja/ui-analyzer.md +17 -116
  49. package/.claude/agents-ja/ui-spec-designer.md +7 -7
  50. package/.claude/agents-ja/verifier.md +9 -53
  51. package/.claude/agents-ja/work-planner.md +51 -51
  52. package/.claude/commands-ja/build.md +1 -1
  53. package/.claude/commands-ja/design.md +1 -1
  54. package/.claude/commands-ja/diagnose.md +1 -1
  55. package/.claude/commands-ja/front-build.md +1 -1
  56. package/.claude/commands-ja/front-design.md +3 -3
  57. package/.claude/commands-ja/front-plan.md +2 -2
  58. package/.claude/commands-ja/implement.md +1 -1
  59. package/.claude/commands-ja/plan.md +2 -2
  60. package/.claude/commands-ja/prepare-implementation.md +4 -4
  61. package/.claude/commands-ja/reverse-engineer.md +1 -1
  62. package/.claude/commands-ja/review.md +1 -1
  63. package/.claude/commands-ja/task.md +2 -2
  64. package/.claude/commands-ja/update-doc.md +1 -1
  65. package/.claude/skills-en/documentation-criteria/references/design-template.md +5 -1
  66. package/.claude/skills-en/documentation-criteria/references/plan-template.md +17 -7
  67. package/.claude/skills-en/documentation-criteria/references/task-template.md +18 -0
  68. package/.claude/skills-en/documentation-criteria/references/ui-spec-template.md +1 -1
  69. package/.claude/skills-en/frontend-technical-spec/SKILL.md +4 -8
  70. package/.claude/skills-en/frontend-typescript-rules/SKILL.md +4 -2
  71. package/.claude/skills-en/frontend-typescript-testing/SKILL.md +5 -11
  72. package/.claude/skills-en/frontend-typescript-testing/references/e2e.md +1 -1
  73. package/.claude/skills-en/technical-spec/SKILL.md +4 -3
  74. package/.claude/skills-en/typescript-testing/SKILL.md +4 -4
  75. package/.claude/skills-ja/coding-standards/SKILL.md +4 -4
  76. package/.claude/skills-ja/coding-standards/references/security-checks.md +1 -1
  77. package/.claude/skills-ja/documentation-criteria/SKILL.md +1 -1
  78. package/.claude/skills-ja/documentation-criteria/references/design-template.md +10 -6
  79. package/.claude/skills-ja/documentation-criteria/references/plan-template.md +18 -8
  80. package/.claude/skills-ja/documentation-criteria/references/task-template.md +18 -0
  81. package/.claude/skills-ja/documentation-criteria/references/ui-spec-template.md +3 -3
  82. package/.claude/skills-ja/frontend-technical-spec/SKILL.md +4 -8
  83. package/.claude/skills-ja/frontend-typescript-rules/SKILL.md +5 -3
  84. package/.claude/skills-ja/frontend-typescript-testing/SKILL.md +5 -11
  85. package/.claude/skills-ja/frontend-typescript-testing/references/e2e.md +2 -2
  86. package/.claude/skills-ja/implementation-approach/SKILL.md +1 -1
  87. package/.claude/skills-ja/integration-e2e-testing/SKILL.md +1 -1
  88. package/.claude/skills-ja/integration-e2e-testing/references/e2e-environment-prerequisites.md +1 -1
  89. package/.claude/skills-ja/project-context/references/template.md +2 -2
  90. package/.claude/skills-ja/task-analyzer/references/skills-index.yaml +3 -3
  91. package/.claude/skills-ja/technical-spec/SKILL.md +4 -3
  92. package/.claude/skills-ja/typescript-testing/SKILL.md +4 -4
  93. package/CHANGELOG.md +19 -0
  94. package/package.json +1 -1
@@ -51,6 +51,14 @@ Maps each Design Doc technical requirement to the covering task(s). One row per
51
51
 
52
52
  **Gap Status values**: `covered` (task exists), `gap` (no task — requires justification in Notes, user confirmation required before plan approval)
53
53
 
54
+ ## Reference Contract Values
55
+
56
+ Include this section when the Design Doc specifies a **binding observable value** the implementation must reproduce exactly — extract these from the Design Doc directly, not from the Traceability table's summarized DD Item: a column/label set and order, a derived-display rule (display value derived from another field), or a state-lifecycle negative (the condition under which the state must stay unused). The Traceability table records *that* a row is covered; this table carries the value *verbatim* so the covering task is checked against the exact contract rather than a re-derived summary. Serialized boundaries are owned by the Connection Map below; ADR-derived structural decisions by ADR Bindings. Omit the section when none apply.
57
+
58
+ | Design Doc (§ Section) | Contract Type | Required Observable Value (verbatim) | Covered By Task(s) |
59
+ |---|---|---|---|
60
+ | [docs/design/XXX.md (§ Section)] | structure-order / derived-display / state-lifecycle-negative | [the exact value copied from the Design Doc — e.g., "the listed fields in the specified order"; "the label shows the looked-up name in place of the raw code"; "the persisted state is applied only when an explicit restore signal is present"] | [Phase X Task Y] |
61
+
54
62
  ## Failure Mode Checklist
55
63
 
56
64
  Domain-independent failure categories this implementation must guard against. Enumerate all eight categories, mark each in the Applies? column as yes/no, and list a covering task for each that applies; keep entries free of project-specific names.
@@ -68,13 +76,13 @@ Domain-independent failure categories this implementation must guard against. En
68
76
 
69
77
  ## UI Spec Component → Task Mapping
70
78
 
71
- Include this section when a UI Spec is among the inputs. Maps each component documented in the UI Spec to the task(s) that implement it. task-decomposer reads this table to populate each task's Investigation Targets with the corresponding UI Spec section. Omit the section when no UI Spec exists.
79
+ Include this section when a UI Spec is among the inputs. Maps each component documented in the UI Spec to the task(s) that implement it. This table is read in a downstream step to populate each task's Investigation Targets with the corresponding UI Spec section. Omit the section when no UI Spec exists.
72
80
 
73
81
  | UI Spec Component (section heading) | States to Cover | Covered By Task(s) | Gap Status | Notes |
74
82
  |---|---|---|---|---|
75
83
  | [Use the UI Spec heading exactly as written, e.g., "§ Component: AlertCard"] | [default / loading / empty / error / partial — list the states the implementation must produce] | [Phase X Task Y] | covered | |
76
84
 
77
- **Reference key rule**: The component identifier in column 1 is the UI Spec section heading (verbatim). ui-spec-designer enforces unique component headings so this reference resolves to exactly one section.
85
+ **Reference key rule**: The component identifier in column 1 is the UI Spec section heading (verbatim). Component headings are unique, so this reference resolves to exactly one section.
78
86
 
79
87
  **Gap Status values**: `covered` (task exists), `gap` (no task — requires justification in Notes, user confirmation required before plan approval)
80
88
 
@@ -92,11 +100,13 @@ One row per binding decision. A single ADR can contribute multiple rows. A singl
92
100
 
93
101
  ## Connection Map
94
102
 
95
- Include this section when the implementation crosses more than one package, service, or process boundary. Document each boundary so task-decomposer can propagate boundary context to the implementation tasks on each side. Omit the section when the implementation stays within a single package.
103
+ Include this section when the implementation crosses a package, service, or process boundary, **or when a value is serialized and re-parsed across a boundary even within a single runtime** — through a medium such as a query string, route/CLI argument, environment variable, config entry, message/queue payload, storage key, or file (producer and consumer must agree on the exact representation). Document each boundary so boundary context propagates to the implementation tasks on each side in a downstream step. Record each Owner as concrete file path(s), not a bare module/package/component name, so it resolves as an Investigation Target the executor can read. Omit the section when no such boundary exists.
96
104
 
97
- | Boundary | Owner (left side) | Owner (right side) | Expected Signal | Covered By Task(s) |
98
- |---|---|---|---|---|
99
- | [e.g., "web client → API gateway"] | [module/package on the request side] | [module/package on the response side] | [Observable evidence the boundary works e.g., "HTTP 200 with response matching ContractA", "row inserted in tableB", "message published to topicC"] | [Phase X Task Y on each side] |
105
+ For a serialized boundary, fill Serialized Format and Consumer Parse Rule. Set both to "—" when the contract is already captured by the Expected Signal (e.g., a cross-process call whose body matches the agreed schema); fill them when producer and consumer must agree on a specific encoding of a value (query string, storage key, CLI argument, config entry, message field).
106
+
107
+ | Boundary | Owner (left side) | Owner (right side) | Serialized Format | Consumer Parse Rule | Expected Signal | Covered By Task(s) |
108
+ |---|---|---|---|---|---|---|
109
+ | [producing side → consuming side] | [owner on the producing side — concrete file path(s)] | [owner on the consuming side — concrete file path(s)] | [exact representation the producer emits; "—" if not serialized] | [how the consumer decodes/validates it; "—" if not serialized] | [Observable evidence the boundary works — e.g., a response matching the agreed contract, or the consumer reproducing the producer's values] | [Phase X Task Y on each side] |
100
110
 
101
111
  ## Objective
102
112
  [Why this change is necessary, what problem it solves]
@@ -212,7 +222,7 @@ This phase is required for ALL implementation approaches.
212
222
  - [ ] Security review: Verify security considerations from Design Doc are implemented
213
223
  - [ ] Quality checks (types, lint, format)
214
224
  - [ ] Execute all tests (including integration/E2E from test skeletons, when provided)
215
- - [ ] Coverage 70%+
225
+ - [ ] Coverage reviewed as a gap signal on critical paths (any enforced threshold per project CI config)
216
226
  - [ ] Document updates
217
227
 
218
228
  ### Quality Assurance
@@ -17,6 +17,13 @@ Metadata:
17
17
  Files to read before starting implementation (file path, with optional search hint):
18
18
  - [e.g., src/orders/checkout (processOrder function) — determined during task decomposition based on task nature]
19
19
 
20
+ ## Change Category
21
+ (Include this field only when the task is a bug fix, regression, state-change, or boundary-change — populated during task decomposition. Omit otherwise.)
22
+
23
+ `Change Category: <one or more of bug-fix, regression, state-change, boundary-change — comma-separated>`
24
+
25
+ When present, the implementation sweeps the cases sharing the same path, contract, persisted state, or external boundary for the same class of defect (see Implementation Steps Red Phase).
26
+
20
27
  ## Binding Decisions
21
28
  (Include this section when the work plan's ADR Bindings table covers this task. Omit otherwise.)
22
29
 
@@ -26,12 +33,22 @@ Each row is an ADR decision the implementation in this task must comply with.
26
33
  |---|---|---|---|
27
34
  | [docs/adr/ADR-XXXX.md (§ <Source Section>) — substitute the section name (`Decision` or `Implementation Guidance`) from the matching work plan row] | [Axis value copied verbatim from the work plan's ADR Bindings row] | [Binding decision copied from the work plan's ADR Bindings row] | [Y/N-answerable positive predicate that evaluates whether the planned/final implementation satisfies the decision] |
28
35
 
36
+ ## Reference Contracts
37
+ (Include this section when the work plan's Reference Contract Values table covers this task. Omit otherwise.)
38
+
39
+ Each row is a DD-derived observable contract the implementation in this task must reproduce exactly. Serialized boundaries are carried by the Boundary Context (from the work plan's Connection Map); ADR-derived structural decisions by Binding Decisions above.
40
+
41
+ | Source | Contract Type | Required Observable Value | Compliance Check |
42
+ |---|---|---|---|
43
+ | [Design Doc path (§ Section) copied from the matching work plan Reference Contract Values row] | [structure-order / derived-display / state-lifecycle-negative, copied from the work plan row] | [Required Observable Value copied verbatim from the work plan row] | [Y/N-answerable positive predicate that evaluates whether the planned/final implementation reproduces the value] |
44
+
29
45
  ## Investigation Notes
30
46
  (Implementation observations are appended here before implementation begins. When Binding Decisions exist, record the planned implementation approach and each Compliance Check result here.)
31
47
 
32
48
  ## Implementation Steps (TDD: Red-Green-Refactor)
33
49
  ### 1. Red Phase
34
50
  - [ ] Read all Investigation Targets and record key observations
51
+ - [ ] (When Change Category is set) Sweep the adjacent cases sharing the same path/contract/state/boundary for the same class of defect; fold any found within scope into the failing tests
35
52
  - [ ] Review dependency deliverables (if any)
36
53
  - [ ] Verify/create contract definitions
37
54
  - [ ] Write failing tests
@@ -73,6 +90,7 @@ Each row is an ADR decision the implementation in this task must comply with.
73
90
  - [ ] Each Proof Obligation is met: the test turns red under its primary failure mode and exercises the stated boundary
74
91
  - [ ] Deliverables created (for research/design tasks)
75
92
  - [ ] (When Binding Decisions exist) Every Compliance Check evaluates to `Y` against the final implementation, with evidence recorded in Investigation Notes (file:line, test result, or command output)
93
+ - [ ] (When Reference Contracts exist) Every Reference Contract Compliance Check evaluates to `Y` against the final implementation, with evidence recorded in Investigation Notes
76
94
 
77
95
  ## Notes
78
96
  - Impact scope: [Areas where changes may propagate]
@@ -59,7 +59,7 @@ Map PRD acceptance criteria to prototype references. Skip this section if no pro
59
59
 
60
60
  ### Component: [ComponentName]
61
61
 
62
- > Component heading uniqueness: every `Component: [ComponentName]` heading must be unique within this UI Spec. work-planner and task-decomposer reference components by exact heading text — duplicate names or paraphrased headings break the propagation to implementation tasks.
62
+ > Component heading uniqueness: every `Component: [ComponentName]` heading must be unique within this UI Spec. Downstream steps reference components by exact heading text — duplicate names or paraphrased headings break the propagation to implementation tasks.
63
63
 
64
64
  #### State x Display Matrix
65
65
 
@@ -133,14 +133,10 @@ Quality checks are mandatory upon implementation completion:
133
133
  - `test:coverage:fresh` - Coverage measurement
134
134
  - `check:all` - Overall integrated check
135
135
 
136
- ### Coverage Requirements
137
- - **Mandatory**: Unit test coverage must be 60% or higher
138
- - **Component-specific targets**:
139
- - Atoms: 70% or higher
140
- - Molecules: 65% or higher
141
- - Organisms: 60% or higher
142
- - Custom Hooks: 65% or higher
143
- - Utils: 70% or higher
136
+ ### Coverage
137
+ - Treat coverage as a diagnostic signal for finding untested areas, not a target (a target gets gamed into trivial tests — Goodhart's Law)
138
+ - Concentrate test rigor on foundational, high-reuse units (shared components, custom hooks, utils) whose regression has the widest blast radius; higher-composition surfaces (organisms, pages) lean on integration/E2E coverage instead
139
+ - Any enforced numeric threshold is the project's CI/coverage config, not a goal in itself
144
140
 
145
141
  ### Non-functional Requirements
146
142
  - **Browser Compatibility**: Chrome/Firefox/Safari/Edge (latest 2 versions)
@@ -34,6 +34,7 @@ const user = raw // narrowed to User
34
34
  - **Custom hooks** are the unit of logic reuse and dependency injection (inject collaborators through the hook for testability).
35
35
  - **Function parameters:** 0-2 positional; for 3+ take a single options object.
36
36
  - **State shape:** type state explicitly; for multi-field state with discrete transitions, use `useReducer` with a discriminated-union action type rather than many `useState` calls.
37
+ - **Server/Client boundary** (RSC frameworks only — e.g. Next.js App Router): default to server components for data fetching/rendering and isolate interactivity behind a `"use client"` boundary at the smallest scope that needs it; keep browser-only APIs (`window`, `localStorage`, event handlers) inside client components, since calling them in a server component breaks the render. N/A for client-only SPAs (e.g. Vite) — skip when the project has no server-component runtime.
37
38
 
38
39
  ## Error Handling
39
40
  - Surface every error: log and handle, or propagate — never swallow.
@@ -41,6 +42,7 @@ const user = raw // narrowed to User
41
42
  - Represent expected failures as values with a `Result` type; reserve `throw` for unexpected/unrecoverable cases.
42
43
  - Use purpose-specific error classes extending a base `AppError` carrying a `code` (e.g. ValidationError, ApiError, NotFoundError).
43
44
  - **Layer responsibilities:** the API layer converts transport errors into domain errors; hooks propagate `AppError` upward; an Error Boundary catches render-time errors and shows fallback UI.
45
+ - **Effect race/cleanup:** guard `useEffect` data fetches against out-of-order responses and post-unmount state updates — abort or ignore stale results (`AbortController` or a mounted flag), or use a server-state library (React Query/SWR) that cancels and dedupes. `try-catch` alone does not cover this.
44
46
  - Never log secrets (password, token, apiKey, creditCard).
45
47
 
46
48
  ```typescript
@@ -63,8 +65,8 @@ class ErrorBoundary extends React.Component<{ children: React.ReactNode; fallbac
63
65
  ```
64
66
 
65
67
  ## Project Conventions
66
- - **Environment variables:** read through the build tool's env system (`process.env` is absent in the browser). Keep all secrets server-side — frontend code ships to the client.
67
- - **Bundle & performance:** monitor with the `build` script, keep under 500KB; memoize expensive components (`React.memo`); code-split with `React.lazy` + `Suspense`; structure state to minimize re-renders.
68
+ - **Environment variables:** read client-side env through the bundler's exposed accessor — only vars carrying its public prefix reach the browser; an unprefixed var is `undefined` there. Match the project's bundler: Vite `import.meta.env.VITE_*`, Next.js public `process.env.NEXT_PUBLIC_*`, CRA `process.env.REACT_APP_*`. Keep all secrets server-side — frontend code ships to the client.
69
+ - **Bundle & performance:** monitor bundle size with the `build` script against the project's budget; code-split with `React.lazy` + `Suspense`; structure state to minimize re-renders. Memoization: when React Compiler is enabled, rely on it; reach for manual `React.memo`/`useMemo`/`useCallback` only as a profiler- or identity-justified escape hatch (a measured bottleneck, or stable reference identity for third-party APIs / effect dependencies).
68
70
  - **Naming:** components/types `PascalCase`; variables/functions `camelCase`; hooks `use`-prefixed; constants `SCREAMING_SNAKE_CASE`.
69
71
  - **Imports:** absolute paths from `src/`; order: React → external libs → internal (absolute) → internal (relative) → type-only → styles/assets.
70
72
  - **Formatting:** follow Biome (semicolons and style come from project config).
@@ -24,21 +24,15 @@ description: Designs tests with React Testing Library, MSW, and Playwright E2E.
24
24
  ## Basic Testing Policy
25
25
 
26
26
  ### Quality Requirements
27
- - **Coverage**: Unit test coverage must be 60% or higher (Frontend standard 2025)
27
+ - **Coverage**: prioritize meaningful assertions on critical paths and high-reuse components; treat coverage as a signal for gaps, not a target (a target gets gamed into trivial tests — Goodhart's Law). Any numeric threshold is the project's CI config
28
28
  - **Independence**: Each test can run independently without depending on other tests
29
29
  - **Reproducibility**: Tests are environment-independent and always return the same results
30
30
  - **Readability**: Test code maintains the same quality as production code
31
31
 
32
- ### Coverage Requirements (ADR-0002 Compliant)
33
- **Mandatory**: Unit test coverage must be 60% or higher
34
- **Component-specific targets**:
35
- - Atoms (Button, Text, etc.): 70% or higher
36
- - Molecules (FormField, etc.): 65% or higher
37
- - Organisms (Header, Footer, etc.): 60% or higher
38
- - Custom Hooks: 65% or higher
39
- - Utils: 70% or higher
32
+ ### Where to concentrate test rigor
33
+ Test foundational, high-reuse units the hardest — shared components, custom hooks, and utils reused across many features carry the widest blast radius. Higher-composition surfaces (organisms, pages) lean on integration/E2E coverage instead. Any numeric threshold is the project's CI config.
40
34
 
41
- **Metrics**: Statements, Branches, Functions, Lines
35
+ **Metrics** (what coverage reports break down): Statements, Branches, Functions, Lines
42
36
 
43
37
  ### Test Types and Scope
44
38
  1. **Unit Tests (React Testing Library)**
@@ -74,7 +68,7 @@ src/
74
68
 
75
69
  **Rationale**:
76
70
  - React Testing Library best practice
77
- - ADR-0002 Co-location principle
71
+ - Co-location principle: tests live alongside the implementation they cover
78
72
  - Easy to find and maintain tests alongside implementation
79
73
 
80
74
  ### Naming Conventions
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Lane Selection
4
4
 
5
- E2E tests in this workflow split into two lanes (defined in integration-e2e-testing skill):
5
+ E2E tests in this workflow split into two lanes:
6
6
 
7
7
  | Lane | Backend setup | Use these patterns |
8
8
  |------|---------------|-------------------|
@@ -92,6 +92,7 @@ Quality checks are mandatory upon implementation completion:
92
92
  - **Cache issues**: Run the `test:coverage:fresh` script
93
93
  - **Dependency errors**: Clean reinstall dependencies
94
94
 
95
- ### Coverage Requirements
96
- - **MANDATORY**: Unit test coverage MUST be 70% or higher
97
- - **Metrics**: Statements, Branches, Functions, Lines
95
+ ### Coverage
96
+ - Treat coverage as a diagnostic signal for finding untested areas, not a target (a target gets gamed into trivial tests — Goodhart's Law). Concentrate tests on critical paths and business logic whose regression would matter
97
+ - Any enforced numeric threshold is the project's CI/coverage config, not a goal in itself
98
+ - **Metrics** (what coverage reports break down): Statements, Branches, Functions, Lines
@@ -14,14 +14,14 @@ description: Applies Vitest test design and quality standards. Provides coverage
14
14
  ## Basic Testing Policy
15
15
 
16
16
  ### Quality Requirements
17
- - **Coverage**: Unit test coverage must be 70% or higher
17
+ - **Coverage**: treat coverage as a diagnostic signal for finding untested areas, not a target (a target gets gamed into trivial tests — Goodhart's Law). Concentrate tests on critical paths, business logic, and behavior whose regression would matter. Any numeric threshold is the project's CI config
18
18
  - **Independence**: Each test can run independently without depending on other tests
19
19
  - **Reproducibility**: Tests are environment-independent and always return the same results
20
20
  - **Readability**: Test code maintains the same quality as production code
21
21
 
22
- ### Coverage Requirements
23
- **Mandatory**: Unit test coverage must be 70% or higher
24
- **Metrics**: Statements, Branches, Functions, Lines
22
+ ### Coverage
23
+ - Prioritize meaningful assertions over the coverage number; raise coverage where a gap leaves a real regression unguarded, not to hit a percentage
24
+ - **Metrics** (what coverage reports break down): Statements, Branches, Functions, Lines
25
25
 
26
26
  ### Test Types and Scope
27
27
  1. **Unit Tests**
@@ -29,7 +29,7 @@ description: コードの品質問題、アンチパターン、可読性を検
29
29
 
30
30
  - **積極的なリファクタリング** - 技術的負債を防ぎ、健全性を維持
31
31
  - **使われない「念のため」のコード禁止** - YAGNI原則(Kent Beck)に反する
32
- - **Minimum Surface for Required Coverage** - 保守対象の要素(永続状態、公開コントラクト要素または境界を越えるフィールド/Props、振る舞いモード/フラグ/バリアント、再利用可能な抽象、コンポーネント分割)を導入する場合、現在のユーザー観察可能な要件と受容済み技術制約(監査、データ整合性、互換性、セキュリティ、パフォーマンス、アクセシビリティ)をカバーする最小の設計面を選ぶ。採用の正当化は「より小さい代替案では満たせない現要件・制約を名指す」形で行い、価値ベースの議論(再利用可能、将来対応、実装が楽)はタイブレーカーのみに用いる。YAGNI との違い: YAGNI は時間軸の判断(将来のためだけの作業はしない)、本原則は固定されたカバレッジ点での設計面を制約する。
32
+ - **Minimum Surface for Required Coverage** - 保守対象の要素(永続状態、公開コントラクト要素または境界を越えるフィールド/Props、振る舞いモード/フラグ/バリアント、再利用可能な抽象、コンポーネント分割)を導入する場合、現在のユーザー観察可能な要件と受容済み技術制約(監査、データ整合性、互換性、セキュリティ、パフォーマンス、アクセシビリティ)をカバーする最小の設計面を選ぶ。採用の正当化は「より小さい代替案では満たせない現要件・制約を明記する」形で行い、価値ベースの議論(再利用可能、将来対応、実装が楽)はタイブレーカーのみに用いる。YAGNI との違い: YAGNI は時間軸の判断(将来のためだけの作業はしない)、本原則は固定されたカバレッジ点での設計面を制約する。
33
33
 
34
34
  ## コメント記述ルール
35
35
 
@@ -283,7 +283,7 @@ Grep -n "targetData\|SetData\|UpdateData" -o content
283
283
  - 操作に必要な権限のみを付与(ファイル、データベース接続、APIスコープ)
284
284
 
285
285
  ### Knowledge Cutoff Supplement (2026-03)
286
- - OWASP Top 10:2025は症状から根本原因にシフトし、「Software Supply Chain Failures」(A03)と「Mishandling of Exceptional Conditions」(A10)が追加
287
- - 最近の研究でAI生成コードがAccess Controlの欠落を高い発生率で示す — 認証と認可を高優先度のレビュー対象として扱う
288
- - OpenSSFが「Security-Focused Guide for AI Code Assistant Instructions」を公開 — 汎用的なアドバイスより言語固有のアクション可能な制約を推奨
286
+ - OWASP Top 10:2025は症状から根本原因へと視点を移し、「Software Supply Chain Failures」(A03)と「Mishandling of Exceptional Conditions」(A10)が追加された
287
+ - 最近の研究ではAI生成コードがAccess Controlの欠落を高い発生率で示しているため、認証と認可を高優先度のレビュー対象として扱う
288
+ - OpenSSFが「Security-Focused Guide for AI Code Assistant Instructions」を公開した。汎用的なアドバイスより、言語固有で実行可能な制約を推奨している
289
289
  - 詳細な検出パターンは`references/security-checks.md`を参照
@@ -49,7 +49,7 @@ Sources: OWASP Top 10:2025, DryRun Agentic Coding Security Report (2026-03)
49
49
  - 認証ミドルウェアなしで定義されたエンドポイントやルートハンドラ
50
50
  - 認可検証なしのリソースアクセス操作(読み取り、更新、削除)
51
51
  - 昇格された権限なしでアクセス可能な管理操作や破壊的操作
52
- - AI生成コードでは認証ミドルウェアと認可チェックの欠落が頻発する — 全ルートハンドラとリソースアクセス操作をレビュー時に明示的に検証対象とする
52
+ - AI生成コードでは認証ミドルウェアと認可チェックの欠落が頻発するため、全ルートハンドラとリソースアクセス操作をレビュー時に明示的に検証対象とする
53
53
  - 検出方法: 認証ミドルウェアを持たないルート/エンドポイントハンドラ定義を検索し、呼び出しチェーン内で認可チェックなしのリソース操作(読み取り、更新、削除)を検索
54
54
 
55
55
  ### 例外条件の不適切な処理(OWASP A10:2025)
@@ -53,7 +53,7 @@ description: PRD、ADR、Design Doc、UI Spec、作業計画書の作成を支
53
53
  - 成功指標とKPI(各指標に数値目標、測定方法、期間を明記)
54
54
  - ユーザーストーリーとユースケース
55
55
  - MoSCoW法による優先順位(Must/Should/Could/Won't)
56
- - 受入基準に連番ID(AC-001, AC-002, ...)を付与し、下流でのトレーサビリティを確保
56
+ - 受入条件(AC)に連番ID(AC-001, AC-002, ...)を付与し、下流でのトレーサビリティを確保
57
57
  - MVPとFutureフェーズの分離
58
58
  - ユーザージャーニー図(必須)
59
59
  - スコープ境界図(必須)
@@ -112,7 +112,7 @@ unknowns:
112
112
 
113
113
  ### Fact Disposition Table
114
114
 
115
- コードベース分析の`focusAreas`の各エントリに対して1行ずつ記載する。この表は**構造的な既存事実**と設計を結び付ける主たるテーブル(Verification StrategyのOutput Comparisonは**ランタイムの振る舞い**を別途拘束する)。既存の振る舞いに言及する他セクションはこの表の行を`fact_id`値で参照する。
115
+ コードベース分析の`focusAreas`の各エントリに対して1行ずつ記載する。この表は**構造的な既存事実**と設計を結び付ける主たるテーブルである(Verification StrategyのOutput Comparisonは**ランタイムの振る舞い**を別途拘束する)。既存の振る舞いに言及する他セクションは、この表の行を`fact_id`値で参照する。
116
116
 
117
117
  | Fact ID | Focus Area | Disposition | Rationale | Evidence | Related Files |
118
118
  |---------|------------|-------------|-----------|----------|---------------|
@@ -120,7 +120,7 @@ unknowns:
120
120
 
121
121
  ### Cross-Layer Assumptions(レイヤー横断フロー時のみ)
122
122
 
123
- 本Design Docが前レイヤーのDesign Docの未検証主張に依存する場合(Prior-Layer Verification参照)、各主張に正当化と下流検証先を記載する:
123
+ 本Design Docが前レイヤーのDesign Docの未検証主張に依存する場合(Prior-Layer Verification参照)、各主張について正当化と下流の検証先を記載する:
124
124
 
125
125
  - [主張]: [正当化]; 検証先: [ステップまたは成果物]
126
126
 
@@ -187,7 +187,7 @@ unknowns:
187
187
 
188
188
  ### Minimal Surface Alternatives(保守対象の要素を導入する場合)
189
189
 
190
- 新規に導入する適用対象要素(永続状態 / 公開コントラクト要素または境界を越えるフィールド・Props / 振る舞いモード・フラグ・バリアント / 再利用可能な抽象またはコンポーネント分割)ごとに1エントリ。設計者エージェントが実行した5ステップの結果を記録する。参照: `coding-standards` スキル「Minimum Surface for Required Coverage」。
190
+ 新規に導入する適用対象要素(永続状態 / 公開コントラクト要素または境界を越えるフィールド・Props / 振る舞いモード・フラグ・バリアント / 再利用可能な抽象またはコンポーネント分割)ごとに1エントリ。設計者エージェントが実行した5ステップの結果を記録する。参照: Minimum Surface for Required Coverage」の原則。
191
191
 
192
192
  #### Element 1: [新規要素の名前]
193
193
 
@@ -220,7 +220,7 @@ unknowns:
220
220
  - **選定**: [代替案の名前]
221
221
  - **根拠**:
222
222
  - 選定が検討した中で最小の代替案である場合: 「検討した中で最小の代替案であり、これ以上の縮減余地なし」と記載
223
- - 選定が最小でない場合: ステップ1から、より小さい代替案では満たせない現要件を名指す
223
+ - 選定が最小でない場合: ステップ1から、より小さい代替案では満たせない現要件を明記する
224
224
 
225
225
  **ステップ5 — 不採用案の記録**
226
226
  - [代替案の名前]: [何だったか・なぜ不採用かを1〜2行]
@@ -254,7 +254,11 @@ unknowns:
254
254
  ```
255
255
 
256
256
  ### フィールド伝播マップ(フィールドが境界を越える場合)
257
+
258
+ ここでの境界には**シリアライズ境界** — 一方の側でエンコードされ、クエリ文字列、CLI引数、環境変数、設定エントリ、メッセージ/キューのペイロード、ストレージキー、ファイルなどの媒体を介して他方の側でパースされる値 — も含まれ、インメモリの受け渡しに限らない。シリアライズ境界の行では `Serialized: [producerが出力する正確な表現]; Parse: [consumerがどうデコード/検証するか]` — すなわち **Serialized Format** と **Consumer Parse Rule** — を付記し、producerとconsumerが合意するようにする。インメモリの受け渡しでは付記を省略する。
259
+
257
260
  - [フィールド名]: [コンポーネントA → B] — preserved / transformed / dropped — [理由]
261
+ - [フィールド名]: [コンポーネントA → B] — transformed — Serialized: [正確な表現]; Parse: [デコード/検証ルール] — [理由](シリアライズ境界)
258
262
 
259
263
  ### 状態遷移と不変条件
260
264
 
@@ -406,9 +410,9 @@ unknowns:
406
410
 
407
411
  「Minimal Surface Alternatives → ステップ5(不採用案)」との区別: ステップ5 は単一の適用対象要素内で比較・棄却した要素レベルの代替案を記録する。本セクションは個別の要素に結び付かない、より粒度の大きな能力レベルの項目(検討したが今回の設計面に含めなかった機能や能力)を記録する。
408
412
 
409
- - **先送りした機能・能力**: [設計時に検討したが現在の設計面から明示的に除外した機能・能力。各エントリには、これが満たしたはずの現要件を名指して記載する]
413
+ - **先送りした機能・能力**: [設計時に検討したが現在の設計面から明示的に除外した機能・能力。各エントリには、これが満たしたはずの現要件を明記する]
410
414
  - **意図的な限定**: [意図的に小さく抑えた範囲とその理由]
411
- - **拡張ポイント(既存・現在のコンシューマーあり)**: [現在のコンシューマーがすでに利用している既存のインターフェースやフック。各エントリには現在のコンシューマーを名指して記載する]
415
+ - **拡張ポイント(既存・現在のコンシューマーあり)**: [現在のコンシューマーがすでに利用している既存のインターフェースやフック。各エントリには現在のコンシューマーを明記する]
412
416
 
413
417
  ## リスクと対策
414
418
 
@@ -51,6 +51,14 @@ Design Docの各技術要件をカバーするタスクへのマッピング。
51
51
 
52
52
  **ギャップステータス値**: `covered`(タスクあり)、`gap`(タスクなし — 備考に理由必須、計画承認前にユーザー確認が必要)
53
53
 
54
+ ## Reference Contract Values
55
+
56
+ Design Docが、実装が正確に再現すべき**拘束的観測値**を指定する場合に本セクションを記載する。これらは設計-計画トレーサビリティ表の要約されたDD項目からではなく、Design Docから直接抽出する: 列/ラベルの集合と順序、派生表示ルール(別フィールドから導出される表示値)、または状態ライフサイクルの否定条件(状態が未使用のままでなければならない条件)。設計-計画トレーサビリティ表は行がカバーされていること*を*記録するが、本表はその値を*逐語で*保持し、カバーするタスクが再導出された要約ではなく正確な契約に対して検証されるようにする。シリアライズ境界は下記のConnection Mapが、ADR由来の構造的決定はADR Bindingsが扱う。該当がない場合は本セクションを省略する。
57
+
58
+ | Design Doc (§ セクション) | Contract Type | Required Observable Value(逐語) | Covered By Task(s) |
59
+ |---|---|---|---|
60
+ | [docs/design/XXX.md (§ セクション)] | structure-order / derived-display / state-lifecycle-negative | [Design Docからコピーした正確な値 — 例: "指定順序での列挙フィールド"; "ラベルは生コードの代わりに参照名を表示"; "永続状態は明示的な復元シグナルがある場合のみ適用"] | [Phase X タスクY] |
61
+
54
62
  ## 故障モードチェックリスト
55
63
 
56
64
  この実装が防ぐべきドメイン非依存の故障カテゴリ。8カテゴリすべてを列挙し、各カテゴリの該当列に yes/no を記入し、該当する各カテゴリにカバーするタスクを挙げる。エントリにはプロジェクト固有の名称を含めない。
@@ -68,13 +76,13 @@ Design Docの各技術要件をカバーするタスクへのマッピング。
68
76
 
69
77
  ## UI Specコンポーネント → タスクマッピング
70
78
 
71
- 入力にUI Specが含まれる場合のみ本セクションを記載する。UI Specに記述された各コンポーネントを実装するタスクへのマッピング。task-decomposerはこの表を読み込み、対応するUI Specセクションを各タスクのInvestigation Targetsに伝播させる。UI Specがない場合は本セクションを省略する。
79
+ 入力にUI Specが含まれる場合のみ本セクションを記載する。UI Specに記述された各コンポーネントを実装するタスクへのマッピング。この表は下流ステップで読み込まれ、対応するUI Specセクションを各タスクのInvestigation Targetsに伝播させる。UI Specがない場合は本セクションを省略する。
72
80
 
73
81
  | UI Specコンポーネント(セクション見出し) | カバーする状態 | カバーするタスク | ギャップステータス | 備考 |
74
82
  |---|---|---|---|---|
75
83
  | [UI Specの見出しを完全一致で記載。例: "§ コンポーネント: AlertCard"] | [default / loading / empty / error / partial — 実装が満たすべき状態を列挙] | [Phase X タスクY] | covered | |
76
84
 
77
- **参照キーのルール**: 列1のコンポーネント識別子はUI Specのセクション見出し(完全一致)。ui-spec-designerが見出しの一意性を保証するため、この参照は1つのセクションに一意に解決する。
85
+ **参照キーのルール**: 列1のコンポーネント識別子はUI Specのセクション見出し(完全一致)。見出しは一意であるため、この参照は1つのセクションに一意に解決する。
78
86
 
79
87
  **ギャップステータス値**: `covered`(タスクあり)、`gap`(タスクなし — 備考に理由必須、計画承認前にユーザー確認が必要)
80
88
 
@@ -82,7 +90,7 @@ Design Docの各技術要件をカバーするタスクへのマッピング。
82
90
 
83
91
  ADRが入力として与えられた場合、またはDesign Docの「Prerequisite ADRs」セクションに記載されている場合に本セクションを記載する。実装を拘束する各ADR決定を、それが制約するタスクへマッピングする。該当するADRがない場合は本セクションを省略する。
84
92
 
85
- 決定が**実装拘束的**であるのは、コード配置、依存方向、コントラクト/スキーマ形状、データフロー、または永続化を制約する場合である。受入基準と必要な振る舞いはDesign Docに記録される。本表はADR由来の構造的制約のみを扱う。
93
+ 決定が**実装拘束的**であるのは、コード配置、依存方向、コントラクト/スキーマ形状、データフロー、または永続化を制約する場合である。ACと必要な振る舞いはDesign Docに記録される。本表はADR由来の構造的制約のみを扱う。
86
94
 
87
95
  | ADR | Source Section | Axis | Binding Decision | Covered By Task(s) |
88
96
  |---|---|---|---|---|
@@ -92,11 +100,13 @@ ADRが入力として与えられた場合、またはDesign Docの「Prerequisi
92
100
 
93
101
  ## Connection Map
94
102
 
95
- 実装が複数のパッケージ、サービス、またはプロセス境界をまたがる場合のみ本セクションを記載する。各境界を文書化することで、task-decomposerは境界の文脈を両側の実装タスクに伝播できる。実装が単一パッケージ内に収まる場合は本セクションを省略する。
103
+ 実装がパッケージ、サービス、またはプロセス境界をまたがる場合、**または値がシリアライズされ単一ランタイム内であっても境界をまたいで再パースされる場合**(クエリ文字列、ルート/CLI引数、環境変数、設定エントリ、メッセージ/キューのペイロード、ストレージキー、ファイルなどの媒体を介する。producerとconsumerは正確な表現をあらかじめ取り決めておく必要がある)に本セクションを記載する。各境界を文書化することで、下流ステップで境界の文脈を両側の実装タスクに伝播できる。各オーナーは、後続の工程でそのままInvestigation Targetとして読み取れるよう、モジュール/パッケージ/コンポーネント名ではなく具体的なファイルパスで記録する。該当する境界がない場合は本セクションを省略する。
96
104
 
97
- | 境界 | オーナー(左側) | オーナー(右側) | 期待されるシグナル | カバーするタスク |
98
- |---|---|---|---|---|
99
- | [例: "web client API gateway"] | [リクエスト側のモジュール/パッケージ] | [レスポンス側のモジュール/パッケージ] | [境界の動作を裏付ける観測可能な証拠 例: "ContractAに一致するスキーマでHTTP 200"、"tableBに行が挿入される"、"topicCにメッセージが発行される"] | [Phase X 各側のタスクY] |
105
+ シリアライズ境界の場合はSerialized FormatとConsumer Parse Ruleを埋める。契約がExpected Signal(期待されるシグナル)で既に表現されている場合(例: ボディが合意スキーマに一致するクロスプロセス呼び出し)は両方を"—"にする。producerとconsumerが値の特定のエンコーディング(クエリ文字列、ストレージキー、CLI引数、設定エントリ、メッセージフィールド)を取り決める必要がある場合に埋める。
106
+
107
+ | 境界 | オーナー(左側) | オーナー(右側) | Serialized Format | Consumer Parse Rule | 期待されるシグナル | カバーするタスク |
108
+ |---|---|---|---|---|---|---|
109
+ | [producer側 → consumer側] | [producer側のオーナー — 具体的なファイルパス] | [consumer側のオーナー — 具体的なファイルパス] | [producerが出力する正確な表現; シリアライズでなければ "—"] | [consumerがどうデコード/検証するか; シリアライズでなければ "—"] | [境界の動作を裏付ける観測可能な証拠 — 例: 合意した契約に一致するレスポンス、またはconsumerがproducerの値を再現すること] | [Phase X 各側のタスクY] |
100
110
 
101
111
  ## 目的
102
112
  [なぜこの変更が必要か、何を解決するか]
@@ -212,7 +222,7 @@ Design Docの実装アプローチに基づいてフェーズ構成をひとつ
212
222
  - [ ] セキュリティレビュー: Design Docのセキュリティ考慮事項が実装されていることを確認
213
223
  - [ ] 品質チェック(型、lint、format)
214
224
  - [ ] 全テスト実行(テストスケルトン提供時は統合/E2Eテスト含む)
215
- - [ ] カバレッジ70%以上
225
+ - [ ] クリティカルパスのギャップシグナルとしてカバレッジを確認(強制しきい値はプロジェクトの CI 設定に従う)
216
226
  - [ ] ドキュメント更新
217
227
 
218
228
  ### 品質保証
@@ -17,6 +17,13 @@ Metadata:
17
17
  実装開始前に読むべきファイル(ファイルパス、任意でサーチヒント付き):
18
18
  - [例: src/orders/checkout (processOrder関数) — タスクの性質に基づきタスク分解時に決定]
19
19
 
20
+ ## Change Category
21
+ (タスクがバグ修正・リグレッション・状態変更・境界変更の場合のみ本フィールドを記載する。設定はタスク分解時に行う。それ以外は省略する。)
22
+
23
+ `Change Category: <bug-fix, regression, state-change, boundary-change のうち該当するものをカンマ区切りで>`
24
+
25
+ 記載がある場合、実装は同一の経路・契約・永続状態・外部境界を共有するケースを、同一クラスの欠陥について走査する(Implementation Steps の Red Phase 参照)。
26
+
20
27
  ## Binding Decisions
21
28
  (作業計画書のADR Bindings表がこのタスクをカバーする場合に本セクションを記載する。それ以外は省略する。)
22
29
 
@@ -26,12 +33,22 @@ Metadata:
26
33
  |---|---|---|---|
27
34
  | [docs/adr/ADR-XXXX.md (§ <Source Section>) — 対応する作業計画書の行のセクション名(`Decision` または `Implementation Guidance`)に置き換える] | [作業計画書のADR Bindings行から逐語コピーしたAxis値] | [作業計画書のADR Bindings行からコピーしたバインディング決定] | [計画中/最終の実装が決定を満たすかをY/Nで判定できる肯定述語] |
28
35
 
36
+ ## Reference Contracts
37
+ (作業計画書のReference Contract Values表がこのタスクをカバーする場合に本セクションを記載する。それ以外は省略する。)
38
+
39
+ 各行は、このタスクの実装が正確に再現すべきDD由来の観測可能契約である。シリアライズ境界はBoundary Context(作業計画書のConnection Mapから)が、ADR由来の構造的決定は上記のBinding Decisionsが扱う。
40
+
41
+ | Source | Contract Type | Required Observable Value | Compliance Check |
42
+ |---|---|---|---|
43
+ | [対応する作業計画書のReference Contract Values行からコピーしたDesign Docパス (§ セクション)] | [作業計画書の行からコピーしたContract Type: structure-order / derived-display / state-lifecycle-negative] | [作業計画書の行から逐語コピーしたRequired Observable Value] | [計画中/最終の実装が値を再現するかをY/Nで判定できる肯定述語] |
44
+
29
45
  ## Investigation Notes
30
46
  (実装観察事項を実装開始前にここへ追記する。Binding Decisionsがある場合、計画した実装アプローチと各Compliance Check結果をここに記録する。)
31
47
 
32
48
  ## Implementation Steps (TDD: Red-Green-Refactor)
33
49
  ### 1. Red Phase
34
50
  - [ ] 全ての Investigation Targets を読み、主要な所見を記録
51
+ - [ ] (Change Category が設定されている場合)同一の経路/契約/状態/境界を共有する隣接ケースを同一クラスの欠陥について走査し、スコープ内で見つかったものを失敗するテストに取り込む
35
52
  - [ ] Dependencies の成果物を確認(ある場合)
36
53
  - [ ] 契約定義を確認・作成
37
54
  - [ ] 失敗するテストを書く
@@ -73,6 +90,7 @@ Metadata:
73
90
  - [ ] 各 Proof Obligation が満たされている: テストが主要な故障モードでレッドになり、指定された境界を通過する
74
91
  - [ ] 成果物作成完了(調査・設計タスクの場合)
75
92
  - [ ] (Binding Decisionsがある場合)全てのCompliance Checkが最終実装に対して`Y`と評価され、根拠(file:line、テスト結果、またはコマンド出力)がInvestigation Notesに記録されている
93
+ - [ ] (Reference Contractsがある場合)全てのReference Contract Compliance Checkが最終実装に対して`Y`と評価され、根拠がInvestigation Notesに記録されている
76
94
 
77
95
  ## Notes
78
96
  - 影響範囲: [変更が波及する可能性のある領域]
@@ -15,7 +15,7 @@
15
15
 
16
16
  ## プロトタイプ管理
17
17
 
18
- プロトタイプコードはこのUI Specの**添付資料**です。正式な仕様は常にこのドキュメント + Design Docです。
18
+ プロトタイプコードはこのUI Specの**添付資料**である。正式な仕様は常にこのドキュメント + Design Docである。
19
19
 
20
20
  - **添付パス**: [docs/ui-spec/assets/{feature-name}/]
21
21
  - **バージョン識別**: [コミットSHA / タグ]
@@ -59,7 +59,7 @@ PRDの受入条件をプロトタイプの参照先にマッピング。プロ
59
59
 
60
60
  ### コンポーネント: [ComponentName]
61
61
 
62
- > コンポーネント見出しの一意性: すべての`コンポーネント: [ComponentName]`見出しはUI Spec内で一意でなければならない。work-plannerとtask-decomposerは見出しテキストの完全一致でコンポーネントを参照するため、重複した名前や言い換えがあると実装タスクへの伝播が破綻する。
62
+ > コンポーネント見出しの一意性: すべての`コンポーネント: [ComponentName]`見出しはUI Spec内で一意でなければならない。下流の工程は見出しテキストの完全一致でコンポーネントを参照するため、重複した名前や言い換えがあると実装タスクへの伝播が破綻する。
63
63
 
64
64
  #### 状態×表示マトリクス
65
65
 
@@ -156,7 +156,7 @@ PRDの受入条件をプロトタイプの参照先にマッピング。プロ
156
156
  ## ビジュアル受入条件
157
157
 
158
158
  ### ゴールデンステート
159
- 受入基準となる主要なビジュアル状態を定義:
159
+ 受入条件(AC)となる主要なビジュアル状態を定義:
160
160
 
161
161
  1. **[状態名]**: [視覚的に確認すべき内容の説明]
162
162
  2. **[状態名]**: [説明]
@@ -133,14 +133,10 @@ package.jsonの`packageManager`フィールドに応じた実行コマンドを
133
133
  - `test:coverage:fresh` - カバレッジ測定
134
134
  - `check:all` - 全体統合チェック
135
135
 
136
- ### カバレッジ要件
137
- - **必須**: 単体テストのカバレッジは60%以上
138
- - **コンポーネント別目標**:
139
- - Atoms: 70%以上
140
- - Molecules: 65%以上
141
- - Organisms: 60%以上
142
- - Custom Hooks: 65%以上
143
- - Utils: 70%以上
136
+ ### カバレッジ
137
+ - カバレッジは目標ではなく未テスト領域を見つける診断シグナルとして扱う(目標化すると自明なテストに歪む — グッドハートの法則)
138
+ - 基盤的で再利用度の高いユニット(共有コンポーネント、カスタムフック、utils)にテストの重点を置く。これらはリグレッション時の影響範囲が最も広い。合成度の高い面(organisms、ページ)は統合/E2Eのカバレッジに委ねる
139
+ - 強制する数値しきい値はプロジェクトの CI / カバレッジ設定であり、それ自体が目的ではない
144
140
 
145
141
  ### 非機能要件
146
142
  - **ブラウザ互換性**: Chrome/Firefox/Safari/Edge(最新2バージョン)
@@ -34,13 +34,15 @@ const user = raw // User に絞り込み済み
34
34
  - **Custom hook** をロジック再利用と依存注入の単位とする(テスト容易性のため、協調オブジェクトは hook 経由で注入する)。
35
35
  - **関数引数:** 位置引数は 0〜2 個。3 個以上は単一の options オブジェクトで受ける。
36
36
  - **状態の形:** 状態は明示的に型付けする。複数フィールドかつ離散的な遷移を持つ状態は、複数の `useState` ではなく discriminated union の action 型を用いた `useReducer` にする。
37
+ - **Server/Client 境界**(RSC フレームワークのみ — 例: Next.js App Router): データ取得とレンダリングは既定でサーバーコンポーネントに置き、インタラクティブ性は必要最小のスコープで `"use client"` 境界の内側に隔離する。ブラウザ専用 API(`window`、`localStorage`、イベントハンドラ)はクライアントコンポーネント内に留める。サーバーコンポーネントで呼ぶとレンダリングが壊れるためである。クライアントのみの SPA(例: Vite)では N/A であり、サーバーコンポーネントランタイムが無いプロジェクトではスキップする。
37
38
 
38
39
  ## エラーハンドリング
39
- - すべてのエラーを表に出す: ログして処理するか伝播する — 握り潰さない。
40
+ - すべてのエラーを表に出す: ログして処理するか伝播し、握り潰さない。
40
41
  - **Fail fast:** 不正な状態では、無言のフォールバックを返さず throw する。
41
42
  - 想定内の失敗は `Result` 型で値として表現する。`throw` は想定外/回復不能なケースに限る。
42
43
  - 目的別のエラークラスは `code` を持つ基底 `AppError` を継承する(例: ValidationError, ApiError, NotFoundError)。
43
44
  - **層の責務:** API 層は transport エラーをドメインエラーへ変換する。hook は `AppError` を上位へ伝播する。Error Boundary はレンダリング時のエラーを捕捉しフォールバック UI を表示する。
45
+ - **Effect の競合/クリーンアップ:** `useEffect` 内のデータ取得は、順序が入れ替わった応答とアンマウント後の状態更新に対してガードする。具体的には、`AbortController` か mounted フラグで stale な結果を中断・無視するか、キャンセルと重複排除を行うサーバー状態ライブラリ(React Query/SWR)を使う。`try-catch` だけではこれをカバーできない。
44
46
  - 機微情報(password, token, apiKey, creditCard)をログに出さない。
45
47
 
46
48
  ```typescript
@@ -63,8 +65,8 @@ class ErrorBoundary extends React.Component<{ children: React.ReactNode; fallbac
63
65
  ```
64
66
 
65
67
  ## プロジェクト規約
66
- - **環境変数:** ビルドツールの環境変数システム経由で読む(ブラウザに `process.env` は存在しない)。秘密情報はすべてサーバーサイドに置く — フロントエンドのコードはクライアントに配信される。
67
- - **バンドルとパフォーマンス:** `build` スクリプトで監視し 500KB 未満に保つ。高コストなコンポーネントは `React.memo` でメモ化する。`React.lazy` + `Suspense` でコード分割する。再レンダリングを最小化する状態構造にする。
68
+ - **環境変数:** クライアント側の環境変数はバンドラが公開するアクセサ経由で読む。公開プレフィックスを持つ変数だけがブラウザに届き、プレフィックスの無い変数はブラウザでは `undefined` になる。プロジェクトのバンドラに合わせる: Vite は `import.meta.env.VITE_*`、Next.js の公開変数は `process.env.NEXT_PUBLIC_*`、CRA `process.env.REACT_APP_*`。秘密情報はすべてサーバーサイドに置く。フロントエンドのコードはクライアントに配信されるためである。
69
+ - **バンドルとパフォーマンス:** バンドルサイズは `build` スクリプトでプロジェクトの予算に対して監視する。`React.lazy` + `Suspense` でコード分割する。再レンダリングを最小化する状態構造にする。メモ化: React Compiler が有効なときはそれに任せる。手動の `React.memo`/`useMemo`/`useCallback` は、プロファイラまたは参照同一性で正当化される逃げ道としてのみ用いる(実測されたボトルネック、またはサードパーティ API effect 依存に対する安定した参照同一性)。
68
70
  - **命名:** コンポーネント/型は `PascalCase`、変数/関数は `camelCase`、hook は `use` 接頭辞、定数は `SCREAMING_SNAKE_CASE`。
69
71
  - **インポート:** `src/` からの絶対パス。順序: React → 外部ライブラリ → 内部(絶対)→ 内部(相対)→ 型のみ → スタイル/アセット。
70
72
  - **フォーマット:** Biome に従う(セミコロンやスタイルはプロジェクト設定に従う)。
@@ -24,21 +24,15 @@ description: React Testing Library、MSW、Playwright E2Eでテストを設計
24
24
  ## テストの基本方針
25
25
 
26
26
  ### 品質要件
27
- - **カバレッジ**: 単体テストのカバレッジは60%以上を必須(フロントエンド標準 2025)
27
+ - **カバレッジ**: クリティカルパスと高再利用コンポーネントに対する意味のあるアサーションを優先する。カバレッジは目標ではなくギャップ検出のシグナルとして扱う(目標化すると自明なテストに歪む — グッドハートの法則)。数値しきい値はプロジェクトの CI 設定に委ねる
28
28
  - **独立性**: 各テストは他のテストに依存せず実行可能
29
29
  - **再現性**: テストは環境に依存せず、常に同じ結果を返す
30
30
  - **可読性**: テストコードも製品コードと同様の品質を維持
31
31
 
32
- ### カバレッジ要件
33
- **必須**: 単体テストのカバレッジは60%以上
34
- **コンポーネント別目標**:
35
- - Atoms(Button、Text等): 70%以上
36
- - Molecules(FormField等): 65%以上
37
- - Organisms(Header、Footer等): 60%以上
38
- - Custom Hooks: 65%以上
39
- - Utils: 70%以上
32
+ ### テストの重点配分
33
+ 基盤的で再利用度の高いユニット(共有コンポーネント、カスタムフック、utils)を最も厚くテストする。多くの機能から再利用されるものほど、リグレッション時の影響範囲が広いためである。合成度の高い面(organisms、ページ)は統合/E2Eのカバレッジに委ねる。数値しきい値はプロジェクトの CI 設定に委ねる。
40
34
 
41
- **指標**: Statements(文)、Branches(分岐)、Functions(関数)、Lines(行)
35
+ **指標**(カバレッジレポートの内訳): Statements(文)、Branches(分岐)、Functions(関数)、Lines(行)
42
36
 
43
37
  ### テストの種類と範囲
44
38
  1. **単体テスト(React Testing Library)**
@@ -74,7 +68,7 @@ src/
74
68
 
75
69
  **理由**:
76
70
  - React Testing Libraryのベストプラクティス
77
- - ADR-0002 Co-location原則
71
+ - Co-location原則: テストはそれがカバーする実装と同じ場所に置く
78
72
  - 実装と一緒にテストを見つけやすく、保守しやすい
79
73
 
80
74
  ### 命名規則