|
| 1 | +# CLAUDE.md — Javabin CLI |
| 2 | + |
| 3 | +Developer CLI for the Javabin platform, written in Go. |
| 4 | + |
| 5 | +## Project Structure |
| 6 | + |
| 7 | +``` |
| 8 | +main.go Entrypoint — calls cmd.Execute() |
| 9 | +cmd/ |
| 10 | + root.go Cobra root command, registers subcommands |
| 11 | + register.go Interactive app registration wizard |
| 12 | + status.go Project status (costs, ECS services) |
| 13 | + whoami.go Show AWS + GitHub identity |
| 14 | +internal/ |
| 15 | + aws/aws.go AWS SDK helpers (STS, Cost Explorer, ECS) |
| 16 | + config/config.go Config directory (~/.javabin/) |
| 17 | + github/github.go GitHub API client (token, branches, PRs) |
| 18 | +``` |
| 19 | + |
| 20 | +## Dependencies |
| 21 | + |
| 22 | +- `github.com/spf13/cobra` — CLI framework |
| 23 | +- `github.com/aws/aws-sdk-go-v2` — AWS SDK (STS, Cost Explorer, ECS) |
| 24 | +- Go 1.22+ |
| 25 | + |
| 26 | +## Authentication |
| 27 | + |
| 28 | +- **GitHub**: Uses `gh auth token` (gh CLI) first, then falls back to `GITHUB_TOKEN` / `GH_TOKEN` environment variables |
| 29 | +- **AWS**: Standard credential chain via `aws-sdk-go-v2/config` (env vars, `~/.aws/credentials`, SSO). Region defaults to `eu-central-1`. |
| 30 | +- **Cognito**: TODO — will add device flow auth against internal Cognito pool when Identity (Phase 1) is implemented. Token will be cached at `~/.javabin/token`. |
| 31 | + |
| 32 | +## Commands |
| 33 | + |
| 34 | +| Command | What it does | |
| 35 | +|---------|-------------| |
| 36 | +| `javabin register` | Interactive wizard — prompts for repo, team, auth, budget; creates a registration PR against `javaBin/registry` via GitHub API | |
| 37 | +| `javabin status` | Shows month-to-date cost (Cost Explorer) and ECS service status. Infers project from git remote or accepts `--project` flag | |
| 38 | +| `javabin whoami` | Shows AWS identity (STS GetCallerIdentity) and GitHub user (gh API) | |
| 39 | + |
| 40 | +## Build and Test |
| 41 | + |
| 42 | +```bash |
| 43 | +go build -o javabin . |
| 44 | +./javabin --help |
| 45 | +``` |
| 46 | + |
| 47 | +No tests yet. When adding tests, use standard `go test ./...`. |
| 48 | + |
| 49 | +## Release |
| 50 | + |
| 51 | +Releases are built with GoReleaser on semver tags. Binaries go to GitHub Releases and the Homebrew tap (`javaBin/tap/javabin`). |
| 52 | + |
| 53 | +## Design Decisions |
| 54 | + |
| 55 | +- **No deploy/plan/apply commands** — those run exclusively in CI. The CLI is for registration and status only. |
| 56 | +- **No infrastructure management** — use `app.yaml` and let the platform handle it. |
| 57 | +- **GitHub API directly** (not `go-github` library) — keeps dependencies minimal for a simple REST client. |
| 58 | + |
| 59 | +## Related |
| 60 | + |
| 61 | +- [javaBin/platform](https://github.com/javaBin/platform) — infrastructure the CLI queries |
| 62 | +- [javaBin/registry](https://github.com/javaBin/registry) — where `javabin register` creates PRs |
0 commit comments