feat: make review loops agent-agnostic with shared library and prompts#1
Conversation
rlorenzo
commented
Mar 17, 2026
- Extract shared library (lib-review-loop) with agent dispatch, validation, artifact cleanup, and temp/elapsed helpers
- Move prompts from .codex/prompts/ to agent-agnostic prompts/ dir; installer symlinks them to ~/.local/share/ai-coding-setup/prompts/
- Add Gemini Policy Engine file and Codex skills for code review
- Gate deprecated tools.allowed migration on active policy file and preserve MCP entries; seed settings.json on fresh Gemini installs
- Restrict Claude reviewer to read-only tools (plus Bash for git); skip artifact cleanup for editor role to preserve Codex-created files
- Derive review-loop config defaults from selected tools instead of hardcoding claude/codex; protect user-modified prompts with marker
- Stash pre-review snapshot so developers can restore mangled files
- Extract shared library (lib-review-loop) with agent dispatch, validation, artifact cleanup, and temp/elapsed helpers - Move prompts from .codex/prompts/ to agent-agnostic prompts/ dir; installer symlinks them to ~/.local/share/ai-coding-setup/prompts/ - Add Gemini Policy Engine file and Codex skills for code review - Gate deprecated tools.allowed migration on active policy file and preserve MCP entries; seed settings.json on fresh Gemini installs - Restrict Claude reviewer to read-only tools (plus Bash for git); skip artifact cleanup for editor role to preserve Codex-created files - Derive review-loop config defaults from selected tools instead of hardcoding claude/codex; protect user-modified prompts with marker - Stash pre-review snapshot so developers can restore mangled files
There was a problem hiding this comment.
Pull request overview
This PR refactors the review-loop automation to be agent-agnostic by centralizing shared logic into a Bash library and moving automation prompts into a shared prompts/ directory, while also introducing Gemini Policy Engine support and new Codex/Gemini “code review”/“code refinement” commands.
Changes:
- Added
lib/lib-review-loopand updatedcode-review-loop/plan-review-loopto dispatch between Claude/Codex/Gemini with shared validation, temp handling, and artifact cleanup. - Moved review-loop prompt dependencies into
prompts/and updatedsetupto install them under~/.local/share/ai-coding-setup/prompts/(preferring symlinks while preserving user edits). - Added Gemini Policy Engine policy + new Codex skills and Gemini commands for code review/refinement; updated docs and pre-commit shellcheck settings.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
setup |
Installs shared prompts + shared library; updates Gemini settings to prefer Policy Engine and migrate deprecated tools.allowed safely. |
lib/lib-review-loop |
New shared Bash library for prompt reading, agent dispatch, validation, temp handling, and artifact cleanup. |
bin/code-review-loop |
Migrated to shared library + shared prompts; adds agent flags/config + stash safety snapshot. |
bin/plan-review-loop |
Migrated to shared library + shared prompts; adds agent flags/config. |
prompts/code-review.md |
Removes tool-specific frontmatter to make prompt agent-agnostic. |
prompts/code-review-followup.md |
New follow-up reviewer prompt for iterative re-review. |
prompts/code-review-response.md |
New editor “respond/implement” instructions prompt. |
prompts/code-refinement.md |
New agent-agnostic refinement prompt used by the review loop. |
prompts/plan-review.md |
Removes tool-specific identifiers to make prompt agent-agnostic. |
prompts/plan-review-followup.md |
Removes tool-specific frontmatter to make prompt agent-agnostic. |
README.md |
Documents shared prompts and adds command docs for code review/refinement. |
.pre-commit-config.yaml |
Runs shellcheck with -x to follow sourced files. |
.gemini/policies/readonly-tools.toml |
Adds Policy Engine file defining read-only permissions. |
.gemini/commands/code-review.toml |
New Gemini code-review command writing agent-code-review.md. |
.gemini/commands/code-refinement.toml |
New Gemini code-refinement command. |
.codex/skills/code-review/SKILL.md |
New Codex skill for code review. |
.codex/skills/code-refinement/SKILL.md |
New Codex skill for code refinement. |
.codex/prompts/code-review-followup.md |
Removes legacy Codex prompt file now replaced by shared prompts/skills. |
.claude/commands/commitmsg.md |
Minor update to context-gathering instructions. |
.claude/commands/code-review.md |
Updates Claude slash command content to a dedicated staged code review prompt. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
The `cd "prompts"` in the subshell would crash with `set -e` if the prompts/ directory didn't exist, making the `[[ -d "prompts" ]]` guard on the next line ineffective.
There was a problem hiding this comment.
Pull request overview
This PR makes the “review loop” automation agent-agnostic by introducing a shared Bash library + a shared prompts directory, and updates setup/configuration so Claude/Codex/Gemini can be mixed as editor/reviewer roles.
Changes:
- Add
lib/lib-review-loopand refactorcode-review-loop/plan-review-loopto use shared prompt loading, agent dispatch, validation, and artifact cleanup. - Move review-loop prompts into
prompts/and updatesetupto install them into~/.local/share/ai-coding-setup/prompts/(with user-edit protection). - Add Gemini Policy Engine read-only policy and add Gemini/Codex standalone “code-review” + “code-refinement” command definitions.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| setup | Installs shared prompts + shared lib; updates Gemini settings to use a policy file and migrate deprecated tools.allowed. |
| prompts/plan-review.md | Removes tool-specific frontmatter/labels to make the prompt agent-agnostic. |
| prompts/plan-review-followup.md | Removes tool-specific frontmatter to make the prompt agent-agnostic. |
| prompts/code-review.md | Removes tool-specific frontmatter to make the prompt agent-agnostic. |
| prompts/code-review-response.md | Adds editor instructions for responding/implementing reviewer feedback inline in agent-code-review.md. |
| prompts/code-review-followup.md | Adds reviewer follow-up instructions for overwriting agent-code-review.md. |
| prompts/code-refinement.md | Adds an agent-agnostic refinement prompt for lint/quality/test checks. |
| lib/lib-review-loop | New shared Bash library for prompts/config/agent dispatch/temp timers/artifact cleanup. |
| bin/plan-review-loop | Refactors plan loop to use shared library, shared prompts, and configurable editor/reviewer agents. |
| bin/code-review-loop | Refactors code loop to use shared library, shared prompts, configurable agents, and adds a safety stash snapshot. |
| README.md | Documents shared prompts and adds sections for /code-review and /code-refinement. |
| .pre-commit-config.yaml | Enables ShellCheck -x to follow sourced files. |
| .gemini/policies/readonly-tools.toml | Adds Gemini Policy Engine read-only rules (web + read tools + readonly shell command prefixes). |
| .gemini/commands/code-review.toml | Adds Gemini standalone “code-review” command (writes agent-code-review.md). |
| .gemini/commands/code-refinement.toml | Adds Gemini standalone “code-refinement” command. |
| .codex/skills/code-review/SKILL.md | Adds Codex “code-review” skill definition. |
| .codex/skills/code-refinement/SKILL.md | Adds Codex “code-refinement” skill definition. |
| .codex/prompts/code-review-followup.md | Removes the old Codex follow-up prompt (replaced by shared prompts/). |
| .claude/commands/commitmsg.md | Minor instructions update to explicitly run context commands. |
| .claude/commands/code-review.md | Replaces prior response-style content with a standalone “code-review” reviewer prompt definition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
When the source file already contains the marker (e.g. TOML policy files), is_up_to_date would always append an extra marker to the expected content, causing a permanent mismatch with the installed destination. Now skips appending when the source already has it.
There was a problem hiding this comment.
Pull request overview
This PR refactors the review-loop automation to be agent-agnostic by introducing a shared Bash library plus shared prompts, and updates setup/installer logic to support Claude/Codex/Gemini consistently (including Gemini Policy Engine support).
Changes:
- Added
lib/lib-review-loopand updatedcode-review-loop/plan-review-loopto dispatch to a configurable editor/reviewer agent and share common utilities (prompt loading, validation, temp/elapsed helpers, artifact cleanup). - Moved review-loop prompts into a shared
prompts/directory and updatedsetupto install them under~/.local/share/ai-coding-setup/prompts/(symlink-first, preserve user edits). - Updated Gemini installation flow to install a Policy Engine file and (optionally) migrate deprecated
tools.allowedwhile preserving MCP-related entries; added new Gemini/Codex review/refinement commands.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
setup |
Installs shared prompts + shared library; updates Gemini settings/policy handling; adds review-loop defaults config creation. |
lib/lib-review-loop |
New shared library for prompt loading, agent dispatch, validation, temp/elapsed helpers, and artifact cleanup. |
bin/code-review-loop |
Uses shared library/prompts; adds configurable editor/reviewer and safety stash snapshot. |
bin/plan-review-loop |
Uses shared library/prompts; adds configurable editor/reviewer. |
prompts/* |
New/updated agent-agnostic prompts for review loops (review, follow-up, response, refinement, plan review). |
.gemini/policies/readonly-tools.toml |
New Gemini Policy Engine ruleset for read-only permissions. |
.gemini/commands/*.toml |
Adds Gemini CLI commands for code review and code refinement. |
.codex/skills/*/SKILL.md |
Adds Codex skills for code review and code refinement. |
.claude/commands/code-review.md |
Updates Claude /code-review command content (reviewer prompt). |
README.md |
Documents shared prompts and adds command docs for /commitmsg, /code-refinement, /code-review. |
.pre-commit-config.yaml |
Configures shellcheck to follow sourced files (-x). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.