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.
- agent-brain-plugin/AGENTS.mdAGENTS.md
- .github/workflows/AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .github/workflows/CLAUDE.mdCLAUDE.md
- mastering-python-skillSkill
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
- Very specific: line 34
IMPORTANT: Always use uv instead of pip for installing packages.
- Distinctive: line 119
Keep functions focused and testable
- Very specific: line 187
Check .gitignore excludes all sensitive files
- Common: line 188
Never generate or expose OpenAI/Anthropic API keys
- Distinctive: line 201
After ANY code changes — no matter how small — you MUST:
- Very specific: line 218
Use conventional commits: feat:, fix:, docs:, test:, refactor:
- Distinctive: line 219
Create feature branches from main
- Very specific: line 220
MANDATORY: Run task before-push before pushing to any branch — NEVER skip this
- Very specific: line 221
MANDATORY: Run task pr-qa-gate before creating PRs
- Very specific: line 227
Before using gh for releases, PRs, or other repository operations, verify the active account and switch if needed:
- Distinctive: line 244
No linting errors (Ruff)
- Distinctive: line 246
All tests pass with coverage report
- Distinctive: line 253
Always read files before editing to understand context
- Distinctive: line 254
Use atomic edits - prefer small, focused changes
- Distinctive: line 255
Create tests for new functionality
- Distinctive: line 258
All new code must have corresponding tests
- Distinctive: line 259
Run the full test suite before committing
≈ “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.
Files
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:
| Package | Path | Description |
| agent-brain-server | agent-brain-server/ | FastAPI REST API server |
| agent-brain-cli | agent-brain-cli/ | CLI management tool |
| agent-brain-skill | agent-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-reinstallBuild 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 codeagent-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 codeFull 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 pytestProject 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/ # DocumentationCode Style
Python Standards
- Formatter: Black (line length 88)
- Linter: Ruff
- Type Checker: mypy (strict mode)
- Type Hints: Required for all function signatures
Style Guidelines
- Use Google-style docstrings
- Sort imports with Ruff/isort
- Type hint all function parameters and returns
- Keep functions focused and testable
API Endpoints
| Endpoint | Method | Description |
/health | GET | Health check |
/health/status | GET | Indexing status |
/query | POST | Semantic search |
/query/count | GET | Document count |
/index | POST | Start indexing |
/index/add | POST | Add documents |
/index | DELETE | Clear index |
CLI Commands
Instance Commands
| Command | Description |
agent-brain init | Initialize project for Agent Brain |
agent-brain start | Start Agent Brain server |
agent-brain stop | Stop the running server |
agent-brain list | List all running instances |
Data Commands
| Command | Description |
agent-brain status | Check server status |
agent-brain query "text" | Search documents |
agent-brain index /path | Index documents (queued) |
agent-brain index /path --force | Index, bypass deduplication |
agent-brain reset --yes | Clear index |
Job Queue Commands
| Command | Description |
agent-brain jobs | List all jobs in queue |
agent-brain jobs --watch | Watch queue with live updates |
agent-brain jobs JOB_ID | Show job details |
agent-brain jobs JOB_ID --cancel | Cancel a job |
Environment Variables
Server (agent-brain-server/.env)
| Variable | Required | Default | Description |
OPENAI_API_KEY | Yes | - | OpenAI API key for embeddings |
ANTHROPIC_API_KEY | Yes | - | Anthropic API key for summarization |
EMBEDDING_MODEL | No | text-embedding-3-large | OpenAI embedding model |
CLAUDE_MODEL | No | claude-haiku-4-5-20251001 | Claude summarization model |
API_HOST | No | 127.0.0.1 | Server host |
API_PORT | No | 8000 | Server port |
DEBUG | No | false | Debug mode |
CLI
| Variable | Description |
DOC_SERVE_URL | Server URL (default: http://127.0.0.1:8000) |
Security Notes
- Never commit
.envfiles or API keys .env.examplefiles are safe to commit (no real keys)- Check
.gitignoreexcludes 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 PRThis 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-pushbefore pushing to any branch — NEVER skip this - MANDATORY: Run
task pr-qa-gatebefore creating PRs - PRs will fail CI if code coverage is below 50%
- If
task before-pushfails, 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 RichardHightowerPre-Push Requirement (MANDATORY — READ THIS)
NEVER PUSH CODE WITHOUT RUNNING task before-push FIRST.
task before-pushThis is a mandatory step that ensures:
- Code is properly formatted (Black)
- No linting errors (Ruff)
- Type checking passes (mypy)
- 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 pointagent-brain-server/agent_brain_server/config/settings.py- Configurationagent-brain-cli/agent_brain_cli/cli.py- CLI entry pointagent-brain-skill/doc-serve/SKILL.md- Skill definition
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
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.

