A lightweight, autonomous AI agent that runs in your terminal. It uses OpenAI's GPT-4o and Pydantic structured outputs to create folders, write Python code, and manage software projects autonomously based on simple text commands.
- Autonomous File Management: Can create directories and subdirectories (
make_directory). - Code Generation: Writes full, executable Python files (
create_file). - Self-Correction: Can read files (
read_file) to check its own work or debug errors. - Structured Thinking: Uses a strict "Thought -> Action -> Result" loop to prevent hallucinations.
- Safe Execution: Checks if directories exist before writing files to prevent crashes.
- Core Logic: Python
- AI Model: OpenAI GPT-4o-mini (via
openaiSDK) - Data Validation: Pydantic (
BaseModel) - Environment Management:
python-dotenv
-
Clone the Repository
git clone [https://github.com/YOUR_USERNAME/cli-coding-agent.git](https://github.com/YOUR_USERNAME/cli-coding-agent.git) cd cli-coding-agent -
Create a Virtual Environment (Optional but Recommended)
python -m venv venv # Windows venv\Scripts\activate # Mac/Linux source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Set Up API Key
- Create a file named
.envin the root folder. - Add your OpenAI API key:
MY_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxx
- Create a file named
Run the agent from your terminal:
python coder.py