TinyCoder is a tiny AI coding assistant designed to be used from command-line.
- Works directly within your existing shell environment (bash, zsh, etc.).
- Tell assistant to do something directly from your command prompt
- You can also use your favorite CLI editor to edit messages
- Maintains context across your commands.
- Parses commands generated by LLM (using
bashlex) and asks for permission unless all commands are from a safe list - Can be used in scripts
- Supports various AI model providers (Ollama, Google Gemini, OpenRouter). More can be added easily, as it is built on LangChain.
curl -o ~/.local/bin/tinycoder https://raw.githubusercontent.com/n-k/tinycoder/refs/heads/master/tinycoder.py
chmod +x ~/.local/bin/tinycoder
tinycoderTo activate TinyCoder in your current session, run the following command:
source <(tinycoder init_shell)Replace tinycoder with the actual path to the script if it is not on your path.
Once activated, you'll have access to new aliases:
ai <your prompt>: Send a message to the AI assistant. The AI will respond by executing commands or asking follow-up questions.aiedit: Open your default editor ($EDITORorvimif not set), write your prompt, save, and exit. The content will be sent to the AI.
You can also run tinycoder find_free to fins current free models on OpenRouter.
# naive prompt
ai list all python files modified in the last 24 hours
# targeted prompt with fragment sentences
ai list all python files modified in the last 24 hours. ignore .venv and anything in .gitignoreTo deactivate TinyCoder and revert your shell to its previous state:
deactivateYou can configure the AI model by setting environment variables:
MODEL_PROVIDER: Set toollama(default),google, oropenrouter.MODEL_NAME: Specify the model name (e.g.,qwen2.5-coder:32b-instructfor Ollama,gemini-2.5-flashfor Google, or specific models for OpenRouter).OLLAMA_BASE_URL: For Ollama, specify the base URL if notlocalhost. E.g.192.168.1.123.GOOGLE_API_KEY: Your Google API key if using thegoogleprovider.OPENROUTER_API_KEY: Your OpenRouter API key if using theopenrouterprovider.
Outstanding tasks can be found in TODO.md.
This tool is deliberately a single file. So you can just edit tinycoder.py and test.
I activate it with source <(./tinycoder.py init_shell), and then edit, and test with ai ....
Note that every time you use ai or aiedit aliases, the environment variables are read again.
This enables you to use different models or even providers for different messages.
This project is licensed under the Mozilla Public License 2.0.