Code Buddy is an AI-powered software engineering assistant built with Python, LangGraph, and Google Gemini. It provides an interactive command-line interface that helps developers analyze, review, and refactor Python code using an LLM while keeping users in control of file modifications.
- Interactive AI-powered CLI
- List Python files in the sandbox
- Read files with syntax highlighting
- AI code analysis
- AI-powered code refactoring
- Confirmation before overwriting files
- Automatic
.bakbackup creation - Conversation memory using LangGraph
- Rich terminal interface
- Python 3.13+
- Google Gemini
- LangGraph
- LangChain
- Rich
- Python Dotenv
- Flake8
- Mypy
code-buddy/
│
├── agents/
│ └── refactor_agent.py
│
├── prompts/
│ ├── analyze.py
│ ├── refactor.py
│ ├── review.py
│ └── system_prompt.py
│
├── tools/
│ ├── analyzer.py
│ └── file_manager.py
│
├── utils/
│ ├── banner.py
│ ├── cli.py
│ ├── command_handler.py
│ ├── command_result.py
│ ├── code_parser.py
│ ├── errors.py
│ ├── printer.py
│ └── response_parser.py
│
├── sandbox/
│
├── main.py
├── requirements.txt
└── README.md
Clone the repository
git clone https://github.com/Jami436/code-buddy.git
cd code-buddyCreate a virtual environment
python -m venv .venvActivate it
.venv\Scripts\activatesource .venv/bin/activateInstall dependencies
pip install -r requirements.txtCreate a .env file
GOOGLE_API_KEY=YOUR_API_KEYRun the project
python main.py| Command | Description |
|---|---|
/help |
Show available commands |
/files |
List Python files inside the sandbox |
/read <file> |
Display a Python file |
/analyze <file> |
Analyze code using Gemini |
/refactor <file> |
Refactor code with AI |
/clear |
Clear the terminal |
/exit |
Exit Code Buddy |
You: /analyze messy_script.py
Thinking...
## Summary
The code is functional but can be improved.
Issues Found
-------------
• Variable names could be more descriptive
• Missing type hints
• Long functions
• Minor code duplication
Recommendations
----------------
• Add type hints
• Improve readability
• Split large functions
User
│
▼
Read Python File
│
▼
Generate AI Refactor
│
▼
Preview Result
│
▼
Apply Changes? (Y/N)
│
├── Yes → Save Refactored File
│
└── No → Discard Changes
- Interactive CLI
- AI Code Analysis
- AI Code Refactoring
- Rich Terminal UI
- Prompt Management
- Automatic Backups
- LangGraph Memory
- Git Integration
- Project-wide Analysis
- Multi-file Refactoring
- AI Code Review
- Unit Test Generation
- Documentation Generation
Muhammad Jami Ahad
AI Student | Backend Developer | Building AI-powered solutions
GitHub: https://github.com/Jami436
This project is licensed under the MIT License.