How anthropics/anthropic-cli works
ant is Anthropic’s Claude Platform CLI. Its main workflow turns resource commands and flags into API requests, then presents the response in terminal-friendly formats. A separate declarative workflow loads resource files, plans changes against remote state and a lockfile, previews the plan, and applies approved changes. Session commands also support live interactive work. The graph preserves the README’s documented capabilities, but source excerpts are incomplete; links for unsampled subsystems are therefore limited to relationships the README documents.
Main entry points: apply.go Apply command · plan.go Change planning · cmd Resource commands · model.go Interactive session UI
Components 19
CLI and API
- Program entry
cmd/ant/main.go - Resource commands
pkg/cmd - Authentication
pkg/cmd/cmd_auth.go
Declarative Apply
- Apply command
pkg/cmd/apply.go - Resource loading
internal/declarative/core/loader.go - Change planning
internal/declarative/core/plan.go - Resource definitions
internal/declarative/claude - API reconciliation
internal/declarative/claude/api.go - Resource lockfile
internal/declarative/core/lock.go - Plan preview
internal/declarative/render/render.go
Managed Sessions
- Session commands
pkg/cmd/betasession.go - Live session transport
internal/sessions/live - Session web server
internal/sessions/web/server.go - Event timeline
internal/sessions/timeline - Interactive session UI
internal/sessions/tui/model.go
Terminal Experience
- Response display
internal/jsonview - Shell completion
internal/autocomplete/autocomplete.go
Other components
- CLI user
- Claude Platform API
Connections 20
- CLI user → Program entry: runs
- Program entry → Resource commands: runs commands
cmd/ant/main.go - CLI user → Authentication: authenticates
- Resource commands → Claude Platform API: sends API requests
- Resource commands → Response display: displays results
- CLI user → Apply command: reconciles resources
- Apply command → Resource loading: loads resource files
- Apply command → Change planning: plans changes
- Change planning → Resource lockfile: tracks resources
- Change planning → Resource definitions: resolves resource kinds
- Change planning → API reconciliation: compares remote state
- Apply command → Plan preview: previews plan
- Apply command → Claude Platform API: applies approved changes
- CLI user → Session commands: manages sessions
- Session commands → Claude Platform API: manages session resources
- CLI user → Interactive session UI: interacts live
- Interactive session UI → Live session transport: sends and receives
internal/sessions/tui/model.go - Interactive session UI → Event timeline: folds and displays
internal/sessions/tui/model.go - Session web server → Live session transport: uses session transport
- CLI user → Shell completion: requests suggestions