# llm-coding-agent

> An llm code command that turns any tool-capable model into a coding agent

- Category: AI Coding / Autonomous Coding Agents
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/simonw/llm-coding-agent
- Canonical page: https://ai-tldr.dev/tools/llm-coding-agent/
- Updated: 2026-07-02

## In short

llm-coding-agent is a plugin for Simon Willison's LLM command-line tool. It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in Python and licensed Apache-2.0. To get started: install the plugin.

## Overview

llm-coding-agent is a plugin for Simon Willison's LLM command-line tool. Installing it adds an llm code command that starts an interactive coding-agent session in the current directory, backed by any tool-capable model LLM already knows about — so the same agent loop runs against a hosted frontier model or a local one, depending on what you have configured.

The agent can read, search and edit files under the session directory and run shell commands there. Read-only tools run freely; file writes, edits and shell commands are shown to you and wait for approval, where y approves once and a approves similar actions for the rest of the session. Declining is handled gracefully: the model is told and can try a different approach. In-session commands cover quitting, toggling auto-approval, switching models mid-conversation and reporting token usage.

Because it is built on LLM, sessions are logged to LLM's SQLite database exactly like llm chat, so llm logs shows full transcripts including every tool call and conversations can be resumed later. The package also exposes a Python API: CodingAgent runs the full loop against any LLM model that supports tools, with an approve parameter that can auto-approve, delegate to a callback, or pause the run and hand you the pending tool calls to approve from an application with no terminal attached.

## What it does

- Adds an llm code command for interactive terminal coding sessions in the current directory
- Works with any tool-capable model LLM supports, and lets you switch models mid-conversation
- Approval flow for mutating actions: read-only tools run freely, writes and shell commands ask first, with per-command pre-approval and a --yolo escape hatch
- Sessions are logged to LLM's SQLite database, so llm logs shows every tool call and conversations can be resumed
- CodingAgent Python API with approve=True, an approval callback, or a pause-and-resume mode for non-terminal applications
- Registers its toolbox with LLM itself, so the same tools work from llm chat and llm prompt

## Getting started

Install the plugin into the same environment as the LLM CLI, then start a session. The --pre flag is needed while the package depends on an LLM alpha release.

1. Install the plugin

   Installs llm-coding-agent and registers the llm code command.

```bash
pip install --pre llm-coding-agent
```

2. Start a session

   Run it bare for an interactive session, or pass an initial task. -m picks a model, -d picks a directory, and --allow pre-approves specific commands.

```bash
llm code
llm code "add type hints to utils.py"
llm code -m gpt-4.1 -d ~/dev/myproject
llm code --allow "pytest*" --allow "git diff*"
```

3. Review or resume the work

   Transcripts live in LLM's own logs, so you can read back what the agent did and continue the conversation later.

```bash
llm logs --short
llm code -c
llm code --cid 01ab...
```

4. Drive it from Python

   CodingAgent runs the same loop programmatically against any tool-capable LLM model; result.tool_calls records everything it did.

```python
from llm_coding_agent import CodingAgent

agent = CodingAgent(
    model="gpt-4.1-mini",        # any llm model ID, or a model instance
    root="/path/to/project",
    approve=True,                # approve every tool call
)
result = agent.run("Fix the failing test in tests/test_parser.py")
print(result.text)
```

## When to use it

- Get a terminal coding agent that reuses the model configuration and API keys you already set up for the LLM CLI
- Compare how different models handle the same coding task by switching models inside one session
- Keep an auditable record of an agent's file edits and shell commands in LLM's SQLite logs
- Embed an approval-gated coding loop in your own Python application using CodingAgent's pause-and-resume mode

## Version history

- 2026-07-02 0.1a0: First working alpha, itself written by an AI coding session from a spec plus red/green TDD prompts. Ships the llm code command and six tools for reading files, editing code and running shell commands on top of the LLM library.
