Reference

Reference


Environment Variables

All variables are optional unless noted. This list reflects the Bahulam CLI runtime environment.

Bahulam runtime

VariableDescription
BAHULAM_HOMEOverride the Bahulam config directory (default: ~/.bahulam)
BAHULAM_CONFIG_DIRAlias for BAHULAM_HOME; config directory override
BAHULAM_TOKENAuth token — used in CI/CD and headless pipelines
BAHULAM_PRODUCTAdvanced compatibility override for product routing; normal CLI runs use Bahulam
BAHULAM_MISSIONOptional mission tag persisted with the session
BAHULAM_NO_PREFLIGHTSkip the onboarding diagnostic on startup (1 / true)
BAHULAM_STATUS_BARToggle the status bar (1 / 0)
BAHULAM_SCRATCH_ROOTSComma-separated writable roots outside the CWD
BAHULAM_PROMPT_BOTTOM_PADDINGBlank rows below the prompt (default 1)
BAHULAM_LONG_RUNNING_TIMEOUT_MSOverride the long-running-tool cutoff
BAHULAM_STAGNATION_DETECTION / BAHULAM_STAGNATION_THRESHOLDTune stagnation heuristics
BAHULAM_TTY_MODEScrollback-safe transcript mode; set to stable if fixed-dock redraws leak on your terminal
TARANG_ENVSelect backend environment: local, treetop, production (default)
TARANG_VERBOSEEnable verbose mode (1)
TARANG_YESAuto-approve all approval prompts (1)
KEPLER_CONFIG_DIRLegacy alias for config directory override
KEPLER_RECONNECT_MAX_ELAPSED_MSMax reconnect window for dropped streams (default 300000)
KEPLER_BLOCK_SEPARATORTool/content separator style: space, dotted, off (default space)

Local browser workspace

VariableDescription
BAHULAM_LIBREOFFICE_PATHPreferred path to the local LibreOffice soffice executable for DOCX/PPTX/ODT/ODP conversion previews
LIBREOFFICE_PATHCompatibility fallback for BAHULAM_LIBREOFFICE_PATH
BAHULAM_LOCAL_SAVE_MAX_BYTESMaximum text-backed file size the browser workspace can save (default 2 MB)
BAHULAM_LOCAL_SAVE_MAX_BODY_BYTESMaximum browser save request body size
BAHULAM_LOCAL_UPLOAD_MAX_BODY_BYTESMaximum browser upload request body size (default 140 MB)

Model provider keys (BYOK)

VariableDescription
ANTHROPIC_API_KEYAnthropic direct access
ANTHROPIC_MODELDefault Anthropic model ID
OPENAI_API_KEYOpenAI direct access
OPENAI_BASE_URLOverride the OpenAI-compatible endpoint (e.g. self-hosted vLLM)
OPENROUTER_API_KEYOpenRouter (multi-provider routing)
GEMINI_API_KEY / GOOGLE_API_KEYGoogle Gemini access
BRAVE_API_KEYBrave Search (used by the web-search tool)

Logging & debugging

VariableDescription
DEBUGNamespace-scoped debug logging (e.g. DEBUG=bahulam:*)
MCP_DEBUGVerbose MCP-transport logging
NO_COLORDisable ANSI colour output

Advanced / rare

VariableDescription
AGENT_IDIdentifies sub-agent processes (set automatically)
CLAUDE_CODE_PERMISSION_MODELegacy compatibility fallback for --permission-mode
CLAUDE_CODE_MAX_CONTEXT_TOKENS / CLAUDE_CODE_MAX_OUTPUT_TOKENSLegacy compatibility model I/O caps
CLAUDE_CODE_STREAMING / CLAUDE_CODE_THINKINGLegacy compatibility feature toggles
CLAUDE_CODE_ENABLE_TASKSEnable the built-in task manager
CLAUDE_CODE_DISABLE_CRON / CLAUDE_CODE_DISABLE_TELEMETRYOpt-outs
CLAUDE_CODE_SUBAGENT_MODELLegacy compatibility override for the model used by sub-agents

Files on Disk

~/.bahulam/ (Global Config)

PathPurpose
~/.bahulam/authCached authentication token
~/.bahulam/config.jsonGlobal preferences (default model, theme, etc.)
~/.bahulam/keys/Encrypted API keys for BYOK providers
~/.bahulam/skills/User-global installed skills
~/.bahulam/projects/Per-project metadata
~/.bahulam/history.jsonlCross-session prompt history
~/.bahulam/state.jsonCurrent session metadata
~/.bahulam/local-service/sessions/Local browser workspace session metadata
~/.bahulam/local-service/previews/Cached local PDF previews generated from Office documents

.bahulam/ (Project-Local)

Run bahulam init in a project to scaffold this folder. Bahulam may also create runtime files in .bahulam/ as sessions run.

PathPurpose
.bahulam/BAHULAM.mdBahulam project memory loaded into context
.bahulam/settings.jsonProject settings, environment entries, permissions, and hook configuration
.bahulam/settings.local.jsonGitignored local override for personal settings
.bahulam/config.jsonProject policy for context loading, planning, tasks, HITL, and command defaults
.bahulam/project.mdAdditional durable project notes
.bahulam/style.mdCode style and communication conventions
.bahulam/hitl.mdHuman-in-the-loop approval guidance
.bahulam/trust.jsonProject trust rules used by approval handling
.bahulam/tasks/backlog.mdDeferred work
.bahulam/tasks/active.mdCurrent work in progress
.bahulam/tasks/blocked.mdWork waiting on input or external state
.bahulam/tasks/done.mdCompleted work
.bahulam/agents/Project-local sub-agent YAML definitions
.bahulam/skills/Project-local skill bundles
.bahulam/commands/Project-local command templates as they become available
.bahulam/approvals.logRuntime approval decision log
.bahulam/sessions/Runtime session transcripts
.bahulam/reports/Runtime mission/report artifacts
.bahulam/index/Runtime code-search index cache

Keyboard Shortcuts

Bahulam’s REPL uses standard terminal keybindings plus a few extras.

ShortcutAction
EscCancel current execution
SpacePause / resume execution
↑ / ↓Navigate command history
Ctrl+CCancel current operation / exit
Ctrl+DExit REPL (same as /quit)
Ctrl+LClear terminal screen
Ctrl+RSearch command history (reverse)
TabAuto-complete commands and file paths
Ctrl+UClear current input line
Ctrl+WDelete word before cursor
Ctrl+AMove cursor to beginning of line
Ctrl+EMove cursor to end of line

Exit Codes

CodeMeaning
0Success — no errors
1General error — check stderr
2Authentication error — session expired or invalid
3Configuration error — missing or invalid config
4Model error — model not found or unavailable
5Credit error — insufficient credits

Permission Modes

Set with --permission-mode <mode> to control approval behavior.

ModeDescription
bypassPermissionsNo approval prompts — all tool calls proceed
acceptEditsAuto-approve file edits, prompt for shell commands
planBlock all write operations — read-only planning mode
autoUse tier-based defaults (see risk tiers below)
dontAskNever prompt — reject anything not auto-approved

Risk Tiers

Every tool call is classified into one of eight tiers.

TierBehaviorExamples
readAuto — proceeds silentlyread_file, search_code, grep
sensitive-readPrompt requiredReading .env, *.pem, secrets/**
local-editAuto with checkpointedit_file, write_file
shell-safeAuto — proceeds silentlyls, cat, pwd, git status
shell-mediumPrompt safe (Enter=approve)npm install, git add, pip install
shell-dangerousPrompt explicit (must type y)rm -rf, chmod -R, sudo
destructivePrompt explicit (must type y)delete_file
networkPrompt safe (Enter=approve)curl, wget, git clone

Resume Modes

When resuming a session with --resume, Bahulam selects a strategy based on context window size and conversation length.

StrategyBehavior
fullSend the entire conversation transcript
summarySend only a summary of the previous conversation
summary+tail-10Summary + last 10 messages
summary+tail-20Summary + last 20 messages

Event Types

The SSE stream between Bahulam and the backend emits these event types:

EventDirectionDescription
contentBackend → CLIFull assistant message
content_partialBackend → CLIStreaming text delta
tool_callBackend → CLITool invocation request
tool_resultCLI → BackendTool execution result
sub_agentBackend → CLIDelegated agent completion, including tool counts and success
errorEitherError event
completeBackend → CLISession complete
timeoutCLI → BackendSession timeout
startCLI → BackendSession start

Tool Catalog

Bahulam has 25+ built-in tools. The agent selects and invokes them automatically based on the task.

File I/O

ToolDescription
read_fileRead a file with line ranges
read_filesRead multiple files at once
write_fileCreate or overwrite a file
write_projectWrite multiple files at once
edit_fileSearch-and-replace edit
multi_editMulti-file edits
delete_fileDelete a file
lsList directory contents
ToolDescription
search_codeSemantic search across project code
search_filesRegex search across files
grepFast regex search (ripgrep)
globPattern-based file search
analyze_codeGet structured analysis of a file
get_project_overviewGet project structure overview
get_file_infoGet file metadata

Shell

ToolDescription
bashRun shell commands
tool_searchSearch available tools

Git

ToolDescription
git_statusShow git status
git_diffShow git diff

Web

ToolDescription
web_fetchFetch URLs
web_searchSearch the web

Agent

ToolDescription
exploreSpawn read-only code explorer
planSpawn planning agent
verifySpawn verification agent
debugSpawn debugging agent
refactorSpawn bounded refactor agent
delegateDelegate to a built-in or user-defined sub-agent
agent_createCreate a project-local sub-agent YAML template
agent_syncOptionally publish project-local agent YAML to the backend

Skills

ToolDescription
skillExecute a skill
skills_listList available skills
skill_viewView a skill’s details

MCP (Model Context Protocol)

ToolDescription
read_mcp_resourceRead MCP resources
mcpMCP tool calls

Scheduling

ToolDescription
cron_createCreate a cron job
cron_deleteDelete a cron job
cron_listList cron jobs

Other

ToolDescription
ask_userAsk the user a question
send_messageSend a message
enter_worktreeEnter a worktree
exit_worktreeExit a worktree
notebook_editEdit Jupyter notebooks
todo_writeWrite task items
lspLanguage server protocol
remote_triggerRemote trigger

File Structure for the Bahulam NPM Package

bahulam/
├── bin/
│   └── cli.js            # Entry point for the `bahulam` command
├── src/
│   ├── terminal/
│   │   ├── main.mjs      # CLI entry, subcommand dispatch
│   │   ├── repl.mjs      # REPL loop, command parsing
│   │   ├── agents.mjs    # Built-in agent definitions (explore, review, architect)
│   │   ├── analytics.mjs # Sessions, stats, history subcommands
│   │   ├── init.mjs      # `bahulam init` — scaffold .bahulam/
│   │   └── skills.mjs    # `bahulam skills` — skill management
│   ├── agents/           # Agent team orchestration
│   ├── auth/             # Browser auth flow (bahulam.ai) + config
│   ├── config/           # CLI args, env, settings, memory, hooks
│   ├── context/          # AST parser, BM25 retriever, skeleton, symbol indexer
│   ├── core/             # Central logic (30+ modules)
│   ├── hooks/            # Hook engine
│   ├── local-service/    # Local browser workspace service, file previews, and browser relay
│   ├── mcp/              # MCP client + transports (SSE, WebSocket, SHTTP)
│   ├── onboarding/       # Preflight diagnostics
│   ├── permissions/      # Command classifier, injection check, path check, sandbox
│   ├── plugins/          # Plugin loader
│   ├── skills/           # Skill installer, loader, runner
│   ├── state/            # Orbit state, verbosity
│   ├── telemetry/        # Telemetry index
│   ├── tools/            # 25+ built-in tool implementations
│   └── ui/               # Approval, banner, commands, dock, formatter, icons
└── package.json

Data Flow

Terminal CLI

┌──────────────┐     ┌──────────────────┐     ┌──────────────────┐
│  Terminal     │────▶│  Bahulam CLI      │────▶│  API Gateway     │
│  (REPL)       │     │  (Agent)         │     │  (Platform)      │
└──────────────┘     └────────┬─────────┘     └────────┬─────────┘
                              │                        │
                              ▼                        ▼
                       ┌──────────────┐       ┌──────────────────┐
                       │  Sub-Agents   │       │  Bahulam Gateway │
                       │  Built-in     │──────▶│  Platform/BYOK   │
                       │  User YAML    │       └────────┬─────────┘
                       └──────────────┘                ▼
                                              ┌──────────────────┐
                                              │  Model Providers │
                                              │  OpenRouter etc. │
                                              └──────────────────┘
  1. You type a request in the REPL
  2. Bahulam builds the primary workspace agent from runtime config
  3. If needed, the primary agent delegates to built-in or user-defined sub-agents
  4. The orchestrator generates code changes via tool calls
  5. Each tool call is classified by risk tier and approved accordingly
  6. Changes are applied to your files
  7. Results are reported back in the terminal

Local browser workspace

┌──────────────┐     ┌──────────────────┐     ┌──────────────────────┐
│  Browser      │────▶│  Local Service    │────▶│  CLI-authenticated   │
│  127.0.0.1    │     │  127.0.0.1        │     │  remote agent path   │
└──────────────┘     └────────┬─────────┘     └──────────┬───────────┘
                              │                          │
                              ▼                          ▼
                       ┌──────────────┐         ┌──────────────────┐
                       │ Local files   │         │ Bahulam Gateway  │
                       │ previews/tools│         │ model routing    │
                       └──────────────┘         └──────────────────┘
  1. You run bahulam workspace open [path]
  2. The CLI starts a localhost service and opens a tokenized browser URL
  3. The browser reads the selected local root through the service
  4. Chat turns are sent through the CLI-authenticated remote agent path
  5. Tool calls execute locally against the granted root
  6. Files, previews, trace events, approvals, and chat updates stream back to the browser

Glossary

TermDefinition
BM25Best Matching 25 — text retrieval algorithm used for project indexing
BYOKBring Your Own Key — use your own API key instead of the platform default
BYOMBring Your Own Model — connect a custom model endpoint
CheckpointA save point recorded before auto-approved edits, enabling undo
CreditUnit of billing on the platform default plan
ExplorerSub-agent that reads files and searches code (read-only)
Full autopilotMode that skips approval prompts while hard safety blocks still apply
GatewayBahulam model routing layer for platform and BYOK calls
HeadlessNon-interactive mode for automation and benchmarks
HITLHuman-in-the-loop — review-and-confirm workflow
Local browser workspaceBrowser UI served by the CLI on 127.0.0.1 for local files, chat, previews, tool trace, uploads, and approvals
MCPModel Context Protocol — connect external tools and data sources
OrchestratorThe main agent that coordinates sub-agents and tool calls
PlannerSub-agent that designs architecture and implementation approach
REPLRead-Eval-Print Loop — Bahulam’s interactive terminal interface
ResumeContinue a previous session with context preservation
SkillA portable SKILL.md bundle with instructions and references
Sub-agentA specialized agent (explorer, planner, etc.) that handles a specific role
TrustAuto-approval granted for a specific tool from a specific agent in a session