|
| 1 | +# CRUSH.md - Fantasy AI SDK |
| 2 | + |
| 3 | +## Build/Test/Lint Commands |
| 4 | +- **Build**: `go build ./...` |
| 5 | +- **Test all**: `task test` or `go test ./... -count=1` |
| 6 | +- **Test single**: `go test -run TestName ./package -v` |
| 7 | +- **Test with args**: `task test -- -v -run TestName` |
| 8 | +- **Lint**: `task lint` or `golangci-lint run` |
| 9 | +- **Format**: `task fmt` or `gofmt -s -w .` |
| 10 | +- **Modernize**: `task modernize` or `modernize -fix ./...` |
| 11 | + |
| 12 | +## Code Style Guidelines |
| 13 | +- **Package naming**: lowercase, single word (ai, openai, anthropic, google) |
| 14 | +- **Imports**: standard library first, then third-party, then local packages |
| 15 | +- **Error handling**: Use custom error types with structured fields, wrap with context |
| 16 | +- **Types**: Use type aliases for function signatures (`type Option = func(*options)`) |
| 17 | +- **Naming**: CamelCase for exported, camelCase for unexported |
| 18 | +- **Constants**: Use const blocks with descriptive names (ProviderName, DefaultURL) |
| 19 | +- **Structs**: Embed anonymous structs for composition (APICallError embeds *AIError) |
| 20 | +- **Functions**: Return error as last parameter, use context.Context as first param |
| 21 | +- **Testing**: Use testify/assert, table-driven tests, recorder pattern for HTTP mocking |
| 22 | +- **Comments**: Godoc format for exported functions, explain complex logic inline |
| 23 | +- **JSON**: Use struct tags for marshaling, handle empty values gracefully |
| 24 | + |
| 25 | +## Project Structure |
| 26 | +- `/ai` - Core AI abstractions and agent logic |
| 27 | +- `/openai`, `/anthropic`, `/google` - Provider implementations |
| 28 | +- `/providertests` - Cross-provider integration tests with VCR recordings |
| 29 | +- `/examples` - Usage examples for different patterns |
0 commit comments