Kilo Code CLI

Make the Kilo Code CLI wait for a person's yes before every shell command, file change, web fetch and MCP tool call: a plugin set up in one command, verified in Kilo 7.8.32.

The Kilo Code CLI, the kilo command, is built from OpenCode, and like OpenCode it runs shell commands and edits files without asking unless you configure it to. In our runs, kilo run wrote a file with echo and nobody was asked. The VariantGate plugin puts a person in: every shell command, file change, web fetch and MCP tool call waits for a yes from the inbox, a phone notification, Slack or email. Rules answer the routine ones, and every answer lands on the same record as your other agents.

The quick way: one command

With Node.js on the computer it runs on, this does both steps for you. It opens the browser to sign in (or to make your free account), saves an agent key on this computer, and adds the approval hook to ~/.config/kilo/plugins/variantgate.js, keeping the old file beside it:

npx -y https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz setup kilo

Restart Kilo and ask it to run echo hello: the command waits until you approve it in the inbox, and so does every file change, web fetch and MCP tool call. A no blocks that one call. A file it cannot change safely, such as one with comments or one that links elsewhere, is left alone, and the command prints the entry to add yourself. The steps below do the same by hand.

1. Create a key

Sign in, open Agents and create a key for Kilo. Copy it: it is shown once. Put it in your shell profile, such as ~/.zshrc, as export VARIANTGATE_KEY=….

2. Add the plugin

Install the variantgate command (more on the SDK page):

npm install -g https://variantgate.com/sdk/variantgate-agent-latest.tgz

The hook reads VARIANTGATE_KEY from the environment Kilo starts in, or a key saved on this computer:

Or run variantgate login once on this computer instead. It opens the browser, you check a code and press Connect, and it saves a new agent key in ~/.config/variantgate/credentials.json, readable only by you. The hook uses that key, with the API address it was made for, whenever VARIANTGATE_KEY is not set. The MCP server still needs the key from step 1.

Kilo keeps OpenCode’s plugins: JavaScript files it loads from ~/.config/kilo/plugins when it starts. The VariantGate plugin is the same one file as for OpenCode, with nothing to install. Before each tool call it runs variantgate hook kilo, and anything but a yes blocks the call. This prints the whole file, to save under that folder as variantgate.js:

variantgate setup kilo --print

The part that decides:

const HOOK = "variantgate hook kilo";

export const VariantGate = async ({ client, directory }) => {
  // ...
  return {
    "tool.execute.before": async (input, output) => {
      if (LOOK_ONLY.has(input.tool)) {
        return;
      }
      const answer = await ask({
        args: output.args,
        directory,
        mcpServers: await mcpServers(),
        tool: input.tool,
      });
      if (answer?.decision !== "allow") {
        throw new Error(`VariantGate: ${answer?.reason ?? "not approved."}`);
      }
      freeze(output.args);
    },
  };
};

The plugin lets the tools that only look, plan or talk to you go ahead at once, without a request: OpenCode’s read, glob, grep, list, lsp, todoread, todowrite, question, task, invalid, and Kilo’s own agent_manager_models, board_read, cron_list, kilo_local_recall, which search its models, read the board its subagents share, list its scheduled tasks and search past sessions. Those four go to the hook first, because an MCP tool could carry the same name: with a server called cron, its tool list is cron_list too, so the hook lets the name through only when no MCP server in Kilo’s config fits it, and asks about it as mcp.cron.list when one does. A task starts a subagent, and each of the subagent’s own calls goes through the plugin; in our runs a subagent’s shell command was asked about, denied and not run. Any other tool, including one a later version adds, waits for a yes. The hook gets the call on stdin:

{
  "opencode": {
    "tool": "bash",
    "args": { "command": "npm test", "description": "Run the tests" },
    "directory": "/home/ada/shop",
    "mcpServers": ["my.shop"]
  }
}

Each call becomes a request with an action name that rules can match:

shell.run
A bash call, with the command and the project folder. The same name the OpenCode, Claude Code, Codex, Gemini CLI, Cursor, Copilot and Cline hooks use, so one rule covers them all.
file.write
A write call, with the file's path and text.
file.edit
An edit, multiedit, patch or apply_patch call.
web.fetch
A webfetch call, with the address.
mcp.<server>.<tool>
A call to an MCP tool, named after the server in your Kilo config: mcp.my%2Eshop.refund_order for Kilo's my_shop_refund_order.
tool.<name>
Any other tool, such as tool.background_process, tool.cron_create or skill, one a later Kilo version adds, or one from another plugin.

Kilo’s own tools

Kilo adds tools OpenCode does not have. The ones that do something are asked about like a shell command, each as tool.<name>:

background_process
starts or stops a long-running process
cron_create, schedule_wakeup
schedule a later run of the session
cron_delete, cancel_wakeup
remove a scheduled run
goal, goal_report
start or close a goal loop
board_post
posts to the board its subagents share
link_pr
links the session to a pull request

A scheduled run that comes due later goes through the plugin again, call by call, so approving cron_create approves the schedule, not what the run will do. If asking about these is more than you want, an allow rule for tool.board_post answers it for you.

A no blocks one call

When a plugin throws before a tool runs, Kilo does not run it and hands the model the error as the tool’s result. The session goes on, so the model learns why and can carry on with the rest of the work. From our run:

✗ echo ran > marker.txt failed
Error: VariantGate: Not approved: denied (Not this one.). Do not try another way to do this.

The reason the person typed in the inbox is in that message. An approval with changes is a no for the call as it was asked, and the message says what was approved instead, so the model can make that call, which is asked about again.

What Kilo does when a plugin fails

We ran the plugin in the Kilo Code CLI 7.8.32 with kilo run, against a scripted model and a local copy of the service:

  • If the service cannot be reached, no key is set or saved, or the hook cannot start, crashes or prints something else, the plugin blocks the call.
  • Kilo, like OpenCode, puts no time limit on a plugin, so a person gets five minutes by default, and VARIANTGATE_KILO_HOOK_WAIT sets another number of seconds, up to a day. After the wait the request is withdrawn and the call blocked.
  • The one gap: Kilo skips a plugin that does not parse, without a word, and then runs every call without it. We checked that with a plugin holding a syntax error: the command ran. That is why the plugin imports nothing but Node’s own child_process and does nothing until a call is made. If you edit the file, run one call and check that it is asked about. Running setup kilo again replaces a plugin an earlier version wrote.

MCP tool names

Kilo names an MCP tool as OpenCode does: the server and the tool joined by an underscore, with characters other than letters, digits, _ and - made _. The tool refund_order on a server called my.shop was my_shop_refund_order in our run. The plugin reads the MCP servers in Kilo’s config and the hook splits the name there, so the request was asked as mcp.my%2Eshop.refund_order (a dot in a name is escaped), the same action the other hooks send. When two servers’ names both fit, the whole name is the action, so no rule for one server’s tools can approve the other’s; the OpenCode guide has the details. Restart Kilo after you add an MCP server.

Kilo and OpenCode side by side

Kilo reads its own folder, ~/.config/kilo, not OpenCode’s: a plugin in ~/.config/opencode/plugins did not run in our Kilo runs. If you use both, run setup kilo and setup opencodeonce each. Kilo loads both a plugins and a plugin folder, so a second copy of the VariantGate plugin asks about each call twice; setup kilo warns about a copy in the other one. A plugin runs with your rights, so treat a project’s plugin folder like a change to your pipeline. Once a call is approved the plugin freezes its arguments, so a plugin that runs after it cannot change what runs.

In scripts and CI

kilo run has nobody at the terminal, so the plugin is the whole approval step there. Give the run a key, and install the variantgate command on the machine so the hook starts fast:

export VARIANTGATE_KEY=...   # a key for this pipeline
kilo run "Fix the failing test and push a branch"

A run that waits for a person holds the pipeline for up to the wait. Plan for a no: the call is blocked and the model is told why, so the task may finish without doing it. Check the result rather than the exit code, which was 0 in our runs either way.

What we have not tested

We tested kilo run on macOS. We have not tested the plugin in Kilo’s terminal app, in the Kilo Code extensions for VS Code or JetBrains, or on Windows, where the plugin starts the hook through the system’s shell. Kilo’s VS Code docs say the extension’s version 7 runs the same engine and reads the same ~/.config/kilo settings, so the plugin may well load there too, but check one call before you rely on it.

Check that it works

Restart Kilo and ask it to run echo hello. A request appears in the inbox; deny it and check that hello was not printed. Then ask again and approve it.