Skip to content

About

A Python AI agent powered by Gemini that can explore, read, create, edit, delete, and run files using natural language.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

CLI Coding Agent

A CLI coding agent built in Python using Google's GenAI SDK (google-genai). Give it a working directory and tell it what you want to do. It can explore your project, read and edit code, create or delete files and folders, and run Python scripts.

Features

The agent uses five tools:

  • get_file_info: Explore files and folders.
  • get_file_content: Read file contents.
  • write_file: Create new files or edit existing ones.
  • run_python_file: Run Python files and check their output.
  • delete_path: Delete files or directories.

Requirements

  • Python 3.12+
  • Google Gemini API key
  • uv

Installation

1. Install uv

On Linux or macOS:

curl -LsSf https://astral.sh/uv/install.sh | sh

Check the installation:

uv --version

2. Clone the project

git clone https://github.com/adityassarode/cli-coding-agent.git
cd cli-coding-agent

3. Install dependencies

uv sync

This creates a virtual environment and installs the dependencies listed in pyproject.toml and uv.lock.

4. Set up your API key

Create a .env file in the project directory:

GEMINI_API_KEY=your_gemini_api_key

Get your API key from Google AI Studio.

Configure Working Directory

Open config.py and set the directory where you want the agent to work.

I've included a calculator folder so you can test the agent without creating your own project.

Run the Agent

Option 1: Use the CLI command (Recommended)

Install the project locally:

uv pip install -e .

Now you can run the agent directly:

cli-coding-agent "Explore the project and explain its structure"

You can use the same command for other tasks:

cli-coding-agent "Find bugs in the calculator project and fix them"
cli-coding-agent "Read calculator.py and explain how it works"
cli-coding-agent "Create a Python file that calculates factorial"
cli-coding-agent "Run main.py and tell me its output"
cli-coding-agent "Delete the test.txt file"
cli-coding-agent "Delete the old_directory folder"

You no longer need to write uv run or main.py every time.

Option 2: Run using uv

You can also run the agent without installing the CLI command separately:

uv run main.py "Explore the project and explain its structure"

Or use the registered project command through uv:

uv run cli-coding-agent "Explore the project and explain its structure"

The agent chooses which tools to use based on your instruction and returns the result.

Troubleshooting

1. Gemini API key error

Make sure your .env file exists in the project directory and contains a valid API key.

2. Module not found

Install the project dependencies again:

uv sync

3. File or directory not found

Check that the path exists inside the working directory configured in config.py.

4. Permission denied

Make sure the requested files or folders are inside the configured working directory and that your operating system allows the agent to read, write, execute or delete them.

About

A Python AI agent powered by Gemini that can explore, read, create, edit, delete, and run files using natural language.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages