Introduction
zelk is an agent loop for Go. It sends the conversation to a model, runs the tools the model asks for, checks each call against the permission rules, keeps the context inside the model’s window and decides when a run is really done. Everything else stays with the program that embeds it: the process, storage, isolation, scheduling, transport and the user’s identity.
Every session is an append-only log of events. The loop reads its state from that log, so a session survives a crash, moves between processes and replays exactly as it happened.
There are three ways to use zelk, in the order most readers want them.
The library
Section titled “The library”The module is github.com/barevoidco/zelk/core, and its root package is zelk.
This is the way zelk is meant to be used: your program embeds the loop and
keeps the process, the storage, the isolation and the people. With no wiring
at all, Run reads OPENAI_API_KEY (or OPENAI_BASE_URL) and works in the
current directory:
res, err := zelk.Run(context.Background(), "Summarize README.md in one sentence.")if err != nil { panic(err)}fmt.Println(res.Outcome, res.Text)For anything more, zelk.New takes each
dependency as an option: the provider, the model, a permission mode, a
workspace and a shell, a store for sessions that outlive the process.
Quickstart: Go builds a first program, and the
Embedding guides take it on from there.
The zelk command, for scripts and CI
Section titled “The zelk command, for scripts and CI”zelk is a coding agent in one binary, built on the library like any other
host. With -p, or in a pipe, it runs one task and prints the answer;
zelk exec runs headless jobs with resumable sessions and structured
output; zelk acp serves editors over the Agent Client Protocol. It takes
its provider from flags and variables, so a script needs no setup.
zelk -p -mode plan "what does ./pkg/foo do?" # one task, read-only, then exitzelk exec -mode accept-edits "fix the typo in README.md"Quickstart: the CLI takes you from a model to a command you can put in a script.
The terminal UI, to try it
Section titled “The terminal UI, to try it”On a terminal, plain zelk opens a full-screen chat in your repository that
asks before it changes anything. It is the quickest way to see zelk work. The
library and the scripting commands are what the rest of these pages build on.
zelk # the terminal UI, in this directoryQuickstart: the terminal UI gets you to a first change in a minute.
How it’s built
Section titled “How it’s built”How zelk works explains the ideas: the loop and the host, sessions as logs, executions and leases. The design contracts under Internals say exactly how each part behaves, starting with the architecture.