mcode-delegate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MiniMax Code Delegate

MiniMax Code Delegate

You are the orchestrator. This skill lets you hand a bounded coding task to a separate implementer — the MiniMax Code CLI (
mcode
) — then review what it produced and land it yourself. You write the brief and own the judgment; MiniMax Code does the typing in your working tree; you verify and commit.
Nothing here is specific to one orchestrating agent. The loop needs only the ability to run a shell command and read a file, so it works the same whether you are Claude Code, OpenCode with a selected model, or any comparable agent. (It is designed for and run on Claude Code; treat other orchestrators as designed-for, not yet proven.)
你是 orchestrator(编排者)。此 skill 让你把一个边界明确的编码任务交给独立的 implementer(实现者)——MiniMax Code CLI(
mcode
)——然后审查其产出并自行落地。 你负责编写 brief(任务简报)并作出最终判断;MiniMax Code 负责在你的 working tree 中编写代码;你负责 验证并 commit。
这里的流程并不限定于某一种 orchestrating agent。这个循环只需要运行 shell 命令和读取文件的能力,因此无论你使用 Claude Code、搭配了所选模型的 OpenCode,还是任何同类 agent,工作方式都相同。(它专为 Claude Code 设计并在 Claude Code 上运行;对于其他 orchestrator,应将其视为已为其设计,但尚未得到验证。)

When NOT to use this

何时不要使用

  • The task is small enough to just do inline — delegation overhead is not worth it.
  • mcode
    is not installed or not signed in (run
    mcode login
    , or
    mcode login --region global
    ).
  • You want to write the code yourself, or you only need a review of local changes (
    mcode exec review
    does that directly).
  • You need writes outside the target tree to be impossible, not just unlikely. MiniMax Code has no sandbox; use an OS-enforced one such as
    codex-delegate
    , or run this inside a container.
  • 任务小到可以直接内联完成——委派开销不值得。
  • 未安装
    mcode
    或尚未登录(运行
    mcode login
    ,或
    mcode login --region global
    )。
  • 你想自己编写代码,或者只需要审查本地更改(
    mcode exec review
    可直接完成)。
  • 你需要确保绝不可能写入目标目录树之外,而不只是降低写入概率。MiniMax Code 没有 sandbox;请使用 OS 强制执行的隔离环境,例如
    codex-delegate
    ,或在 container 中运行。

Read this before the first dispatch: the autonomy model

首次派发前必读:自主性模型

mcode exec
takes a permission policy —
smart
,
full
, or
off
— and has no sandbox and no read-only or plan setting for a headless run (
ask
needs the TUI or ACP).
  • smart
    (the relay's default; TUI Auto):
    already approves file writes and deletions headlessly. A live probe asked for an
    rm
    and got it with no prompt. So
    smart
    is not a guardrail: the brief and a clean working tree are the real scope.
  • full
    (TUI Full access):
    skips normal confirmation entirely. The relay passes it only on an explicit
    --permission full
    .
  • off
    :
    refused by the relay; MiniMax Code does not document what it disables.
--read-only
is advisory: the relay appends a system prompt forbidding edits, keeps
smart
, and then runs a Git-visible change tripwire (
readOnlyViolation
). A change is detected after the fact, not prevented, and ignored or outside-repository paths are not covered.
mcode exec
接受权限策略——
smart
、
full
或
off
——且在 headless run 中没有 sandbox,也没有 read-only 或 plan 设置(
ask
需要 TUI 或 ACP)。
  • **
    smart
    (relay 的默认值;TUI Auto):**已经会在 headless 模式下批准文件写入和删除。 一次实时探测执行了
    rm
    ,且未出现任何提示。 因此,
    smart
    并不是防护栏:真正的范围边界是 brief 和干净的 working tree。
  • **
    full
    (TUI Full access):**完全跳过常规确认。relay 仅在显式指定
    --permission full
    时才会传入该选项。
  • **
    off
    :**relay 会拒绝;MiniMax Code 并未说明它会禁用哪些能力。
--read-only
仅具有建议性:relay 会追加一段禁止编辑的 system prompt,保留
smart
, 然后运行一个 Git 可见变更检测机制(
readOnlyViolation
)。变更是事后检测,而非事前阻止; 被忽略的路径或 repository 之外的路径均不在检测范围内。

Prerequisites (check once)

前置条件(检查一次)

  1. mcode --version
    succeeds and you are signed in (
    mcode
    →
    /status
    in the TUI). If not, install MiniMax Code and run
    mcode login
    .
  2. Confirm
    mcode
    is on PATH in the shell the relay runs from.
    The official installer puts it in
    ~/.minimax-code/bin
    , which only your shell profile adds to PATH; an orchestrator's non-login shell may not see it. Pass
    --mcode-path <file>
    or set
    MCODE_CLI
    when
    command -v mcode
    comes back empty. The relay records the version it ran in
    result.json
    .
  3. You are in (or will point
    --cd
    at) the target git repository, and its tree is clean before you dispatch — a run with no sandbox is much easier to review against a clean baseline.
  1. mcode --version
    执行成功,并且你已登录(可在 TUI 中输入
    mcode
    →
    /status
    )。如果尚未登录, 请安装 MiniMax Code 并运行
    mcode login
    。
  2. **确认 relay 运行所在的 shell 中,
    mcode
    位于 PATH 上。**官方安装器将其放在
    ~/.minimax-code/bin
    ,而只有 shell profile 才会把该目录加入 PATH;orchestrator 的非登录 shell 可能看不到它。当
    command -v mcode
    返回空时,请传入
    --mcode-path <file>
    或设置
    MCODE_CLI
    。 relay 会将其运行的版本记录在
    result.json
    中。
  3. 你位于目标 git repository 中(或将使用
    --cd
    指向它),并且在派发前工作树保持干净—— 在没有 sandbox 的情况下,以干净的基线审查要容易得多。

The loop

工作循环

Run these five steps per task. Steps 1, 4, and 5 are your judgment; 2 and 3 are mechanical.
每个任务执行以下五步。第 1、4、5 步由你判断;第 2、3 步是机械操作。

1. Write the brief

1. 编写 brief

MiniMax Code sees only the text you send — no repo memory, no chat history, no shared context (beyond the repo's own
AGENTS.md
, which it reads). Everything the task needs goes in the brief: the goal, the current state, what to change, what to leave untouched, the project's actual gate commands (discover them from the repo's AGENTS.md/CLAUDE.md/Makefile — do not assume), and a report contract. Tell it that it will not commit (you will). Keep one task per brief. Full guidance and a template: references/writing-the-brief.md.
MiniMax Code 只能看到你发送的文本——没有 repository memory、没有 chat history、没有 shared context(除了 repository 自身的
AGENTS.md
,它会读取)。brief 必须包含任务所需的一切:目标、当前状态、需要修改的内容、需要保持不变的内容、项目实际使用的 gate 命令(从 repository 的 AGENTS.md/CLAUDE.md/Makefile 中发现——不要臆测),以及 report contract。告诉它不要 commit(由你 commit)。每份 brief 只处理一个任务。完整指南和模板: references/writing-the-brief.md。

2. Dispatch

2. 派发

Send the brief to MiniMax Code with the bundled helper. It wraps
mcode exec
, captures the run, and writes a structured
result.json
— so your only job is "run a command, read a file." (
<skill-dir>
below is this skill's installed directory — the folder containing this
SKILL.md
, i.e. the directory you loaded the skill from. Claude Code prints it as "Base directory for this skill" when the skill loads; on other orchestrators use that same directory — if unsure where it landed, run
find ~ -name relay.mjs -path '*mcode-delegate*'
and substitute the directory above it.)
bash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/repo
使用随附的 helper 将 brief 发送给 MiniMax Code。它会封装
mcode exec
、捕获运行过程,并写入结构化的
result.json
——因此你只需“运行一个命令,读取一个文件”。(下文
<skill-dir>
指此 skill 的安装目录——即包含此
SKILL.md
的文件夹,也就是你加载该 skill 时所在的目录。加载 skill 时,Claude Code 会将其显示为“Base directory for this skill”;在其他 orchestrator 上,也应使用同一个目录——如果不确定它落在哪里,请运行
find ~ -name relay.mjs -path '*mcode-delegate*'
,并替换为其上级目录。)
bash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/repo

read-only (review/diagnosis; advisory): add --read-only

read-only (review/diagnosis; advisory): add --read-only

continue the exact session: add --session <sessionId> (from result.json; send only the delta brief)

continue the exact session: add --session <sessionId> (from result.json; send only the delta brief)

model / effort for this run: add --model minimax/<model> --effort high

model / effort for this run: add --model minimax/<model> --effort high

hard time limit (watchdog): add --timeout 2h (default: off; implementation runs routinely need 1-2h)

hard time limit (watchdog): add --timeout 2h (default: off; implementation runs routinely need 1-2h)

see all options: node .../relay.mjs --help

see all options: node .../relay.mjs --help


The helper defaults to a write-capable (`--permission smart`) run, which intentionally edits the target
repository. Its temp directory keeps only relay artifacts out of that repository. The relay **never
commits** — see step 5. Mechanics, flags, and the `result.json` shape:
[references/dispatch-and-poll.md](references/dispatch-and-poll.md).

helper 默认运行具备写权限的(`--permission smart`)任务,并会有意编辑目标 repository。其 temp directory 仅将 relay artifacts 保留在 repository 之外。relay **绝不 commit**——参见第 5 步。机制、flags 及 `result.json` 结构:
[references/dispatch-and-poll.md](references/dispatch-and-poll.md)。

3. Wait for completion

3. 等待完成

The helper blocks until MiniMax Code finishes, so back it with whatever your orchestrator offers and resume when it returns:
  • Claude Code: run the Bash call with
    run_in_background: true
    ; you are notified on completion.
  • Plain shell / other agents: run it in the foreground for short tasks, or background it and poll the result file —
    … &
    in bash/zsh, or your shell's equivalent. The run is done when
    result.json
    exists with a
    status
    . (A pre-run usage error — bad args or an empty brief — instead exits with code 2 and a stderr message and writes no result file, so check the exit code too. A missing
    mcode
    binary exits 127 but does write a
    result.json
    with status
    mcode_unavailable
    .)
A run is finished when
result.json
is written and the process has exited — read the working tree, not a status line. The implementer's full report is the
finalMessage
field in
result.json
(also printed in full on stdout between the report markers).
helper 会阻塞至 MiniMax Code 完成,因此可利用 orchestrator 提供的任何后台执行能力,并在返回后继续:
  • **Claude Code:**使用
    run_in_background: true
    在后台运行 Bash 调用;完成后会收到通知。
  • **Plain shell / other agents:**短任务可在前台运行;也可在后台运行并轮询 result file——在 bash/zsh 中使用
    … &
    ,或使用 shell 的等效方式。当
    result.json
    已生成且包含
    status
    时,运行即已完成。(如果是运行前的 usage error——参数错误或 brief 为空——则进程会以 code 2 退出并输出 stderr message,且不会写入 result file,因此也要检查 exit code。缺少
    mcode
    binary 时会以 127 退出,但确实会写入一个
    status
    为
    mcode_unavailable
    的
    result.json
    。)
一次运行完成的判定条件是:
result.json
已写入且进程已退出——应读取 working tree,而不是 status line。implementer 的完整报告位于
result.json
的
finalMessage
字段中(也会在 stdout 上报告标记之间完整打印)。

4. Review — do not trust the self-report

4. 审查——不要相信自我报告

result.json
includes MiniMax Code's own summary and gate claims. Re-verify, don't accept:
  • Re-run the project's gates yourself (the test/lint/build commands from step 1). Never take "gates passed" on faith.
  • Read the diff against the brief: did it do what was asked, nothing more (scope creep) and nothing less?
    touchedFiles
    in the result is your starting point — and because there was no sandbox, check for edits and deletions outside the paths the brief named, not just inside them.
  • Run the relevant guard skills on the diff if you have them installed (clean-code-guard, test-guard, etc. from
    guard-skills
    ) — this skill produces the work; those skills judge it.
  • For schema/migration changes, round-trip them; for removals, grep for dangling references.
Full checklist: references/review-and-land.md.
result.json
包含 MiniMax Code 自己的摘要和 gate 声明。请重新验证,不要直接接受:
  • **重新运行项目自己的 gate。**使用第 1 步中的测试、lint 和 build 命令。绝不要仅凭“gate 已通过”就相信结果。
  • 对照 brief 阅读 diff:确认它完成了要求的内容,既没有多做(scope creep),也没有少做。
    result.json
    中的
    touchedFiles
    是检查起点——由于没有 sandbox,除了 brief 指定的路径外, 还要检查其他路径中是否发生编辑和
    删除
    。
  • 如果已安装相关 guard skills,则对 diff 运行这些 skill(例如来自
    guard-skills
    的
    clean-code-guard
    、
    test-guard
    等)——此 skill 负责产出工作,而这些 skill 负责评判工作。
  • 对于 schema/migration 更改,对其执行 round-trip 验证;对于删除操作,使用 grep 查找悬空引用。
完整清单: references/review-and-land.md。

5. Land it

5. 落地

The relay never commits, but nothing stops MiniMax Code from writing
.git
. The brief forbids implementer commits, and the reviewer compares
HEAD
with the recorded pre-dispatch baseline before landing anything. The orchestrator commits. Only after the gates pass and the diff holds:
  • Commit the verified work yourself, with a clear message.
  • If it needs changes, send a delta brief with
    --session <sessionId>
    from the prior
    result.json
    , and review again.
relay 从不 commit,但没有任何机制阻止 MiniMax Code 写入
.git
。brief 禁止 implementer commit,而 reviewer 在落地任何内容前,会将
HEAD
与派发前记录的 baseline 进行比较。**orchestrator 负责 commit。**只有 gate 全部通过且 diff 经核对无误后:
  • 由你 commit 已验证的工作,并使用清晰的 commit message。
  • 如果还需要修改,使用上一次
    result.json
    中的
    --session <sessionId>
    发送 delta brief,然后再次审查。

Read-only second opinions

Read-only 第二意见

The relay doubles as a way to get an adversarial second opinion: dispatch
--read-only
with a brief that lists the agreed points, then each contested point with both positions, and ask MiniMax Code to defend or concede each — deliverable in its final message, touching no files. Because that read-only state is only a prompt, read the verdict every time:
readOnlyViolation: false
means the Git-visible detector saw no change (ignored or outside-repository paths are not covered);
true
means it saw one;
null
means git could not tell. Dispatch second opinions on a clean tree you can afford to restore.
relay 还可以用作获取对抗性 second opinion:通过
--read-only
派发一份 brief,其中先列出双方已达成一致的要点,再针对每个有争议的要点列出双方立场,并要求 MiniMax Code 为每个要点进行辩护或让步;交付物位于其 final message 中,且不触碰任何文件。由于 read-only 状态只是一段 prompt,因此每次都必须读取 verdict:
readOnlyViolation: false
表示 Git 可见变更检测机制未发现变更(被忽略的路径或 repository 之外的路径不在覆盖范围内);
true
表示检测到变更;
null
表示 git 无法判断。请在可以放心恢复的干净 working tree 上派发 second opinion。

Authorization model

授权模型

Delegation is something the human opts into. Once they have ("run this queue", "proceed"), committing verified, gate-passing work is the agreed contract — that is the whole point. Two limits on that mandate: surface, don't absorb (report MiniMax Code's design decisions, defensible-but-unasked turns, and non-blocking nitpicks rather than silently keeping them) and stop for scope changes (if correct completion needs going beyond the brief, ask — don't expand the mandate yourself). The full treatment is in references/review-and-land.md.
委派需要由 human 主动选择。一旦 human 表示同意(“运行这个队列”“继续”),将已验证且通过 gate 的工作 commit 就构成双方约定的 contract——这正是整个流程的核心。该授权有两个限制:surface, don't absorb(报告 MiniMax Code 的设计决策、有道理但未被要求的改动,以及不阻塞的细节问题,而不是默默保留它们)和 stop for scope changes(如果正确完成任务需要超出 brief 的范围,应询问,而不是自行扩大授权)。完整说明见 references/review-and-land.md。

References

参考资料

  • references/writing-the-brief.md — how to write a brief MiniMax Code can execute blind: structure, XML blocks, the report contract, embedding the real gate commands.
  • references/dispatch-and-poll.md —
    relay.mjs
    flags, the
    result.json
    contract, backgrounding per orchestrator, and recovery when a run misbehaves.
  • references/review-and-land.md — the review checklist, the commit boundary, and the exact-session rework cycle.
  • references/multi-task-queues.md — running a sequential queue: carrying constraints forward, progress tracking, and the end-of-run coherence check.
  • references/writing-the-brief.md——如何编写一份 MiniMax Code 可在不了解上下文的情况下执行的 brief:结构、XML blocks、report contract,以及嵌入真实的 gate 命令。
  • references/dispatch-and-poll.md——
    relay.mjs
    flags、
    result.json
    contract、针对各 orchestrator 的后台运行方式,以及运行异常时的恢复方法。
  • references/review-and-land.md——审查清单、commit 边界,以及基于原 session 的返工循环。
  • references/multi-task-queues.md——运行顺序队列:延续约束、跟踪进度,以及运行结束时的整体一致性检查。