/mex:mex [what to review [full | fresh | diff-only] | rerun [aspect]]from mex
Explains code changes across multiple aspects and displays results in a local web UI. Invoked via /mex with targets like uncommitted changes, a branch, a PR, or last N commits.
Ships in mex. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Explain the change described by $ARGUMENTS from several aspects and show the result in the mex web UI. The UI is the output of this skill; keep your chat messages to one or two lines.
The mex CLI is ${CLAUDE_PLUGIN_ROOT}/bin/mex. Run it from the root of the project being reviewed.
One command starts the round and opens the UI: mex start with --serve --agent claude. Make it your first command, alone, whenever the request is one of the table below: do not look at the repository first (no git status, no git log, no listing of earlier reviews), the reviewer is waiting for the browser to open.
If $ARGUMENTS starts with rerun, go to step 2 after one of:
${CLAUDE_PLUGIN_ROOT}/bin/mex start --reuse --clear --serve --agent claude # rerun: all aspects will be rewritten
${CLAUDE_PLUGIN_ROOT}/bin/mex start --reuse --serve --agent claude # rerun <aspect>: the other aspects stay
Otherwise turn the request into a target (a stable name for what is reviewed), a base and a head, and run mex start with a short human subject. The CLI takes the diff from git itself. An empty request is uncommitted changes; when that fails on an empty diff, it is this branch.
| request | target | base | head | subject |
|---|---|---|---|---|
| uncommitted changes, my changes, working tree | uncommitted | HEAD | WORKTREE | uncommitted changes |
| this branch | branch-<name> | MAIN (the CLI takes main, or master where there is no main) | HEAD | branch <name> |
| last N commits | last-N-commits | HEAD~N | HEAD | last N commits |
| commit X | commit-X | X~1 | X | commit X: <first line of its message> |
| this PR, PR N | pr-N | origin/<baseRefName> | <headRefOid> | PR #N: <title> |
Add --branch <headRefName> for a PR, so the review shows the decisions logged on the PR's branch, if any were logged in this checkout.
${CLAUDE_PLUGIN_ROOT}/bin/mex start "uncommitted changes" --target uncommitted --base HEAD --head WORKTREE --serve --agent claude
The branch name is the checked-out one; when you do not know it, put git branch --show-current into the same command (b=$(git branch --show-current); ... --target "branch-$b"), not into a command of its own.
For a PR, first gh pr view [N] --json number,title,baseRefName,headRefName,headRefOid, then git fetch origin <baseRefName> pull/N/head so both commits exist locally.
Anything else that is a valid git diff argument (staged changes: --cached) is piped instead; such a review always covers the whole change:
git diff --cached | ${CLAUDE_PLUGIN_ROOT}/bin/mex start "staged changes" --serve --agent claude
If $ARGUMENTS ends with full (or asks for the whole change, a full review), add --full; with fresh (start over, forget earlier reviews), add --fresh.
If $ARGUMENTS contains the word diff-only, add --diff-only; the rest of the request says what to review. The round then has no aspects: the reviewer gets the code diff alone and asks questions on it. Nothing else turns this on: the word diff by itself is a part of the description (review the main vs current branch diff is a normal review of this branch).
mex start prints the round directory (e.g. .mex/reviews/branch-iterate/02), what kind of round it is, the prompt file it copied there, the exact list of aspects to write, and last, as Review UI: <url>, where the review is open. Rounds of the same target build on each other:
Round NN: reviews the whole change - the first review of this target, or --full. Also when the base of the change moved since the previous round (a rebase) and git could not separate the base's changes from the new work; the output then says so, and the round is written like a first review.Round NN: incremental - the target was reviewed before and has changed since. diff.patch holds only the changes since the previous round, previous.md the previous round's comments and summaries, and the prompt is a follow-up prompt that asks how the comments were addressed. When the output says the base of the change moved, diff.patch leaves out what came with the new base; in a file it lists as conflicted, conflict markers in the removed lines are the conflict as git left it (between the previous round's version and the new base) and the added lines are how it was resolved.Unchanged: ... - nothing changed since the latest round. Write nothing: the reviewer has that round with its discussion back, continue with step 3.Diff only: ... (after the line about the round) - a --diff-only round. Write nothing here either: the browser is open on the code diff, continue with step 3.It fails on an empty diff, and then opens nothing; in that case tell the user there is nothing to review and stop. With --head WORKTREE the diff includes untracked files that are not ignored. A piped diff and a --head <rev> review do not; there, if git status --short lists ?? entries, mention in your final message that they were not reviewed.
The UI is open by now: --serve started the server in the background (or reused a running one) and opened the browser. If you started the round without it, run this before reading anything:
${CLAUDE_PLUGIN_ROOT}/bin/mex serve --agent claude
The reviewer gets the code diff at once and reads it while you write; the page shows how many aspects are ready and picks up each one as soon as it is saved. With --agent the server answers the reviewer's comments itself, in a separate read-only session of the agent, so that an answer appears in the thread while it is being written.
Read aspects.md in the round directory. It is the prompt: the text before the first ## is the rules and the output format, every ## is one aspect to write. Read diff.patch there (and previous.md for an incremental round). Read the source files around the change when you need them to understand it, but explain the change, not the files.
Write the aspects in the order mex start printed them, one at a time, and save each through the CLI, never by writing the file yourself:
${CLAUDE_PLUGIN_ROOT}/bin/mex aspect NN <<'EOF'
# <question>
...
EOF
NN is the aspect's number. The command checks that the text follows the aspect file format and saves it only then; otherwise it saves nothing and prints what is wrong. Fix it and run the command again; do not move on to the next aspect until it is saved. To change a saved aspect, save it again the same way. For rerun <aspect> write only the matching aspect (match by its number or by words of its question); for plain rerun write all of them.
Format reminders (the full rules are in aspects.md):
# <question> first, then the summary, then a line with --- (with an empty line before it), then the details. The --- line is required in every aspect that has text, whatever its own instructions say about the summary and the details; it is the only way the page tells them apart.# <question> line alone; the UI hides it. Still save it, or the page keeps waiting for it. on its own line embeds a screenshot or video saved into media/ of the round directory. Capture them only for the UI aspect, only when the project gives you a way to, and before saving that aspect so it never references a missing image.@diff path:from-to on its own line embeds that part of the round's diff.patch. Line numbers are new-file numbers: take them from the hunk headers @@ -old,len +new,len @@ and count from new. Every range you reference must contain changed lines; the UI shows a red placeholder for a reference that matches nothing.@thread NN/id on its own line embeds a comment thread of an earlier round (ids as in previous.md).Tell the user in one line that the review is open at the Review UI URL and that you are waiting for comments. Then loop:
${CLAUDE_PLUGIN_ROOT}/bin/mex wait
It blocks up to 50 seconds and prints one JSON event:
{"type":"timeout"} - nothing happened; call mex wait again. Keep looping silently, do not report timeouts.
{"type":"comment","id":N,"anchor":{...},"text":"...","history":[...]} - the user asked something and the server could not answer it itself, so it is yours to answer (rare: normally you never see comments). anchor is one of: lines of the diff ({"kind":"line","file","side","line"}; side is old for deleted lines, new otherwise; a range of lines also has startSide and startLine and runs from there to side/line in the order of the unified diff, so it may start in deleted lines and end in added ones - read the whole range), a file as a whole ({"kind":"file","file"}), a passage of an aspect ({"kind":"text","aspect","quote"}), or a decision of the Decisions page ({"kind":"decision","decision","question"}: the logged decision with that id and question as a whole, or with quote that passage of it; the log is the branch's .jsonl file in .mex/breadcrumbs/). history holds the earlier messages of the same thread, and changes, when there are any, the changes to the code the thread has noted so far, each with its id. Answer it from the code (read whatever you need), briefly and concretely, in markdown, then:
${CLAUDE_PLUGIN_ROOT}/bin/mex answer N <<'EOF'
<your answer>
EOF
and call mex wait again. If the user asks for a change to the code, do not make it: changes are made after the review, from the final note. Say in a sentence what would change, and end the answer with a line of its own for each change asked for, @change: <the change as an instruction that stands on its own: what to do and where, on one line>. These lines are not shown in the thread: each becomes an item in the draft of the user's final review note. Write one only for a change the user asks for, not for a question or an idea of yours. The comment's changes are already noted, so do not repeat them: @change 2: <the change as it is now> rewords the one with id 2 when the user adjusts it, @change 2: none takes it back.
{"type":"finished","note":"..."} - the user pressed "Finish review". note is their final review note (absent when they left none): the overall verdict and what they want done which outranks the individual threads when they conflict. It is also the list of changes to make: its draft starts with the changes noted in the threads, and the user edits it. changes (absent when there are none) holds every change the threads asked for, as {"thread","text"}. One that the note does not cover, in whatever words, was taken out of it by the user (with no note, that is all of them): never make such a change on your own. Warn the user about it and act only if they confirm. Run ${CLAUDE_PLUGIN_ROOT}/bin/mex stop, then reply briefly: the review is closed, the final note quoted in full if there is one, a warning listing the requested changes the note leaves out (if any), which says they will not be made unless the user confirms, and the questions asked (if any) as a short list so the user has a record. The comments are saved; mex threads prints them, with the final note, as markdown, so work on them can start from that; the same rule holds there: the note is what to do, and a thread's requested change that the note leaves out needs the user's confirmation. Running the same /mex again after more work reviews only what changed and how the comments were addressed; /mex <what> full reviews the whole change again, /mex <what> diff-only shows only the diff, without the aspects. /mex rerun regenerates the aspects of the latest round, /mex:customize copies the prompts into the project for editing.
While looping, the only things you write to the chat are answers that could not be delivered (because mex answer failed) and the final message.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub evilmartians/martian-explainer --plugin mex2 skills in this plugin
Other plugins' skills for the same job