Skip to content
Agent

mel agent (command line)

Run Mel's agent for one request from a terminal or a script, with approvals, JSON output and exit codes.


mel agent runs Mel's agent for one request from a terminal or a script. It works on the folder you run it in, on your own Mel account, with the same agent, tools and models as the Mel app.

mel agent "fix the failing test"

The answer streams to your terminal. What the agent does while it works (the commands it runs, the files it changes) is printed on a separate line each, so you can pipe the answer without them.

The Mel app does not add a mel command to your terminal by itself. On macOS and Windows, mel agent says "command not found" until you set it up once, as shown in Set up the mel command below. The examples on this page write mel.

Set up the mel command

Your terminal looks for commands in a list of folders called your PATH. The Mel app does not put its own folder on that list for you. This is true of the macOS download, of Homebrew, and of the Windows installer. On Linux, install.sh does it.

Each system below has two lines. The first runs Mel once, by its full path. The second makes mel work in every new terminal.

macOS

From v0.1.68 the quickest way is inside the app: open the command palette, choose Install the mel command, then open a new Terminal window. The same button is in Settings > Features > Command line. It links /usr/local/bin/mel to the app, may ask for your password, and can be removed from the same place.

On an older version, or if you would rather not give your password, the program is inside the app. This runs it once:

/Applications/Mel.app/Contents/MacOS/mel agent "fix the failing test"

This puts that folder on your PATH. It is for zsh, which is the Mac default. It works in every new Terminal window, and in scripts you start from one:

echo 'export PATH="$PATH:/Applications/Mel.app/Contents/MacOS"' >> ~/.zshrc

Open a new Terminal window to use it. If Mel is in your own Applications folder, write $HOME/Applications/Mel.app/Contents/MacOS instead. A scheduled job (cron or launchd) does not read ~/.zshrc, so give it the full path. To undo it, delete that line from ~/.zshrc.

Windows

The installer puts Mel in %LOCALAPPDATA%\Programs\Mel, for example C:\Users\you\AppData\Local\Programs\Mel. This runs it once from Command Prompt, and waits for it to finish (see Limits to know about):

start /wait "" "%LOCALAPPDATA%\Programs\Mel\mel.exe" agent "fix the failing test"

This puts that folder on your user PATH. It needs no administrator rights. Run it once in PowerShell:

[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$env:LOCALAPPDATA\Programs\Mel", "User")

Open a new terminal window to use it. Then start /wait mel agent "fix the failing test" works in Command Prompt. If you use the portable zip, write the folder you extracted it to instead. To undo it, search Start for "Edit environment variables for your account" and remove the Mel line from Path.

Linux

From the folder you unpacked the download into, this runs Mel once:

./mel agent "fix the failing test"

This installs it, and puts mel at ~/.local/bin/mel:

./install.sh

Most Linux systems already have ~/.local/bin on the PATH. If mel is not found, log out and in once, or add export PATH="$HOME/.local/bin:$PATH" to your ~/.bashrc.

Check it

Open a new terminal and run mel --version. It prints mel and the version. On Windows, run start /wait mel --version.

Before you start

Sign in to the Mel app once. mel agent uses the same account and the same settings: it runs on your credits, or on your own model keys if you have added them in Settings > AI. A Free account with no key of its own gets the same message in the terminal as in the app.

What it does

  • Works on the current folder as the project (or the folder you give with --cwd).
  • Runs one request. If the agent reaches its tool-call limit while it is still changing things, Mel carries on by itself, at most 20 times in a row. --max-credits stops it starting another one once that many credits are spent.
  • Saves the conversation like any other: it appears in the Mel app's conversation list, titled from your request. Use --no-save to keep nothing.
  • Opens no window and needs no display.
  • Stops what it started when it ends: background jobs the agent left running are stopped, and unless you pass --quiet or --json it tells you how many.

Give it the request

mel agent "explain what changed since main"       # the words after the options
mel agent --prompt "add a --verbose flag"          # or --prompt
echo "summarise the open TODOs" | mel agent        # or on standard input, when nothing else is given

Options

OptionWhat it does
--prompt TEXTThe request. You can also put it after the options, or pipe it in.
--model ID or autoA model from Settings > AI, or auto. Without it, the model your Settings start a new conversation on. A model Mel does not offer is refused, not replaced.
--mode NAMEThe Auto mode when the model is auto: balanced, cost-efficient, genius or open-weights.
--max-credits NDo not start another continuation once N credits are spent. It never cuts a turn that is running, so a run can spend N plus its last turn. 0 means no cap.
--timeout-secs NEnd the run N seconds after it starts. 0 means no limit.
--cwd DIRWork in DIR instead of the current folder.
--yesApprove commands and file edits without asking. It never answers anything that always asks (see below).
--jsonPrint events as JSON lines on standard output instead of the answer's text.
--quietPrint on standard error only what needs you: approval questions, refusals and a run that did not succeed.
--no-saveKeep nothing: the conversation is not saved or listed, the full text of long tool results is not kept, no result e-mail is sent, and Mel's automatic memory is off for the run.
-h, --helpThe options, the approval rules and the exit codes.

Approvals

The agent asks before it runs a command or changes a file, as it does in the app. Where the question goes depends on where you run it.

At a terminal (standard input and standard error are a terminal), each question is printed as a card on standard error and you answer. Commands and file edits take y or N; an edit shows the same diff the app shows. A command that cannot be undone, a change outside your project, a connector call, a file that holds secrets and control of your screen always ask, and take only the word yes typed out. --yes never answers those. A card is shown whole: a long line wraps and is never cut. A card too long to show whole (past 200 lines or 20 000 characters) says what it left out and takes only a typed yes. Commands that only read, from a closed list, run without a card, as they do in the app.

Not at a terminal (a pipe, a script, a scheduled job), nobody can answer. Without --yes, every approval is refused by name, for example Not run: a command needs a person; run mel agent in a terminal or pass --yes for commands and edits., and the run goes on with the refusal. With --yes, commands, background commands and file edits are approved, and everything that always asks is still refused.

The requestAt a terminalAt a terminal with --yesNot at a terminalNot at a terminal with --yes
A command, a background command, a file editYou answer y or NApprovedRefusedApproved
Anything that always asksYou type yesYou type yesRefusedRefused

An approval nobody answers for 30 minutes is denied and the run ends.

Output

  • Standard output is the answer, and nothing else (or, with --json, the event lines).
  • Standard error is for you: one line per tool call, notices from Mel, the approval cards, and a closing line with what the run did and cost.
  • On a terminal, control characters in a model's text are shown as visible marks, so a model cannot rewrite your screen. A pipe gets the text as it is.

Stopping it

Press Ctrl-C. The agent stops the way Stop does in the app: a running command is stopped, the conversation is saved, and the exit code is 130. Press it twice to leave at once.

JSON events

With --json, standard output is one JSON object per line, each with an event word first.

eventWhenFields
turn_startonce, first (a run refused before it starts has only an end)schema, mel_version, cwd, model, mode, interactive, approvals, saved, max_credits, timeout_secs
modelthe model that answers is known or changeslabel
texta piece of the answerdelta
tool_starta tool call beginsindex, title, summary
tool_endit endedindex, state (ok, failed, denied)
diffa file was changedpath, adds, dels
noticea line Mel says about the runtext
approval_askeda call needs an approvalid, kind, summary, always_asks, will, adds, dels
approval_answeredit was answeredid, kind, answer, by, reason
usagea segment of the run endedsegment, model, token and tool counts, total_ms, credits_milli, byok, budget_capped
endonce, lastreason, exit_code, message, conversation, title, usage

A field that is not known is left out, never written as zero: credits_milli is present only when Mel measured the cost, and 0 with byok: true means your own key paid. summary is one line with secrets masked. File contents and command output are never in the stream. schema is 1; within a schema number the stream only grows, so ignore a field or an event you do not know.

In turn_start, mode is the Auto mode's own word. Balanced is written responsive there; the other modes are cost-efficient, genius and open-weights. --mode takes either spelling.

{"event":"turn_start","schema":1,"mel_version":"0.1.64","cwd":"~/projects/shop","model":"auto","mode":"responsive","interactive":false,"approvals":"refuse","saved":true}
{"event":"tool_start","index":1,"title":"Run command","summary":"cargo test --lib"}
{"event":"tool_end","index":1,"state":"ok"}
{"event":"text","delta":"All tests pass."}
{"event":"end","reason":"completed","exit_code":0,"message":"completed","conversation":"1727700000-fix-the-failing-test","title":"Fix the failing test"}

Exit codes

CodereasonMeaning
0completedThe request was carried out.
2bad_usageThe command line was wrong, or the request was a Mel slash command, not a request.
3signed_outNo Mel account is signed in on this computer, or the session ended.
4plan_unconfirmedMel's server could not be asked about your plan, and nothing stands in for the answer.
7save_failedThe run finished but the conversation could not be written to disk.
10stoppedThe turn was stopped without a signal.
11errorMel's server or a model provider ended the run.
12context_exceededThe conversation is larger than the model's window.
13auth_requiredThe session was refused during the run.
14credits_exhaustedOut of credits and no key of your own to run on.
15vanishedThe turn's thread ended without a result.
18approval_expiredAn approval waited 30 minutes with no answer.
19deadline_exceeded--timeout-secs passed.
22rate_limitedYour account's daily or per-minute ceiling was reached.
23credit_cap--max-credits ended the run.
24plan_refusedYour plan does not include the Mel app.
25budget_cappedThe run hit its tool-call limit while still changing things and was not carried on: the work may be unfinished. Open the conversation in the Mel app and send "keep going".
130interruptedCtrl-C.
141output_closedStandard output was closed by its reader.
143terminatedThe process was terminated.

Where mel agent and Mel's cloud tasks share a code (3, 4, 7, 10 to 15, 18, 19, 22 and 23), it means the same for both, so one script can read both.

Limits to know about

  • mel agent has no --resume. To continue a run, open its conversation in the Mel app.
  • A request whose first word is a slash and a name (/plan, /compact, /pin, a saved prompt's name) is refused with exit code 2: those are the app's commands. A path is fine (/etc/hosts is wrong, why?), and so is a request with a word before the slash.
  • --no-save turns off Mel's automatic memory for the run; it does not stop the agent from using its own remember tool if it chooses to.
  • The agent cannot ask you a question in the middle of a run. If it tries, it goes on without an answer and the line says so.
  • It does not start other agents: orchestration needs panes, which a terminal run does not have.
  • Windows: the Mel program is a windowed program, so cmd.exe and PowerShell do not wait for it to finish. To get its exit code in %ERRORLEVEL%, and to be asked about a command or a file change in the console, run it as start /wait mel agent "..." (after you have set up the `mel` command, or with the full path shown there). Closing the console gives the run up to four seconds to stop the turn and save it.