ai-workflow-init 1.2.2 → 1.2.3
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.
|
@@ -90,8 +90,9 @@ Use these exact markers to wrap generated content:
|
|
|
90
90
|
### Generated Content Order (for CODE_CONVENTIONS)
|
|
91
91
|
- Merge templates in preload order (when present):
|
|
92
92
|
1) `docs/ai/project/template-convention/common.md`
|
|
93
|
-
2) `docs/ai/project/template-convention/javascript.md` (when JS/TS
|
|
93
|
+
2) `docs/ai/project/template-convention/javascript.md` (when JS/TS detected)
|
|
94
94
|
3) `docs/ai/project/template-convention/react.md` (when React is detected)
|
|
95
|
+
4) `docs/ai/project/template-convention/typescript.md.md` (when TS is detected)
|
|
95
96
|
- After the merged templates, append auto-discovered rules from the codebase analysis.
|
|
96
97
|
|
|
97
98
|
## Step 5: Next Actions
|
|
@@ -2,40 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
> These rules are preloaded by the standards generator before analyzing the codebase. They establish non-negotiable, high-signal conventions. The generator should merge these rules first, then append auto-discovered patterns.
|
|
4
4
|
|
|
5
|
+
## Principles — The "Why"
|
|
6
|
+
- DRY (Don't Repeat Yourself): Avoid duplicating code. Abstract common logic into reusable functions, classes, or modules.
|
|
7
|
+
- KISS (Keep It Simple, Stupid): Prefer simple, straightforward solutions over clever or unnecessarily complex ones. Code should be as simple as possible, but no simpler.
|
|
8
|
+
- YAGNI (You Ain't Gonna Need It): Do not add functionality or create abstractions until they are actually needed. Avoid premature optimization.
|
|
9
|
+
|
|
5
10
|
## Naming — Clarity & Descriptiveness
|
|
6
11
|
- Prefer meaningful, verbose names over abbreviations.
|
|
7
|
-
- Avoid 1–2 character identifiers (except conventional counters in very small scopes).
|
|
12
|
+
- Avoid 1–2 character identifiers (except conventional counters like `i`, `j`, `k` in very small loop scopes).
|
|
13
|
+
- Be consistent. If you use `getUser` in one place, use `getProduct` in another, not `fetchProduct`.
|
|
14
|
+
- Function names should be verbs; variables and classes should be nouns. (e.g., `calculateTotal()`, `const user`, `class Order`).
|
|
15
|
+
|
|
16
|
+
## Functions / Methods
|
|
17
|
+
- Single Responsibility Principle: A function should do one thing and do it well. If you can't describe what a function does in one simple sentence, it's likely doing too much.
|
|
18
|
+
- Limit Arguments: Prefer 0-2 arguments per function. If you need more than two, consider passing a single configuration object.
|
|
19
|
+
- Avoid Side Effects: Functions should be predictable. They should avoid modifying external state, global variables, or their own input arguments whenever possible. A function `calculateTotal(items)` should return a new value, not modify the original `items` array.
|
|
8
20
|
|
|
9
21
|
## Control Flow
|
|
10
22
|
- Prefer guard clauses (early returns) to reduce nesting depth.
|
|
11
23
|
- Handle errors and edge cases first.
|
|
12
|
-
- Avoid deep nesting beyond 2–3 levels.
|
|
24
|
+
- Avoid deep nesting beyond 2–3 levels. Refactor deeply nested logic into smaller, well-named functions.
|
|
25
|
+
|
|
26
|
+
## Variables & Data Structures
|
|
27
|
+
- Minimize Scope: Declare variables in the smallest possible scope (e.g., inside a loop or conditional block if they are only used there).
|
|
28
|
+
- Avoid Magic Values: Do not use "magic" strings or numbers directly in code. Define them as named constants to provide context and avoid typos.
|
|
29
|
+
- *Bad:* `if (status === 2) { ... }`
|
|
30
|
+
- *Good:* `const STATUS_APPROVED = 2; if (status === STATUS_APPROVED) { ... }`
|
|
31
|
+
- Prefer Immutability:** Do not reassign variables or mutate data structures if it can be avoided. Creating new data structures instead of changing existing ones leads to more predictable code.
|
|
13
32
|
|
|
14
33
|
## Error Handling
|
|
15
34
|
- Throw errors with clear, actionable messages.
|
|
16
|
-
- Do not catch errors without meaningful handling.
|
|
35
|
+
- Do not catch errors without meaningful handling (e.g., logging, retrying, or re-throwing a more specific error). Swallowing exceptions silently is a major source of bugs.
|
|
17
36
|
|
|
18
37
|
## Comments
|
|
19
|
-
- Add comments only for complex or non-obvious logic; explain "why"
|
|
38
|
+
- Add comments only for complex or non-obvious logic; explain **"why"**, not **"how"**. Well-written code should explain the "how" by itself.
|
|
20
39
|
- Place comments above code blocks or use language-specific docstrings.
|
|
21
|
-
- Avoid trailing inline comments.
|
|
40
|
+
- Avoid trailing inline comments as they can clutter code.
|
|
41
|
+
- Remove Dead Code: Do not leave commented-out code in the codebase. Source control (like Git) is the history.
|
|
22
42
|
|
|
23
43
|
## Formatting
|
|
24
|
-
- Match existing repository formatting tools and styles.
|
|
25
|
-
- Prefer multi-line over long one-liners or complex ternaries.
|
|
26
|
-
- Wrap long lines and do not reformat unrelated code.
|
|
44
|
+
- Match existing repository formatting tools and styles (e.g., Prettier, Black, gofmt). Consistency is key.
|
|
45
|
+
- Prefer multi-line over long one-liners or complex ternaries for readability.
|
|
46
|
+
- Wrap long lines and do not reformat unrelated code in a change that is focused on logic.
|
|
27
47
|
|
|
28
48
|
## Types (for statically typed languages)
|
|
29
49
|
- Explicitly annotate public APIs and function signatures.
|
|
30
|
-
- Avoid unsafe casts or overly broad types (e.g., `any`).
|
|
50
|
+
- Avoid unsafe casts or overly broad types (e.g., `any`, `Object`). Be as specific as possible.
|
|
31
51
|
|
|
32
52
|
## Change Discipline
|
|
33
53
|
- Perform changes via file editing tools; avoid pasting large code blobs in reviews.
|
|
34
54
|
- Re-read target files before editing to ensure accurate context.
|
|
35
55
|
- After edits, run only fast, non-interactive validation on changed files:
|
|
36
|
-
- If
|
|
37
|
-
- If
|
|
56
|
+
- If a linter is configured, run it on changed paths (e.g., `eslint --max-warnings=0 <changed-paths>`). Use `--fix` when safe to auto-fix.
|
|
57
|
+
- If a type checker is used, run type-check only (e.g., `tsc --noEmit` or `mypy <changed-paths>`).
|
|
38
58
|
- Do NOT run Prettier as part of validation (formatting is enforced separately by tooling/CI).
|
|
39
|
-
- Do NOT run full build or dev server (to avoid unnecessary time cost).
|
|
59
|
+
- Do NOT run a full build or dev server (to avoid unnecessary time cost).
|
|
40
60
|
- Attempt auto-fixes up to 3 times for linter issues before requesting help.
|
|
41
61
|
|
|
@@ -6,17 +6,23 @@
|
|
|
6
6
|
- Use strict equality `===`/`!==`.
|
|
7
7
|
- Prefer optional chaining `?.` and nullish coalescing `??` over `||` when `0/''/false` are valid values.
|
|
8
8
|
|
|
9
|
+
## Syntax & Readability
|
|
10
|
+
- Use destructuring to access properties from objects and arrays.
|
|
11
|
+
- Use the spread syntax (`...`) for creating shallow copies of arrays and objects.
|
|
12
|
+
- Prefer array methods (`.map`, `.filter`, `.reduce`) over `for` loops for data transformation.
|
|
13
|
+
- Use `for...of` for simple iterations over iterables.
|
|
14
|
+
|
|
9
15
|
## Functions & Data
|
|
10
16
|
- Keep functions small and single-purpose.
|
|
17
|
+
- Use arrow functions (`=>`) for callbacks and to preserve `this` context.
|
|
11
18
|
- Avoid mutations; prefer immutable updates for objects/arrays.
|
|
12
19
|
- Return early (guard clauses) to reduce nesting.
|
|
13
20
|
|
|
14
21
|
## Errors & Async
|
|
15
22
|
- Use `async/await`; avoid unhandled promises (no floating promises).
|
|
16
|
-
- Throw
|
|
23
|
+
- Throw `Error` objects with clear messages; catch only to handle meaningfully.
|
|
17
24
|
|
|
18
25
|
## Style & Safety
|
|
19
26
|
- Avoid implicit globals; module scope only.
|
|
20
27
|
- Prefer explicit returns over side effects.
|
|
21
|
-
- Keep imports minimal and ordered (std/third-party/internal).
|
|
22
|
-
|
|
28
|
+
- Keep imports minimal and ordered (std/third-party/internal).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# TypeScript Conventions (Essential)
|
|
2
|
+
|
|
3
|
+
## Types & Interfaces
|
|
4
|
+
- Use `interface` for public APIs and object shapes, as they are easily extended.
|
|
5
|
+
- Use `type` for unions (`|`), intersections (`&`), tuples, or complex type aliases.
|
|
6
|
+
|
|
7
|
+
## Naming Conventions
|
|
8
|
+
- Use `PascalCase` for all type-level identifiers (Types, Interfaces, Classes, Enums, Generics).
|
|
9
|
+
- Use `camelCase` for all value-level identifiers (variables, functions, properties).
|
|
10
|
+
- Avoid the `I` prefix for interfaces (e.g., `User`, not `IUser`).
|
|
11
|
+
- Use the `private` keyword instead of an underscore (`_`) prefix for private members.
|
|
12
|
+
|
|
13
|
+
## Type Safety
|
|
14
|
+
- Avoid `any`. It disables type-checking and defeats the purpose of TypeScript.
|
|
15
|
+
- Prefer `unknown` over `any`. It is a type-safe alternative that forces type-checking before use.
|
|
16
|
+
- Use `readonly` for properties that should not be mutated after initialization to enforce immutability.
|
|
17
|
+
- Explicitly type all public function signatures to ensure a clear and stable API.
|
|
18
|
+
|
|
19
|
+
## Modules & Organization
|
|
20
|
+
- Always use ES Modules (`import`/`export`).
|
|
21
|
+
- Prefer named exports over `default` exports. They improve consistency and refactorability.
|
|
22
|
+
- Avoid `namespace`. ES Modules provide superior encapsulation and are the language standard.
|
|
23
|
+
|
|
24
|
+
## Documentation
|
|
25
|
+
- Use JSDoc (`/** ... */`) for all exported members (functions, classes, types). This provides context and enables rich editor tooltips.
|