Archive the differentiated YuXinGu product docs, AI engineering system, design contract, and Go/Vue scaffold. Next execution prioritizes Cece-parity over early innovation (see .ai/product/STRATEGY.md). Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.2 KiB
Markdown
38 lines
1.2 KiB
Markdown
# Coding — Golden Rules
|
|
|
|
## Size
|
|
|
|
- One responsibility per file.
|
|
- One responsibility per function.
|
|
- No function longer than **50** lines.
|
|
- No file longer than **400** lines (hard preference; split earlier if possible).
|
|
- No circular dependency.
|
|
|
|
## Go
|
|
|
|
- Business packages by domain: `auth`, `profile`, `report`, `order`, `payment` — not `utils`.
|
|
- Interface defined at **caller** (usually handler), implemented by service.
|
|
- First parameter of I/O methods: `context.Context`.
|
|
- Errors: `return fmt.Errorf("create user: %w", err)`.
|
|
- Never `panic` in request path.
|
|
- Never use package-level mutable globals for request state.
|
|
- Export comments required on public funcs (what / in / out / side effects).
|
|
|
|
## TypeScript / Vue
|
|
|
|
- `strict: true`. No casual `any`.
|
|
- Components: `PascalCase.vue` (`UserCard.vue`).
|
|
- Pages under `src/pages/`, composables under `src/hooks/`.
|
|
- No direct `fetch` in pages — use SDK.
|
|
- Shared domain types go to `packages/types`.
|
|
|
|
## Naming
|
|
|
|
- Consistent domain words: profile, report, scale, membership, order.
|
|
- Prefer boring clear names over clever short names.
|
|
|
|
## Comments
|
|
|
|
- Public APIs: always document.
|
|
- Do not narrate obvious code. Document intent, invariants, side effects.
|