Files
digital-psychology/.ai/coding.md
T
jackyu66gitandCursor 2fb1dfee14 chore: seal Design Vision v1 and monorepo scaffold
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>
2026-08-02 16:00:44 +08:00

1.2 KiB

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.