This repository has been archived on 2026-06-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
nerve/.knowledge/coding-conventions.md
T
xiaomo 97840e25ab chore: add .knowledge/ cards + knowledge.yaml
7 curated knowledge cards extracted from RFCs and docs:
- architecture: core pipeline, extension points, process isolation
- sense: compute behavior, Sense→Workflow, config
- workflow: engine, threads, WorkflowSpec
- adapter: AgentFn protocol, available adapters, extract layer
- coding-conventions: functional-first, Result type, naming
- monorepo: package structure, dependency rules
- knowledge-layer: sync/query CLI, embedding service

knowledge.yaml indexes .knowledge/**/*.md only.
2026-04-29 09:29:29 +00:00

1.2 KiB

Nerve Coding Conventions

Functional-First

  • type over interface, function over class
  • No this, no inheritance, composition over inheritance
  • Immutability first: Readonly<T>, as const

No Optional Properties

Never use ?:. Use T | null for nullable fields. Use discriminated unions for mutually exclusive fields.

// ✅ Good
type Config = { throttle: string | null }

// ❌ Bad
type Config = { throttle?: string }

Error Handling

  • Result<T, E> for expected failures
  • throw only for programmer errors (bugs)
  • No try-catch for flow control

Naming

Type Style
Files kebab-case.ts
Types PascalCase
Functions/vars camelCase
Constants UPPER_SNAKE

Exports

  • Always named exports, never default
  • One module = one responsibility

Async

  • Always async/await, never .then() chains

No Dynamic Import

Static import only. Exceptions: sense-runtime.ts, workflow-worker.ts (runtime module paths).

Toolchain

pnpm + TypeScript (strict) + Biome (lint/format) + Vitest (test)

pnpm run check   # biome check
pnpm test        # vitest
pnpm run build   # full build