_
___| | __ ___ __ ___
/ __| |/ _` \ \ /\ / /___ / __|
| (__| | (_| |\ V V /|___|| (__
\___|_|\__,_| \_/\_/ \___|
AI coding agent in your terminal. Pure C. No bloat.

me building an HTTP client from scratch instead of linking libcurl
git clone https://github.com/apoorvdarshan/claw-c.git
cd claw-c && ./install.shthat's it. builds, installs to ~/.local/bin/claw-c, adds to PATH. on macOS it auto-installs mbedTLS via brew. on linux you need mbedTLS 4.x first.
then from anywhere:
claw-cfirst run asks you to pick a provider and enter your key. config saved to ~/.claw-c/config.json. next time just type claw-c.
$ claw-c
Welcome to claw-c! Let's get you set up.
1 anthropic (claude-sonnet-4-6, claude-opus-4-6)
2 openai (gpt-4o, o3, o4-mini)
3 gemini (gemini-2.5-flash, gemini-2.5-pro)
4 groq (llama-3.3-70b-versatile)
5 xai (grok-3)
6 openrouter (any model)
7 ollama (local, no key needed)
...
Pick a provider [1-10]: 3
Model [gemini-2.5-flash]:
API key: AIza...
Config saved to ~/.claw-c/config.json
to change provider/model/key: claw-c --setup or /setup inside the REPL.
you type a prompt. claw-c talks to the LLM. the LLM can run commands, read/write/edit files, search code — claw-c executes it all, feeds results back, and loops until the task is done. just like claude code but ~3500 lines of C.
$ claw-c
gemini | gemini-2.5-flash | main
> write hello.c that prints "built by claw-c", compile and run it
── write_file ──
/tmp/hello.c
Wrote 81 bytes to /tmp/hello.c
── bash ──
$ cc /tmp/hello.c -o /tmp/hello && /tmp/hello
built by claw-c
Done.
> find all functions with "parse" in their name
── grep ──
/parse/
c/src/json.c:228:json_value_t *json_parse(const char *src, size_t len) {
c/src/sse.c:27:static int parse_frame(const char *frame, ...) {
...
> /quit
6 built-in tools, same as claude code:
| tool | what it does |
|---|---|
bash |
shell commands via /bin/sh -c (120s timeout, 512KB cap) |
read_file |
read file with line numbers |
write_file |
create/overwrite file (auto-creates parent dirs) |
edit_file |
find-and-replace exact string match |
glob |
recursive file pattern matching (*.c, src/**/*.h) |
grep |
recursive regex search with line numbers |
auto-detected from model name. 10 providers, 3 API formats built from scratch.
| provider | models | env var |
|---|---|---|
| Anthropic | claude-* |
ANTHROPIC_API_KEY |
| OpenAI | gpt-* o1-* o3-* o4-* |
OPENAI_API_KEY |
| Gemini | gemini-* |
GEMINI_API_KEY |
| xAI | grok-* |
XAI_API_KEY |
| Groq | llama* mixtral* |
GROQ_API_KEY |
| Together | deepseek* qwen* |
TOGETHER_API_KEY |
| OpenRouter | any (-p openrouter) |
OPENROUTER_API_KEY |
| Ollama | any (-p ollama) |
none |
| Minimax | -p minimax |
MINIMAX_API_KEY |
| Kimi | moonshot* |
MOONSHOT_API_KEY |
claw-c # REPL (uses saved config)
claw-c "find all TODO comments" # one-shot
claw-c -m gpt-4o -k sk-... "explain this" # override model/key
claw-c -p ollama -m llama3.2 "hello" # local
claw-c -p openai -b my-server:8080 "hi" # custom endpoint
claw-c --setup # change provider/model/keyflags: -m MODEL -k KEY -p PROVIDER -b HOST:PORT -h -v --setup
repl: /help /status /clear /setup /quit
keys: Ctrl-C cancel Ctrl-D exit Up/Down history
prompt → JSON request (per provider format)
→ raw TCP socket → TLS handshake → HTTP/1.1 POST
→ SSE stream → text printed live
→ tool calls? → execute (fork/exec, file I/O, regex)
→ feed results back → loop until done (max 25 turns)
everything from scratch: JSON parser, HTTP client, SSE streaming, TLS (via mbedTLS). no curl, no libevent, no external JSON lib.
reads CLAUDE.md from your project (walks up to git root). shows git branch + status in context.

tokens streaming through the hand-rolled SSE parser
c/src/
claw.h all types + declarations (single header)
strbuf.c dynamic string buffer
json.c recursive descent JSON parser/serializer
tls.c raw POSIX TCP + mbedTLS 4.x TLS
http.c HTTP/1.1 with chunked streaming
sse.c SSE event parser
api.c multi-provider API client (3 format families)
tools.c 6 tools: bash, read, write, edit, glob, grep
agent.c agent loop with tool execution
terminal.c raw mode REPL with history
main.c CLI, config, onboarding, CLAUDE.md, git context
brew install mbedtls # macOS
cd c && make # dynamic
make static # portable static binary
make install # → ~/.local/bin/claw-cthis repo was originally cloned from ultraworkers/claw-code (a Rust/Python reimplementation of Claude Code). i stripped all of that out and rewrote the whole thing from scratch in pure C — different language, different architecture, different code. the Rust implementation was used as a behavioral reference to understand how the agent loop, tool system, and API streaming should work.
not Claude Code. not affiliated with Anthropic, OpenAI, Google, or any provider. hobby project. use at your own risk — this thing runs shell commands.
- this repository does not claim ownership of the original Claude Code source material.
- this repository is not affiliated with, endorsed by, or maintained by Anthropic.
Apoorv Darshan