brocode is a lightweight coding assistant in CLI
Project description
BroCode
Goal
BroCode is a study of agentic workflow and AI agents framework designed to solve coding problems. It's model-agnostic and aims to work with all files in a repository like Claude, Amazon Q Developer, and other AI coding tools. Future versions will include code acceptance/rejection capabilities.
Overview
A CLI tool for managing and running LLM-based chat agents with support for multiple model backends. BroCode uses an agentic workflow system that combines code generation, chat capabilities, and codebase analysis in an interactive flow.
Installation
Use this:
pip install brocode
Or this:
uv add brocode
Quick Start
- Register a model:
brocode register --path mylocal.py --model llama3.2-11b --default
- Start chatting:
brocode start
Commands
Register Models
Register LLM models from Python files:
# Register and set as default
brocode register --path mylocal.py --model mymodel --default
# Register with auto-generated name
brocode register --path mylocal.py
Start Chat
Start interactive chat sessions:
# Use default model
brocode start
# Use specific model
brocode start --llm mymodel
Model Management
# List registered models
brocode model list
# Remove models interactively
brocode model remove
Creating Custom Models
Create a Python file with your LLM class:
# mylocal.py
from brollm import BaseLLM, BedrockChat
from brocode.register import register_llm
@register_llm("llama3.2-11b")
class MyLocalLLM(BedrockChat):
def __init__(self):
super().__init__(model_name="us.meta.llama3-2-11b-instruct-v1:0")
How BroCode Works
When you run brocode start, BroCode creates a brosession directory in your current location and initiates an agentic workflow with two main modes:
BroSession Directory Structure
BroCode organizes all session-related files in a brosession directory:
your-project/
├── brosession/
│ ├── brocode_config.yaml # Model configurations
│ ├── session.db # Session data
│ └── prompt_hub/ # Customizable prompts
│ ├── chat.md # Chat assistant persona
│ └── code_generator.md # Code generation guidelines
└── your-code-files...
Session Management
- Per-Directory Sessions: Each directory gets its own
brosessionwith independent configurations - Customizable Prompts: Edit files in
brosession/prompt_hub/to customize AI behavior - Portable Sessions: Move or copy
brosessionfolders to share configurations - Easy Cleanup: Delete
brosessionfolder to reset everything
Workflow Overview
[Start] → [Setup BroSession] → [User Input] → [Route Decision]
↓
┌─────────────────┐
↓ ↓
[Code Mode] [Chat Mode]
↓ ↓
[Code Generator] [Chat Agent]
↓ ↓
└─────────────────┘
↓
[Back to User Input]
Interactive Commands
-
/code- Enter code generation mode- Prompts for coding task description
- Optionally analyze existing codebase for context
- Choose output format (terminal display or save to file)
- Generates Python code following best practices
-
/exit- Quit the session -
/clear- Clear chat history -
Default input - Enter chat mode for general conversation
Code Generation Workflow
- Task Input: Describe what you want to code
- Codebase Analysis (optional):
- Provide folder or file path
- BroCode analyzes Python files using AST parsing
- Extracts classes, functions, imports, and structure
- Maintains consistency with existing code patterns
- Output Selection: Choose terminal display or file save
- Code Generation: AI generates code following:
- PEP 8 style guidelines
- Google docstring format
- Type hints and error handling
- Consistency with existing codebase patterns
Chat Mode
Provides general coding assistance, debugging help, and technical discussions using a knowledgeable coding assistant persona.
Configuration
Models are stored in brosession/brocode_config.yaml in your current directory. Use brocode model config to see the exact location.
Configuration File Structure
models:
llama3.2-11b: /path/to/mylocal.py
gpt-4: /path/to/gpt4_model.py
default_model: llama3.2-11b
Customizing Prompts
After running brocode start once, you can customize the AI behavior by editing:
brosession/prompt_hub/chat.md- Chat assistant personality and instructionsbrosession/prompt_hub/code_generator.md- Code generation guidelines and style
Dependencies
- Python >=3.12
- click >=8.2.1
- brollm >=0.1.2
- broflow >=0.1.4
- broprompt >=0.1.5
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
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 brocode-0.1.1.tar.gz.
File metadata
- Download URL: brocode-0.1.1.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fbb046d70b12b1ad71fc3a9e83d572c16be3e801dfab6e3eba93e62964d65a6
|
|
| MD5 |
730bfebf1a4be58b49bcb27218306120
|
|
| BLAKE2b-256 |
cc006985c85d2fc628714e71c0f4eba880ce8f63885873f4d097369282812f96
|
File details
Details for the file brocode-0.1.1-py3-none-any.whl.
File metadata
- Download URL: brocode-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a71cb8edfa65256512994b7d335c7b44630e011fc83adda5d2708053a290decc
|
|
| MD5 |
8c2721f39eeae43cafd89c08e61d206e
|
|
| BLAKE2b-256 |
0eb642cf45b8da2da46f7d9e4df6379179697547cc9dda1cf11ac06e05996af9
|