3.9 KiB
3.9 KiB
Flynn AGENTS.md
General Rules
- Parallelise with subagents: For every task, use multiple subagents with the appropriate model to work more efficiently. Dispatch independent subtasks in parallel rather than executing them sequentially.
- Subagent model selection (MANDATORY): You MUST use the right model tier for each subagent —
claude-haiku-4.5for fast/simple/mechanical tasks,claude-sonnet-4.5for default/standard implementation work, andclaude-opus-4.6for complex reasoning or architecture decisions. Never use the same model for all subagents. - Commit often:
git commitfrequently — after each meaningful unit of work, not just at the end of a task. - Update state.json: After every feature implementation, modification, or significant change, update
docs/plans/state.jsonaccordingly — add new phases/entries, update test counts, adjust theoverall_progresssection, and update thefeature_gap_scorecardif the gap analysis is affected. Commit state.json alongside the feature change, not as a separate afterthought.
Build, Lint, and Test Commands
# Build
pnpm build # Compile TypeScript to dist/
# Development
pnpm dev # Run daemon with watch mode
pnpm tui # Run TUI in minimal mode (readline)
pnpm tui:fs # Run TUI in fullscreen mode (React/Ink)
pnpm tui:dev # Run TUI with watch mode
# Run
pnpm start # Start production build
# Testing
pnpm test # Run tests in watch mode
pnpm test:run # Run tests once (no watch)
# Linting and Type Checking
pnpm lint # Run ESLint
pnpm typecheck # Run TypeScript compiler (no emit)
Code Style Guidelines
Imports
- Use
.jsextensions for imports (e.g.,import { readFileSync } from 'fs';) - Use
typekeyword for type-only imports:import type { Config } from './schema.js'; - Group imports: stdlib → third-party → local
- Export all public APIs from
index.ts
Naming Conventions
- Classes/Interfaces/Types: PascalCase (
AnthropicClient,NativeAgentConfig) - Functions: camelCase (
loadConfig,expandEnvVars) - Private fields: camelCase with underscore (
_client,_model) - Files: camelCase for .ts files, PascalCase for .tsx files
- Test files:
*.test.tssuffix
TypeScript Configuration
tsconfig.jsonuses strict mode- Target: ES2022
- Module resolution: NodeNext
- Module format: NodeNext
- Enables
declaration,declarationMap, andsourceMapfor all builds
Error Handling
- Throw errors with descriptive messages
- Check for undefined/null with context:
throw new Error('Environment variable ${envVar} is not set') - In stream handlers, wrap errors in try-catch and yield error events
- Use
instanceof Errorfor error type checking:error instanceof Error ? error.message : 'Unknown error' - Catch errors and convert to appropriate error types with context
React/Ink Patterns
- Use
useCallbackfor event handlers to prevent unnecessary re-renders - Use
useReffor mutable values that don't trigger re-renders - Define interface props explicitly
- Event handlers receive
(inputChar: string, key: KeyInfo)as arguments
Project Structure
src/
├── config/ # YAML config + validation
├── models/ # Model providers + router
├── session/ # SQLite persistence
├── hooks/ # Confirmation engine
├── daemon/ # Lifecycle management
├── frontends/ # Telegram bot, TUI
└── backends/native/ # Agent implementation
Testing
- Use Vitest for testing
- Follow
describe/itpattern - Use
expect()for assertions - Test both success and failure cases
- Clean up test resources (files, dirs) in
afterEachoritcleanup blocks - Mock file system and environment variables when needed