@zigrivers/scaffold 2.1.2 → 2.28.1

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 (97) hide show
  1. package/README.md +272 -59
  2. package/knowledge/core/adr-craft.md +53 -0
  3. package/knowledge/core/ai-memory-management.md +246 -0
  4. package/knowledge/core/api-design.md +4 -0
  5. package/knowledge/core/claude-md-patterns.md +254 -0
  6. package/knowledge/core/coding-conventions.md +246 -0
  7. package/knowledge/core/database-design.md +4 -0
  8. package/knowledge/core/design-system-tokens.md +465 -0
  9. package/knowledge/core/dev-environment.md +223 -0
  10. package/knowledge/core/domain-modeling.md +4 -0
  11. package/knowledge/core/eval-craft.md +1008 -0
  12. package/knowledge/core/multi-model-review-dispatch.md +250 -0
  13. package/knowledge/core/operations-runbook.md +37 -226
  14. package/knowledge/core/project-structure-patterns.md +231 -0
  15. package/knowledge/core/review-step-template.md +247 -0
  16. package/knowledge/core/{security-review.md → security-best-practices.md} +5 -1
  17. package/knowledge/core/task-decomposition.md +57 -34
  18. package/knowledge/core/task-tracking.md +225 -0
  19. package/knowledge/core/tech-stack-selection.md +214 -0
  20. package/knowledge/core/testing-strategy.md +63 -70
  21. package/knowledge/core/user-stories.md +69 -60
  22. package/knowledge/core/user-story-innovation.md +57 -0
  23. package/knowledge/core/ux-specification.md +5 -148
  24. package/knowledge/finalization/apply-fixes-and-freeze.md +165 -14
  25. package/knowledge/product/prd-craft.md +55 -34
  26. package/knowledge/review/review-adr.md +32 -0
  27. package/knowledge/review/{review-api-contracts.md → review-api-design.md} +34 -1
  28. package/knowledge/review/{review-database-schema.md → review-database-design.md} +27 -1
  29. package/knowledge/review/review-domain-modeling.md +33 -0
  30. package/knowledge/review/review-implementation-tasks.md +50 -0
  31. package/knowledge/review/review-operations.md +55 -0
  32. package/knowledge/review/review-prd.md +33 -0
  33. package/knowledge/review/review-security.md +53 -0
  34. package/knowledge/review/review-system-architecture.md +28 -0
  35. package/knowledge/review/review-testing-strategy.md +51 -0
  36. package/knowledge/review/review-user-stories.md +54 -0
  37. package/knowledge/review/{review-ux-spec.md → review-ux-specification.md} +37 -1
  38. package/methodology/custom-defaults.yml +32 -3
  39. package/methodology/deep.yml +32 -3
  40. package/methodology/mvp.yml +32 -3
  41. package/package.json +2 -1
  42. package/pipeline/architecture/review-architecture.md +18 -6
  43. package/pipeline/architecture/system-architecture.md +14 -2
  44. package/pipeline/consolidation/claude-md-optimization.md +73 -0
  45. package/pipeline/consolidation/workflow-audit.md +73 -0
  46. package/pipeline/decisions/adrs.md +14 -2
  47. package/pipeline/decisions/review-adrs.md +18 -5
  48. package/pipeline/environment/ai-memory-setup.md +70 -0
  49. package/pipeline/environment/automated-pr-review.md +70 -0
  50. package/pipeline/environment/design-system.md +73 -0
  51. package/pipeline/environment/dev-env-setup.md +65 -0
  52. package/pipeline/environment/git-workflow.md +71 -0
  53. package/pipeline/finalization/apply-fixes-and-freeze.md +1 -1
  54. package/pipeline/finalization/developer-onboarding-guide.md +1 -1
  55. package/pipeline/finalization/implementation-playbook.md +3 -3
  56. package/pipeline/foundation/beads.md +68 -0
  57. package/pipeline/foundation/coding-standards.md +68 -0
  58. package/pipeline/foundation/project-structure.md +69 -0
  59. package/pipeline/foundation/tdd.md +60 -0
  60. package/pipeline/foundation/tech-stack.md +74 -0
  61. package/pipeline/integration/add-e2e-testing.md +65 -0
  62. package/pipeline/modeling/domain-modeling.md +14 -2
  63. package/pipeline/modeling/review-domain-modeling.md +18 -5
  64. package/pipeline/parity/platform-parity-review.md +70 -0
  65. package/pipeline/planning/implementation-plan-review.md +56 -0
  66. package/pipeline/planning/{implementation-tasks.md → implementation-plan.md} +29 -9
  67. package/pipeline/pre/create-prd.md +13 -4
  68. package/pipeline/pre/innovate-prd.md +37 -8
  69. package/pipeline/pre/innovate-user-stories.md +38 -7
  70. package/pipeline/pre/review-prd.md +18 -6
  71. package/pipeline/pre/review-user-stories.md +23 -6
  72. package/pipeline/pre/user-stories.md +12 -2
  73. package/pipeline/quality/create-evals.md +102 -0
  74. package/pipeline/quality/operations.md +38 -13
  75. package/pipeline/quality/review-operations.md +17 -5
  76. package/pipeline/quality/review-security.md +17 -5
  77. package/pipeline/quality/review-testing.md +20 -8
  78. package/pipeline/quality/security.md +25 -3
  79. package/pipeline/quality/story-tests.md +73 -0
  80. package/pipeline/specification/api-contracts.md +17 -2
  81. package/pipeline/specification/database-schema.md +17 -2
  82. package/pipeline/specification/review-api.md +18 -6
  83. package/pipeline/specification/review-database.md +18 -6
  84. package/pipeline/specification/review-ux.md +19 -7
  85. package/pipeline/specification/ux-spec.md +29 -10
  86. package/pipeline/validation/critical-path-walkthrough.md +34 -7
  87. package/pipeline/validation/cross-phase-consistency.md +34 -7
  88. package/pipeline/validation/decision-completeness.md +34 -7
  89. package/pipeline/validation/dependency-graph-validation.md +34 -7
  90. package/pipeline/validation/implementability-dry-run.md +34 -7
  91. package/pipeline/validation/scope-creep-check.md +34 -7
  92. package/pipeline/validation/traceability-matrix.md +34 -7
  93. package/skills/multi-model-dispatch/SKILL.md +326 -0
  94. package/skills/scaffold-pipeline/SKILL.md +195 -0
  95. package/skills/scaffold-runner/SKILL.md +465 -0
  96. package/pipeline/planning/review-tasks.md +0 -38
  97. package/pipeline/quality/testing-strategy.md +0 -42
@@ -0,0 +1,246 @@
1
+ ---
2
+ name: coding-conventions
3
+ description: Universal coding standards patterns across languages and linter/formatter configuration
4
+ topics: [coding-standards, linting, formatting, naming-conventions, error-handling, code-style]
5
+ ---
6
+
7
+ # Coding Conventions
8
+
9
+ Coding conventions eliminate decision fatigue, reduce code review friction, and make codebases navigable by any team member. Good conventions are enforced by tooling, not willpower. This knowledge covers universal patterns across languages, language-specific catalogs, and the tooling that makes conventions stick.
10
+
11
+ ## Summary
12
+
13
+ ### Categories of Standards
14
+
15
+ Coding standards fall into six categories, each requiring different enforcement strategies:
16
+
17
+ 1. **Naming Conventions** — Variable, function, class, file, and directory naming patterns. Language-specific (camelCase in JS/TS, snake_case in Python/Go). Enforced by linters.
18
+ 2. **Formatting** — Indentation, line length, brace placement, trailing commas, semicolons. Enforced by formatters (Prettier, Black, gofmt). Never debated in code review.
19
+ 3. **Error Handling** — How errors are created, propagated, caught, and reported. Language-specific patterns (try/catch, Result types, error returns). Enforced by linters + adherence evals.
20
+ 4. **Import Organization** — Ordering (stdlib, third-party, local), grouping, path aliasing. Enforced by linters (eslint-plugin-import, isort).
21
+ 5. **Comment Philosophy** — When to comment (why, not what), documentation comments vs inline, TODO format, deprecation markers. Partially enforced by linters.
22
+ 6. **Code Structure** — Function length limits, file length guidelines, single responsibility, early returns. Enforced by linters + code review.
23
+
24
+ ### Linter/Formatter Selection
25
+
26
+ **Rule**: Formatters handle style. Linters handle correctness and patterns. Never configure linter rules that a formatter already handles.
27
+
28
+ | Language | Formatter | Linter | Config Location |
29
+ |----------|-----------|--------|----------------|
30
+ | TypeScript | Prettier | ESLint (flat config) | `eslint.config.js`, `.prettierrc` |
31
+ | Python | Black / Ruff format | Ruff | `pyproject.toml` |
32
+ | Go | gofmt (built-in) | golangci-lint | `.golangci.yml` |
33
+ | Shell | shfmt | ShellCheck | `.shellcheckrc`, `.editorconfig` |
34
+ | Rust | rustfmt | clippy | `rustfmt.toml`, `clippy.toml` |
35
+
36
+ ### The Golden Rule
37
+
38
+ If a convention cannot be checked by a tool, it will not be followed consistently. Prefer conventions that can be automated. Document the rest, but accept lower compliance.
39
+
40
+ ### Comment Philosophy at a Glance
41
+
42
+ Comments explain **why**, not **what**. If you need a comment to explain what code does, the code is too complex — refactor first. Extract well-named functions, use descriptive variables, replace magic numbers with constants. TODOs must include a task ID: `// TODO [BD-123]: Reason`. Bare TODOs are not allowed.
43
+
44
+ ## Deep Guidance
45
+
46
+ ### Language-Specific Convention Catalogs
47
+
48
+ #### TypeScript / JavaScript
49
+
50
+ **Naming**: Variables and functions use `camelCase`. Types, interfaces, and classes use `PascalCase`. True constants use `UPPER_SNAKE_CASE`. File names use `kebab-case.ts` for modules, `PascalCase.tsx` for React components. Booleans prefix with `is`, `has`, `can`, `should`. Private class fields use `#` prefix.
51
+
52
+ **Error handling**: Never catch and swallow — `catch (e) {}` is forbidden. Use custom error classes for domain errors. Never use `any` as a catch-all; use `unknown` and narrow. No `@ts-ignore` without a comment explaining why and linking to an issue.
53
+
54
+ **Imports**: Order as Node builtins, third-party, path-aliased local (`@/`), relative local. One blank line between groups. Prefer named exports over default exports. Use path aliases over deep relative paths.
55
+
56
+ **Key ESLint rules**: `no-explicit-any: error`, `no-unused-vars` (with `^_` pattern ignored), `prefer-const: error`, `no-var: error`, `eqeqeq: always`.
57
+
58
+ #### Python
59
+
60
+ **Naming**: Variables, functions, methods use `snake_case`. Classes use `PascalCase`. Constants use `UPPER_SNAKE_CASE`. Modules and packages use short `snake_case` names. Type variables use `T`, `K`, `V` or descriptive `UserT`.
61
+
62
+ **Error handling**: Never bare `except:` — always catch specific exceptions. Use custom exceptions inheriting from a project base exception. Use context managers for resource cleanup. Avoid `assert` in production code (stripped with `-O`).
63
+
64
+ **Imports**: Order as stdlib, third-party, local (enforced by isort/ruff). No `from module import *`. Absolute imports preferred; relative imports acceptable within a package.
65
+
66
+ **Ruff config**: Select rules `E, F, W, I, N, UP, B, SIM, T20` covering pycodestyle, pyflakes, isort, naming, pyupgrade, bugbear, simplify, and no-print.
67
+
68
+ #### Go
69
+
70
+ **Naming**: Exported identifiers use `PascalCase`, unexported use `camelCase`. Acronyms are all caps (`ID`, `HTTP`, `URL`). Single-method interfaces use method name + `er` suffix (`Reader`, `Writer`). Package names are short, lowercase, no underscores.
71
+
72
+ **Error handling**: Always check error returns — never discard with `_`. Wrap errors with context: `fmt.Errorf("fetch user %s: %w", id, err)`. Use sentinel errors for expected conditions. Use `errors.Is()` and `errors.As()`, never string comparison. Return errors, don't panic.
73
+
74
+ **Formatting**: `gofmt` is non-negotiable. Run on save. No style discussions in Go.
75
+
76
+ **Linter**: Enable `errcheck`, `govet`, `staticcheck`, `unused`, `gosimple`, `ineffassign`, `gocritic` via golangci-lint.
77
+
78
+ #### Shell (Bash)
79
+
80
+ **Naming**: Variables use `snake_case`. Constants/environment use `UPPER_SNAKE_CASE`. Functions use `snake_case`. Script files use `kebab-case.sh`.
81
+
82
+ **Error handling**: Every script starts with `set -euo pipefail`. Use `trap` for cleanup. Quote all variable expansions. Use `[[ ]]` over `[ ]`. Check command existence before use.
83
+
84
+ **ShellCheck**: Run on all `.sh` files. Address warnings; if a directive is needed, comment why.
85
+
86
+ ### Naming Convention Matrix
87
+
88
+ | Context | TypeScript | Python | Go |
89
+ |---------|-----------|--------|-----|
90
+ | Local variable | `camelCase` | `snake_case` | `camelCase` |
91
+ | Function/method | `camelCase` | `snake_case` | `PascalCase` (exported) |
92
+ | Class/type | `PascalCase` | `PascalCase` | `PascalCase` |
93
+ | Constant | `UPPER_SNAKE` | `UPPER_SNAKE` | `PascalCase` (exported) |
94
+ | File name | `kebab-case` | `snake_case` | `snake_case` |
95
+ | Database column | `snake_case` | `snake_case` | `snake_case` |
96
+ | Environment var | `UPPER_SNAKE` | `UPPER_SNAKE` | `UPPER_SNAKE` |
97
+ | URL path | `kebab-case` | `kebab-case` | `kebab-case` |
98
+
99
+ **The context rule**: Follow the convention of the domain you are writing in, not the language you are writing with. Database columns are `snake_case` regardless of whether your ORM is in TypeScript or Go.
100
+
101
+ ### Comment and Documentation Standards
102
+
103
+ **When to comment**: Explain intent, constraints, and non-obvious decisions. Never narrate code. Bad: `// increment counter` before `counter++`. Good: `// Retry up to 3 times — upstream API has transient 503s during deployments`.
104
+
105
+ **When code should self-document**: Extract well-named functions instead of commenting blocks. Use descriptive variable names instead of commenting values. Use enums/constants instead of commenting magic numbers.
106
+
107
+ **Documentation comments**: Public APIs always need documentation comments. TypeScript uses JSDoc `/** */`. Python uses docstrings. Go uses comments above exported identifiers starting with the identifier name.
108
+
109
+ **TODO format**: `// TODO [BD-123]: Reason for the TODO`. Also `FIXME [BD-456]` and `HACK [BD-789]`. Bare TODOs without task IDs accumulate without accountability and are not allowed.
110
+
111
+ ### Error Handling Patterns by Language
112
+
113
+ The error handling strategy must be consistent within each architectural layer and documented in `docs/coding-standards.md`.
114
+
115
+ #### TypeScript Error Pattern
116
+
117
+ ```typescript
118
+ // Domain errors with discriminated unions
119
+ class AppError extends Error {
120
+ constructor(message: string, public readonly code: string) {
121
+ super(message);
122
+ this.name = 'AppError';
123
+ }
124
+ }
125
+ class NotFoundError extends AppError {
126
+ constructor(resource: string, id: string) {
127
+ super(`${resource} not found: ${id}`, 'NOT_FOUND');
128
+ }
129
+ }
130
+
131
+ // Service layer: throw domain errors
132
+ async function getUser(id: string): Promise<User> {
133
+ const user = await userRepo.findById(id);
134
+ if (!user) throw new NotFoundError('User', id);
135
+ return user;
136
+ }
137
+
138
+ // Controller layer: catch and map to HTTP responses
139
+ app.get('/users/:id', async (req, res) => {
140
+ try {
141
+ const user = await getUser(req.params.id);
142
+ res.json(user);
143
+ } catch (err) {
144
+ if (err instanceof NotFoundError) return res.status(404).json({ error: err.message });
145
+ throw err; // re-throw unexpected errors for global handler
146
+ }
147
+ });
148
+ ```
149
+
150
+ #### Python Error Pattern
151
+
152
+ ```python
153
+ class AppError(Exception):
154
+ """Base exception for the application."""
155
+ def __init__(self, message: str, code: str = "INTERNAL"):
156
+ super().__init__(message)
157
+ self.code = code
158
+
159
+ class NotFoundError(AppError):
160
+ def __init__(self, resource: str, id: str):
161
+ super().__init__(f"{resource} not found: {id}", "NOT_FOUND")
162
+
163
+ # FastAPI exception handler
164
+ @app.exception_handler(NotFoundError)
165
+ async def not_found_handler(request, exc):
166
+ return JSONResponse(status_code=404, content={"error": str(exc)})
167
+ ```
168
+
169
+ #### Go Error Pattern
170
+
171
+ ```go
172
+ var ErrNotFound = errors.New("not found")
173
+
174
+ func (r *UserRepo) FindByID(ctx context.Context, id string) (*User, error) {
175
+ user, err := r.db.QueryRow(ctx, "SELECT ... WHERE id = $1", id)
176
+ if err != nil {
177
+ if errors.Is(err, sql.ErrNoRows) {
178
+ return nil, fmt.Errorf("user %s: %w", id, ErrNotFound)
179
+ }
180
+ return nil, fmt.Errorf("query user %s: %w", id, err)
181
+ }
182
+ return user, nil
183
+ }
184
+ ```
185
+
186
+ ### Import Organization Details
187
+
188
+ Consistent import ordering makes files scannable and diffs cleaner. Every language has an established convention:
189
+
190
+ **TypeScript** (enforced by `eslint-plugin-import`):
191
+ ```typescript
192
+ // 1. Node built-ins
193
+ import { readFileSync } from 'fs';
194
+ import path from 'path';
195
+
196
+ // 2. Third-party packages
197
+ import express from 'express';
198
+ import { z } from 'zod';
199
+
200
+ // 3. Path-aliased local imports
201
+ import { config } from '@/config/env';
202
+ import { UserService } from '@/features/auth';
203
+
204
+ // 4. Relative imports
205
+ import { validateInput } from './helpers';
206
+ import type { RequestContext } from './types';
207
+ ```
208
+
209
+ **Python** (enforced by `isort` or `ruff`):
210
+ ```python
211
+ # 1. Standard library
212
+ import os
213
+ from pathlib import Path
214
+
215
+ # 2. Third-party
216
+ from fastapi import Depends
217
+ from sqlalchemy.orm import Session
218
+
219
+ # 3. Local
220
+ from app.core.config import settings
221
+ from app.services.auth import AuthService
222
+ ```
223
+
224
+ ### Linter Configuration Strategies
225
+
226
+ **Strict from Day One**: Enable all rules at project start. Zero warnings policy. Best for new projects and small teams.
227
+
228
+ **Progressive Adoption**: Start with formatter + critical rules only. Add rules incrementally. Track `eslint-disable-next-line` counts as a health metric — they should decrease over time, not increase. Best for existing projects and large teams.
229
+
230
+ **The Warning Trap**: Never leave linter rules as warnings long-term. Warnings are ignored. Either a rule is an error (enforced) or off (not enforced). Warnings create noise without value.
231
+
232
+ **Monorepo inheritance**: Root config has shared rules. Package configs extend root with package-specific additions. Override blocks handle per-directory exceptions (test files get relaxed rules).
233
+
234
+ ### Common Anti-Patterns
235
+
236
+ **Inconsistent Naming**: Same concept has different names — `userId`, `user_id`, `UserID`, `uid` in one codebase. Fix: define a naming glossary in `docs/coding-standards.md`. One name for one concept.
237
+
238
+ **Swallowed Errors**: `catch (e) {}` or `except: pass` discards errors silently. Fix: lint rules that forbid empty catch blocks. If truly intentional, require a justification comment.
239
+
240
+ **Magic Numbers**: `if (retries > 3)` or `setTimeout(fn, 86400000)` with no context. Fix: extract to named constants. Lint rules can flag numeric literals in conditionals.
241
+
242
+ **Over-Commenting**: Every line has a comment restating what the code does. Fix: delete comments that restate code. Keep only "why" comments.
243
+
244
+ **Inconsistent Error Handling**: Some functions throw, some return null, some return error codes. Fix: document one error strategy per architectural layer. Controllers throw HTTP errors. Services return Result types. Repositories throw data access errors.
245
+
246
+ **Import Chaos**: No ordering, mixed styles, deep relative paths. Fix: configure import-ordering tools (`eslint-plugin-import`, `isort`) and path aliases. Run formatter on save.
@@ -378,3 +378,7 @@ For distributed databases (DynamoDB, Cassandra), the partition key determines da
378
378
  **Allowing unbounded growth in aggregate tables.** An events or logs table that grows without limit, eventually consuming all storage and degrading query performance. Fix: define a retention policy and implement it (archival, partitioning, or deletion).
379
379
 
380
380
  **Using the database as a message queue.** Polling a table for new rows to process. This creates lock contention, wastes resources, and scales poorly. Fix: use a proper message queue (Redis, RabbitMQ, SQS) for event-driven processing.
381
+
382
+ ## See Also
383
+
384
+ - [domain-modeling](../core/domain-modeling.md) — Domain entities map to database schema