llm による自立型 Cli コーディングエージェントライブラリ
Project description
llm-coder
llm-coder is an autonomous CLI coding agent library powered by LLMs.
It codes according to user instructions, runs its own linter, formatter, and test code in an evaluation phase, and keeps fixing until all checks pass.
The LLM API interface uses the litellm library, allowing you to use any LLM such as Claude or OpenAI.
Model and API key configuration follows the litellm provider settings.
See https://docs.litellm.ai/docs/providers for details.
Installation
You can install llm-coder via PyPI:
pip install llm-coder
Or, install from source:
git clone https://github.com/igtm/llm-coder.git
cd llm-coder
pip install -e .
This makes the llm-coder command available in your project directory.
Usage
After installation, you can run the CLI tool with:
llm-coder <prompt> [options...]
Available Options
positional arguments:
prompt Prompt to execute (if omitted, read from stdin or TOML file)
options:
-h, --help Show help message and exit
--config CONFIG Path to TOML config file (default: llm-coder-config.toml)
--model MODEL, -m MODEL
LLM model to use (default: gpt-4.1-nano)
--temperature TEMPERATURE, -t TEMPERATURE
LLM temperature parameter (default: 0.5)
--max-iterations MAX_ITERATIONS, -i MAX_ITERATIONS
Maximum execution iterations (default: 10)
--allowed-dirs ALLOWED_DIRS [ALLOWED_DIRS ...]
Directories allowed for file system operations (space separated, default: ['.', 'playground'])
--repository-description-prompt REPOSITORY_DESCRIPTION_PROMPT
Repository description prompt for LLM (default: from TOML file or empty)
--output OUTPUT, -o OUTPUT
Output file path (default: none, stdout only)
--conversation-history CONVERSATION_HISTORY, -ch CONVERSATION_HISTORY
Output file path for agent conversation history (default: none)
--request-timeout REQUEST_TIMEOUT
Timeout per LLM API request in seconds (default: 60)
Examples
# Basic usage
llm-coder "Create a python script that outputs 'hello world'"
# Specify model
llm-coder --model claude-3-opus-20240229 "Create a python script that outputs 'hello world'"
# Specify temperature and max iterations
llm-coder --temperature 0.7 --max-iterations 5 "Create a python script that outputs 'hello world'"
# Specify allowed directories
llm-coder --allowed-dirs . ./output ./src "Create a python script that outputs 'hello world'"
# Specify request timeout
llm-coder --request-timeout 120 "Create a python script that outputs 'hello world'"
# Output result to file
llm-coder --output result.txt "Create a python script that outputs 'hello world'"
# Output conversation history to file
llm-coder --conversation-history conversation.txt "Create a python script that outputs 'hello world'"
# Output both result and conversation history to files
llm-coder --output result.txt --conversation-history conversation.txt "Create a python script that outputs 'hello world'"
Configuration
You can configure llm-coder via command line arguments or a TOML file.
Priority: Command line arguments > TOML config file > hardcoded defaults
Example TOML Config File
By default, llm-coder-config.toml is loaded. You can specify a custom config file with --config.
# Global settings
model = "claude-3-opus-20240229"
prompt = "Create a python script that outputs 'hello world'"
temperature = 0.5
max_iterations = 10
request_timeout = 60
allowed_dirs = ["."]
repository_description_prompt = "This repository is a Python utility tool."
# output = "result.txt"
# conversation_history = "conversation.txt"
To use a config file:
# Use default config file (llm-coder-config.toml)
llm-coder
# Specify custom config file
llm-coder --config my_config.toml
Running Directly During Development
You can run cli.py directly during development without installing. A playground directory is provided for testing, but you must run scripts from the project root directory.
From the project root (llm-coder top directory), run:
# Make sure you are in the project root directory
uv run python -m llm-coder.cli <args...>
Example:
# Assuming you are in the project root directory
uv run python -m llm-coder.cli "Create a python script that outputs 'hello world'"
llm-coder-litellm Command
The llm-coder-litellm command is a simple wrapper for calling the LLM completion API directly using the LiteLLM library.
llm-coder-litellm --model <model> [options...] "prompt"
Available Options
usage: llm-coder-litellm [-h] --model MODEL [--temperature TEMPERATURE] [--max_tokens MAX_TOKENS] [--top_p TOP_P] [--n N] [--stream] [--stop [STOP ...]]
[--presence_penalty PRESENCE_PENALTY] [--frequency_penalty FREQUENCY_PENALTY] [--user USER] [--response_format RESPONSE_FORMAT]
[--seed SEED] [--timeout TIMEOUT] [--output OUTPUT] [--extra EXTRA]
[prompt]
litellm completion API wrapper
positional arguments:
prompt Prompt (if omitted, read from stdin)
options:
-h, --help show this help message and exit
--model MODEL Model name
--temperature TEMPERATURE
Temperature parameter (default: 0.2)
--max_tokens MAX_TOKENS
max_tokens
--top_p TOP_P top_p
--n N n
--stream Stream output
--stop [STOP ...] Stop words
--presence_penalty PRESENCE_PENALTY
presence_penalty
--frequency_penalty FREQUENCY_PENALTY
frequency_penalty
--user USER user
--response_format RESPONSE_FORMAT
response_format (e.g. json)
--seed SEED seed
--timeout TIMEOUT Request timeout in seconds (default: 60)
--output OUTPUT, -o OUTPUT
Output file
--extra EXTRA Additional JSON parameters
Examples
# Basic usage
llm-coder-litellm --model gpt-4.1-nano "Generate a summary of the following text"
# Specify temperature
llm-coder-litellm --model gpt-4.1-nano --temperature 0.7 "Generate a summary of the following text"
# Save output to file
llm-coder-litellm --model gpt-4.1-nano --output summary.txt "Generate a summary of the following text"
GitHub Actions Integration
You can easily use llm-coder in your GitHub workflows with llm-coder-action, a convenient GitHub Actions composite.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_coder-0.0.4.tar.gz.
File metadata
- Download URL: llm_coder-0.0.4.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6cbea2875b4ab5f1c056c8c4c429b5f58346c0c00a1db2418c8801c10996083
|
|
| MD5 |
b2a6fed4ece2243868b58aa2c78f709e
|
|
| BLAKE2b-256 |
dffe4fa2ab28c109c9c09f03a608c3a17e23db5b2e1e7c89410292fd356e71f6
|
File details
Details for the file llm_coder-0.0.4-py3-none-any.whl.
File metadata
- Download URL: llm_coder-0.0.4-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76364fdf4200649bdf051ab1b31678ac5aec0ebf3d7c5c64afeffa06698f6328
|
|
| MD5 |
ec031b97d7f06611cbd5fee42391a60f
|
|
| BLAKE2b-256 |
6a2168536d50ba743ab8c7216765bad612d62999012dac4c0da2ad6fc3f2f987
|