agentleFS
SpillwaveSolutionsSpillwaveSolutions/agent-brain/AGENTS.md

agent-brain

AGENTS.md120 starsChanged 6 months agoMITView on GitHub

Instructions for AI agents (Cursor, Windsurf, OpenCode, etc.) when working on this repository. Planning rule: after any planning step, save the plan to docs/plans/<name>.md before doing work. Agent Brain is a RAG-based document indexing and semantic search system. It's a monorepo containing: IMPORTANT: Always use uv instead of pip for installing packages. It's faster and handles dependencies better.

  • Reads credentials
  • Installs packages
  • Commits and pushes
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository6 other files it gives its agents.

The file

Show its rules and text

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

17 rules. About 1 is common, 10 are distinctive, and 6 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    IMPORTANT: Always use uv instead of pip for installing packages.

    line 34
  2. Distinctive:

    Keep functions focused and testable

    line 119
  3. Very specific:

    Check .gitignore excludes all sensitive files

    line 187
  4. Common:

    Never generate or expose OpenAI/Anthropic API keys

    line 188
  5. Distinctive:

    After ANY code changes — no matter how small — you MUST:

    line 201
  6. Very specific:

    Use conventional commits: feat:, fix:, docs:, test:, refactor:

    line 218
  7. Distinctive:

    Create feature branches from main

    line 219
  8. Very specific:

    MANDATORY: Run task before-push before pushing to any branch — NEVER skip this

    line 220
  9. Very specific:

    MANDATORY: Run task pr-qa-gate before creating PRs

    line 221
  10. Very specific:

    Before using gh for releases, PRs, or other repository operations, verify the active account and switch if needed:

    line 227
  11. Distinctive:

    No linting errors (Ruff)

    line 244
  12. Distinctive:

    All tests pass with coverage report

    line 246
  13. Distinctive:

    Always read files before editing to understand context

    line 253
  14. Distinctive:

    Use atomic edits - prefer small, focused changes

    line 254
  15. Distinctive:

    Create tests for new functionality

    line 255
  16. Distinctive:

    All new code must have corresponding tests

    line 258
  17. Distinctive:

    Run the full test suite before committing

    line 259

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.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
AGENTS.md

Agent Brain Agent Guidelines

Instructions for AI agents (Cursor, Windsurf, OpenCode, etc.) when working on this repository.

Planning rule: after any planning step, save the plan to docs/plans/<name>.md before doing work.

Project Overview

Agent Brain is a RAG-based document indexing and semantic search system. It's a monorepo containing:

PackagePathDescription
agent-brain-serveragent-brain-server/FastAPI REST API server
agent-brain-cliagent-brain-cli/CLI management tool
agent-brain-skillagent-brain-skill/Claude Code skill

Technology Stack

  • Python: 3.10+
  • Build System: Poetry
  • Package Installer: uv (preferred over pip)
  • Server: FastAPI + Uvicorn
  • CLI: Click + Rich
  • Vector Store: ChromaDB
  • Embeddings: OpenAI text-embedding-3-large
  • Indexing: LlamaIndex

Package Installation

IMPORTANT: Always use uv instead of pip for installing packages. It's faster and handles dependencies better.

# Build packages
cd agent-brain-server && poetry build
cd agent-brain-cli && poetry build

# Install with uv (NOT pip)
uv pip install dist/agent_brain_rag-*.whl --force-reinstall
uv pip install dist/agent_brain_cli-*.whl --force-reinstall

Build and Test Commands

agent-brain-server

cd agent-brain-server
poetry install                    # Install dependencies
poetry run agent-brain-serve      # Run server
poetry run pytest                 # Run tests
poetry run pytest --cov=agent_brain_server       # Tests with coverage
poetry run mypy agent_brain_server               # Type checking
poetry run ruff check agent_brain_server         # Linting
poetry run black agent_brain_server              # Format code

agent-brain-cli

cd agent-brain-cli
poetry install                    # Install dependencies
poetry run agent-brain --help     # Show CLI help
poetry run pytest                 # Run tests
poetry run mypy agent_brain_cli               # Type checking
poetry run ruff check agent_brain_cli         # Linting
poetry run black agent_brain_cli              # Format code

Full Quality Check

# Run from package directory
poetry run black agent_brain_server tests && poetry run ruff check agent_brain_server tests && poetry run mypy agent_brain_server && poetry run pytest

Project Structure

doc-serve/
├── agent-brain-server/           # FastAPI server
│   ├── agent_brain_server/           # FastAPI server
│   │   ├── api/                # REST endpoints
│   │   │   ├── main.py         # App entry point
│   │   │   └── routers/        # Route handlers
│   │   ├── config/             # Settings (Pydantic)
│   │   ├── indexing/           # Document processing
│   │   ├── models/             # Request/response models
│   │   ├── services/           # Business logic
│   │   └── storage/            # ChromaDB integration
│   └── tests/
├── agent-brain-cli/                # CLI tool
│   ├── agent_brain_cli/           # CLI package
│   │   ├── cli.py              # Main entry point
│   │   ├── client/             # API client
│   │   └── commands/           # CLI commands
│   └── tests/
├── agent-brain-skill/            # Claude skill
│   └── doc-serve/
│       └── SKILL.md
└── docs/                       # Documentation

Code Style

Python Standards

  • Formatter: Black (line length 88)
  • Linter: Ruff
  • Type Checker: mypy (strict mode)
  • Type Hints: Required for all function signatures

Style Guidelines

  1. Use Google-style docstrings
  2. Sort imports with Ruff/isort
  3. Type hint all function parameters and returns
  4. Keep functions focused and testable

API Endpoints

EndpointMethodDescription
/healthGETHealth check
/health/statusGETIndexing status
/queryPOSTSemantic search
/query/countGETDocument count
/indexPOSTStart indexing
/index/addPOSTAdd documents
/indexDELETEClear index

CLI Commands

Instance Commands

CommandDescription
agent-brain initInitialize project for Agent Brain
agent-brain startStart Agent Brain server
agent-brain stopStop the running server
agent-brain listList all running instances

Data Commands

CommandDescription
agent-brain statusCheck server status
agent-brain query "text"Search documents
agent-brain index /pathIndex documents (queued)
agent-brain index /path --forceIndex, bypass deduplication
agent-brain reset --yesClear index

Job Queue Commands

CommandDescription
agent-brain jobsList all jobs in queue
agent-brain jobs --watchWatch queue with live updates
agent-brain jobs JOB_IDShow job details
agent-brain jobs JOB_ID --cancelCancel a job

Environment Variables

Server (agent-brain-server/.env)

VariableRequiredDefaultDescription
OPENAI_API_KEYYes-OpenAI API key for embeddings
ANTHROPIC_API_KEYYes-Anthropic API key for summarization
EMBEDDING_MODELNotext-embedding-3-largeOpenAI embedding model
CLAUDE_MODELNoclaude-haiku-4-5-20251001Claude summarization model
API_HOSTNo127.0.0.1Server host
API_PORTNo8000Server port
DEBUGNofalseDebug mode

CLI

VariableDescription
DOC_SERVE_URLServer URL (default: http://127.0.0.1:8000)

Security Notes

  • Never commit .env files or API keys
  • .env.example files are safe to commit (no real keys)
  • Check .gitignore excludes all sensitive files
  • Never generate or expose OpenAI/Anthropic API keys

Documentation

  • User Guide - End-user documentation
  • Developer Guide - Development setup
  • API Reference - Full API docs
  • Original Spec - Project specification

Quality Assurance

NEVER PUSH WITHOUT TESTING. NEVER. NOT EVEN "JUST A SMALL CHANGE".

After ANY code changes — no matter how small — you MUST:

task before-push    # MUST pass before ANY push
task pr-qa-gate     # MUST pass before ANY PR

This runs format, lint, typecheck, and tests with coverage.

MANDATORY: You MUST run task before-push and verify exit code 0 before EVERY git push. No exceptions.

MANDATORY: Any feature or task is not considered done unless task pr-qa-gate passes successfully.

If it fails, FIX IT. Then run it again. Only push when it passes.

Git Workflow

  • Use conventional commits: feat:, fix:, docs:, test:, refactor:
  • Create feature branches from main
  • MANDATORY: Run task before-push before pushing to any branch — NEVER skip this
  • MANDATORY: Run task pr-qa-gate before creating PRs
  • PRs will fail CI if code coverage is below 50%
  • If task before-push fails, DO NOT push. Fix first, test again, then push.

GitHub Auth

Before using gh for releases, PRs, or other repository operations, verify the active account and switch if needed:

gh auth status
gh auth switch --user RichardHightower

Pre-Push Requirement (MANDATORY — READ THIS)

NEVER PUSH CODE WITHOUT RUNNING task before-push FIRST.

task before-push

This is a mandatory step that ensures:

  1. Code is properly formatted (Black)
  2. No linting errors (Ruff)
  3. Type checking passes (mypy)
  4. All tests pass with coverage report

If it fails, FIX IT. Then run it again. Only push when it passes.

Agent-Specific Notes

File Operations

  • Always read files before editing to understand context
  • Use atomic edits - prefer small, focused changes
  • Create tests for new functionality

Testing Requirements

  • All new code must have corresponding tests
  • Run the full test suite before committing
  • Maintain or improve code coverage (minimum 50%)

Key Files to Understand

  • agent-brain-server/agent_brain_server/api/main.py - Server entry point
  • agent-brain-server/agent_brain_server/config/settings.py - Configuration
  • agent-brain-cli/agent_brain_cli/cli.py - CLI entry point
  • agent-brain-skill/doc-serve/SKILL.md - Skill definition

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.