5-phase-workflow 2.0.4 → 2.0.5
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/bin/install.js +1 -1
- package/package.json +1 -1
- package/src/agents/step-executor-agent.md +3 -1
- package/src/commands/5/configure.md +9 -1
- package/src/commands/5/plan.md +3 -0
- package/src/commands/5/reconfigure.md +3 -3
- package/src/commands/5/review.md +2 -1
- package/src/references/configure-tables.md +3 -0
- package/src/skills/configure-docs-index/SKILL.md +35 -1
- package/src/templates/AGENTS.md +15 -0
- package/src/templates/ARCHITECTURE.md +3 -3
- package/src/templates/CONVENTIONS.md +74 -0
package/bin/install.js
CHANGED
|
@@ -354,7 +354,6 @@ const LEGACY_REMOVED_FILES = [
|
|
|
354
354
|
'agents/step-verifier.md',
|
|
355
355
|
'templates/STACK.md',
|
|
356
356
|
'templates/STRUCTURE.md',
|
|
357
|
-
'templates/CONVENTIONS.md',
|
|
358
357
|
'templates/INTEGRATIONS.md',
|
|
359
358
|
'commands/5/plan-feature.md',
|
|
360
359
|
'commands/5/plan-implementation.md',
|
|
@@ -422,6 +421,7 @@ function getWorkflowManagedFiles() {
|
|
|
422
421
|
'AGENTS.md',
|
|
423
422
|
'ARCHITECTURE.md',
|
|
424
423
|
'CONCERNS.md',
|
|
424
|
+
'CONVENTIONS.md',
|
|
425
425
|
'TESTING.md',
|
|
426
426
|
// Workflow output templates
|
|
427
427
|
'workflow/PLAN.md',
|
package/package.json
CHANGED
|
@@ -19,7 +19,9 @@ You follow the plan, state entry, and existing codebase patterns. You do not wid
|
|
|
19
19
|
6. Run every verify command assigned to your component. If none is assigned, verify touched files exist and run the narrowest relevant test/build command you can infer.
|
|
20
20
|
7. Fix local mechanical issues you caused. Stop for architectural changes, auth gates, missing external services, or unclear product decisions.
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Simplicity
|
|
23
|
+
|
|
24
|
+
Write the minimum that satisfies the component. Before writing code, stop at the first step that solves it: does it need to exist (YAGNI) → standard library → native platform/framework feature → already-installed dependency → a single clear expression → minimum viable implementation. Add no new dependency for this. Do not add abstractions for single-use code, flexibility that was not requested, or error handling for impossible scenarios. Follow `Simplicity First` in the project `AGENTS.md`. This sharpens "smallest coherent change" — it never widens scope.
|
|
23
25
|
|
|
24
26
|
End with exactly:
|
|
25
27
|
|
|
@@ -262,6 +262,12 @@ If no patterns/commands detected:
|
|
|
262
262
|
1. "Yes, add to .gitignore (recommended)" — workflow artifacts stay local, not tracked in version control
|
|
263
263
|
2. "No, track in git" — useful if you want to share specs and plans with your team
|
|
264
264
|
|
|
265
|
+
**2n. Code Conventions:**
|
|
266
|
+
- "Generate `.5/CONVENTIONS.md` with coding conventions for this project? It will include a default set of strict rules (typing, code structure, naming, error handling, testing, and documentation standards) plus project-specific conventions derived from your codebase."
|
|
267
|
+
- Options:
|
|
268
|
+
1. "Yes (recommended)" → `conventions.generate: true`
|
|
269
|
+
2. "Skip" → `conventions.generate: false`
|
|
270
|
+
|
|
265
271
|
### Step 2.5: Write config.json
|
|
266
272
|
|
|
267
273
|
Using the values gathered from Steps 1 and 2, write `.5/config.json` directly.
|
|
@@ -274,7 +280,7 @@ Using the values gathered from Steps 1 and 2, write `.5/config.json` directly.
|
|
|
274
280
|
mkdir -p .5
|
|
275
281
|
```
|
|
276
282
|
|
|
277
|
-
**Schema:** Read `.claude/references/configure-tables.md` section "Config Schema" for the full JSON structure. Fill all values from user responses (including `rules.generate` from step 2k2). Write with pretty-printed JSON. Read back to verify correctness.
|
|
283
|
+
**Schema:** Read `.claude/references/configure-tables.md` section "Config Schema" for the full JSON structure. Fill all values from user responses (including `rules.generate` from step 2k2 and `conventions.generate` from step 2n). Write with pretty-printed JSON. Read back to verify correctness.
|
|
278
284
|
|
|
279
285
|
**Update `.5/version.json` with configure timestamp:**
|
|
280
286
|
|
|
@@ -350,6 +356,7 @@ Generates AGENTS.md, CLAUDE.md shim, a rebuildable codebase index, and project-s
|
|
|
350
356
|
- [ ] `.5/ARCHITECTURE.md` exists when architecture knowledge was found.
|
|
351
357
|
- [ ] `.5/TESTING.md` exists when test knowledge was found.
|
|
352
358
|
- [ ] `.5/CONCERNS.md` exists only if concerns were found.
|
|
359
|
+
- [ ] `.5/CONVENTIONS.md` exists when `conventions.generate` is true.
|
|
353
360
|
- [ ] `.5/index/rebuild-index.sh` exists and rebuilds the index.
|
|
354
361
|
- [ ] `.5/index/README.md` documents generated index files.
|
|
355
362
|
- [ ] `AGENTS.md` references created `.5/` files and the index rebuild rule.
|
|
@@ -388,6 +395,7 @@ Analyze the codebase and generate focused documentation capturing only non-deriv
|
|
|
388
395
|
- `.5/ARCHITECTURE.md` - Architecture pattern, layers & data flow, key abstractions, non-obvious conventions, where to add new code
|
|
389
396
|
- `.5/TESTING.md` - Test organization, patterns, mocking approach, gotchas
|
|
390
397
|
- `.5/CONCERNS.md` - Tech debt, known issues, security/integration/performance notes (**only if concerns found — skip file entirely if nothing detected**)
|
|
398
|
+
- `.5/CONVENTIONS.md` - Default strict coding conventions plus project-specific conventions derived from codebase analysis (**only when `conventions.generate` is true**)
|
|
391
399
|
|
|
392
400
|
**Create a rebuildable codebase index in `.5/index/`:**
|
|
393
401
|
- Generate a repository-local script at `.5/index/rebuild-index.sh`
|
package/src/commands/5/plan.md
CHANGED
|
@@ -122,6 +122,8 @@ Discuss naturally until you can articulate:
|
|
|
122
122
|
|
|
123
123
|
Ask only useful questions. Prefer proposing a concrete understanding and letting the user correct it.
|
|
124
124
|
|
|
125
|
+
Apply a necessity gate to every component before it enters the plan. For each one, ask "does this need to exist?" and prefer the simplest approach that meets the acceptance criteria: reuse the standard library, a native platform/framework feature, or an already-installed dependency before adding anything new. Push speculative or "might need later" work to `[DEFERRED]`. Do not plan abstractions, flexibility, or configurability that no acceptance criterion requires.
|
|
126
|
+
|
|
125
127
|
## Step 5: Write `plan.md`
|
|
126
128
|
|
|
127
129
|
Determine a short kebab-case feature folder name. If a ticket ID is known, use `{ticket-id}-{feature-name}`. Sanitize folder names to alphanumeric, dash, and underscore only.
|
|
@@ -153,6 +155,7 @@ Verify:
|
|
|
153
155
|
- Acceptance criteria are checkboxes.
|
|
154
156
|
- Decisions are labeled `[DECIDED]`, `[FLEXIBLE]`, or `[DEFERRED]`.
|
|
155
157
|
- Every component traces to scope or acceptance criteria.
|
|
158
|
+
- No component adds abstraction, flexibility, or configurability beyond what an acceptance criterion requires.
|
|
156
159
|
- No implementation code or pseudo-code is present.
|
|
157
160
|
|
|
158
161
|
Output exactly:
|
|
@@ -116,7 +116,7 @@ Use the existing skills in `.claude/skills/` (from Step 2e) as the source of tru
|
|
|
116
116
|
|
|
117
117
|
Use `AskUserQuestion` to show a summary and get confirmation. Present:
|
|
118
118
|
|
|
119
|
-
1. **Documentation files that will be rewritten** — list `.5/ARCHITECTURE.md`, `.5/TESTING.md`, `.5/CONCERNS.md` (conditional), `.5/index/rebuild-index.sh`, `.5/index/*.md`, and `AGENTS.md`
|
|
119
|
+
1. **Documentation files that will be rewritten** — list `.5/ARCHITECTURE.md`, `.5/TESTING.md`, `.5/CONCERNS.md` (conditional), `.5/CONVENTIONS.md` (when `conventions.generate` is true), `.5/index/rebuild-index.sh`, `.5/index/*.md`, and `AGENTS.md`
|
|
120
120
|
2. **Skills that will be refreshed** — list ALL skills found in `.claude/skills/` (both workflow-generated and user-created)
|
|
121
121
|
3. **Rules that will be refreshed** (if rules enabled) — list workflow-generated rule files in `.claude/rules/`
|
|
122
122
|
4. **New patterns detected** (if any) — "These patterns were found in your codebase but don't have skills yet: [list]. Create skills for them?"
|
|
@@ -138,7 +138,7 @@ Write `.5/reconfigure-manifest.json` with the compact decisions needed by refres
|
|
|
138
138
|
```json
|
|
139
139
|
{
|
|
140
140
|
"mode": "refresh",
|
|
141
|
-
"docs": ["ARCHITECTURE.md", "TESTING.md", "CONCERNS.md", "index", "AGENTS.md"],
|
|
141
|
+
"docs": ["ARCHITECTURE.md", "TESTING.md", "CONCERNS.md", "CONVENTIONS.md", "index", "AGENTS.md"],
|
|
142
142
|
"skills": {
|
|
143
143
|
"refresh": ["skill names"],
|
|
144
144
|
"create": ["new skill names"],
|
|
@@ -185,7 +185,7 @@ rm -f .5/.reconfig-reminder .5/.migration-v2
|
|
|
185
185
|
### Step 9: Report
|
|
186
186
|
|
|
187
187
|
Show the user a summary:
|
|
188
|
-
- List of documentation files updated
|
|
188
|
+
- List of documentation files updated (including `.5/CONVENTIONS.md` when applicable)
|
|
189
189
|
- Mention whether the codebase index script and index files were regenerated
|
|
190
190
|
- List of skills refreshed
|
|
191
191
|
- List of new skills created (if any)
|
package/src/commands/5/review.md
CHANGED
|
@@ -51,7 +51,8 @@ Process:
|
|
|
51
51
|
4. For medium-risk files, read targeted symbols or nearby changed sections plus direct imports only when needed.
|
|
52
52
|
5. For low-risk mechanical/docs/config changes, review the diff without reading full files unless something looks inconsistent.
|
|
53
53
|
6. Review for bugs, security, performance, code quality, API design, and missing tests.
|
|
54
|
-
7.
|
|
54
|
+
7. Review for over-engineering: unnecessary abstractions, single-use indirection, unused flexibility or configurability, speculative generality, and reinventing standard-library or existing-dependency behavior. Report clear cases as Fixable and judgment calls as Questions.
|
|
55
|
+
8. Categorize findings as Fixable, Questions, or Manual.
|
|
55
56
|
|
|
56
57
|
Output:
|
|
57
58
|
Status: success | failed
|
|
@@ -71,6 +71,14 @@ Perform focused analysis to gather data for documentation templates. Only captur
|
|
|
71
71
|
- Identify non-obvious integration details: auth flows, required env vars not documented elsewhere, webhook contracts, gotchas with external services
|
|
72
72
|
- Look for performance bottlenecks or scaling limits mentioned in comments/docs
|
|
73
73
|
|
|
74
|
+
**Conventions Analysis** (for CONVENTIONS.md — when `conventions.generate` is true in config.json):
|
|
75
|
+
- Identify the primary language(s) and runtime (TypeScript, Java, Python, Go, etc.) for the summary line
|
|
76
|
+
- **Typing patterns:** Check tsconfig.json for `strict` mode (TypeScript); check mypy.ini or pyproject.toml `[tool.mypy]` for strict settings (Python); scan source files for `any` type usage count, non-null assertion (`!`) patterns, and missing return types
|
|
77
|
+
- **Error handling patterns:** Scan for try/catch structures, custom error classes/types, and patterns of silent catches (empty catch blocks)
|
|
78
|
+
- **Test assertion patterns:** Read 3-5 test files to identify assertion library (Jest `expect`, Chai, JUnit `assertEquals`, etc.), mocking approach, and whether factories/builders exist
|
|
79
|
+
- **Naming patterns:** Observe the dominant casing and naming conventions already established in the codebase
|
|
80
|
+
- **Code structure patterns:** Note average file lengths and any consistent structural patterns across modules
|
|
81
|
+
|
|
74
82
|
### A2. Fill Templates
|
|
75
83
|
|
|
76
84
|
For each template in `.claude/templates/`:
|
|
@@ -86,6 +94,7 @@ ARCHITECTURE.md:
|
|
|
86
94
|
- `{Pattern name}` → "Layered Architecture" or "MVC" or "Modular Monolith"
|
|
87
95
|
- `{Layer}` → "Controllers", "Services", "Repositories"
|
|
88
96
|
- `{path}` → "src/controllers/", "src/services/"
|
|
97
|
+
- `{skill links}` → slash-command links to project-specific skills installed in `.claude/skills/` that correspond to this layer (e.g., `/controller`, `/service`). Check which `create-*` skills exist for this layer's pattern. If none exist, use "—".
|
|
89
98
|
|
|
90
99
|
TESTING.md:
|
|
91
100
|
- Describe actual patterns observed, not framework names/versions (those are in config files)
|
|
@@ -102,6 +111,29 @@ Write filled templates to `.5/` folder:
|
|
|
102
111
|
- `.5/ARCHITECTURE.md` — always created
|
|
103
112
|
- `.5/TESTING.md` — always created
|
|
104
113
|
- `.5/CONCERNS.md` — **only if concerns were found** (skip if all sections empty)
|
|
114
|
+
- `.5/CONVENTIONS.md` — **only when `conventions.generate` is true in config.json** (see A3.1)
|
|
115
|
+
|
|
116
|
+
### A3.1. Generate CONVENTIONS.md
|
|
117
|
+
|
|
118
|
+
Skip this section entirely if `conventions.generate` is `false` in `.5/config.json`.
|
|
119
|
+
|
|
120
|
+
Read `.claude/templates/CONVENTIONS.md` as the source template.
|
|
121
|
+
|
|
122
|
+
**Placeholder mapping:**
|
|
123
|
+
|
|
124
|
+
- `{PROJECT_CONVENTIONS_SUMMARY}` → 1 sentence naming the primary language/runtime and any detected strict-mode tooling (e.g., "TypeScript project with `strict: true` in tsconfig." or "Python 3.11 service with mypy strict mode enabled."). Remove the placeholder if nothing useful can be stated.
|
|
125
|
+
- `{PROJECT_TYPING}` → Project-specific findings from Conventions Analysis: detected tsconfig settings, any `any` usage count, non-null assertion patterns, absence of return types. Frame as imperative directives ("Enable `strict: true` in tsconfig — currently disabled." or "49 usages of `any` detected; prioritize removal in new code."). Remove placeholder if nothing project-specific to add.
|
|
126
|
+
- `{PROJECT_STRUCTURE}` → Observed structural patterns or deviations from defaults (e.g., "Files in `src/controllers/` average 380 lines — respect the 300-line default; split controllers that exceed it."). Remove placeholder if no notable findings.
|
|
127
|
+
- `{PROJECT_NAMING}` → Casing or naming patterns specific to this codebase beyond the defaults (e.g., "This project uses `kebab-case` for file names and `PascalCase` for classes — match existing files."). Remove placeholder if defaults already cover it.
|
|
128
|
+
- `{PROJECT_ERROR_HANDLING}` → Detected error-handling patterns or gaps (e.g., "Custom `AppError` class in `src/errors/` — use it for all domain errors." or "3 empty catch blocks found in `src/services/` — always log or rethrow."). Remove placeholder if no notable findings.
|
|
129
|
+
- `{PROJECT_TESTING}` → Project-specific testing directives beyond the defaults: assertion library in use, factory/builder location, any detected weak assertions or disabled tests (e.g., "Use `src/test/factories/` helpers for test data — do not inline objects." or "12 uses of `toBeDefined()` as sole assertion detected — always assert the actual value."). Remove placeholder if defaults already cover it.
|
|
130
|
+
- `{PROJECT_COMMENTS}` → Any documentation patterns or gaps observed (e.g., "Public controllers lack JSDoc — add docblocks to all new public methods."). Remove placeholder if defaults already cover it.
|
|
131
|
+
|
|
132
|
+
**Rules for filling placeholders:**
|
|
133
|
+
- Write project-specific sections as imperative directives, not observations.
|
|
134
|
+
- Remove (do not leave) any placeholder whose section has nothing project-specific to add.
|
|
135
|
+
- Do not duplicate the default convention text — project sections supplement, not restate, the defaults.
|
|
136
|
+
- Keep each project-specific addition under 5 bullet points.
|
|
105
137
|
|
|
106
138
|
### A3.5. Generate Codebase Index Script and Index Files
|
|
107
139
|
|
|
@@ -147,8 +179,9 @@ Use `.claude/templates/AGENTS.md` as the source template.
|
|
|
147
179
|
Placeholder mapping:
|
|
148
180
|
- `{PROJECT_OVERVIEW}` → 1-2 sentences from README/package.json
|
|
149
181
|
- `{BUILD_RUN_COMMANDS}` → build, test, and other detected commands
|
|
150
|
-
- `{PROJECT_DOCUMENTATION_LINKS}` → links to whichever `.5/` files were created (only list files that exist)
|
|
182
|
+
- `{PROJECT_DOCUMENTATION_LINKS}` → links to whichever `.5/` files were created (only list files that exist — includes CONVENTIONS.md when generated)
|
|
151
183
|
- `{CODEBASE_INDEX_LINKS}` → links to `.5/index/README.md`, generated index files, and `.5/index/rebuild-index.sh`
|
|
184
|
+
- `{CONVENTIONS_REFERENCE}` → when `.5/CONVENTIONS.md` was generated: `"Read \`.5/CONVENTIONS.md\` before writing any code. It defines the full convention set for this project: typing rules, code structure limits, naming, error handling, and testing standards."` — when not generated: remove the placeholder entirely
|
|
152
185
|
- `{CUSTOM_DOCUMENTATION}` → preserved user-authored sections under `## Custom Documentation`; remove the placeholder entirely if there is no custom content
|
|
153
186
|
|
|
154
187
|
Preserve the static template sections exactly as written, including skill usage, commit messages, workflow rules, coding guidelines, simplicity, testing, surgical changes, goal-driven execution, and index freshness.
|
|
@@ -189,6 +222,7 @@ Component A (Documentation + Index): SUCCESS - Created documentation files, code
|
|
|
189
222
|
- .5/ARCHITECTURE.md (Pattern: Layered, 4 layers identified)
|
|
190
223
|
- .5/TESTING.md (mocking patterns, gotchas documented)
|
|
191
224
|
- .5/CONCERNS.md (3 TODO items, 1 security note) [or "skipped — no concerns found"]
|
|
225
|
+
- .5/CONVENTIONS.md (defaults + project-specific typing/testing findings) [or "skipped — conventions.generate is false"]
|
|
192
226
|
- .5/index/rebuild-index.sh (generated index rebuild script)
|
|
193
227
|
- .5/index/*.md (focused codebase index files)
|
|
194
228
|
- AGENTS.md (updated with references)
|
package/src/templates/AGENTS.md
CHANGED
|
@@ -24,6 +24,8 @@ Each phase produces a specific artifact - do not create artifacts belonging to o
|
|
|
24
24
|
|
|
25
25
|
## Coding Guidelines
|
|
26
26
|
|
|
27
|
+
{CONVENTIONS_REFERENCE}
|
|
28
|
+
|
|
27
29
|
1. Prefer explicit types or contracts for public APIs, data transfer shapes, service methods, hooks, and async return values where the language supports them.
|
|
28
30
|
2. Keep comments and docs concise; document constraints and non-obvious behavior, not the obvious.
|
|
29
31
|
3. Keep files focused and bounded; split broad controllers, services, hooks, and components early.
|
|
@@ -33,6 +35,19 @@ Each phase produces a specific artifact - do not create artifacts belonging to o
|
|
|
33
35
|
|
|
34
36
|
## Simplicity First
|
|
35
37
|
|
|
38
|
+
Before writing code, walk this decision hierarchy and stop at the first step that solves the problem:
|
|
39
|
+
|
|
40
|
+
1. **Does this need to exist at all?** If the requirement is speculative, don't build it (YAGNI).
|
|
41
|
+
2. Does the **language or standard library** already solve it?
|
|
42
|
+
3. Is there a **native platform or framework** feature for it?
|
|
43
|
+
4. Does an **already-installed dependency** cover it? Don't add a new dependency for this.
|
|
44
|
+
5. Can it be a **single, clear expression** instead of a new abstraction?
|
|
45
|
+
6. Only then: write the **minimum viable implementation**.
|
|
46
|
+
|
|
47
|
+
Non-negotiable regardless of the above: security, data integrity, correctness, and accessibility.
|
|
48
|
+
|
|
49
|
+
Then apply these rules:
|
|
50
|
+
|
|
36
51
|
- No features beyond what was asked.
|
|
37
52
|
- No abstractions for single-use code.
|
|
38
53
|
- No flexibility or configurability that was not requested.
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
## Layers & Data Flow
|
|
10
10
|
|
|
11
|
-
| Layer | Location | Depends On | Notes |
|
|
12
|
-
|
|
13
|
-
| {Layer} | `{path}` | {Dependencies} | {Key responsibility or constraint} |
|
|
11
|
+
| Layer | Location | Depends On | Notes | Skills |
|
|
12
|
+
|-------|----------|------------|-------|--------|
|
|
13
|
+
| {Layer} | `{path}` | {Dependencies} | {Key responsibility or constraint} | {skill links} |
|
|
14
14
|
|
|
15
15
|
## Key Abstractions
|
|
16
16
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Code Conventions
|
|
2
|
+
|
|
3
|
+
{PROJECT_CONVENTIONS_SUMMARY}
|
|
4
|
+
|
|
5
|
+
## Typing
|
|
6
|
+
|
|
7
|
+
- Never use implicit `any` types; if unavoidable, add a `// reason:` comment explaining why.
|
|
8
|
+
- Enable strict null checks: treat `null` and `undefined` as distinct types.
|
|
9
|
+
- Avoid non-null assertions (`!`) without an explanatory comment.
|
|
10
|
+
- Prefer explicit return types on all public functions and methods.
|
|
11
|
+
- Use typed/domain types for IDs, money, dates, and other value objects; avoid raw primitives.
|
|
12
|
+
|
|
13
|
+
{PROJECT_TYPING}
|
|
14
|
+
|
|
15
|
+
## Code Structure
|
|
16
|
+
|
|
17
|
+
- Maximum function or method body: 40 lines of logic.
|
|
18
|
+
- Maximum file length: 300 lines (excluding generated or vendor code).
|
|
19
|
+
- One primary responsibility per file, class, or module — split when in doubt.
|
|
20
|
+
- No more than three levels of nesting; use early returns to flatten control flow.
|
|
21
|
+
- Extract helpers when logic mixes orchestration, IO, parsing, and mapping in one place.
|
|
22
|
+
|
|
23
|
+
{PROJECT_STRUCTURE}
|
|
24
|
+
|
|
25
|
+
## Naming
|
|
26
|
+
|
|
27
|
+
- Names must express intent; avoid abbreviations (exceptions: `i`, `j`, `err`, `ctx`, `req`, `res`).
|
|
28
|
+
- No magic numbers or strings: extract to named constants with descriptive names.
|
|
29
|
+
- Booleans: prefix with `is`, `has`, `can`, `should`, or `needs`.
|
|
30
|
+
- Collections and arrays: plural noun names (`users`, `errors`, `pendingItems`).
|
|
31
|
+
- Functions and methods: verb phrases that describe the action (`fetchUser`, `validateEmail`, `parseResponse`).
|
|
32
|
+
|
|
33
|
+
{PROJECT_NAMING}
|
|
34
|
+
|
|
35
|
+
## Error Handling
|
|
36
|
+
|
|
37
|
+
- Never silently swallow exceptions or errors — always log, rethrow, or convert to a typed result.
|
|
38
|
+
- Distinguish recoverable errors from unrecoverable ones; do not use exceptions for control flow.
|
|
39
|
+
- All async code must handle error paths: catch rejected promises and wrap `async/await` in `try/catch`.
|
|
40
|
+
- Use typed/structured errors with context, not raw strings.
|
|
41
|
+
|
|
42
|
+
{PROJECT_ERROR_HANDLING}
|
|
43
|
+
|
|
44
|
+
## Testing
|
|
45
|
+
|
|
46
|
+
- Follow AAA structure in each test: **Arrange** (set up state), **Act** (call the subject), **Assert** (verify the outcome).
|
|
47
|
+
- One behavior per test — a single test function must cover exactly one scenario.
|
|
48
|
+
- Test names describe the behavior being tested, not the method: `"returns 404 when user not found"`, not `"test getUserById"`.
|
|
49
|
+
- Assert on meaningful, observable outcomes. Forbidden:
|
|
50
|
+
- `expect(result).toBeDefined()` as the only assertion
|
|
51
|
+
- `expect(true).toBe(true)` or any trivially-passing assertion
|
|
52
|
+
- Empty or body-less tests
|
|
53
|
+
- Mock only at system boundaries: external HTTP, databases, filesystem, and clocks.
|
|
54
|
+
- Never mock internal modules or pure functions — test them directly.
|
|
55
|
+
- Cover all paths: happy path, known error cases, boundary values, and null/empty inputs.
|
|
56
|
+
- No disabled tests (`skip`, `xtest`, `xit`, `@Ignore`) without a linked issue comment.
|
|
57
|
+
- New code must reach ≥ 80% branch coverage; bug fixes must include a regression test.
|
|
58
|
+
- Use factories or builders for test data; avoid inline hardcoded objects duplicated across tests.
|
|
59
|
+
|
|
60
|
+
{PROJECT_TESTING}
|
|
61
|
+
|
|
62
|
+
## Comments and Documentation
|
|
63
|
+
|
|
64
|
+
- Comment the **why**, not the what; well-named code should be self-documenting.
|
|
65
|
+
- Forbidden: comments that restate the code (`// increment counter`, `// call save()`).
|
|
66
|
+
- Document: non-obvious invariants, workarounds, performance trade-offs, and cross-system constraints.
|
|
67
|
+
- All public APIs (functions, classes, interfaces, endpoints) require a docstring or docblock.
|
|
68
|
+
- Never leave commented-out code; use version control history instead.
|
|
69
|
+
|
|
70
|
+
{PROJECT_COMMENTS}
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
*Project-specific conventions above were derived from codebase analysis and supplement the defaults.*
|