// Use Result<T,E> for fallible operationstype Result<T, E> = { ok: true; value: T } | { ok: false; error: E };// Use unknown over anyfunction parse(input: unknown): Result<Data, ParseError> {}// Use Zod for validationconst Schema = z.object({ name: z.string() });
Naming
Type
Convention
Example
Interface
I prefix
IModelAdapter
Type
PascalCase
CompletionRequest
Function
camelCase, verb-first
createAdapter
Constant
SCREAMING_SNAKE
MAX_RETRIES
File
kebab-case
model-adapter.ts
File Structure
// 1. Imports (external, then internal)// 2. Types/Interfaces// 3. Constants// 4. Main export// 5. Helper functions
Common Tasks
Adding a New Expert
// 1. Define expert configconst config: ExpertConfig = { type: 'my-expert', prompt: 'You are an expert in...', tier: 'balanced',};// 2. Add to BUILT_IN_EXPERTS in expert-config.ts// ExpertFactory.create('my-expert') will then find it