rb-setup

A first-time setup command for RepoBrain, a tool that lets an agent ask questions about a codebase and refresh its codebase knowledge. It configures either an API-key service or a local command-line agent that is already signed in.

In plain words
What is it for?
It helps create the project’s .env configuration, choose an OpenAI-compatible API provider, or connect Codex, Trae, Claude, or another headless command-line runner.
Why use it?
It removes the setup work needed before RepoBrain’s question and refresh commands can run.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/study8677/repobrain/rb-setup
Clone the repo
git clone --depth 1 https://github.com/study8677/repobrain
Per session 92 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,223 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00092 $0.03223
Opus 5 $0.00046 $0.01612
Sonnet 5 $0.00018 $0.00645
Haiku 4.5 $0.00009 $0.00322

Measured 2d ago against content hash 270def867e50, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rb-setup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/rb-setup.md · 194 lines

How it starts

The opening of the file, as written. The whole thing — 194 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are running first-time setup for the RepoBrain plugin. The user just installed the plugin and needs an LLM backend configured before the ask/refresh commands will work (/repobrain:rb-ask in Claude Code; /rb-ask in Codex CLI). There are two families of backends:

  1. API-key providers (OpenAI-compatible) — write OPENAI_* keys.
  2. Local host runners (no API key) — drive a headless CLI the user already has logged in (Codex, Trae, Claude, or any command that answers a prompt on stdin). This covers both rb-ask and rb-refresh: refresh runs its tool-free stages (module docs, map) through the host runner and automatically falls back to deterministic output for tool/handoff stages (conventions, git insights).

Goal: write a .env file at the current workspace root.

你正在执行 RepoBrain 插件的首次 setup。用户刚安装插件,需要先配置一个 LLM 后端,ask/refresh 命令才能正常工作(Claude Code 内为 /repobrain:rb-ask;Codex CLI 内为 /rb-ask)。后端分两类:

  1. API-key 提供商(OpenAI 兼容)—— 写入 OPENAI_* 配置。
  2. 本地 host runner(无需 API key)—— 驱动用户本机已登录的无头 CLI(Codex、Trae、Claude,或任意能在命令行吃 prompt、吐文本的命令)。这条路同时支持 rb-ask rb-refresh:refresh 的无工具阶段(module 文档、map)走 host runner,工具/handoff 阶段(conventions、git insights)会自动降级为确定性产物。

目标是在当前工作区根目录写入 .env 文件。

Step 1 — Detect existing config / 步骤 1 —— 检测已有配置

Read .env at the workspace root if it exists. If OPENAI_API_KEY or RB_HOST_RUNNER is already set, ask the user whether to overwrite the RepoBrain LLM/host-runner keys. If they say no, confirm "already configured" and stop.

如果工作区根目录已有 .env,先读取它。如果已经设置了 OPENAI_API_KEYRB_HOST_RUNNER,询问用户是否覆盖 RepoBrain 的 LLM/host-runner 配置。若用户选择不覆盖,确认“already configured / 已配置”并停止。

Step 2 — Ask which backend (use AskUserQuestion) / 步骤 2 —— 询问后端(使用 AskUserQuestion)

First, detect which local headless CLIs are available so you only offer runners that can actually work. Run these checks (ignore ones that error):

先探测本机可用的无头 CLI,只向用户提供真正能用的 runner。运行以下检查(报错的忽略即可):

  • command -v codex and, if present, codex login status
  • command -v trae-cli and, if present, trae-cli login status
  • command -v claude (Claude Code; logged-in state is implicit)
  • command -v gemini, command -v ollama

Read the full file on GitHub · 194 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 194 lines · 92 tokens per session scan A 270def867e50

Subscribe to this mod's changes

rb-setup is a command published in the GitHub repository study8677/repobrain (1,321 stars, last pushed 4d ago), licensed MIT. It adds 92 tokens to every session and 3,223 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.