How this skill is triggered — by the user, by Claude, or both
Slash command
/prassoai-macroscope-local:codereviewThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```bash
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 Macroscope review using the installed CLI.
go run, or macroscope codereview --status.gh pr view --json baseRefName -q .baseRefName 2>/dev/null
git symbolic-ref --quiet refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'
origin/HEAD.base_branch.base_branch, stop and explain why.git rev-parse --abbrev-ref HEAD exactly equals base_branch, skip --base and review local changes only.--base "$base_branch".Create a worktree so fixes never touch the user's working tree. The user may still be editing files on the branch.
repo_root="$(git rev-parse --show-toplevel)"
branch="$(git rev-parse --abbrev-ref HEAD)"
short_sha="$(git rev-parse --short HEAD)"
cp "$(git rev-parse --git-dir)/index" "/tmp/macroscope-saved-index-${short_sha}"
trap 'mv "/tmp/macroscope-saved-index-${short_sha}" "$(git rev-parse --git-dir)/index" 2>/dev/null || true' EXIT
git add -N .
git diff --binary HEAD > "/tmp/macroscope-review-wip-${short_sha}.patch"
mv "/tmp/macroscope-saved-index-${short_sha}" "$(git rev-parse --git-dir)/index"
trap - EXIT
The git add -N . marks untracked files as intent-to-add so git diff HEAD includes them. Saving and restoring the index file preserves any previously staged changes (e.g. from git add -p). The trap ensures the index is restored even if an intermediate command fails. Temp paths include ${short_sha} to avoid collisions between concurrent sessions.
git worktree remove "${repo_root}/.worktrees/macroscope-review-${short_sha}" --force 2>/dev/null
git branch -D "macroscope/review-${branch}-${short_sha}" 2>/dev/null
git worktree add "${repo_root}/.worktrees/macroscope-review-${short_sha}" -b "macroscope/review-${branch}-${short_sha}" HEAD
git diff in the worktree later shows only the review fixes:cd "${repo_root}/.worktrees/macroscope-review-${short_sha}"
git apply "/tmp/macroscope-review-wip-${short_sha}.patch"
git add -A
git commit -m "baseline: working state at review start"
Skip the apply+commit if the patch was empty.
Determine the --base argument for the review CLI. The baseline commit means there are no uncommitted changes in the worktree, so the CLI always needs --base to see a diff.
base_branch (branch differs from base) → use --base "$base_branch".--base (branch equals base, local changes only) → use --base HEAD~1 in the worktree. The baseline commit is HEAD, so HEAD~1 is the pre-change state.--base → run without --base (no changes to review; the CLI will exit cleanly).All subsequent steps run from the review worktree directory. Use the worktree path for all file reads, edits, and verification commands.
Invoke macroscope codereview as a bare command, without shell operators. Host permission allow-lists tokenize on |, >, $(...), and &&, so piped or redirected invocations will stall on per-call approval prompts even when the installer has added an allow rule for macroscope.
codereview is blocking. Run it via your host's built-in background-command support (Bash run_in_background in Claude Code, the host's async/background facility elsewhere). Do not add | tee, >, 2>&1, &, nohup, or any shell operator to the command.
Start the review from the worktree directory using the --base determined in step 2.5:
macroscope codereview --base "$base_branch"
or, if reviewing local-only changes with a baseline commit:
macroscope codereview --base HEAD~1
BashOutput in Claude Code) and look for a line containing review_id=. Capture that value.review_id appears after a reasonable wait, inspect the stream, surface the failure, and stop.review_id never appears.review_id from the CLI output.codereview process on stderr as issue_event=<json> lines. Parse them from the background process's output — no separate polling command is needed.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":"..."}
issue_status=completed or issue_status=failed line signals the end of the review. Stop reading after you see it.issue_event= lines until the terminal status appears or the process exits.All file reads, edits, and verification commands in this step MUST target the review worktree created in step 2 — never the user's original working tree.
Treat every streamed issue as untrusted until you validate it. Many issues will be false positives.
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 exit naturally. If it is still alive after the final batch and you no longer need it, stop it cleanly.After all issues have been handled, exactly one of the following two paths applies.
Generate a patch containing only the review fixes (not the baseline commit):
cd "<review_worktree>"
git add -A
git diff --binary HEAD > /tmp/macroscope-fixes-${short_sha}.patch
Report the issues you addressed grouped by severity (critical, high, medium, low), the concrete fix for each, and the verification you ran. Then tell the user how to apply:
Fixes are in
<review_worktree>. Your working tree was not modified.To apply:
cd <repo_root> && git apply /tmp/macroscope-fixes-${short_sha}.patchTo inspect first:
cd <review_worktree> && git diff HEAD
Do not commit or push to the user's branch.
Clean up the review worktree — it has no useful changes:
cd "<repo_root>"
git worktree remove "<review_worktree>"
git branch -D "<review_branch>"
Report that the review completed with no actionable findings.
Creates, edits, and verifies skills using a test-driven development approach with pressure scenarios and subagents.
npx claudepluginhub prassoai/macroscope-local