BharatCode

Usage

TUI & Slash Commands

Running bharatcode with no arguments launches the interactive terminal UI. Inside it you talk to the agent in plain language and steer the session with slash commands — switch models, branch sessions, review diffs, set a budget, or hand the agent an autonomous goal, all without leaving the keyboard.

Starting the TUI

With no arguments, bharatcode opens the terminal UI in your current directory. Type a request, hit enter, and the agent reads files, runs tools, and proposes edits — pausing for your approval according to the current permission mode.

terminalbash
bharatcode

To pick up where you left off instead of starting empty, resume the most recent session straight from the shell:

terminalbash
bharatcode --continue

Headless mode

Everything below lives inside the interactive UI. If you want to script the agent — in CI, a Makefile, or a one-off — use bharatcode run "<prompt>" instead. See the CLI reference for run and its flags.

Command reference

Slash commands are typed at the prompt inside the TUI. Type / to start one; /help lists every command and key binding. Here is the full set at a glance:

CommandWhat it does
/helpList commands and key bindings.
/keysShow keyboard shortcuts.
/clearClear the screen and start a fresh context.
/sessionsBrowse and restore a past session.
/tabOpen or switch between session tabs.
/tabsList the open session tabs.
/compactSummarize older turns to shrink the context.
/forkBranch the current session into a new one.
/diffShow the latest edit diff.
/revertUndo this session's file changes.
/exportWrite the transcript to a file (md or html).
/copyCopy the last reply or whole chat to the clipboard.
/searchFind a term in the current chat.
/statusShow model, session, and spend status.
/mcpList MCP servers and their connection state.
/planRestrict to read-only tools and propose a plan.
/approveExit plan mode and re-enable execution.
/modelSwitch the active model.
/agentSwitch the active agent.
/goalSet, run, clear, or stop a bounded autonomous goal.
/permissionsSet the approval mode: read-only, auto, or full.
/budgetView the cost ledger and monthly budget.
/themeShow or switch the color theme.
/yoloBypass approvals for this session.
/saveSave the current session.
/quitExit the TUI.

The sections below describe each command in turn. A handful of areas have their own deep-dive pages — autonomous goals, sessions and forking, and permissions — and are summarized here with a link to the full treatment.

Session basics

/help

Lists the available slash commands along with key bindings. Start here when you forget the name of a command or want to see what the UI can do.

/clear

Clears the conversation and starts a fresh context. Use it when you finish one task and want to begin another without the previous conversation influencing the agent — it gives you a clean slate without quitting and relaunching.

/keys

Shows the keyboard shortcuts for the TUI. Pass an optional filter — /keys <filter> — to narrow the list when you are hunting for a specific binding.

/status

Shows the current session at a glance — the active model and agent, the approval mode in effect, and where the session stands. It is the quickest way to confirm what BharatCode is about to do before you send a prompt.

Finds a term in the current chat — /search <term> — so you can jump back to an earlier answer or command without scrolling the whole transcript.

/quit

Exits the TUI. Your session history is preserved and can be reopened later with /sessions or bharatcode --continue.

Model & agent

/model

Opens the model picker so you can switch the active model mid-session. The list is drawn from the providers in your config — the same set you see from bharatcode models. Switch to a cheaper open-weight model for routine edits and a stronger one for hard problems without restarting. See Providers & Models for how the catalogue is defined.

/agent

Switches the active agent for the session. Use it to move between the agent personas available in your configuration without leaving the TUI.

/mcp

Lists the configured MCP (Model Context Protocol) servers and their connection state, so you can confirm an external tool server is wired up and reachable from the current session.

Sessions & history

/sessions

Browse your past sessions and restore one to continue the conversation where it ended. This is the in-TUI counterpart to launching with bharatcode --continue, except you choose which session to reopen rather than always taking the latest. For the full story on how sessions are stored and resumed, see Sessions & Fork.

/fork

Branches the current session into a new one. Forking lets you explore an alternative approach from a known-good point — the original session stays intact, so you can try something risky in the branch and come back if it does not pan out. The Sessions & Fork page covers branching in depth.

/save

Saves the current session so you can return to it later via /sessions.

/tab & /tabs

Work on more than one session side by side. /tab opens or switches session tabs — it takes an action argument, /tab [new|next|prev|close|N], to open a fresh tab, cycle between tabs, close the current one, or jump to tab N. /tabs lists the tabs you have open.

/compact

Summarizes older turns to shrink the context window while keeping the thread going. Reach for it on a long session that is filling the context budget — it condenses earlier history so newer turns have room, without starting over the way /clear does.

Reviewing changes

/diff

Shows the diffs for the agent's recent edits, so you can review exactly what changed before moving on or committing. It is the fastest way to audit a multi-file edit without switching to a separate Git tool.

/revert

Undoes this session's file changes, restoring the files it touched to their pre-session state — the in-TUI counterpart to bharatcode revert. It takes an action argument: bare /revert previews the changes, /revert apply performs the undo, and /revert force also reverts files that were modified outside the session.

/export

Writes the session transcript to a file so you can keep or share a run. Choose the format with the argument — /export [md|html] — for a Markdown or HTML copy of the conversation.

/copy

Copies session output to your clipboard. /copy [last|all] grabs either the agent's most recent reply or the entire chat, so you can paste an answer straight into a PR, issue, or message.

Autonomy & control

/goal

Hands the agent a goal and lets it iterate autonomously within bounds. /goal takes a sub-command:

  • /goal set <goal> — define the goal to pursue.
  • /goal run — start the autonomous loop, iterating toward the goal.
  • /goal stop — halt the loop while keeping the goal set.
  • /goal clear — clear the current goal.

Because the iteration is bounded, the agent works toward the goal in a contained loop rather than running open-ended. The /goal Autonomous Mode page walks through the workflow end to end.

/plan

Enters plan mode: BharatCode is restricted to read-only tools and, rather than editing, proposes a plan of what it intends to do. Use it to let the agent investigate and lay out an approach before any changes are made — nothing is written while plan mode is active.

/approve

Exits plan mode and re-enables execution, so the agent can act on the plan it proposed. It is the natural follow-up to /plan once you are happy with the proposed approach.

/permissions

Sets the approval mode that governs how much the agent can do on its own. There are three modes:

  • read-only — the agent can inspect your project but cannot make changes without approval.
  • auto — routine actions proceed automatically while riskier ones still ask.
  • full — the agent acts without pausing for per-action approval.

Approval modes sit on top of BharatCode's ask/allow/deny permission system. See Permissions for how rules, scopes, and modes fit together.

/yolo

Bypasses approval prompts for the session — the in-TUI equivalent of launching with the --yolo flag. It is fast but unguarded, so reach for it only on throwaway work or when you fully trust the task.

Use with care

/yolo removes the approval gate, so the agent can edit files and run commands without asking. Prefer /permissions auto when you want speed but still want a check on the riskiest actions.

Cost control

/budget

Shows the cost ledger and your monthly budget. BharatCode tracks spend in INR-aware terms and gates against a monthly limit, so /budget is where you check how much a session is costing and how much of the month's budget remains.

Appearance

/theme

Shows or switches the color theme of the TUI — /theme [dark|light|high-contrast]. Run it bare to see the current theme, or pass a name to switch, including a high-contrast option for readability.

Custom Markdown prompts

Beyond the built-ins, you can define your own slash commands as Markdown files. Drop a file at ~/.bharatcode/prompts/<name>.md and it becomes available in the TUI as /<name>. The file's contents are the prompt sent to the agent, with two kinds of placeholder interpolated at call time:

  • {{input}} — replaced by everything you type after the command name.
  • {{var}} — a named placeholder you can reference anywhere in the prompt body.

For example, create a reusable code-review command. The file name becomes the command name — review.md /review:

~/.bharatcode/prompts/review.mdmarkdown
Review the following changes for correctness, security, and clarity. Focus area: {{focus}} Pay special attention to error handling and edge cases, then list anyissues you find as a short, prioritized checklist. Changes to review:{{input}}

Invoke it from the TUI like any built-in command. Everything after /review fills {{input}}:

bharatcode TUItext
/review the diff in internal/auth/session.go

Project-wide prompts

Because prompts are just Markdown files, you can keep a shared library in your dotfiles or check team conventions into AGENTS.md and a prompt registry, so everyone runs the same /review or /explain flow.