mb-cli follows the standard Go project layout:
mb-cli/
├── cmd/mb/main.go # Application entry point
├── internal/
│ ├── cli/ # CLI command implementations (Cobra)
│ ├── client/ # Metabase API client
│ ├── config/ # Configuration management
│ ├── formatter/ # Output formatting (JSON, table)
│ └── version/ # Version information
├── tests/ # Test files
└── Makefile # Build targets
make build- Build binary to bin/mbmake test- Run all testsmake test-verbose- Run tests with verbose outputmake fmt- Format code with gofmtmake vet- Static analysis with go vetmake lint- Run golangci-lintmake clean- Remove build artifactsmake deps- Download and tidy dependenciesmake build-all- Cross-platform builds
Environment variables (both required):
MB_HOST- Metabase instance URL (e.g.https://your-metabase-instance.com)MB_API_KEY- Metabase API key
- Use Go standard formatting (gofmt)
- Package names: lowercase, single word
- Types: PascalCase
- Functions/methods: PascalCase (exported), camelCase (unexported)
- Variables: camelCase
- Constants: PascalCase or ALL_CAPS
- Import ordering: standard library, third-party, local packages
- Use
fmt.Errorffor error wrapping - Always defer
resp.Body.Close()after error check for HTTP responses - Use table-driven tests with
tests := []struct{}pattern - Test files go in the
tests/directory - Use
httptest.NewServerfor HTTP client testing
- After implementing API methods or CLI commands, always smoke test every method against the real Metabase API (
make build && ./bin/mb-cli <command>) - Do not consider a step complete until all endpoints have been verified end-to-end, not just unit tested
- When you generate or update the CHANGELOG.md, be concise
- New additions go in [Unreleased] section
- Don't bump version unless requested
When asked to create a new release, follow this exact sequence:
- Ensure tests pass without errors:
make test- Set the release version in
internal/version/version.go:
- Use the provided version if one is given.
- Otherwise bump the patch version (example:
0.1.0->0.1.1). - Update
var Version = "..."ininternal/version/version.go.
- Update
CHANGELOG.md:
- Add a short bullet-point summary of changes since the last release.
- Follow the existing changelog format.
- Commit the release-prep changes.
- Push the release-prep commit.
- Create the tag using the version from
internal/version/version.go:
git tag v<version>- Push the tag:
git push origin v<version>Notes:
- The tag push triggers
.github/workflows/release.yml. - Do not manually create a GitHub release before the workflow runs.