Code review patterns

From FerroxLabs/murage · View interactive version

Code review patterns is an AI agent skill from the GitHub repository FerroxLabs/murage. Guides expert-level code review patterns implementation: clean-code and best-practices decision frameworks, production-ready patterns, and concrete templates for code review patterns workflows. Use when the user asks about code review patterns, code review patterns configuration, or clean-code best

How to use this skill

Skill file

Code Review Patterns

When to Use

Use this skill when:

Do NOT use this skill when:


Process

1. Diagnose the Current Review Culture and Pain Points

Before prescribing patterns, understand where the team's reviews are breaking down.

2. Establish a Severity Classification System

Without explicit severity labels, every review comment carries equal implied weight, which leads to blocking PRs on trivial issues and missing critical ones.

3. Structure the Author's Responsibilities Before Review Begins

The highest-leverage place to improve review quality is before the reviewer ever looks at the code.

4. Define the Reviewer's Responsibilities and Review Scope

Reviewers need an explicit contract about what they are and are not responsible for checking.

5. Implement Automated Pre-Review Gates

Every issue caught by automation before human review is reviewer time saved and bias removed.

6. Design the Review Feedback Communication Standard

How feedback is written is as important as what is in it. Poor communication patterns cause rework loops and damage team relationships.

7. Establish Review Metrics and a Continuous Improvement Loop

Without measurement, review process improvements are invisible and hard to justify.

8. Tailor the Pattern to Team Size and PR Volume

The appropriate code review pattern varies significantly based on team composition and throughput.


Output Format

When helping a user with code review patterns, produce the following structured output:

## Code Review Pattern Recommendation

### Diagnosis Summary
| Pain Point               | Severity  | Root Cause Hypothesis        |
|--------------------------|-----------|------------------------------|
| [observed problem]       | High/Med  | [process or tooling gap]     |

### Recommended Pattern Configuration

**Team Profile:** [size, experience mix, velocity]
**PR Volume:** [approx PRs/week]
**Primary Failure Mode:** [from taxonomy: rubber stamp / nitpick gridlock / drive-by / opinion blocking]

---

### Severity Classification Scheme
| Level   | Definition                              | Blocks Merge? | Example                                      |
|---------|-----------------------------------------|---------------|----------------------------------------------|
| Blocker | Correctness, security, data loss risk   | Yes           | Missing null check causes NPE on empty input |
| Major   | Design issue worth tracking             | Soft (deferrable with ticket) | Duplicated logic across 3 files |
| Minor   | Readability or maintainability suggestion | No          | Extract magic number to named constant        |
| Nit     | Style or preference, no action required | No           | nit: rename `getData` to `fetchUserProfile`  |

---

### Pre-Review Automation Checklist
- [ ] Linter: [specific tool + config file location]
- [ ] Formatter: [specific tool]
- [ ] Static analysis: [specific tool]
- [ ] Test coverage gate: [threshold]% diff coverage
- [ ] Dependency vulnerability scan: [tool]
- [ ] PR size warning: [line threshold]

---

### PR Description Template (Author Requirement)

**What**: [1-2 sentences: what does this change do?]
**Why**: [1-2 sentences: what problem does this solve or requirement does it fulfill?]
**How to test**: [steps a reviewer can take to validate correctness]
**Trade-offs / known limitations**: [anything deferred, any alternative approaches considered]
**Linked issues**: [ticket number(s)]

---

### Review SLA
| Priority     | Time to First Review | Time to Follow-up After Author Response |
|--------------|----------------------|-----------------------------------------|
| Urgent       | 2 business hours     | 2 business hours                        |
| Normal       | 1 business day       | 1 business day                          |
| Low / Large  | 3 business days      | 2 business days                         |

---

### Reviewer Checklist (Layer Model)

**Layer 1 -- Correctness (always required)**
- [ ] Does the code correctly implement the described behavior?
- [ ] Are all error paths explicitly handled or documented?
- [ ] Are there any race conditions, concurrency hazards, or TOCTOU issues?
- [ ] Are inputs validated at trust boundaries?
- [ ] Are resource allocations (connections, file handles, memory) properly released?

**Layer 2 -- Design (required for production-path changes)**
- [ ] Does the abstraction level match the surrounding code?
- [ ] Is this change consistent with the existing architectural patterns?
- [ ] Is the interface designed so correct use is easy and incorrect use is hard?
- [ ] Are responsibilities separated appropriately?

**Layer 3 -- Polish (optional under time pressure)**
- [ ] Are names self-explanatory without needing a comment to decode them?
- [ ] Are comments explaining "why", not "what"?
- [ ] Do tests cover happy path, edge cases, and error paths?
- [ ] Are test names descriptive enough to serve as documentation?

---

### Metrics Targets
| Metric                         | Current Baseline | Target         |
|--------------------------------|------------------|----------------|
| Time to first review           | [measure]        | < 4 hours      |
| PR cycle time                  | [measure]        | < 2 biz days   |
| Median review round count      | [measure]        | 1-2 rounds     |
| PRs over 400 lines             | [measure]        | < 20%          |

Rules

  1. Never let style be a blocking issue. If a style preference is not encoded in an automated linter or formatter, it is not a legitimate reason to block a PR merge. Style debates in PR threads are a tax on the whole team's velocity. The correct response to a style disagreement is to open a discussion about updating the linter configuration -- not to block the PR.
  1. Never review more than 400 lines of diff in a single sitting without breaking it up. Cognitive load research in software engineering (Bacchelli & Bird, Microsoft Research; Google's code review study) consistently shows defect detection drops sharply after 200-400 lines and after 60-90 minutes of continuous review. Instruct reviewers to take breaks or request that large PRs be split.
  1. Always respond to a review request within the agreed SLA, even if only to acknowledge and set an expectation. Silence is the worst possible review response. A comment that says "I'll get to this tomorrow morning" is infinitely more valuable than nothing, because it prevents the author from wondering whether to follow up, re-assign, or merge without review.
  1. Never use approval as a social gesture. Approving a PR signals that the reviewer has completed a substantive review and is confident the code is safe to merge. Approving immediately after a PR is opened, or with a comment of "LGTM" on a 300-line change with no other comments, is a process failure and should be flagged by the team lead.
  1. Always distinguish between "this is wrong" and "I would have done it differently." Reviewers who block PRs on personal style or architectural preference create a culture where the highest-seniority opinion always wins, regardless of correctness. The test is: "Is there a concrete, demonstrable reason the author's approach is worse?" If not, the reviewer's preference is a Minor or Nit, not a Blocker.
  1. Never leave a review thread unresolved at merge. Unresolved threads create ambiguity about whether the underlying issue was addressed. Either resolve threads explicitly or leave a final comment explaining why it was not resolved before merging. GitHub's "require resolved conversations before merge" branch protection setting enforces this automatically.
  1. Always configure CODEOWNERS for high-risk paths. Authentication code, payment processing logic, data migration scripts, and security configuration files must have mandatory reviewers assigned via CODEOWNERS. These files are too high-risk to rely on whoever happens to be available for review.
  1. Never allow secrets, credentials, or PII to be merged, even temporarily. Scanning for secrets in PR diffs using tools like Gitleaks, detect-secrets, or GitHub's built-in secret scanning must be a blocking CI gate. "We'll rotate it" is not an acceptable response -- secrets committed to a repository should be treated as compromised immediately, regardless of whether the commit is later reverted.
  1. Always provide a positive signal when work is genuinely good. Review culture fails in two directions -- too much criticism with no positive reinforcement, and empty praise that provides no signal. When code demonstrates a clever approach, excellent test coverage, or a well-named abstraction, say so specifically. "The way you inverted the dependency here makes the unit test considerably simpler -- good call" is a useful comment.
  1. Never allow the review process to become a gatekeeping mechanism. A review process that takes 5+ days per round, has no defined SLAs, or allows single individuals to indefinitely block work is a delivery risk, not a quality mechanism. If a reviewer is consistently blocking PRs without clear justification, that is a team health issue to address directly -- not a signal that the review process is working correctly.

Edge Cases

Hotfix PRs Under Production Incident Conditions

When a production incident requires an immediate fix, the standard review process creates unacceptable delay. Handle this with a defined hotfix protocol -- not by abandoning review entirely.

Legacy Codebase With No Existing Review Culture

Introducing code review to a team that has never practiced it formally requires careful change management, not just process documentation.

Disagreement Between Reviewer and Author That Cannot Be Resolved

When a reviewer and author are stuck on a design disagreement after two rounds of back-and-forth, the thread is no longer productive.

High-Volume Teams With Hundreds of PRs Per Week

At 50+ PRs per week (common for teams of 20+ engineers), manual reviewer assignment and unstructured review SLAs create bottlenecks.

Junior Engineers Receiving Harsh or Demoralizing Reviews

Code review is a high-stakes feedback environment for engineers early in their careers. A single harsh review from a senior engineer can set back an engineer's confidence for months.

Open Source or External Contributor PRs

External contributors do not have the same context as internal team members and require different review handling.


Example

Input: "Our team of 8 engineers is getting really frustrated with code review. PRs are sitting open for 3+ days, reviewers are leaving huge comment threads that feel like personal attacks, and a couple senior engineers are blocking everything on their architectural preferences. Half the team doesn't bother leaving real feedback -- they just click approve to avoid conflict. What should we do?"

Output:

Code Review Pattern Recommendation

Diagnosis Summary

| Pain Point | Severity | Root Cause Hypothesis |

|-----------------------------------|----------|------------------------------------------------------------------------|

| PRs sitting open 3+ days | High | No defined SLA; reviewer assignment is informal or voluntary |

| Comments that feel like attacks | High | No severity classification; feedback is unstructured and non-specific |

| Senior engineers blocking on preference | High | No distinction between blocking correctness issues and design opinions |

| Rubber stamp approvals | High | Social pressure to avoid conflict; no accountability for review quality |

This team is exhibiting three simultaneous failure modes: nitpick/opinion gridlock (senior engineers blocking on preference), rubber stamping (junior engineers approving to avoid conflict), and SLA breakdown (no defined time expectations). These three problems reinforce each other -- rubber stamping happens because the alternative (leaving real feedback) leads to conflict.

The solution requires three parallel interventions: process structure (SLAs and severity classification), communication standards (how to write feedback), and automation (remove style debates from human review entirely).


Recommended Pattern Configuration

Team Profile: 8 engineers, mixed seniority (presence of "a couple senior engineers" who dominate reviews), likely 15-30 PRs/week based on team size

PR Volume: Estimated 15-25 PRs/week

Primary Failure Mode: Opinion blocking from senior engineers + rubber stamping from junior engineers as a defensive response


Immediate Actions (Week 1-2)

Step 1: Establish automated style enforcement to defuse the nitpick problem

The senior engineers blocking on style and architectural preferences almost certainly includes legitimate style concerns mixed in with personal opinions. The fastest way to remove style from human review is to make it automatic.

Deploy the following in your CI pipeline this week:

This single change will eliminate a significant fraction of the comment volume that is causing the "personal attack" feeling. When a style issue is caught by a bot, it's not personal.

Step 2: Implement the four-level severity classification

At your next team meeting (this week), agree on and document the following:

| Level | Definition | Blocks Merge? | Example for your codebase |

|---------|-----------------------------------------|---------------|--------------------------------------------------------------------|

| Blocker | Correctness, security, data loss risk | Yes | "This endpoint is missing authentication -- any user can call it" |

| Major | Real design issue, worth a ticket | Soft (deferrable) | "This service now owns 4 distinct responsibilities -- worth splitting" |

| Minor | Readability or maintainability suggestion | No | "Extracting this 40-line block into a named function would clarify intent" |

| Nit | Style preference, no action required | No | "nit: I'd name this userRepository rather than userRepo" |

The most important rule to add immediately: Only Blocker comments prevent merge. Senior engineers who are currently blocking PRs on design preferences must reclassify those comments as Major or Minor. If they have a genuine Blocker, they must articulate specifically why the code is incorrect, insecure, or will cause data loss.

Announce this at a team meeting. Do not implement it silently. Senior engineers need to buy in, or they will work around it.

Step 3: Define SLAs and assign review responsibility

Starting immediately, implement:

| Priority | Time to First Review | Follow-up After Author Responds |

|----------|----------------------|---------------------------------|

| Urgent | 2 business hours | 2 business hours |

| Normal | 1 business day | 1 business day |

Assign reviewers explicitly at PR open using GitHub's review request feature. Don't let "available to anyone" mean "invisible to everyone." With 8 engineers, a simple rotation works: maintain a list, and the next two engineers on the rotation are assigned to each PR. One can be the author's immediate collaborator on the feature, one should be a fresh set of eyes.

Use GitHub's branch protection settings to require at least two approvals before merge and to require all conversations to be resolved. This creates accountability on both sides -- reviewers must follow up and authors must respond.


PR Description Template (Make This a GitHub PR Template)

Create .github/pull_request_template.md in your repository:

## What does this change do?
<!-- 1-2 sentences describing the behavior change -->

## Why is this change being made?
<!-- The business or technical problem this solves. Link to ticket: -->
Resolves #

## How to test this
<!-- Steps a reviewer can take to validate correctness manually, or what automated tests cover it -->

## Trade-offs and known limitations
<!-- Anything deferred to a follow-up, or approaches considered and rejected -->

## Checklist (author)
- [ ] I have self-reviewed this diff
- [ ] CI passes locally
- [ ] Tests cover the happy path and at least one error case
- [ ] PR is under 400 lines of diff (or I have explained why it cannot be smaller)

A PR that arrives without a completed description gets one comment from the first reviewer: "Please complete the PR template before requesting review." No other review happens until then. This is not a punishment -- it is a quality gate that protects reviewer time.


Reviewer Checklist (Three-Layer Model)

Layer 1 -- Correctness (always required)

Layer 2 -- Design (required for production-path changes)

Layer 3 -- Polish (optional; skip under time pressure -- say so explicitly)


Addressing the Senior Engineer Problem Directly

The blocking behavior from senior engineers is the hardest problem to solve because it involves seniority dynamics, not just process.

Recommend the following conversation with the senior engineers directly (or through their manager):


Metrics to Track (Starting Now)

| Metric | Your Likely Current State | 90-Day Target |

|----------------------------|---------------------------|---------------------|

| Time to first review | 24-72+ hours | Under 4 hours |

| PR cycle time | 3-5+ days | Under 2 business days |

| Median review round count | 3-4+ | 1-2 |

| PRs over 400 lines | Unknown | Under 20% |

| Rubber stamp approval rate | High (estimate 40-60%) | Under 10% |

Track these manually in a shared spreadsheet for the first month, then invest in a tool like LinearB or Swarmia to automate the measurement. Review the numbers at your monthly team retrospective. If cycle time is not dropping after 4 weeks, the process changes have not been adopted -- find out which step is being skipped.


What to Expect in the First 30 Days

The goal is not a perfect review process -- it is a review process the team trusts, that catches real problems, and that does not create enough friction to make engineers avoid it.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.