Local-first AI codebase memory and graph intelligence system.
Project description
BrainGraph
Local-first codebase graph memory for AI-assisted development.
BrainGraph helps developers and AI coding tools understand a repository without reading everything blindly. It scans your project, builds a graph of files and relationships, stores compact memory, and returns focused context for tasks like auth flow tracing, routing analysis, dependency understanding, and system explanations.
What BrainGraph Does
- Scans your repository locally
- Detects functions, classes, imports, routes, components, and relationships
- Builds a graph you can inspect and query
- Writes summaries and diagnostics automatically
- Gives AI tools smaller, better, more relevant context
Visual Overview
flowchart LR
A[Project Folder] --> B[BrainGraph Scan]
B --> C[Parser]
C --> D[Graph]
C --> E[Summaries]
C --> F[Memory]
D --> G[graph.json]
D --> H[graph.html]
E --> I[BRAIN_REPORT.md]
F --> J[query / explain]
flowchart TD
A[Task or AI prompt] --> B[braingraph query]
B --> C[Relevant files]
C --> D[Compact context]
D --> E[Less token waste]
D --> F[Better AI grounding]
Step-by-Step Setup Guide
1. Prerequisites
Make sure Python is available in your terminal:
python --version
BrainGraph is designed for Python 3.12+.
2. Install BrainGraph
Once BrainGraph is published, users should install it directly with pip:
python -m pip install braingraph
Optional vector backend:
python -m pip install "braingraph[vector]"
Verify installation:
braingraph --help
braingraph version
Upgrade later:
python -m pip install --upgrade braingraph
3. Platform-Specific Setup
BrainGraph works best when installed in the same environment your terminal or AI tool can access.
Windows
If python works in terminal, then:
python -m pip install braingraph
If python does not work
Try:
py -m pip install braingraph
4. Run BrainGraph on Your Codebase
If you are already inside your project folder:
braingraph .
Or explicitly initialize it:
braingraph init .
This generates:
braingraph-out/
├── graph.json
├── graph.html
├── BRAIN_REPORT.md
├── summaries/
├── memory.db
├── embeddings.db
├── cache/
└── integrations/
Run BrainGraph on another project location
braingraph "C:\Users\YourName\Desktop\MyProject"
Folder path with spaces
braingraph "C:\Users\YourName\Desktop\Client Project\Frontend App"
5. Make BrainGraph Always Available to AI
BrainGraph can generate project-local instruction files for coding assistants so they use BrainGraph first before broad repo reads.
Codex
braingraph codex install .
Claude Code
braingraph claude install .
Cursor
braingraph cursor install .
Gemini CLI
braingraph gemini install .
GitHub Copilot
braingraph copilot install .
Files BrainGraph creates for AI tools
.codex/braingraph.md.claude/commands/brainGraph.md.cursor/rules/braingraph.mdc.gemini/commands/brainGraph.md.github/instructions/braingraph.instructions.md
6. Ignore Unnecessary Files
BrainGraph already ignores common noise such as:
.gitnode_modulesdistbuild- cache folders
- virtual environments
- generated BrainGraph output
That keeps scans cleaner and retrieval more useful.
7. Query Your Graph
After scanning, ask BrainGraph for focused context.
Query relevant files
braingraph query "auth flow"
Explain a system
braingraph explain "routing system"
Show repository stats
braingraph stats
Run diagnostics
braingraph doctor
Export graph again
braingraph graph
Refresh after changes
braingraph update .
Watch a project for changes
braingraph watch . --seconds 30
8. Give Context to the Agent
This is the recommended workflow for AI tools.
Instead of:
Read the full repo and explain authentication
Use:
Run braingraph query "authentication flow" first, then use only the returned files.
Good BrainGraph-first AI workflow
- Run
braingraph query "<task>" - Read only the returned files
- Use
braingraph explain "<system>"for compact understanding - Use
braingraph path "<file A>" "<file B>"for relationship tracing - Re-run
braingraph update .after major refactors
Example prompts for AI workflows
Run braingraph query "login flow" and explain the returned files.
Use braingraph explain "routing system" before reading controllers manually.
Run braingraph path "login.tsx" "auth.py" and explain how they are connected.
9. How to Give Project Location Explicitly
Some commands accept a project argument directly, and some use --project.
Direct project path commands
braingraph "C:\Projects\MyApp"
braingraph init "C:\Projects\MyApp"
braingraph update "C:\Projects\MyApp"
braingraph watch "C:\Projects\MyApp" --seconds 20
Use --project for query/explain/stats/doctor/graph
braingraph query "payment flow" --project "C:\Projects\MyApp"
braingraph explain "order pipeline" --project "C:\Projects\MyApp"
braingraph stats --project "C:\Projects\MyApp"
braingraph doctor --project "C:\Projects\MyApp"
10. What BrainGraph Detects
BrainGraph currently focuses on practical repo understanding:
- Python functions and classes
- JavaScript and TypeScript functions
- React-style components
- imports and dependency-like links
- route-like patterns
- duplicate files by content
- circular imports
- weak or dead files
- syntax issues in broken files
11. Reference Commands
braingraph install
braingraph init .
braingraph .
braingraph version
braingraph query "show auth flow"
braingraph explain "routing system"
braingraph path "login.tsx" "auth.py"
braingraph stats
braingraph graph
braingraph doctor
braingraph update .
braingraph watch . --seconds 10
braingraph clear --yes
12. Typical End-to-End Flow
python -m pip install braingraph
braingraph "C:\Users\YourName\Desktop\MyProject"
braingraph query "auth flow" --project "C:\Users\YourName\Desktop\MyProject"
braingraph explain "routing system" --project "C:\Users\YourName\Desktop\MyProject"
braingraph doctor --project "C:\Users\YourName\Desktop\MyProject"
13. Why This Helps in Real AI Work
Without BrainGraph:
- AI reads too many files
- token usage increases
- context gets noisy
- architecture understanding becomes slower
With BrainGraph:
- context is filtered
- relevant files are surfaced faster
- prompts stay smaller
- AI gets better structure before reasoning
14. Notes for Contributors
This section is only for contributors, not end users.
Run tests
python -m pytest -q
Local editable install
python -m venv .venv
.venv\Scripts\activate
python -m pip install -e .
python -m pip install -e ".[dev]"
15. Credits
Built and prepared by Mohd.Kaif with team ClarusCodix.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file braingraph-0.1.1.tar.gz.
File metadata
- Download URL: braingraph-0.1.1.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbcd124fe470fc706e8c1af7dc5fb2a0bc501d0dd3ec6af0914dc887776c9a7f
|
|
| MD5 |
eb3ce8443f5581c9fcc339b14829e0e2
|
|
| BLAKE2b-256 |
77fd364f9c8d045a77ad8a423794dd9f61a067205c618cf3ce91ed888c4d447f
|
Provenance
The following attestation bundles were made for braingraph-0.1.1.tar.gz:
Publisher:
python-publish.yml on Dislike12/BrainGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
braingraph-0.1.1.tar.gz -
Subject digest:
cbcd124fe470fc706e8c1af7dc5fb2a0bc501d0dd3ec6af0914dc887776c9a7f - Sigstore transparency entry: 1349605854
- Sigstore integration time:
-
Permalink:
Dislike12/BrainGraph@d44440f115f1332bbdb30c731af1541ed599aa9b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Dislike12
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d44440f115f1332bbdb30c731af1541ed599aa9b -
Trigger Event:
push
-
Statement type:
File details
Details for the file braingraph-0.1.1-py3-none-any.whl.
File metadata
- Download URL: braingraph-0.1.1-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63b7b5fdacf39788e5f6a543ab8d9627b908c878b6c3c5f53af96741bcb038d7
|
|
| MD5 |
b84ae77bf6e00fcaea20510401038b2d
|
|
| BLAKE2b-256 |
08291d9da3951ebfa0b1ff00578056faff72af19744ffad9160bca96d1ac8acc
|
Provenance
The following attestation bundles were made for braingraph-0.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on Dislike12/BrainGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
braingraph-0.1.1-py3-none-any.whl -
Subject digest:
63b7b5fdacf39788e5f6a543ab8d9627b908c878b6c3c5f53af96741bcb038d7 - Sigstore transparency entry: 1349605919
- Sigstore integration time:
-
Permalink:
Dislike12/BrainGraph@d44440f115f1332bbdb30c731af1541ed599aa9b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Dislike12
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d44440f115f1332bbdb30c731af1541ed599aa9b -
Trigger Event:
push
-
Statement type: