Skip to content

mr-kelly/freecode

Repository files navigation

freecode logo

freecode

A minimal autonomous coding agent in Rust.
~300 lines. $0. Free forever. Always picks the best free model automatically.

release license rust


Install

curl -fsSL https://raw.githubusercontent.com/mr-kelly/freecode/main/install.sh | bash
brew tap mr-kelly/tap && brew install freecode   # Homebrew
cargo install --path .                           # from source

Usage

Quick setup & Server ops — great on a fresh machine before installing anything else

freecode "install nvm and set up Node 20"
freecode "configure nginx to reverse proxy localhost:3000"
freecode "install openclaw from https://openclaw.ai"
freecode "show me the top 10 processes by memory usage"
freecode "find all log files larger than 100MB and show their paths"

Coding tasks & Refactoring

freecode "fix the failing tests in src/"
freecode "add pagination to the /users endpoint"
freecode "find and fix the memory leak in worker.go"
freecode "refactor main.rs to split the agent loop into its own module"

File & data tasks

freecode "convert all .png files in this folder to .jpg"
freecode "parse access.log and show me the top 10 IPs by request count"
freecode "rename all files to lowercase"

Programmatic use

# pipe JSON for programmatic execution
echo '{"prompt": "fix the bug", "cwd": "./myproject"}' | freecode

How the free model works

freecode has no hardcoded model. On every run, it fetches the real-time popularity ranking from OpenRouter and picks the #1 free model by weekly usage across all users.

startup
  └─ GET openrouter.ai/api/frontend/models/find?order=top-weekly
       └─ filter: pricing.prompt == "0"
            └─ try #1 → 429/401? → try #2 → fail? → try #3 → ...

If the top model is rate-limited or down, it automatically falls back to #2, #3, and so on — no intervention needed.

freecode --list-free   # see current ranking
#     MODEL
------------------------------------------------------------
1     arcee-ai/trinity-large-preview:free  ← selected
2     stepfun/step-3.5-flash:free
3     z-ai/glm-4.5-air:free
4     nvidia/nemotron-3-nano-30b-a3b:free
5     openai/gpt-oss-120b:free
...

A built-in OpenRouter key is bundled — run with zero setup. Set OPENROUTER_API_KEY to use your own.


How it works

Turns Up to 40 per task
Tools run_cmd (shell) · write_file · apply_patch
Safety Dangerous commands (rm, sudo, git push …) require confirmation
Context Output truncated at 8 000 bytes · history compressed every 10 turns
Git Auto-seeds git status + git diff at start
Log All commands logged to .freecode.log

Benchmark

Note: The built-in OpenRouter API key has limited quota and may be rate-limited. For best results, set your own free OpenRouter API key:

export OPENROUTER_API_KEY="your-key-here"  # Get free key at https://openrouter.ai/keys

Tested with arcee-ai/trinity-large-preview:free (top free model on OpenRouter):

# Task Description Result
01 count_files Count files in dir, write to answer.txt
02 hello_world Create hello.txt with exact content
03 fizzbuzz Write fizzbuzz function from scratch
04 bugfix Find and fix off-by-one bug
05 refactor Refactor messy code, preserve behavior
06 new_feature Add is_palindrome to existing module
07 file_ops Create JSON file + Python reader script
08 sort_numbers Sort numbers from file, write to sorted.txt
09 word_count Count words in file, write to count.txt
10 rename_file Rename a file

9/10 with free models (March 2026).

Note: For better results, use a paid model by setting:

export OPENROUTER_API_KEY="your-key"
export FREECODE_MODEL="anthropic/claude-3.5-sonnet"  # or other paid models

Run benchmark yourself:

./bench/run.sh

Override model or provider

By default, freecode uses a built-in OpenRouter key that only works with free models — no setup needed.

To use your own key or a paid model:

export OPENROUTER_API_KEY="sk-or-v1-..."   # your own OpenRouter key
export FREECODE_MODEL="claude-opus-4"       # pin any model available on OpenRouter

MIT License · openrouter.ai · issues

About

Free / Micro / Nano Claude Code

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors