- Source lives at the repo root.
main.go: CLI entry; TUI startup; flags-switch-claudeand-switch-codex.config.go: config persistence at/opt/switcher/config.json; applies settings to~/.claude/settings.jsonand~/.codex/{auth.json,config.toml}.tui.go: Bubble Tea + Lip Gloss TUI.- Tooling:
Makefile(build/install/clean),switcher.sh(local run),README.md,CLAUDE.md.
make build— compile to./switcher.sudo make install— install binary to/usr/bin/switcher.make clean— remove build artifacts.go run .— run locally without installing.gofmt -s -w .andgo vet ./...— format and basic checks.go test ./...— run tests (none present yet; see below).
- Go 1.24+. Always run
gofmt -sbefore committing. - Exported identifiers:
CamelCase. Unexported:lowerCamel. - Filenames: lowercase words (underscores if needed), package
mainfor CLI. - Error handling: prefer returning errors; wrap with
fmt.Errorf("context: %w", err). Avoid panics in non-mainpaths.
- Use the standard
testingpackage; name files*_test.gonext to sources. - Favor table-driven tests for pure helpers (e.g.,
parseTomlStringArray,serverToTomlArray). - For filesystem-affecting code, use temp dirs and avoid touching real
~/.claude,~/.codex, or/opt/switcher. - Run
go test -v ./...locally; keep tests deterministic and fast.
- Conventional Commits style (e.g.,
feat:,fix:,docs:,refactor:,chore:,test:). English or Chinese OK. - Keep PRs focused and small; include a clear description, rationale, and screenshots/gifs if UI behavior changes.
- Link related issues; update
README.md/CLAUDE.mdwhen flags, paths, or behavior change.
- Never commit secrets or user configs.
.gitignorealready excludesswitcherand.claude/. - Keep API keys masked in logs/UI (align with existing TUI behavior).
- Installing writes to
/usr/binand/opt/switcher; usesudoand least privilege.
- Do not commit the compiled
switcherbinary. - Prefer
make buildandgo vetbefore proposing changes. - Keep edits minimal and consistent with current patterns and formatting.