1# Crush Development Guide
 2
 3## Build/Test/Lint Commands
 4
 5- **Build**: `go build .` or `go run .`
 6- **Test**: `task test` or `go test ./...` (run single test: `go test ./internal/llm/prompt -run TestGetContextFromPaths`)
 7- **Lint**: `task lint-fix`
 8- **Format**: `task fmt` (gofumpt -w .)
 9- **Dev**: `task dev` (runs with profiling enabled)
10
11## Code Style Guidelines
12
13- **Imports**: Use goimports formatting, group stdlib, external, internal packages
14- **Formatting**: Use gofumpt (stricter than gofmt), enabled in golangci-lint
15- **Naming**: Standard Go conventions - PascalCase for exported, camelCase for unexported
16- **Types**: Prefer explicit types, use type aliases for clarity (e.g., `type AgentName string`)
17- **Error handling**: Return errors explicitly, use `fmt.Errorf` for wrapping
18- **Context**: Always pass context.Context as first parameter for operations
19- **Interfaces**: Define interfaces in consuming packages, keep them small and focused
20- **Structs**: Use struct embedding for composition, group related fields
21- **Constants**: Use typed constants with iota for enums, group in const blocks
22- **Testing**: Use testify's `require` package, parallel tests with `t.Parallel()`,
23  `t.SetEnv()` to set environment variables.
24- **JSON tags**: Use snake_case for JSON field names
25- **File permissions**: Use octal notation (0o755, 0o644) for file permissions
26- **Comments**: End comments in periods unless comments are at the end of the line.
27
28## Testing with Mock Providers
29
30When writing tests that involve provider configurations, use the mock providers to avoid API calls:
31
32```go
33func TestYourFunction(t *testing.T) {
34    // Enable mock providers for testing
35    originalUseMock := config.UseMockProviders
36    config.UseMockProviders = true
37    defer func() {
38        config.UseMockProviders = originalUseMock
39        config.ResetProviders()
40    }()
41
42    // Reset providers to ensure fresh mock data
43    config.ResetProviders()
44
45    // Your test code here - providers will now return mock data
46    providers := config.Providers()
47    // ... test logic
48}
49```
50
51## Formatting
52
53- ALWAYS format any Go code you write.
54  - First, try `goftumpt -w .`.
55  - If `gofumpt` is not available, use `goimports`.
56  - If `goimports` is not available, use `gofmt`.
57  - You can also use `task fmt` to run `gofumpt -w .` on the entire project,
58    as long as `gofumpt` is on the `PATH`.