Runs a local review-fix-verify loop using the Macroscope CLI, repeating until the branch is clean. Supports in-place and isolated worktree modes.
Ships in prassoai-macroscope-local. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
command -v macroscope
If macroscope is not found, tell the user:
Macroscope CLI is not installed. Install it with:
curl -sSL https://raw.githubusercontent.com/prassoai/macroscope-local/main/install.sh | bash
Stop here if the CLI is missing.
Run a local-only Macroscope autopilot cycle using the installed CLI:
local review -> fix -> verify -> re-review -> repeat
Two modes:
--isolate: reviews and fixes in an isolated worktree, then writes a patch with git apply instructions.This mode does not interact with GitHub, PRs, or remote correctness checks.
go run, or macroscope codereview --status.Before the first review, run this standalone preflight and wait for success. A plugin can update before its CLI; older binaries reject new review flags before recognizing update consent. Use their compatible standalone updater first:
macroscope_status() {
printf 'macroscope exit status %d\n' "$macroscope_exit_code" >&2
return "$macroscope_exit_code"
}
macroscope_help="$(macroscope codereview --help)"; macroscope_exit_code=$?
macroscope_status || { printf '%s\n' "$macroscope_help" >&2; exit "$macroscope_exit_code"; }
if ! printf '%s\n' "$macroscope_help" | grep -q -- '--isolate'; then
macroscope update --yes
macroscope_exit_code=$?
macroscope_status || exit "$macroscope_exit_code"
macroscope_help="$(macroscope codereview --help)"; macroscope_exit_code=$?
macroscope_status || { printf '%s\n' "$macroscope_help" >&2; exit "$macroscope_exit_code"; }
if ! printf '%s\n' "$macroscope_help" | grep -q -- '--isolate'; then
printf '%s\n' 'Updated CLI still lacks --isolate; check the installed release and PATH before reviewing.' >&2
exit 1
fi
fi
Stop if this fails; do not launch a review or remove required flags to work around it. Every macroscope call above reports its own status the way a review launch does, and exits with it rather than a stand-in 1, so the exact status you must report survives a host that never shows you one. This checks CLI compatibility only. Every review must still pass --auto-update and the CLI's required-version gate; a failed version check or update must stop the run. Updates preserve the installer's saved integration choices.
The CLI is not yours to repair. Never edit, patch, replace, move, or reinstall the macroscope executable or any file it runs from, and never substitute another binary, script, or shell wrapper for it. Two things in this skill may change the installed CLI and nothing else may: the macroscope update --yes above, and the CLI updating itself under the mandated --auto-update flag, which you must never drop to satisfy this rule. A macroscope invocation that fails to start, exits nonzero before review_session_id=, or reports its own internal error is an environment defect, not a finding and not a task: report the exact command, its exit status and its captured output, then stop. Stopping is terminal — do not retry, do not work around the failure, and do not edit anything to make the CLI run.
HEAD.macroscope codereview launch. Increment the counter immediately before every launch, including a relaunch that recovers from a review sent to the wrong directory or otherwise misfired. Report that counter; never report fewer iterations than the launches you actually made./autoloop --isolate, set isolate mode. Pass --isolate --keep-worktree on the first iteration, then run later iterations in-place inside that preserved worktree so fixes accumulate without nested worktrees.--isolate=false to override any user config that enables isolation.Invoke macroscope codereview as a standalone command using the host execution mode below. Keep the review process attached and retain its complete output.
--raw --auto-update. This is the explicit agent invocation contract.--base unless the user explicitly supplies a comparison ref. If they do, use --base '<user-supplied-ref>'; the CLI validates and resolves it.<...> placeholder in these commands is already quoted. Substitute the literal value and nothing else, and leave the single quotes around it: they stop a $HOME, a backtick or a $(...) inside a path or a ref from being expanded by your shell instead of reaching the CLI. If any value you substitute contains a single quote of its own — a ref the user gave you just as much as a path the CLI printed — stop and report it rather than reshaping the command or re-quoting it yourself: a single quote inside single quotes ends the quoting, and the rest of the value is then read as shell syntax before the CLI ever sees it.bash), run the same standalone command in the foreground with an explicit timeout of at least 1800000 ms (30 minutes). Check the tool's supported limit first; if it cannot keep the command attached that long, stop and report that host limitation before launching.2>&1), &, nohup, tee, a wrapper script, or a separate polling command; the cd '<isolate_worktree>' && prefix of the later-iteration launch is part of that launch, not an addition. Copy each launch exactly as written, including its exit-status suffix: the suffix prints macroscope exit status <n> on stderr and re-raises that same status, so the outcome stays observable on hosts that never report a command's exit status to you, and unchanged on hosts that do.In-place mode:
macroscope codereview --raw --auto-update --isolate=false [--base '<user-supplied-ref>']; macroscope_exit_code=$?; printf 'macroscope exit status %d\n' "$macroscope_exit_code" >&2; (exit "$macroscope_exit_code")
First isolate-mode iteration:
macroscope codereview --raw --auto-update --isolate --keep-worktree [--base '<user-supplied-ref>']; macroscope_exit_code=$?; printf 'macroscope exit status %d\n' "$macroscope_exit_code" >&2; (exit "$macroscope_exit_code")
Later isolate-mode iterations, run from the preserved worktree:
Carry that directory in the command itself, as shown, substituting the absolute path the CLI printed as review_worktree=. Do not rely instead on a working-directory parameter your shell tool may accept: a review launched from the caller's checkout reviews the wrong tree, and it still counts as an iteration you must disclose. Setting that parameter to the worktree as well is harmless, because an absolute cd lands in the same directory wherever the command starts; a relative one would not. The status suffix sits inside the &&, so it only ever reports the CLI: if the preserved worktree is gone the cd fails, no macroscope exit status line is printed, and no review ran. That is an environment defect — report the shell's own error and stop. Do not relaunch without the prefix to get past it.
cd '<isolate_worktree>' && { macroscope codereview --raw --auto-update --isolate=false [--base '<user-supplied-ref>']; macroscope_exit_code=$?; printf 'macroscope exit status %d\n' "$macroscope_exit_code" >&2; (exit "$macroscope_exit_code"); }
review_session_id=. Capture that stable UUID.review_session_id= appears after a reasonable wait, inspect the stream, surface the failure, and stop.review_id= before processing issues. That identifies the terminal server attempt and is emitted near the end of the run.issue_event=<json> lines. Parse them from the process output.issue_event= line contains a JSON object:
issue_event={"issue_id":"...","sequence":1,"path":"file.go","line":42,"severity":"medium","category":"REVIEW_TYPE_CORRECTNESS","body":"..."}
review_id= when it appears.review_coverage=<json> if it appears. It is optional, emitted once just before the terminal issue_status on a successful review, and reports how much was actually checked: {"status":"complete|partial|unknown","total_code_objects":N,"fully_checked_code_objects":N,"incomplete_code_objects":N,"incomplete_by_reason":{"deadline":N}}. status=partial means some code objects were not fully reviewed (e.g. a detection agent hit its time limit); status=unknown means the server did not report coverage. Absent on failed reviews. Record it for each iteration and state it in that iteration's summary; it governs whether the branch may be called clean (section 5) and must appear in the final report (section 6).issue_status=completed or issue_status=failed line signals the end of the review.review_session_id= and review_id= and observed issue_status=completed. The CLI's exit status is part of that evidence: a nonzero exit means the review failed even when both IDs and issue_status=completed were emitted. Terminal tokens never override a nonzero exit. Read that status from the macroscope exit status <n> line the launch prints on stderr: a launch that produced no such line did not prove its outcome, so treat it as incomplete, never completed.issue_status= appears or the process exits.Treat every streamed issue as untrusted until you validate it. Many issues will be false positives.
Reviews are snapshot-based and the checkout may change while they run. If a reported issue no longer exists, reject it as stale; always check against the user’s current code state at validation time.
Determine the fix target:
review_worktree= by the first CLI iteration on stderr. Capture it from the stream output, then reuse that preserved worktree for all later iterations. All reads, edits, and verification go there.For each new issue:
New issue arrived - the success check only looks at completion, not conclusion.Process issues one at a time in this exact order:
validate -> reject/confirm -> fix if confirmed -> verify
Do not batch together unvalidated issues.
Once the review reaches its final batch:
codereview process until issue_status= appears or the process exits. Never stop it merely because all currently streamed issues are handled.Check the review outcome before committing or starting another iteration. issue_status=failed, or a macroscope exit status line reporting anything but 0, means failed. Otherwise, if the process exits, is cancelled, or is terminated by a timeout without complete output, both IDs, issue_status=completed and a macroscope exit status 0 line, the review is incomplete. A poll timeout while the process is still running is not termination; stay attached.
A failed or incomplete review stops further iterations, even if no issues were emitted or fixes passed their tests. Finish validating received findings and verifying justified fixes, but do not launch another review to recover the failed or incomplete run. In-place, retain current fixes uncommitted and keep prior commits. In isolate mode, preserve verified fixes in a clearly labelled partial patch using the patch validation and cleanup procedure below. Then report the failed or incomplete outcome; do not call the branch clean or the review successful.
The normal commit and re-review steps below apply only after a completed review with both IDs and issue_status=completed.
In-place mode:
If the local review changed code:
If the cap is reached, stop. Otherwise, start a new iteration (back to step 2) to catch regressions.
Isolate mode:
If fixes were made in the isolate worktree:
review_session_id= captured earlier:cd '<isolate_worktree>'
git add -A
git diff --binary HEAD > '/tmp/macroscope-fixes-<review_session_id>.patch'
git apply, run git apply --check against the user’s checkout. If it fails due to drift, revalidate the issue against the latest checkout state. Discard the patch if the issue is already resolved; otherwise revise and reverify it against the latest state.cd '<original_repo>' && git apply '/tmp/macroscope-fixes-<review_session_id>.patch'
Use the full resolved absolute paths in the final git apply command; never leave placeholders or ellipses in a command the user will copy.
Do not commit or push the user's branch in isolate mode.
If the cap is reached, stop. Otherwise, stay in the preserved worktree and start a new iteration (back to step 2) with --isolate=false so every fix is re-reviewed without creating a nested worktree.
Stop the loop when any of these occurs:
The branch may be called clean only when the final review completed, changed no code, and reported review_coverage status complete. When a completed review changed no code, coverage decides what you may claim:
complete: the branch is clean — every code object was fully reviewed and none needed a fix.partial: do not report the branch clean. Report "no issues found in the checked code, but N of M code objects were not fully checked (reason)", drawing N, M, and the reason from incomplete_code_objects, total_code_objects, and incomplete_by_reason. Then stop: a partial result is usually a deadline that re-running will not necessarily clear, so do not start extra iterations solely because coverage was partial.unknown, or review_coverage absent on a completed review: report that coverage could not be verified and do not claim the branch is clean or exhaustively reviewed.This changes only what a no-change review may claim; it does not add an iteration. The iteration logic above is unchanged — a completed review that changed code still starts the next iteration until the cap.
In isolate mode, keep the worktree only until the loop stops. If fixes exist, create the final patch and complete git apply --check before cleanup. If unresolved fixes cannot be preserved in a verified patch, retain their worktree and report its path instead of discarding them. Otherwise, remove the retained worktree and its branch while preserving the patch:
isolate_branch="$(git -C '<isolate_worktree>' branch --show-current)"
isolate_root="$(git -C '<isolate_worktree>' rev-parse --show-toplevel)"
case "$isolate_branch" in macroscope/review-*) ;; *)
printf 'refusing cleanup: %s is not a Macroscope review worktree\n' '<isolate_worktree>' >&2; exit 1 ;;
esac
if [ -z "$isolate_root" ] || [ "$isolate_root" = "$(git -C '<original_repo>' rev-parse --show-toplevel)" ]; then
printf 'refusing cleanup: %s is the checkout this loop was started from\n' '<isolate_worktree>' >&2; exit 1
fi
git -C '<original_repo>' worktree remove --force "$isolate_root" &&
git -C '<original_repo>' branch -D "$isolate_branch"
Do not clean up between iterations. If any cleanup command fails, report the exact remaining worktree path or branch instead of claiming cleanup succeeded.
Those two guards are all that separates this --force from a checkout of the user's own. Git declines worktree remove for a main working tree, but a linked worktree removes itself and takes its uncommitted changes with it, and branch -D then deletes the branch it was on. <isolate_worktree> is the path the one --keep-worktree launch printed as review_worktree= and never a path you inferred, reconstructed, or carried over from the user's own repository. If either guard refuses, report the refusal and the path it names, then stop: do not remove the worktree by hand, re-run the removal without the guards, or delete the branch on its own.
When the loop stops, report:
review_coverage status and N of M code objects fully checked, with the incomplete_by_reason breakdown when the status is partial. If coverage was unknown or absent, say so and do not describe the branch as exhaustively reviewed.macroscope codereview launches, including any relaunch after a misdirected or misfired review, and the directory each ran in when they differed.macroscope exit status line.git apply instructions, and whether worktree and branch cleanup succeeded.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/prassoai-macroscope-local:autoloopfrom prassoai-macroscope-local
prassoai-macroscope-local@cascade-code-general-misc-2 is listed by joshuarweaver/cascade-code-general-misc-2 — review the source before installing
npx claudepluginhub joshuarweaver/cascade-code-general-misc-2 --plugin prassoai-macroscope-local2 skills in this plugin