This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build for current platform
go build -o vico-cli main.go
# Build for multiple platforms
GOOS=linux GOARCH=amd64 go build -o vico-cli-linux-amd64 main.go
GOOS=darwin GOARCH=arm64 go build -o vico-cli-darwin-arm64 main.go
GOOS=windows GOARCH=amd64 go build -o vico-cli-windows-amd64.exe main.go# Check formatting - the CI/CD pipeline will fail if there are formatting issues
gofmt -l .
# Fix formatting issues
gofmt -w .
# Run golint (install first: go install golang.org/x/lint/golint@latest)
golint -set_exit_status ./...# Run all tests
go test ./...To create a new release:
git tag v1.0.0
git push origin v1.0.0The GitHub Actions workflow will automatically build binaries for all platforms and create a release.
The CLI uses the Cobra library with a hierarchical command structure:
- Root command (
cmd/root.go)devicessubcommand (cmd/devices/)list- List all devicesget- Get details for a specific device
eventssubcommand (cmd/events/)list- List recent eventsget- Get details for a specific eventsearch- Search events by field
pkg/auth/- Handles API authentication with automatic token refresh and cachingpkg/cache/- Token caching to minimize authentication requestspkg/models/- Data models for API responses (Event, Device structures)pkg/output/- Output formatting (table and JSON formats)
- Credentials are read from environment variables:
VICOHOME_EMAILandVICOHOME_PASSWORD - Token is obtained from the API and cached for future requests
- Token is automatically refreshed when expired (based on error codes -1024 to -1027)
- Uses authentication middleware pattern in
pkg/auth/auth.go
The TESTING.md file contains manual acceptance tests that define the expected CLI interface.
When implementing new features, tests are marked as [FAIL] and implementation continues until
all tests pass [PASS].
GitHub Actions workflow (.github/workflows/workflow.yml) runs on:
- Pull requests: Linting and build tests
- Main branch pushes: Multi-arch Docker builds, documentation generation
- Tag pushes: Full release with binaries for all platforms
The workflow ensures:
- Code is properly formatted (
gofmt) - Code passes linting (
golint) - Tests pass
- Multi-platform builds succeed