An AI-powered coding agent that generates complete projects from natural language prompts. CodeBuddy uses a multi-agent workflow (Planner β Architect β Coder) to understand your requirements and automatically generate production-ready code.
-
Multi-Agent Architecture: Three specialized agents work together:
- Planner: Analyzes your prompt and creates a structured project plan
- Architect: Breaks down the plan into ordered implementation tasks
- Coder: Implements each task using file system tools
-
Web Interface: Beautiful Streamlit-based UI for easy interaction
-
CLI Support: Command-line interface for automation and scripting
-
Safe File Operations: All file operations are restricted to the project directory
-
Production-Ready Code: Generates well-structured, documented code
- Python 3.11 or higher
- Groq API key (Get one here)
-
Clone the repository (or navigate to the project directory):
cd CodeBuddy -
Install dependencies:
# Using uv (recommended) uv sync # Or using pip pip install -e .
-
Set up environment variables: Create a
.envfile in the project root:GROQ_API_KEY=your_groq_api_key_here LLM_MODEL=openai/gpt-oss-120b # Optional, defaults to this DEBUG=false # Optional, set to true for verbose logging
Launch the Streamlit web interface:
streamlit run app.pyOr use the CLI shortcut:
python main.py --webThen open your browser to http://localhost:8501 and enter your project description.
Direct prompt:
python main.py "create a simple calculator website"Interactive mode:
python main.py --interactiveHelp:
python main.py --helpCodeBuddy/
βββ agent/
β βββ __init__.py
β βββ graph.py # LangGraph workflow definition
β βββ prompts.py # Prompt templates for agents
β βββ states.py # Pydantic data models
β βββ tools.py # File system tools
β βββ generated_project/ # Generated projects are stored here
βββ app.py # Streamlit web interface
βββ main.py # CLI entry point
βββ pyproject.toml # Project configuration
βββ README.md # This file
- User Input: User provides a natural language description of the project
- Planner Agent:
- Analyzes the request
- Creates a structured
Planwith:- Project name and description
- Technology stack
- List of features
- Files to be created
- Architect Agent:
- Takes the plan
- Creates a
TaskPlanwith orderedImplementationTaskobjects - Ensures dependencies are handled correctly
- Coder Agent:
- Processes each task sequentially
- Uses tools to read/write files
- Implements the complete solution
Defines the LangGraph workflow with three agent nodes:
planner_agent: Converts user prompt to Planarchitect_agent: Converts Plan to TaskPlancoder_agent: Implements tasks using tools
Contains prompt templates that guide each agent's behavior:
planner_prompt(): Instructions for the Plannerarchitect_prompt(): Instructions for the Architectcoder_system_prompt(): Instructions for the Coder
Pydantic models for type safety:
Plan: High-level project structureTaskPlan: Ordered implementation tasksImplementationTask: Individual task definitionCoderState: Execution state tracking
Safe file system operations:
write_file(): Write content to filesread_file(): Read file contentslist_files(): List files in directoryget_current_directory(): Get project rootrun_cmd(): Execute shell commands (with restrictions)
| Variable | Description | Default | Required |
|---|---|---|---|
GROQ_API_KEY |
Your Groq API key | - | Yes |
LLM_MODEL |
LLM model to use | openai/gpt-oss-120b |
No |
DEBUG |
Enable debug logging | false |
No |
You can use different Groq models by setting LLM_MODEL in your .env file:
openai/gpt-oss-120b(default)llama-3.1-70b-versatilemixtral-8x7b-32768- And other Groq-supported models
python main.py "create a simple calculator website with HTML, CSS, and JavaScript"python main.py "build a Python Flask web app with a todo list feature and SQLite database"python main.py "make a React component for a weather dashboard that fetches data from an API"- All file operations are restricted to
agent/generated_project/ - Path validation prevents directory traversal attacks
- Commands executed via
run_cmdare limited to the project directory - No arbitrary code execution outside the project boundary
The project follows PEP 8 conventions. Optional development tools:
# Install dev dependencies
uv sync --extra dev
# Format code
black .
# Lint code
ruff check .# Add tests and run them
pytestExecute the full agent workflow.
Parameters:
user_prompt: Natural language description of the project
Returns:
- Dictionary containing:
plan: The generated Plan objecttask_plan: The TaskPlan with implementation stepscoder_state: Final state of the Coder agentstatus: Completion status
Raises:
ValueError: If workflow execution fails
from agent.graph import run_agent
result = run_agent("create a blog website")
plan = result["plan"]
print(f"Project: {plan.name}")- Ensure you've created a
.envfile in the project root - Verify the API key is correctly formatted:
GROQ_API_KEY=your_key_here - Check that
python-dotenvis installed
- This is a security feature. All files must be within
agent/generated_project/ - Check that your file paths are relative and don't use
..to go up directories
- Check your internet connection (API calls required)
- Verify your Groq API key is valid and has sufficient quota
- Enable
DEBUG=truein.envfor more detailed error messages
This project is open source. Please check the license file for details.
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check existing documentation
- Review the code comments for implementation details
Happy Coding! π