Instructions for Codex when working in this repository.
OpenUsage is a Go terminal dashboard for monitoring AI coding tool usage/spend.
It uses Bubble Tea for UI and a local telemetry daemon for ongoing data collection.
CGO is required (CGO_ENABLED=1) due to mattn/go-sqlite3 (Cursor + telemetry store).
# Build / run
make build
make run
make demo
# Quality checks
make fmt
make vet
make lint
make test
make test-verbose
# Focused tests
go test ./internal/providers/... -v
go test ./internal/telemetry/... -v
go test ./internal/tui/... -v
# Daemon / telemetry
go run ./cmd/openusage telemetry daemon
go run ./cmd/openusage telemetry daemon status
go run ./cmd/openusage telemetry hook codex < /tmp/payload.json- CLI entrypoint:
cmd/openusage/main.go - Dashboard runtime wiring:
cmd/openusage/dashboard.go - Telemetry subcommands:
cmd/openusage/telemetry.go - Core interface:
core.UsageProviderininternal/core/provider.go - Provider registry:
internal/providers/registry.go(16 providers) - Auto-detection:
internal/detect/ - Telemetry/daemon pipeline:
internal/daemon/+internal/telemetry/ - TUI rendering:
internal/tui/ - Config:
~/.config/openusage/settings.json - Credentials:
~/.config/openusage/credentials.json
- Use
gofmtstyle and grouped imports (stdlib, third-party, internal). - Alias Bubble Tea as
tea. - Wrap errors with provider/context prefixes (
fmt.Errorf("openai: ...: %w", err)). - Use pointer numerics for optional metrics (
*float64). - Keep runtime-only fields non-serializable (
json:"-"). - Tests: standard
testing, table-driven patterns,httptest.NewServer,t.TempDir.
Each provider must implement:
ID()Describe()Spec()DashboardWidget()DetailWidget()Fetch(ctx, acct) (core.UsageSnapshot, error)
Status-first behavior is preferred for non-fatal failures (StatusAuth, StatusLimited) with a usable UsageSnapshot.
- Codex skill stubs live in
.codex/skills/*/SKILL.mdand are generated bymake sync-tools. - These stubs are thin wrappers that point to the canonical definitions in
docs/skills/. - Primary skills:
docs/skills/add-new-provider.mddocs/skills/develop-feature/SKILL.mddocs/skills/design-feature/SKILL.mddocs/skills/review-design/SKILL.mddocs/skills/implement-feature/SKILL.mddocs/skills/validate-feature/SKILL.mddocs/skills/iterate-feature/SKILL.mddocs/skills/finalize-feature/SKILL.mddocs/skills/dev-workflow-improvements/SKILL.mddocs/skills/openusage-provider/SKILL.md