BharatCode โ an open, sovereign terminal AI coding agent. OpenCode for India. Local-first, your code stays in India.
Rust
1
38 commits
updated Sep 12, 2026
A local-first, Apache-2.0, Rust terminal AI coding agent โ built for India.
BharatCode is a terminal-native AI coding agent that runs on your machine and, by default, talks to a local model instead of a cloud API. It is engineered for developers who want data residency, predictable cost in rupees, and a tool that defaults to keeping work on-device โ without giving up a modern agentic coding experience.
BharatCode is currently built from source. You need a recent Rust toolchain
(rustup + cargo; the repo pins a toolchain via rust-toolchain.toml).
# from the repo root
cargo build -p bharatcode-cli --no-default-features --features portable-default
This produces the bharatcode binary:
./target/debug/bharatcode --help
./target/debug/bharatcode --version
Notes:
portable-default feature set is the light build: it drops heavy native
in-process inference engines (llama.cpp / candle / mlx), code-mode, and the
system keyring so the CLI builds quickly and runs anywhere. A plain
cargo build uses the default features and pulls those engines in.bharatcode
with no provider configured โ it will target your local Ollama by default.# 1) (recommended) run a local model
ollama pull qwen2.5-coder # or any coding model you prefer
# 2) start BharatCode in your project
bharatcode
# first run walks you through setup; "Local model โ Ollama (Recommended)"
# is offered first, so you can stay fully on-device.
Handy commands:
bharatcode # interactive session in the current directory
bharatcode tui # terminal UI (launches the ui/text artifact)
bharatcode presets # list the India / open-weight model presets
bharatcode cost # INR spend ledger (per session / day / month)
bharatcode git # read-only summary of the current git repo
bharatcode recipes-library # curated recipe templates for Indian dev workflows
bharatcode doctor # environment + BharatCode settings summary
bharatcode configure # providers, models, and onboarding
Everything below is actually built and wired in this repository. Features that are opt-in / default OFF are marked with the environment variable that turns them on.
apply_patch file-editing tool โ a streaming patch parser/applier in the
bharatcode-apply-patch crate, wired into the developer toolset as the apply_patch
tool.bharatcode cost, with a compact โน figure in the session footer. USDโINR rate is
configurable with BHARATCODE_USD_INR; day/month buckets use IST.sarvam and krutrim providers plus a
presets module / bharatcode presets listing and a "Recommended (India /
open-weight)" first-run choice (local Qwen-Coder / DeepSeek via Ollama; hosted
Sarvam / Krutrim / Qwen / DeepSeek).bharatcode recipes-library ships curated templates
(e.g. UPI review, Aadhaar/PII + DPDP audit, GST helper, Indic localization).bharatcode git โ a concise, read-only repo summary (branch, status,
ahead/behind, recent commits).bharatcode doctor โ environment checks plus a read-only summary of the active
BharatCode settings (residency mode, budget, USDโINR rate, offline, etc.).BHARATCODE_THEME (tiranga / bharat / india); honors NO_COLOR, and when
unset the output is byte-identical to the default theme.BHARATCODE_LANG โ config โ
LANG โ en) with embedded en.json / hi.json and a tr!() helper. A starter
set of high-traffic strings is translated to Hindi today; English output is
unchanged. This is a scaffold, not a complete Hindi UI.BHARATCODE_SANDBOX โ in-process Linux exec sandbox (landlock + seccomp) applied
to shell commands. Modes: read-only / workspace-write (default off). Linux-only;
a no-op stub elsewhere.BHARATCODE_EXEC_POLICY โ path to a JSON allow/deny policy that gates shell
commands (a hardened, clean-room exec policy).BHARATCODE_RESIDENCY (+ BHARATCODE_RESIDENCY_ALLOWLIST) โ data-residency
egress guard that can block requests to non-allowlisted (e.g. non-India) endpoints.
Wired centrally so it screens every provider.BHARATCODE_OFFLINE โ a single switch that composes local-only egress +
residency + telemetry-off for an offline/no-egress posture.BHARATCODE_BUDGET_INR (+ BHARATCODE_BUDGET_MODE = warn default / deny) โ
an INR spend cap that warns near the cap and, in deny mode, refuses to start the
next model turn once exceeded.BHARATCODE_COST_ROUTING โ cost-aware routing that prefers cheaper / local
models for the lead model when enabled.BHARATCODE_VERIFY โ verify-before-done: runs your project's test/build and
reports Verified / Failed / Skipped before finalizing.BHARATCODE_CACHE โ on-disk prompt/response cache (SHA-256 keyed) wired into the
streaming path; a hit short-circuits to a zero-cost stream.BHARATCODE_RETRY_* โ retry/backoff tuning (BHARATCODE_RETRY_MAX,
BHARATCODE_RETRY_BASE_MS, BHARATCODE_RETRY_MAX_MS) applied centrally so all
providers honor it.BHARATCODE_CODEBASE_CONTEXT โ a bounded, gitignore-respecting codebase
scanner (RAG-lite) that builds a compact repo layout/manifest blob.BHARATCODE_KEYS / BHARATCODE_CLI_NEWLINE_KEY โ customizable interactive
keybindings (built-in defaults reproduced when unset).BHARATCODE_APPROVAL โ approval-mode selection (chat / ask / auto / full) with a
safe default when unset.Heads-up on honesty: the i18n layer is a scaffold (starter Hindi strings only). The sandbox is Linux-only and off by default. Cost routing, prompt cache, retry, residency, offline, budget, exec-policy, verify, and codebase context are all off unless you set their environment variable. None of these change default behavior until you opt in.
BharatCode reads its configuration from ~/.config/bharatcode/ and from
BHARATCODE_* environment variables (the env namespace was rebranded throughout).
Common ones:
| Variable | Effect |
|---|---|
BHARATCODE_PROVIDER / BHARATCODE_MODEL | Override the active provider / model |
BHARATCODE_LANG | UI language (en, hi) |
BHARATCODE_THEME | tiranga / bharat / india for the Tiranga palette |
BHARATCODE_USD_INR | USDโINR rate for the cost ledger |
BHARATCODE_OFFLINE | Local-only / no-egress posture |
BHARATCODE_RESIDENCY | Egress residency guard |
BHARATCODE_SANDBOX | read-only / workspace-write exec sandbox (Linux) |
See the per-feature notes above for the full opt-in set.
Apache License 2.0 โ see LICENSE.
38 commits
Rust
95.3%
Python
1.1%
HTML
1.1%
Shell
1.0%
BharatCode โ an open, sovereign terminal AI coding agent. OpenCode for India. Local-first, your code stays in India.
Rust
1
38 commits
updated Sep 12, 2026
A local-first, Apache-2.0, Rust terminal AI coding agent โ built for India.
BharatCode is a terminal-native AI coding agent that runs on your machine and, by default, talks to a local model instead of a cloud API. It is engineered for developers who want data residency, predictable cost in rupees, and a tool that defaults to keeping work on-device โ without giving up a modern agentic coding experience.
BharatCode is currently built from source. You need a recent Rust toolchain
(rustup + cargo; the repo pins a toolchain via rust-toolchain.toml).
# from the repo root
cargo build -p bharatcode-cli --no-default-features --features portable-default
This produces the bharatcode binary:
./target/debug/bharatcode --help
./target/debug/bharatcode --version
Notes:
portable-default feature set is the light build: it drops heavy native
in-process inference engines (llama.cpp / candle / mlx), code-mode, and the
system keyring so the CLI builds quickly and runs anywhere. A plain
cargo build uses the default features and pulls those engines in.bharatcode
with no provider configured โ it will target your local Ollama by default.# 1) (recommended) run a local model
ollama pull qwen2.5-coder # or any coding model you prefer
# 2) start BharatCode in your project
bharatcode
# first run walks you through setup; "Local model โ Ollama (Recommended)"
# is offered first, so you can stay fully on-device.
Handy commands:
bharatcode # interactive session in the current directory
bharatcode tui # terminal UI (launches the ui/text artifact)
bharatcode presets # list the India / open-weight model presets
bharatcode cost # INR spend ledger (per session / day / month)
bharatcode git # read-only summary of the current git repo
bharatcode recipes-library # curated recipe templates for Indian dev workflows
bharatcode doctor # environment + BharatCode settings summary
bharatcode configure # providers, models, and onboarding
Everything below is actually built and wired in this repository. Features that are opt-in / default OFF are marked with the environment variable that turns them on.
apply_patch file-editing tool โ a streaming patch parser/applier in the
bharatcode-apply-patch crate, wired into the developer toolset as the apply_patch
tool.bharatcode cost, with a compact โน figure in the session footer. USDโINR rate is
configurable with BHARATCODE_USD_INR; day/month buckets use IST.sarvam and krutrim providers plus a
presets module / bharatcode presets listing and a "Recommended (India /
open-weight)" first-run choice (local Qwen-Coder / DeepSeek via Ollama; hosted
Sarvam / Krutrim / Qwen / DeepSeek).bharatcode recipes-library ships curated templates
(e.g. UPI review, Aadhaar/PII + DPDP audit, GST helper, Indic localization).bharatcode git โ a concise, read-only repo summary (branch, status,
ahead/behind, recent commits).bharatcode doctor โ environment checks plus a read-only summary of the active
BharatCode settings (residency mode, budget, USDโINR rate, offline, etc.).BHARATCODE_THEME (tiranga / bharat / india); honors NO_COLOR, and when
unset the output is byte-identical to the default theme.BHARATCODE_LANG โ config โ
LANG โ en) with embedded en.json / hi.json and a tr!() helper. A starter
set of high-traffic strings is translated to Hindi today; English output is
unchanged. This is a scaffold, not a complete Hindi UI.BHARATCODE_SANDBOX โ in-process Linux exec sandbox (landlock + seccomp) applied
to shell commands. Modes: read-only / workspace-write (default off). Linux-only;
a no-op stub elsewhere.BHARATCODE_EXEC_POLICY โ path to a JSON allow/deny policy that gates shell
commands (a hardened, clean-room exec policy).BHARATCODE_RESIDENCY (+ BHARATCODE_RESIDENCY_ALLOWLIST) โ data-residency
egress guard that can block requests to non-allowlisted (e.g. non-India) endpoints.
Wired centrally so it screens every provider.BHARATCODE_OFFLINE โ a single switch that composes local-only egress +
residency + telemetry-off for an offline/no-egress posture.BHARATCODE_BUDGET_INR (+ BHARATCODE_BUDGET_MODE = warn default / deny) โ
an INR spend cap that warns near the cap and, in deny mode, refuses to start the
next model turn once exceeded.BHARATCODE_COST_ROUTING โ cost-aware routing that prefers cheaper / local
models for the lead model when enabled.BHARATCODE_VERIFY โ verify-before-done: runs your project's test/build and
reports Verified / Failed / Skipped before finalizing.BHARATCODE_CACHE โ on-disk prompt/response cache (SHA-256 keyed) wired into the
streaming path; a hit short-circuits to a zero-cost stream.BHARATCODE_RETRY_* โ retry/backoff tuning (BHARATCODE_RETRY_MAX,
BHARATCODE_RETRY_BASE_MS, BHARATCODE_RETRY_MAX_MS) applied centrally so all
providers honor it.BHARATCODE_CODEBASE_CONTEXT โ a bounded, gitignore-respecting codebase
scanner (RAG-lite) that builds a compact repo layout/manifest blob.BHARATCODE_KEYS / BHARATCODE_CLI_NEWLINE_KEY โ customizable interactive
keybindings (built-in defaults reproduced when unset).BHARATCODE_APPROVAL โ approval-mode selection (chat / ask / auto / full) with a
safe default when unset.Heads-up on honesty: the i18n layer is a scaffold (starter Hindi strings only). The sandbox is Linux-only and off by default. Cost routing, prompt cache, retry, residency, offline, budget, exec-policy, verify, and codebase context are all off unless you set their environment variable. None of these change default behavior until you opt in.
BharatCode reads its configuration from ~/.config/bharatcode/ and from
BHARATCODE_* environment variables (the env namespace was rebranded throughout).
Common ones:
| Variable | Effect |
|---|---|
BHARATCODE_PROVIDER / BHARATCODE_MODEL | Override the active provider / model |
BHARATCODE_LANG | UI language (en, hi) |
BHARATCODE_THEME | tiranga / bharat / india for the Tiranga palette |
BHARATCODE_USD_INR | USDโINR rate for the cost ledger |
BHARATCODE_OFFLINE | Local-only / no-egress posture |
BHARATCODE_RESIDENCY | Egress residency guard |
BHARATCODE_SANDBOX | read-only / workspace-write exec sandbox (Linux) |
See the per-feature notes above for the full opt-in set.
Apache License 2.0 โ see LICENSE.
38 commits
Rust
95.3%
Python
1.1%
HTML
1.1%
Shell
1.0%