Hello! If you are new to coding, APIs, or AI agents, don't worry — this guide walks you through getting CodeMechanic-Bot running step by step.
- Python 3.11+ — the language the bot is built in.
- A GitHub account + token — the bot uses your account to hunt bounties and submit code.
- Ollama — runs the local AI model that writes the fixes. Install from https://ollama.com.
- (Optional, recommended) Docker Desktop — lets the bot test its fixes in a sandbox and run the zero-day researcher. The bot still works without it; the generated fixes just aren't test-checked.
- Log into GitHub.
- Go to Settings → Developer settings → Personal access tokens → Tokens (classic).
- Click Generate new token (classic).
- Check the
repobox. - Generate it and copy it somewhere safe. It looks like
ghp_something123.
- Open a terminal and
cdinto theCodeMechanic-Botfolder. - Create a virtual environment and install dependencies:
python -m venv .venv .venv\Scripts\activate # Windows (use source .venv/bin/activate on macOS/Linux) pip install -r requirements.txt
- Create a file named
.envin the project folder with your token (this file is gitignored, so it never leaves your machine):GITHUB_TOKEN=ghp_your_token_here - Pull the local AI model (must match
config.yaml):ollama pull gemma3:4b
- Start the web server from the same virtualenv (loopback only — it holds your token):
uvicorn api.main:app --host 127.0.0.1 --port 8000
⚠️ Don't use--host 0.0.0.0— that exposes your token and bot controls to your whole network. - Open http://127.0.0.1:8000 — you'll see the Catppuccin Mocha dashboard.
- Click Start Bot.
The bot runs two loops. Every 30 minutes the bounty hunter:
- Scours GitHub for new bug bounties.
- Throws away the fake/scam ones.
- Reads the code of the good ones and asks the local AI for a minimal fix.
- Tests the fix in a Docker sandbox (if Docker is running).
- Posts a short "comment-first" note on the issue, then queues the patch in the Approvals tab for you to review.
By default
manual_approval: trueinconfig.yaml, so the bot waits for your approval (in the Approvals tab) before opening a real PR. Set it tofalsefor fully autonomous submission. Watch the live terminal logs in the dashboard to see the bot working — when it submits a fix you'll seePR created successfully!and it writes a short post inblog_posts/.