refine-code

Automates iterative code review and remediation loops via dispatched reviewer and coder subagents.

Updated May 19, 2026
One-click install
npx skills add https://github.com/davidsunglee/pi-flow --skill refine-code-davidsunglee
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refine-code
Source: https://github.com/davidsunglee/pi-flow/tree/main/packages/pi-flow-core/skills/refine-code
Command: npx skills add https://github.com/davidsunglee/pi-flow --skill refine-code-davidsunglee

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Manually cycling between code review and fixes is slow and error-prone, especially when tracking findings across multiple iterations. This Skill automates the review-remediate loop: it dispatches a code-refiner subagent that alternates between reviewing a git diff and fixing flagged issues until the change is approved or the iteration budget runs out. ## Core Features & Use Cases - Automated review-remediate loop: Dispatches code-reviewer and coder subagents across configurable model tiers, iterating until approval or budget exhaustion. - Provenance-validated review artifacts: Every review file carries a reviewer provenance line validated against allowed model tiers, preventing silently degraded or improvised reviews. - Era-based versioned reviews and carry-over: Review files are versioned per era (e.g., review-v1.md, review-v2.md), and a prior era's findings can be carried over for a targeted remediation pass. - Use Case: After executing an implementation plan, run refine-code with the pre- and post-implementation SHAs to get a cross-provider verified review, automatic fixes for Critical/Important findings, and a structured STATUS summary consumable by execute-plan. ## Quick Start Ask the AI to run the refine-code skill on the current git range, providing the base SHA, head SHA, and a description of what was implemented.

Frequently Asked Questions about refine-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run an automated code review and fix loop on a git diff?▼

Invoke refine-code with a BASE_SHA, HEAD_SHA, and a description of what was implemented. It dispatches a code-refiner subagent that alternates between reviewing the diff and remediating findings until approved or the iteration budget (default 3) is exhausted.

What inputs does the refine-code skill require?▼

It requires BASE_SHA and HEAD_SHA plus a description of the implementation; it stops with an error if the SHAs are missing. Optional inputs include requirements/plan text, max iterations, working directory, review output path, and a carry-over review file.

Does refine-code work outside a git repository?▼

No. The skill checks git rev-parse --git-dir as a precondition and stops with an error if it fails, since the entire review-remediate protocol is built around git diff ranges and remediation commits.

What happens when the review is not approved within the iteration budget?▼

The skill reports STATUS: not_approved_within_budget with remaining findings and offers three choices: continue refining with a fresh budget and carry-over review, proceed with known issues, or stop execution. It never auto-continues.

Why does refine-code fail with a provenance validation error?▼

Every review file must begin with a Reviewer provenance line matching the exact model and CLI used for that dispatch, validated against allowed flow config tiers. A missing, malformed, or mismatched line causes a hard failure to prevent silently degraded reviews.

Can refine-code fall back to an inline review if subagent dispatch fails?▼

No. Inline review is explicitly forbidden on coordinator unavailability, worker dispatch exhaustion, or artifact handoff failure. The skill emits STATUS: failed with a specific reason instead of improvising a review.