Project rules
Go CLI Rules
Project rules for Go command line tools: cobra command layout, config precedence, wrapped errors, exit codes and table-driven tests.
CLAUDE.md
1Layout
2- `cmd/<tool>/main.go` only builds the root command and exits. Commands live in `internal/cli`, one file per subcommand; logic lives in `internal/<domain>` packages that know nothing about cobra.
3- Avoid `init()` and package-level mutable state. Build commands with constructors that take their dependencies.
4Config and I/O
5- Precedence: flags, then environment variables, then config file, then defaults. Document it in `--help`.
go
#
Go CLI Rules
Project rulesgo
Free