A minimal, terminal-based AI coding agent powered by Google's Gemini API — inspired by Claude Code and Cursor's Agent Mode. I built this project to explore agentic workflows, function calling, and LLM-powered code editing directly from the command line.
This project is a CLI terminal tool that uses function calling and feedback loops to autonomously find and fix bugs in a codebase. It interacts with the gemini-2.5-flash model to analyze code, execute custom functions, and iteratively repair issues in target projects (such as the included calculator package).
The architecture of the agent is built on four main capabilities:
The agent connects to the Gemini API using the Python client library. It handles prompts and maintains conversational context directly within the CLI environment.
The agent is equipped with custom tools to interact with the file system and run Python code. For example, functions/get_files_info.py provides the agent with secure directory traversal and file listing capabilities.
Through its system prompt and context window, the AI is granted the ability to dynamically select and execute the appropriate tools based on the user's terminal commands.
A proper feedback loop makes the tool truly "agentic." It can analyze the results of its own function calls, re-evaluate the codebase's state, and iteratively work towards resolving bugs without manual intervention.
pyproject.toml/uv.lock: Project dependencies (managed viauv), requiring Python 3.12+ and packages likegoogle-genaiandpython-dotenv.main.py: The CLI entry point for the agent. Use it to send prompts and initiate debugging sessions.functions/: Contains the tools exposed to the agent.get_files_info.py: Allows the agent to list directory contents safely within a restricted working directory.
calculator/: A sample target codebase used for testing the agent's ability to debug and repair broken logic..env: Environment variables (add yourGEMINI_API_KEYhere).
- Install dependencies: Ensure you have Python 3.12 or above. Install the requirements from
pyproject.toml:uv sync # or pip install -e . - Environment Variables: Create a
.envfile in the root directory and add your API key:GEMINI_API_KEY=your_gemini_api_key_here
- Run the CLI:
For verbose output with token usage:
python main.py "Find and fix the bug in the calculator package"python main.py "Hello, Gemini!" --verbose