ml code is a coding agent for the terminal. (ml is the short name the installer links next to manylayers; manylayers code works too.) Start it in a project directory and ask for a change. It finds the relevant code, edits files, runs your build and tests, and fixes what fails. It asks before it changes anything unless you let it.
The model can run on the same machine (a model you pulled with manylayers pull), or be any OpenAI-compatible endpoint: a ManyLayers deployment, the ManyLayers gateway, or another provider.
The agent runs as you, in your directory, so it can edit your files. Only the model runs as the
manylayers service user. It is started for the session behind a random API key on 127.0.0.1 and stopped when you leave. You may be asked for your sudo password once, to start it.Choosing a model
Local models are loaded with their own chat template (llama.cpp
--jinja), which is what lets them call tools. The context window defaults to 32,768 tokens; set it with --context. Larger contexts need more memory.
What it can do
Rules the agent follows:
- It must read a file before editing it. If the file changed since it was read (by you, a formatter, or a command), it has to read it again, so it never overwrites changes it hasn’t seen.
bashkeeps its directory: acdcarries over to later commands. Commands run in their own process group, time out after 2 minutes by default (up to 10), and are stopped with Ctrl+C.- Output is capped so one large result cannot fill the context. It keeps the start and the end.
grepuses ripgrep when it is installed.globandgrepskip files ignored by git.
Permissions
When a call needs permission, the agent shows it (an edit as a diff, a command in full) and asks:bash(go test:*) to the project’s .manylayers/settings.local.json, so you are not asked again for that kind of command. If you choose No without saying anything, the agent stops and waits for you.
Modes
Shift+Tab cycles the mode;/mode or --permission-mode sets it.
Rules
Rules aretool or tool(pattern). Tool names are read_file, edit_file, write_file, bash, web_fetch and so on, or a kind: edit, exec, network.
A command line with
&&, ; or | is checked part by part. An allow rule must cover every part (read-only parts are fine). A deny rule applies if it covers any part, so bash(git push:*) also blocks make && git push.
Settings are merged from ~/.manylayers/settings.json, then the project’s .manylayers/settings.json (commit this one) and .manylayers/settings.local.json (yours, git-ignored):
--allowedTools and --disallowedTools add rules for one run.
Project instructions
The agent readsMANYLAYERS.md (or AGENTS.md where there is none) from the repository root down to your directory, plus your own ~/.manylayers/MANYLAYERS.md. Put build and test commands, architecture notes and conventions there.
/inithas the agent look through the repository and writeMANYLAYERS.md.#followed by a note adds that line toMANYLAYERS.md, e.g.# use pnpm, not npm..manylayers/MANYLAYERS.local.mdis for notes you don’t commit.
The interactive session
ml code fills the terminal. The conversation scrolls at the top: PgUp/PgDn or the mouse wheel scroll back, and it follows new output unless you have scrolled up. The bottom stays fixed:
- the spinner while the agent works (
✻ Brewing… (12s · ↓ 300 tokens · esc to interrupt)), and any messages you typed meanwhile (queued; they are sent when it finishes); - the command menu as you type
/, or files as you type@; - the input, framed by two rules;
- a footer with the model, a context meter, the permission mode and the machine’s memory.
? on an empty line shows the shortcuts. Pickers, the permission prompt and the settings panel take the input’s place while they are open. When you leave, the conversation is printed to the terminal so it stays in the scrollback.
While the agent works, a spinner shows what it is doing, how long it has taken and the tokens so far. Anything you type waits for the next prompt. When it finishes, a line such as
✻ Brewed for 12.4s · done 4:35 PM · ↑ 8.1k ↓ 420 tokens sums up the turn.
Pickers
Choosing a model, a session, a mode or a checkpoint opens a list under the prompt. Move with ↑↓ (or Ctrl+P/Ctrl+N), select with Enter, close with Esc. Lists with a search box filter as you type.ml code --resume with no ID opens the session picker as it starts.
Rewind
Before each message you send, the agent records how much of the conversation came before it and keeps the original of every file it changes from then on. Rewinding to a message can restore the files the agent changed (files it created are removed), drop the conversation from that message on, or both. When the conversation is rewound, your message goes back into the input box so you can change it and send it again.Only changes made with the agent’s edit and write tools are tracked. What commands changed (a formatter,
git checkout, a build) is not undone. After /compact, earlier checkpoints can restore code only.Settings
/settings opens one panel with four tabs; /status, /config, /usage and /stats open it on that tab. Switch tabs with ←/→; close with Esc.
All commands
When the conversation nears the context limit (about 85%), the agent compacts it on its own, unless auto-compact is off in Config. A summary of what was asked, done and found replaces the history, and the work continues. If the model still refuses the request as too long, the agent compacts and retries once. Below the input, Context left until auto-compact appears once half the window is used.
Sessions are saved as you go under
~/.manylayers/sessions/. Continue the last one with -c, or choose one with --resume or /resume.
Scripts and CI
-p answers one prompt (an argument, or stdin) and exits. Nothing is asked in this mode: calls that need permission are refused unless you allow them beforehand with --allowedTools or --permission-mode.
All flags
MANYLAYERS_BASE_URL, MANYLAYERS_MODEL, MANYLAYERS_API_KEY. Commands the agent runs see MANYLAYERS_AGENT=1.