Skip to main content

Ollama Code CLI

PyPI version Python 3.13+ License: MIT

Ollama Code CLI is an open-source AI agent that brings the power of local LLMs through Ollama, right in your terminal, with advanced tool-calling features.


Table of Contents


Features

  • 🎨 Elegant CLI Interface: Rich colors and structured output
  • 🤖 Local AI Power: Interact with local LLMs through Ollama
  • 🛠️ Tool Calling: Execute coding-related tools (file operations, code execution, etc.)
  • 🔒 Permission Prompts: Safety prompts before executing potentially dangerous operations
  • 💬 Interactive Mode: Maintain conversation context for multi-turn interactions
  • 📝 Markdown Support: Elegantly formatted responses with syntax highlighting
  • 📋 Structured Output: Clear panels and tables for tool calls and results

Installation

First, install a compatible model in Ollama:

# Choose one of these models:
ollama pull qwen3:4b
ollama pull qwen2.5:3b

Then install the CLI:

pip install ollama-code-cli

Requirements

  • Python 3.13+
  • Ollama installed and running
  • An Ollama model that supports tool calling (e.g., Qwen3, Qwen2.5, etc.)

Usage

Start an interactive session:

ollama-code-cli --model qwen3:4b

Run a single command:

ollama-code-cli "Create a Python function to calculate factorial"

Use a specific model:

ollama-code-cli --model qwen3:4b "Explain how async/await works in Python"

Disable permission prompts (use with caution):

ollama-code-cli --no-permission "Create and run a Python script"

Security Features

The CLI includes built-in security features to protect against potentially dangerous operations:

Permission Prompts

By default, the CLI will ask for your permission before executing potentially dangerous operations such as:

  • Writing or modifying files
  • Executing code
  • Running shell commands
  • Running Python files

Safe Operations

These operations are considered safe and don't require permission:

  • Reading files
  • Listing directory contents

Bypassing Permission Prompts

You can disable permission prompts using the --no-permission flag, but this should be used with caution:

ollama-code-cli --no-permission "Your prompt here"

Warning: Disabling permission prompts allows the AI to execute operations without user confirmation. Only use this in trusted environments.


Available Tools

  • read_file: Read the contents of a file
  • write_file: Write content to a file
  • execute_code: Execute code in a subprocess
  • list_files: List files in a directory
  • run_command: Run a shell command

Examples

1. Create a Python script and save it to a file:

ollama-code-cli "Create a Python script that calculates factorial and save it to a file named factorial.py"

2. Read a file and explain its contents:

ollama-code-cli "Read the contents of main.py and explain what it does"

3. Execute a shell command:

ollama-code-cli "List all files in the current directory"

Interactive Mode

Launch the interactive mode for a conversational experience:

ollama-code-cli

In interactive mode, you can:

  • Have multi-turn conversations with the AI
  • See elegantly formatted responses with Markdown support
  • Watch tool calls and results in real-time with visual panels
  • Clear conversation history with the clear command
  • Exit gracefully with the exit command

Project Structure

ollama-code-cli/
├── ollama_code_cli/
│   ├── __init__.py
│   ├── cli/
│   │   ├── __init__.py
│   │   └── cli.py          # Main CLI interface
│   ├── tools/
│   │   ├── __init__.py
│   │   └── tool_manager.py # Tool implementations
├── pyproject.toml          # Project configuration
├── LICENSE
└── README.md

Dependencies


Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements, bug fixes, or suggestions.


License

This project is licensed under the MIT License.

Metadata

Release files for ollama-code-cli 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ollama-code-cli 1.0.3
File Size Uploaded
ollama_code_cli-1.0.3.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ollama-code-cli 1.0.3
File Interpreter ABI Platform
ollama_code_cli-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 25.2 kB

Release files / ollama_code_cli-1.0.3.tar.gz

Download URL ollama_code_cli-1.0.3.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c822aac6abada4f460af639d22779d9729bdff35eace2b604b88310eb8193b89
BLAKE2b-256 checksum
How to use checksums
9f764613f9105686fea485eed902eb1fc43878fbb5b6e7bb31a3ee2152b3616b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Release files / ollama_code_cli-1.0.3-py3-none-any.whl

Download URL ollama_code_cli-1.0.3-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87cb5446f16945eacf160aa47f47a8ef32e96718e1ca60ef28a05e9be81b5bcb
BLAKE2b-256 checksum
How to use checksums
074afe5f6ad2fb6d8176cf9703692c27ed92b0f5f6bd77c515155a34c409341a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page