agentleFS
MicrosoftKnown publishermicrosoft/aibast-agents-library/rapp_brainstem/CLAUDE.md

aibast-agents-library / rapp_brainstem

CLAUDE.md8 starsChanged 3 months agoMITView on GitHub

RAPP Brainstem is a local-first AI agent server. It's a Flask app that proxies conversation through the GitHub Copilot API with automatic tool-calling via user-defined agents. Single dependency: a GitHub account with Copilot access. Runs on port 7071. Philosophy: "engine, not experience" — infrastructure only, no opinionated UI or workflows (see CONSTITUTION.md). No build step, linter, or type checker is configured. Entry point: brainstem.py — a single-file Flask server (~2,000 lines) that handles auth, chat, agent orchestration, and the web…

  • Reads credentials
  • Installs packages

We split this CLAUDE.md into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No build step, linter, or type checker is configured.

    line 28
  2. Distinctive:

    Call GitHub Copilot API with system prompt + conversation history + tools

    line 37
  3. Very specific:

    If the LLM returns tool calls, execute agent .perform() methods and loop (up to 3 rounds)

    line 38
  4. Very specific:

    Use self.metadata["description"] to tell the LLM when to invoke the agent

    line 69

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

RAPP Brainstem is a local-first AI agent server. It's a Flask app that proxies conversation through the GitHub Copilot API with automatic tool-calling via user-defined agents. Single dependency: a GitHub account with Copilot access. Runs on port 7071.

Philosophy: "engine, not experience" — infrastructure only, no opinionated UI or workflows (see CONSTITUTION.md).

Commands

# Start server
./start.sh                # macOS/Linux (creates venv, installs deps, runs)
python brainstem.py       # Direct run (assumes deps installed)

# Install dependencies
python3 -m pip install -r requirements-dev.txt

# Run all tests
python3 -m pytest tests -v

# Run a single test
python3 -m pytest tests/test_local_agents.py::TestLocalStorage::test_write_and_read -v

No build step, linter, or type checker is configured.

Architecture

Entry point: brainstem.py — a single-file Flask server (~2,000 lines) that handles auth, chat, agent orchestration, and the web UI.

Request flow (POST /chat):

  1. Load soul.md (system prompt) and fresh-discover agents from agents/
  2. Build OpenAI-format tool definitions from agent metadata
  3. Call GitHub Copilot API with system prompt + conversation history + tools
  4. If the LLM returns tool calls, execute agent .perform() methods and loop (up to 3 rounds)
  5. Return final response + agent_logs

Agent system:

  • Auto-discovered via glob agents/*_agent.py (flat directory only — agents/experimental/ is intentionally excluded)
  • Each agent is a Python class extending BasicAgent with metadata (OpenAI function schema) and perform(**kwargs) method
  • Optional system_context() injects text into the system prompt every turn
  • Agents are reloaded from disk on every request — edit and test without restart
  • Missing pip dependencies are auto-installed at import time

Local storage shim (local_storage.py): Agents import from utils.azure_file_storage import AzureFileStorageManager — brainstem intercepts via sys.modules and provides a local JSON-file implementation under .brainstem_data/. This enables transparent migration to Azure later.

Auth chain: GITHUB_TOKEN env var → .copilot_token file (device-code OAuth) → gh auth token CLI. The GitHub token is exchanged for a short-lived Copilot API token, cached in .copilot_session with auto-refresh.

Key Files

FilePurpose
brainstem.pyMain server: all routes, agent loading, Copilot API integration
agents/basic_agent.pyBase class for all agents
local_storage.pyLocal shim for Azure File Storage
soul.mdDefault system prompt loaded every request
index.htmlBuilt-in web UI served at /
VERSIONSemantic version string (currently 0.6.14)
CONSTITUTION.mdGovernance doc defining what belongs in this repo

Writing Agents

Agents must:

  • Live in agents/ with filename matching *_agent.py
  • Define a class extending BasicAgent with metadata dict (OpenAI function-calling schema) and perform(**kwargs) returning a string
  • Use self.metadata["description"] to tell the LLM when to invoke the agent

The agents/experimental/ subdirectory exists for agents that should not be auto-loaded.

Environment

Configuration via .env (auto-created from .env.example by start.sh):

  • GITHUB_TOKEN — auto-detected from gh CLI if blank
  • GITHUB_MODEL — default auto (auto-selects the highest Claude Haiku the account can use — fastest responses — else the highest Sonnet, else gpt-4o); or pin a specific id. A UI pick is persisted to .brainstem_model and overrides this. Switchable at runtime via /models/set (auto re-selects)
  • SOUL_PATH, AGENTS_PATH, PORT, VOICE_MODE

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.