Skip to main content

Local-first developer intelligence CLI for semantic repository analysis and Git diff understanding.

Project description

๐Ÿง  project-brain

Local-first developer intelligence CLI for semantic repository analysis, Git-aware code understanding, and AI-friendly engineering workflows.

Python CLI License Status Tests PyPI Production


๐Ÿš€ What is project-brain?

project-brain is a CLI-first developer intelligence tool built for analyzing codebases, tracking Git changes at function level, generating structured exports for AI systems, and explaining code changes using optional LLM integrations.

Unlike traditional Git tooling that operates on raw line diffs, project-brain uses AST-based parsing to understand code structure and produce developer-friendly insights.

The project is designed around a local-first, privacy-friendly, and AI-optional workflow.


๐ŸŽฏ Why project-brain Exists

Modern development workflows suffer from several problems:

Git diffs are noisy

Traditional diffs show line changes, not semantic meaning.

A small refactor can generate large diffs while hiding the actual behavioral impact.


Codebases become difficult to understand

Large repositories contain:

  • deeply nested modules
  • duplicated logic
  • unclear ownership
  • hidden dependencies

Understanding them manually is slow.


AI tools require structured context

Most AI systems perform poorly when fed raw repositories.

project-brain creates:

  • structured exports
  • focused change sets
  • function-level intelligence
  • AI-friendly context

โœจ Features

Implemented

  • ๐Ÿ” Recursive repository scanning
  • ๐Ÿง  AST-based Python analysis
  • ๐Ÿงฉ Function extraction
  • ๐Ÿ›๏ธ Class extraction
  • ๐Ÿ”„ Git diff parsing
  • ๐Ÿ“Œ Function-level change tracking
  • ๐Ÿ“ฆ AI-friendly code export system
  • ๐Ÿค– Optional LLM explanations
  • ๐Ÿ’พ Explanation caching
  • ๐ŸŒ HTML diff reports
  • โš ๏ธ Config validation
  • ๐Ÿฉบ Environment diagnostics
  • ๐Ÿชต Persistent logging
  • ๐Ÿšซ Binary file skipping
  • ๐Ÿ›ก๏ธ Invalid Python safety handling
  • โšก Deep directory traversal

โš™๏ธ Installation

Requirements

  • Python >= 3.10

  • Git installed

  • Optional:

    • Ollama
    • OpenAI API access
    • Gemini API access
    • HuggingFace API access

Install from PyPI

pip install project-brain-cli

Verify Installation

brain --version

Upgrade

pip install --upgrade project-brain-cli

CLI Aliases

Both commands work:

brain
project-brain

โšก Quick Start (30 Seconds), For More INFO Click


1. Initialize project-brain

brain project init

Demo:

Creates:

.brain/
brain.yaml

2. Analyze Repository

brain project analyze .

Demo:

Performs:

  • recursive scan
  • AST parsing
  • metadata generation

Stores results inside:

.brain/data.json

3. Inspect Git Changes

brain diff show

Demo:

Default behavior:

HEAD~1 โ†’ HEAD

Shows:

  • modified files
  • added files
  • deleted files
  • function-level changes

4. Export AI-Friendly Context

brain export full-code

Demo:

Creates:

.brain/exports/full_code.txt

5. Diagnostics

Validate project readiness:

brain project doctor

Demo:

Checks:

  • git availability
  • project initialization
  • analysis freshness
  • export availability
  • provider configuration
  • API key presence

6. Access Community Resources

brain community

Demo:

Open feedback/discussions directly:

brain --feedback

๐Ÿงช LLM Commands


brain testllm test

Test provider connectivity.

Syntax

brain testllm test

What It Does

  • loads provider config
  • sends test prompt
  • validates response
  • optionally fetches model list

Disabled Mode

If:

provider: none

Output:

LLM disabled

โš™๏ธ Configuration

Configuration file:

brain.yaml

Example Configuration

version: "1.1.0"

llm:
  provider: none
  model: ""
  timeout_sec: 60

analysis:
  depth: fast
  include_tests: false

  ignore:
    - .brain/
    - .git/
    - node_modules/
    - venv/
    - .venv/
    - __pycache__/
    - env/
    - .env/
    - project_brain_cli.egg-info/
    - tests/
    - test/

diff:
  mode: function

export:
  full_code:
    include_tests: false
    max_file_size_kb: 200

  manual_add:
    allow_duplicates: true

  changes:
    mode: function
    include_context: true
    output_path: .brain/exports/code_changes.txt

  ignore:
    - .brain/
    - .git/
    - node_modules/
    - venv/
    - .venv/
    - __pycache__/
    - env/
    - .env/
    - project_brain_cli.egg-info/
    - tests/
    - test/

explain:
  level: detailed
  include_risks: true

output:
  format: text

๐Ÿ”‘ API Key Setup

Secrets should NEVER be stored inside brain.yaml.


Windows CMD

setx OPENAI_API_KEY "your_key"
setx GEMINI_API_KEY "your_key"
setx HUGGINGFACE_API_KEY "your_key"

PowerShell

[Environment]::SetEnvironmentVariable("OPENAI_API_KEY","your_key","User")

Linux/macOS

export OPENAI_API_KEY="your_key"

๐Ÿ“ด Offline Mode

project-brain fully supports offline workflows.

Use:

llm:
  provider: none

Behavior:

  • no API calls
  • no cloud dependency
  • local-only analysis
  • fallback explanations enabled

๐Ÿ“„ Example Outputs


Analysis

๐Ÿ” Analyzing: .

๐Ÿ“‹ File Paths:
src/api.py
src/utils.py

โœ… Analysis complete

Diff Review

Function: create_user

Change:
Added validation layer

Impact:
Improves input integrity

Risk:
medium

๐Ÿ—๏ธ Architecture

CLI Layer
โ”‚
โ”œโ”€โ”€ Analyzer Engine
โ”œโ”€โ”€ Diff Engine
โ”œโ”€โ”€ Explain Engine
โ”œโ”€โ”€ Export Engine
โ”œโ”€โ”€ Diagnostics Layer
โ”œโ”€โ”€ Config Validation
โ”œโ”€โ”€ Logging System
โ””โ”€โ”€ LLM Provider Layer

๐Ÿ”„ Supported Providers

Provider Supported
OpenAI โœ…
Ollama โœ…
Gemini โœ…
HuggingFace โœ…
Offline Mode โœ…

๐Ÿชต Logging System

Logs stored inside:

.brain/logs.txt

Tracks:

  • warnings
  • provider failures
  • parsing errors
  • export failures
  • cache issues

Logging failures never crash the CLI.


๐Ÿ› ๏ธ Troubleshooting


โŒ Not a git repository

Initialize git:

git init

โŒ Invalid git reference

Check refs:

git log --oneline

โŒ Empty export

Possible causes:

  • ignored paths
  • file size limits
  • tests excluded

โŒ Provider failures

Check:

  • API keys
  • internet connectivity
  • provider model name

โŒ Missing API key

Verify environment variable:

echo %OPENAI_API_KEY%

๐Ÿงช Testing & QA

Current QA status:

  • 18 automated tests passing
  • export validation
  • function diff validation
  • config validation
  • edge-case handling
  • provider fallback testing

๐Ÿ”ฎ Roadmap

Near-Term

  • semantic diff intelligence
  • integration tests
  • incremental analysis
  • performance improvements
  • rename detection

Mid-Term

  • multi-language parsing
  • plugin architecture
  • dependency graphing
  • richer semantic indexing

๐Ÿ” Security & Privacy

project-brain is designed with a local-first philosophy.

Key principles:

  • no automatic code uploads
  • offline workflows supported
  • API keys via environment variables only
  • repository data stored locally

LLM usage is fully optional.


๐Ÿค Contributing

Contributions are welcome.

Recommended workflow:

git checkout -b feature/my-feature

Guidelines:

  • keep PRs focused
  • preserve CLI consistency
  • add tests for new logic
  • avoid unnecessary dependencies

๐Ÿ“œ License

MIT License


๐Ÿง  Final Positioning

project-brain is a local-first developer intelligence CLI that transforms repositories and Git diffs into structured, explainable engineering context.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

project_brain_cli-1.1.1.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

project_brain_cli-1.1.1-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file project_brain_cli-1.1.1.tar.gz.

File metadata

  • Download URL: project_brain_cli-1.1.1.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for project_brain_cli-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a4d4416be8ddfe829aaefba91d7595f332046b13692dfe67734e1c6cd470f16e
MD5 b4d5d55c8ad145c2c11c729ee6a92869
BLAKE2b-256 a1605f1cc78ae388d2c1e7be94fa15a25cce72e171305b2c67e09207225d8a2a

See more details on using hashes here.

File details

Details for the file project_brain_cli-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for project_brain_cli-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87a4f3e8d66b7dd51ba204f213121247a3a630fce4e13eb4b0bf0cf19cdc5086
MD5 1a192e8c12e7da4b74873f11b2147c02
BLAKE2b-256 14aad5a080dc728bf4c5e0cc745635341bbebbecbda795657c63b4d35c848bcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page