Running the CLI
Worktree cleanup
mibyan -w sessions create disposable worktrees under <repo>/.worktrees/.
A conservative pruner runs automatically at startup (it only removes clean,
fully-merged scratch trees past an age threshold), but preserved trees and
merged local branches still accumulate on busy machines. Reclaim them
explicitly:
.worktrees/ (created by hand or by another
tool) are reported read-only in list output and are never removed. The one
exception is metadata: registrations whose directory no longer exists are
dropped via git worktree prune (no files are touched). --older-than DAYS
only ever narrows what gets reaped — a tree carrying real work is kept at any
age regardless of the flag.
Inside a session, /worktree prune [--dry-run] does the same (and never
touches the tree the session is running in).
Safety guarantees (all modes, any age):
- Uncommitted tracked changes are never deleted.
- Unique unpushed commits are never deleted — commits that were
rebase/squash-merged upstream are detected via
git cherrypatch-equivalence and count as merged, which is what lets the dominant “merged PR, tree preserved forever” leak finally reclaim. - Repositories without a remote are judged against the local trunk
(
main/master, else the branch checked out in the main worktree): only trees and branches whose commits are reachable from — or patch-equivalent to — that trunk are reclaimed. With no trunk to compare against, every tree and branch is preserved. - Pushed open-PR lanes free their disk without losing anything: when a
clean tree’s branch head exactly matches what
originholds (checked with onegit ls-remoteper sweep), the checkout is redundant — the tree is removed but its branch ref is kept, so the lane is onegit worktree add .worktrees/<name> <branch>away from restored. If the remote can’t be reached, the tree is preserved. - Trees in use by a running mibyan session are never touched.
- Untracked-only scratch (PR body drafts, notes) is archived to
~/.mibyan/archive/worktree-prune/before its tree is removed — never destroyed. - Branch deletion is content-gated, not name-gated: any local branch whose
commits are all on upstream is safe to delete; branches with unique work,
checked-out branches, and
main/master/developare always kept.
mibyan -w for days — no longer accumulate merged scratch trees
between CLI sessions.
When .worktrees/ grows past 10 trees or 5 GB, startup prints a one-line
notice pointing at these commands.
Plugin management
Themibyan plugins commands manage native Mibyan plugins and portable Agent
Plugins v1 packages through the same opt-in workflow:
Interface Layout
The welcome banner shows your model, terminal backend, working directory, available tools, and installed skills at a glance.Status Bar
A persistent status bar sits above the input area, updating in real time:
A
~ before a context count or percentage means it includes a local estimate. This also applies to gateway /status and /context, the TUI, and the Desktop context gauge. An unchanged provider-usage reading has no ~; a provider anchor plus unpriced new messages does. /context reports the selected source. Category, free-space, skill, and toolset breakdowns are always local estimates, even when the overall occupancy comes from provider usage. These display labels do not change compaction decisions or make extra provider requests.
The bar adapts to terminal width — full layout at ≥ 76 columns, compact at 52–75, minimal (model + duration, plus the YOLO badge when active) below 52.
Context color coding:
Use
/usage for a detailed breakdown including per-category costs (input vs output tokens).
On the openai-codex provider, /usage also shows any banked usage-limit resets on your ChatGPT account (“You have N resets banked - use /usage reset to activate”). /usage reset redeems one banked reset, fully restoring your 5-hour and weekly limits. Mibyan refuses to redeem while your limits aren’t exhausted (a banked reset restores the full allowance, so spending it early wastes it) — pass /usage reset --force to redeem anyway.
Session Resume Display
When resuming a previous session (mibyan -c or mibyan --resume <id>), a “Previous Conversation” panel appears between the banner and the input prompt, showing a compact recap of the conversation history. See Sessions — Conversation Recap on Resume for details and configuration.
Keybindings
On macOS,F6/F7 mean the physical function keys, not the media/system controls shown on the top row. Hold Fn (the globe key on newer keyboards) while pressing the function key, or enable Use F1, F2, etc. keys as standard function keys in System Settings → Keyboard → Keyboard Shortcuts → Function Keys. The reliable terminal fallbacks are Ctrl+T for F6 and Ctrl+R for F7.
Multiline paste preview. When you paste a multi-line block, the CLI echoes a compact single-line preview (
[pasted: 47 lines, 1,842 chars — press Enter to send]) instead of dumping the whole payload into the scrollback. The full content is still what gets sent; this is just display polish.
! Shell Mode
Start a line with ! to run it as a shell command instead of sending it to the agent:
- Zero cost. The model is never invoked — no API call, no tokens, no latency.
- Nothing enters the conversation. The command and its output are not added to history, so your context stays clean and the prompt cache is untouched.
- Runs on your machine, in the session working directory. With the default local terminal backend
!pwdmatches what the agent would see. A remote or sandboxedterminal.backend(ssh,docker, …) is not used for!commands — they always run on the host where Mibyan itself runs, so!hostnamenames your machine while the agent’sterminaltool names the backend. Ask the agent (or open a shell on the target) to run something inside the backend. Path completion in the composer, by contrast, does follow the configured backend and lists the target’s filesystem. - Approvals still apply. A dangerous command (
rm -rf, writes to~/.mibyan/config.yaml, etc.) goes through the same approval prompt the agent’sterminaltool uses.!is a cost/latency shortcut, not a security bypass. - Non-zero exits are shown. A failing command prints
! exited <code>after its output. !on its own prints a one-line usage reminder.
**bold** / *italic* wrappers from final agent replies so they render as readable terminal prose rather than raw source. Code blocks and lists are preserved. This does not affect gateway platforms or tool results — they keep their markdown for native rendering.
Slash Commands
Type/ to see the autocomplete dropdown. Mibyan supports a large set of CLI slash commands, dynamic skill commands, and user-defined quick commands.
Common examples:
For the full built-in CLI and messaging lists, see Slash Commands Reference.
For setup, providers, silence tuning, and messaging/Discord voice usage, see Voice Mode.
Quick Commands
You can define custom commands that run shell commands instantly without invoking the LLM. These work in both the CLI and messaging platforms (Telegram, Discord, etc.)./status, /gpu, or /restart in any chat. See the Configuration guide for more examples.
Preloading Skills at Launch
If you already know which skills you want active for the session, pass them at launch time:Persistent auto-load via config
To have the same skills active at the start of every new session — CLI, TUI, gateway, cron and API sessions alike — setskills.auto_load in config.yaml:
-s names that overlap the list are loaded once.
--ignore-rules (equivalently mibyan_IGNORE_RULES=1) skips auto-load together with AGENTS.md, SOUL.md, .cursorrules and memory injection; explicit -s skills still load. The setting is profile-scoped: each profile’s config.yaml controls its own list.
Skill Slash Commands
Every installed skill in~/.mibyan/skills/ is automatically registered as a slash command. The skill name becomes the command:
Personalities
Set a predefined personality to change the agent’s tone:helpful, concise, technical, creative, teacher, kawaii, catgirl, pirate, shakespeare, surfer, noir, uwu, philosopher, hype.
To go back to the default (no overlay), use /personality none — default and neutral work too.
You can also define custom personalities in ~/.mibyan/config.yaml:
Multi-line Input
There are two ways to enter multi-line messages:Alt+Enter,Ctrl+J, orShift+Enter— inserts a new line- Backslash continuation — end a line with
\to continue:
Ctrl+J and backslash continuation are enabled by default, matching Claude Code / Codex / OpenCode multiline shortcuts. On supported terminals such as iTerm2, Mibyan also requests extended key reporting so Shift+Enter arrives as a distinct newline key. If your terminal sends LF for plain Enter and you need the legacy Ctrl+J-as-submit fallback, opt out:
Pasting multi-line text is supported — use any of the newline keys above, or simply paste content directly.In terminals using the Kitty keyboard protocol,
Alt+Enter on the numeric keypad also inserts a newline, including next to a collapsed paste. Modified keypad navigation keys follow their non-keypad equivalents.Shift+Enter compatibility
Most terminals send the same byte sequence forEnter and Shift+Enter by default, so applications cannot distinguish them. Mibyan recognises Shift+Enter only when the terminal sends a distinct sequence via the Kitty keyboard protocol or xterm’s modifyOtherKeys mode.
Where the terminal cannot distinguish them,
Alt+Enter and Ctrl+J continue to work by default. On Windows Terminal specifically, Alt+Enter is captured by the terminal (toggles fullscreen) and never reaches Mibyan — use Ctrl+Enter (delivered as Ctrl+J) or Ctrl+J directly for a newline.
Redirecting the Agent Mid-Turn
While the agent is working, you can send a correction without starting a new turn:- Type a new message + Enter — redirects the active turn using your correction
Ctrl+C— interrupt the current operation (press twice within 2s to force exit)- Completed tool work and reasoning already shown stay in context
- A running tool reaches its safe boundary before the correction is applied
Busy Input Mode
Thedisplay.busy_input_mode config key controls what happens when you press Enter while the agent is working:
"queue" mode prepares a separate follow-up turn. "steer" always waits for the next tool-result boundary. The default "interrupt" mode responds sooner during model generation while avoiding cancellation of a running tool; a long foreground terminal command (a build, a poller) is handed to the background so the agent sees your message right away instead of after the command exits. Use /stop when you want to cancel the turn and its foreground work. Unknown values fall back to "interrupt".
"steer" has two automatic fallbacks: if the agent hasn’t started yet, or if images are attached, the message falls back to "queue" behavior so nothing is lost.
Whatever the mode, /queue <prompt> queues a follow-up turn explicitly, and /queue list, /queue rm N, /queue edit N … and /queue move A B act on the pending queue immediately, even mid-run. The live work dock lists what is waiting.
You can also change it inside the CLI:
Suspending to Background
On Unix systems, pressCtrl+Z to suspend Mibyan to the background — just like any terminal process. The shell prints a confirmation:
fg in your shell to resume the session exactly where you left off. This is not supported on Windows.
Tool Progress Display
The CLI shows animated feedback as the agent works: Thinking animation (during API calls):/verbose: off → new → all → verbose. This command can also be enabled for messaging platforms — see configuration.
Tool Preview Length
Thedisplay.tool_preview_length config key controls the maximum number of characters shown in tool call preview lines (e.g. file paths, terminal commands). The default is 0, which means no limit — full paths and commands are shown.
Session Management
Resuming Sessions
When you exit a CLI session, a resume command is printed:/title My Session Name inside a chat to name the current session, or mibyan sessions rename <id> <title> from the command line. Use mibyan sessions list to browse past sessions.
Session Storage
CLI sessions are stored in Mibyan’s SQLite state database under~/.mibyan/state.db. The database keeps:
- session metadata (ID, title, timestamps, token counters)
- message history
- lineage across compressed/resumed sessions
- full-text search indexes used by
session_search
Context Compression
Long conversations are automatically summarized when approaching context limits:Background Sessions
Run a prompt in a separate background session while continuing to use the CLI for other work:How It Works
Each/bg prompt spawns a completely separate agent session in a daemon thread:
- Isolated conversation — the background agent has no knowledge of your current session’s history. It receives only the prompt you provide.
- Same configuration — the background agent inherits your model, provider, toolsets, reasoning settings, and fallback model from the current session.
- Non-blocking — your foreground session stays fully interactive. You can chat, run commands, or even start more background tasks.
- Multiple tasks — you can run several background tasks simultaneously. Each gets a numbered ID.
Results
When a background task finishes, the result appears as a panel in your terminal:display.bell_on_complete is enabled in your config, the terminal bell rings when the task finishes.
Use Cases
- Long-running research — “/bg research the latest developments in quantum error correction” while you work on code
- File processing — “/bg analyze all Python files in this repo and list any security issues” while you continue a conversation
- Parallel investigations — start multiple background tasks to explore different angles simultaneously
Background sessions do not appear in your main conversation history. They are standalone sessions with their own task ID (e.g.,
bg_143022_a1b2c3).Quiet Mode
By default, the CLI runs in quiet mode which:- Suppresses verbose logging from tools
- Enables kawaii-style animated feedback
- Keeps output clean and user-friendly

