Chudbot is a stupid-simple “chat in a file” bot.
You write messages in a chat.md file, save it, and Chudbot appends the assistant reply right into the same file.
- A computer (Windows or Mac)
- Node.js (free)
- An OpenRouter account + API key
- Go to nodejs.org
- Download the LTS installer
- Run it (Next, Next, Finish)
- Open PowerShell (Start menu → type “PowerShell”)
- Go to nodejs.org
- Download the LTS installer
- Run it
- Open Terminal
To confirm Node is installed, run:
node -v
npm -vInstall it globally:
npm install -g chudbotConfirm it works:
chudbot --help
# alias also works
chud --helpchud updateIf an update is available, Chudbot prints the exact install command. To install automatically, use -y/--yes or set CHUDBOT_AUTO_UPDATE=1.
- Create an account:
- Create an API key:
https://openrouter.ai/settings/keys
You’ll paste that key into Chudbot’s .env in a minute.
Create a new folder anywhere you want, for example:
Desktop/chudbot-test
Now open a terminal and make sure you’re “in” that folder.
If you already have a terminal open, you can always use cd to switch into the folder.
Option A (easiest): open PowerShell directly in the folder
- Open File Explorer and open your
chudbot-testfolder - Click the address bar (where the folder path is)
- Type
powershelland press Enter
Option B: open PowerShell first, then cd
cd $HOME
cd Desktop
cd chudbot-testOption A: open Terminal, then cd
- Open Terminal
- Type
cd(with a space) - Drag the folder into the Terminal window
- Press Enter
Option B (if enabled): open Terminal at the folder
- In Finder, right-click the folder → Services → New Terminal at Folder
This creates a starter chat.md in your folder.
It also creates ~/.chudbot/.env if it doesn’t exist yet.
chudbot initChudbot reads its API key from your user folder:
- Mac:
~/.chudbot/.env - Windows:
%USERPROFILE%\\.chudbot\\.env
Open that file and set:
OPENROUTER_API_KEY=YOUR_KEY_HERE
OPENROUTER_MODEL=openrouter/free
OPENROUTER_DEFAULT_MODEL=openrouter/freeOPENROUTER_MODEL is the primary env var for model selection.
If set, it takes precedence.
OPENROUTER_DEFAULT_MODEL is also supported as a fallback when
OPENROUTER_MODEL is not set.
openrouter/free routes to a currently-free option on OpenRouter.
If it ever errors later, pick a different model.
Open chat.md, type under the last # %% user block, save the file, then run:
chudbot runIt only runs if the chat ends with a non-empty # %% user message.
On success it appends # %% assistant with the reply, then appends a fresh # %% user header so you can type the next message.
You can inject one or more local files into model context without copy/paste:
chudbot run -f src/a.js -f notes/todo.md
chudbot run -files src/a.js,notes/todo.md
chudbot run -f src/a.js -files notes/todo.md,README.mdPaths are resolved relative to your current working directory. Files are
prepended in deterministic order: repeated -f/--file entries first (in the
order provided), then -files entries left-to-right.
You can also set files in chat.md front matter:
---
files:
- src/a.js
- notes/todo.md
---These entries are appended after CLI -f/--file and -files values.
You can cap how much chat history is sent to the model:
chudbot run --max-messages 24
chudbot run --max-tokens 4000
chudbot run --max-messages 24 --max-tokens 4000You can also pass the same limits in watch mode:
chudbot watch --max-messages 24 --max-tokens 4000And you can set global defaults once per invocation:
chudbot --max-messages 24 --max-tokens 4000 run
chudbot --max-messages 24 --max-tokens 4000 watchchudbot watchStop with Ctrl+C.
A chat file is just blocks. Each block starts with a header line:
# %% system# %% user# %% assistant
Everything under that header (until the next header) is the message content.
Important rule: only type into the LAST # %% user block.
If you create a memory.md, it gets injected as extra system instructions.
Example memory.md:
- My name is Craig
- Keep answers short and practical
- I like humorAt the very top of chat.md, you can add front matter to set the model and memory file for that chat:
---
model: openrouter/free
memory: memory.md
---If you want the local memory file to override root memory instead of merging, add:
---
memory.override: true
---You can also trim long chats before model calls:
---
max_messages: 24
max_tokens: 4000
---Trimming is deterministic: system messages are kept, the first user message is kept as seed continuity, and then the newest remaining messages are kept within the message/token limits.
Chat:
- Uses
chat.mdin your current folder by default (or--chat)
Env:
- Mac:
~/.chudbot/.env - Windows:
%USERPROFILE%\\.chudbot\\.env
Memory:
- Root memory:
~/.chudbot/memory.md(Windows:%USERPROFILE%\\.chudbot\\memory.md) - Local memory:
memory.mdnext to yourchat.md - Default behavior is merge (root + blank line + local)
- If
memory.override: trueis set in chat front matter, local memory overrides root
- “Missing OPENROUTER_API_KEY”
- Put your key into
~/.chudbot/.env(Windows:%USERPROFILE%\\.chudbot\\.env)
- Put your key into
- “It didn’t reply”
- Make sure the chat ends with a
# %% userblock that has real text
- Make sure the chat ends with a
- “401 / unauthorized”
- Your API key is missing or wrong
- “Model not found”
- Try a different
OPENROUTER_MODEL - Or set
OPENROUTER_DEFAULT_MODELif you want a fallback env key - Or set
model:in chat front matter
- Try a different
- “It replied twice / weird loop”
- Only edit the last
# %% userblock, and let the bot append assistant blocks
- Only edit the last
