Imported from f00b455/cc-builder (
go/templates/AGENTS.md). Install upstream withnpx skills add f00b455/cc-builder --skill templates. Copyright stays with the author.
Go TDD Project
Tech Stack
- Language: Go 1.22+
- BDD: godog (Cucumber for Go)
- Testing: go test (standard library)
- Coverage: go test -cover
Project Structure
āāā cmd/
ā āāā main.go # Entry point
āāā internal/
ā āāā api/ # HTTP handlers
ā ā āāā handlers.go
ā ā āāā handlers_test.go
ā āāā domain/ # Business logic
ā ā āāā models.go
ā ā āāā models_test.go
ā āāā storage/ # Data persistence
ā āāā store.go
ā āāā store_test.go
āāā features/
ā āāā *.feature # Gherkin scenarios
ā āāā steps/
ā āāā steps_test.go # Step definitions (MUST be _test.go!)
āāā docs/
ā āāā STORY.md
āāā go.mod
Critical Rules
Clean Code Principles
- Pure functions - No side effects, same input = same output
- Single Responsibility - Each function does ONE thing
- Meaningful names - Variables and functions describe their purpose
- Small functions - Max 20-30 lines, prefer smaller
- No magic numbers - Use named constants
- Early returns - Avoid deep nesting, return early for errors
- Immutability - Prefer value types, avoid pointer mutations
Go Idioms
- Accept interfaces, return structs
- Errors are values - handle them explicitly
- Make zero values useful
- Don't panic in library code
BDD Step Definitions
- Step files MUST be named
*_test.goinfeatures/steps/ - Use
go test ./features/steps/...to run BDD tests - Do NOT use
godog runCLI
Testing
- Unit tests:
*_test.gonext to source files - Table-driven tests preferred
- Coverage target: 80%+
- Test behavior, not implementation
Code Style
- Use
internal/for private packages - Keep
cmd/minimal - just bootstrap - Error handling everywhere
- Use
errors.Is()anderrors.As()for error checking
Commands
go build ./... # Build all
go test ./... # All tests
go test -v ./features/steps/... # BDD tests
go test -cover ./internal/... # Coverage
go test -coverprofile=c.out ./... # Coverage report
When Extending This Codebase
- Read existing code first - understand patterns
- Follow existing package structure
- Add tests for new code
- Run
go test ./...before committing