shr is the sharur CLI binary. It supports three runtime modes and a rich flag surface for model selection, session management, tools, and extensions.
Runtime Modes
Mode
Flag
Description
TUI
--mode tui(default)
Interactive Bubble Tea terminal interface with streaming, tool cards, and session management
JSON
--mode json
One-shot query with line-delimited JSON event output — useful for shell pipelines
gRPC
--mode grpc
Persistent multi-session gRPC service — any gRPC-capable client can connect
Quick Start
# Launch the interactive TUIshr
# One-shot answer (JSONL output)shr --mode json "What is the best way to structure a Go project?"# Resume the most recent sessionshr --continue
See the sub-pages for full keybinding and slash command references, JSON event schema, gRPC proto overview, provider setup, and the full configuration schema.
Subsections of CLI
Configuration
sharur uses layered JSON configuration. Project-level settings override global defaults.
Path
Scope
~/.sharur/config.json
Global defaults — applies to all projects
.sharur/config.json
Project-level overrides — applies in this directory
API keys can also be set via environment variables — env vars take priority over config file values.
Context Files
sharur auto-discovers AGENTS.md, CLAUDE.md, GEMINI.md, and .context.md in your project root and parent directories and injects them into the system prompt. Outermost files take precedence (parent directory wins over project root).
sharur supports five LLM providers. All configuration lives in config.json files or environment variables; environment variables take priority over config file values.
Model Naming
Models can be specified as provider/model shorthand or with separate flags:
# Shorthand: provider inferred from the slash-prefixshr --model anthropic/claude-sonnet-4-6
# Explicit: provider and model as separate flagsshr --provider anthropic --model claude-sonnet-4-6
Both forms are equivalent. The shorthand is convenient for one-off overrides; the config file form is better for persistent defaults.
Environment Variables
API keys set via environment variable take priority over values in config.json. The env var names use the SHARUR_ prefix:
Provider
Environment Variable
Anthropic
SHARUR_ANTHROPIC_API_KEY
OpenAI
SHARUR_OPENAI_API_KEY
Google
SHARUR_GOOGLE_API_KEY
Ollama and llama.cpp are local servers and do not use API keys.
Ollama
Ollama runs models locally. It is the default provider.
// ~/.sharur/config.json or .sharur/config.json
{"defaultProvider":"ollama","defaultModel":"llama3.2","ollamaBaseURL":"http://localhost:11434"}
# Pull a model and launchollama pull llama3.2
shr
# Use a specific modelshr --model ollama/llama3.2
# Point at a remote Ollama servershr --model llama3.2 --provider ollama
Notes:
Default base URL is http://localhost:11434. Override with ollamaBaseURL.
Ollama models support tools and images (vision models).
Use shr --list-models to see all locally available models.
Thinking is supported on models that emit <think> tokens (e.g. qwq, deepseek-r1).
llama.cpp
llama.cpp exposes an OpenAI-compatible HTTP server.
Gemini 1.5 Pro and later have a 1M+ token context window.
Supports tools and vision (images).
Use shr --list-models to see available Gemini models.
Listing Available Models
All five providers implement model listing. Use --list-models to query the active provider:
# List Ollama modelsshr --list-models
# List models from a specific providershr --provider anthropic --list-models
# Filter resultsshr --provider openai --list-models gpt-4
The output is a plain list of model names, suitable for piping:
The TUI is a rich, Bubble Tea-powered interface with real-time streaming, tool cards, session management, and a live context usage progress bar in the status footer.
Keybindings
Key
Action
Enter
Send message (or Steer the running agent)
Shift+Enter
Insert newline
Ctrl+Enter
Queue follow-up message (runs after agent finishes)
Ctrl+C
Abort the current agent run and clear the input editor
Esc
Cancel streaming / Close modal / Abort current turn
Ctrl+O
Toggle tool call output expansion
Ctrl+P
Open model selection modal (cycling via --models flag)
↑/↓
Navigate prompt history (if at start/end of editor) / Scroll viewport
F1
Show help modal
Slash Commands
Command
Description
/new
Start a fresh session
/resume <id>
Resume a session by ID or partial UUID (fuzzy search enabled)
/branch [idx]
Create a new child session branching from a specific message index (defaults to last)
/fork
Duplicate current session into a new independent session (no parent link)
/rebase
Interactive rebase: select specific messages to keep in a new session
/merge <id>
Merge another session’s history into the current one with a synthesis turn
/tree [-g|-p]
Open session tree modal. Flags: --global (-g) or --project (-p)
/import <path>
Import a session from a JSONL file
/export <path>
Export the current session to a JSONL file
/model <p/m>
Switch model mid-conversation (e.g. /model anthropic/claude-sonnet-4-6)
/stats
View session statistics and token usage
/config
View and edit active configuration
/context
View detailed context window usage
/compact
Manually trigger a context compaction
/skill:<name> [args]
Invoke a skill
/prompt:<name>
Expand a prompt template into the editor
/exit
Quit (alias: /quit)
Session Tree Modal (/tree)
Key
Action
↑/↓ / PgUp/PgDn
Navigate the session list
Enter
Resume the selected session (or branch from it if it’s an interior node)
B
Create a new branch from the selected session
F
Create an independent fork of the selected session
R
Start an interactive rebase from the selected session’s history
Esc
Close modal
Bang Commands
Bang commands execute a shell command and inject the output into the conversation:
!ls -la # Execute shell command, paste output into editor!!cat README.md # Execute shell command, send output directly to agent
!cmd — pastes stdout into the editor so you can review before sending
!!cmd — sends stdout directly to the agent without review
At-File Attachments
Type @ in the input to fuzzy-search and attach file contents to your prompt:
Tell me what this does @src/agent/loop.go
The file content is embedded inline in the message sent to the agent.
JSON Mode
JSON mode runs a single prompt and streams the agent’s events as line-delimited JSON (JSONL) to stdout. It is designed for shell pipelines and tooling integration.
shr --mode json "What is the best way to structure a Go project?"# Pipe stdin as contextcat main.go | shr --mode json "Refactor this to use interfaces"# Specify a modelshr --mode json "Summarize the last 10 git commits" --model anthropic/claude-opus-4-5
Event Format
Each line is the protobuf JSON encoding of an AgentEvent. Event types mirror the TUI stream:
EVENT_AGENT_START / EVENT_AGENT_END
EVENT_TEXT_DELTA — incremental response text
EVENT_THINKING_DELTA — incremental thinking text (extended thinking models)
EVENT_TOOL_CALL — tool invocation start
EVENT_TOOL_DELTA — streaming tool output
EVENT_TOOL_OUTPUT — final tool result
EVENT_TURN_START / EVENT_TURN_END
Common Patterns
# Capture only the text deltasshr --mode json "Explain Go interfaces"\
| jq -r 'select(.type == "EVENT_TEXT_DELTA") | .content'# Run without saving the sessionshr --mode json --no-session "Quick one-off question"# Dry-run to see what tools would be calledshr --mode json --dry-run "Delete all .tmp files in the current directory"
gRPC mode starts a persistent AgentService server. Each connecting client supplies a session_id and gets its own isolated agent. Sessions are saved to disk after each turn and reloaded automatically on reconnect.
# Start on the default portshr --mode grpc
# Use a custom addressshr --mode grpc --grpc-addr :9090
The server responds to SIGINT/SIGTERM with a graceful shutdown: in-flight turns are allowed to finish (30 s timeout), all sessions are flushed to disk, then the listener closes.
Proto Definition
The service is defined in proto/sharur/v1/agent.proto. Generated Go stubs live in internal/gen/sharur/v1/. Regenerate with mage generate.
Key RPCs:
RPC
Description
Prompt
Send a user message; streams back AgentEvents
NewSession
Create a new session
GetMessages
Retrieve message history for a session
GetState
Get current agent state
Steer
Inject a steering message mid-turn
FollowUp
Queue a follow-up after the current turn
Abort
Cancel the current running turn
ForkSession
Fork a session into a new independent copy
ConfigureSession
Change model, provider, or thinking level
In-Process Transport
For the TUI and JSON modes, all internal communication also goes through this same protobuf boundary using a bufconn in-memory pipe — not a network socket. This means all three modes share identical code paths. See Service Architecture for details.