Quick code review before committing (code + error handling)
Performs automated code quality checks and cross-validated reviews on staged changes before committing.
npx claudepluginhub harmaalbers/claude-requirements-framework[aspects]Run focused code quality checks on unstaged/staged changes before committing. Uses Agent Teams for cross-validated review when 2+ review agents are enabled.
Arguments: "$ARGUMENTS"
See ADR-012 for design rationale.
Run three essential checks:
You MUST follow these steps in exact order. Do not skip steps or interpret - execute as written.
Execute these bash commands to get the scope:
git diff --cached --name-only --diff-filter=ACMR > /tmp/review_scope.txt 2>&1
if [ ! -s /tmp/review_scope.txt ]; then
git diff --name-only --diff-filter=ACMR > /tmp/review_scope.txt 2>&1
fi
Then check the result:
Arguments received: "$ARGUMENTS"
Initialize all flags to false, then set based on arguments:
RUN_TOOL_VALIDATOR=false
RUN_CODE_REVIEWER=false
RUN_SILENT_FAILURE_HUNTER=false
RUN_BACKWARD_COMPATIBILITY_CHECKER=false
RUN_TEST_ANALYZER=false
RUN_TYPE_DESIGN_ANALYZER=false
RUN_COMMENT_ANALYZER=false
RUN_FRONTEND_REVIEWER=false
RUN_CODE_SIMPLIFIER=false
Now compute derived values:
TEAM_AGENT_COUNT = count of true flags among: RUN_CODE_REVIEWER, RUN_SILENT_FAILURE_HUNTER, RUN_BACKWARD_COMPATIBILITY_CHECKER, RUN_TEST_ANALYZER, RUN_TYPE_DESIGN_ANALYZER, RUN_COMMENT_ANALYZER, RUN_FRONTEND_REVIEWER
USE_TEAM = true if TEAM_AGENT_COUNT >= 2
Note: the parallel argument is accepted for backward compatibility but is a no-op — teams are inherently parallel.
This step uses a subagent (not a teammate) because it runs deterministic linters — no debate value.
If RUN_TOOL_VALIDATOR is true:
Use TeamCreate:
team_name: "pre-commit-{timestamp}"
description: "Cross-validated pre-commit review"
Where {timestamp} is the current Unix timestamp (use date +%s to get it).
Create tasks on the shared task list:
For EACH enabled review agent flag, create a task:
Then create a synthesis task:
Fallback: If TeamCreate fails and hooks.agent_teams.fallback_to_subagents is true (default), log the error and skip to Step 9 (subagent fallback).
For each review task, spawn a teammate via the Task tool.
Standard preamble for ALL teammate prompts (include at the top of each prompt):
You MUST use the standard output format from ADR-013. All findings must use:
- ### CRITICAL: [title] — for blocking issues
- ### IMPORTANT: [title] — for significant concerns
- ### SUGGESTION: [title] — for improvements
Each finding must have Location, Description, Impact, and Fix fields.
End with ## Summary containing counts and Verdict (ISSUES FOUND | APPROVED).
Share your findings via SendMessage to the team lead when done.
Mark your task as complete using TaskUpdate.
Each teammate gets:
team_name: the team name from Step 5subagent_type: matching the agent (e.g., "requirements-framework:code-reviewer")name: descriptive name (e.g., "code-reviewer", "error-auditor", "compat-checker", "test-analyzer", "type-analyzer", "comment-analyzer", "frontend-reviewer")prompt: Standard preamble + diff context + review focusLaunch ALL teammates in a SINGLE message with multiple Task tool calls (parallel execution).
Monitor the task list until all review tasks (except the synthesis task) are complete:
If a teammate fails to complete within timeout:
Read all teammate findings received via messages. Apply domain-specific cross-validation rules (subset of ADR-013, based on active agents):
Location matching: Same file within 10-line proximity = "same location".
Apply these rules only when BOTH referenced agents are active teammates:
| Rule | Agents | Condition | Action |
|---|---|---|---|
| Error handling quality | code-reviewer + silent-failure-hunter | Both flag same region | Escalate to CRITICAL |
| Error handling specialist | code-reviewer vs silent-failure-hunter | Only sfh flags | Trust specialist (keep sfh severity) |
| Documentation drift | code-reviewer + comment-analyzer | Code change + comment issue same location | Corroborate with note |
| Untested bugs | test-analyzer + code-reviewer | Bug + no tests for same function | Escalate both to CRITICAL |
| Type safety breaks | type-design-analyzer + backward-compat | Weak types + breaking change | Escalate to CRITICAL |
| Suppressed breaks | silent-failure-hunter + backward-compat | Breaking change + silent suppression | Escalate to CRITICAL |
| Untested components | frontend-reviewer + test-analyzer | Component issue + no component tests | Escalate both to CRITICAL |
| Frontend + error handling | frontend-reviewer + silent-failure-hunter | a11y/error boundary gap in same region | Escalate to CRITICAL |
| Frontend + code quality | frontend-reviewer + code-reviewer | Both flag same component region | Corroborate with note |
| Frontend + types | frontend-reviewer + type-design-analyzer | Props type issue + component issue | Corroborate |
| Frontend + breaking changes | frontend-reviewer + backward-compat | Breaking prop change + component | Escalate to CRITICAL |
After applying rules:
Code Simplifier (if RUN_CODE_SIMPLIFIER is true):
Subagent Fallback — handles cases where team mode was not used:
Count findings across all sources (team + subagent):
Provide ONE verdict:
If CRITICAL_COUNT > 0: Verdict: "FIX ISSUES FIRST"
Else if IMPORTANT_COUNT > 5: Verdict: "REVIEW IMPORTANT ISSUES"
Else if IMPORTANT_COUNT > 0: Verdict: "MINOR ISSUES FOUND"
Else: Verdict: "READY TO COMMIT"
If a team was created (USE_TEAM was true and TeamCreate succeeded):
tools specified → tool-validator (always subagent, runs first as blocking gate)code specified → code-reviewer (teammate when 2+ review agents)errors specified → silent-failure-hunter (teammate when 2+ review agents)compat specified → backward-compatibility-checker (teammate when 2+ review agents)tests specified → test-analyzer (teammate when 2+ review agents)types specified → type-design-analyzer (teammate when 2+ review agents)comments specified → comment-analyzer (teammate when 2+ review agents)frontend specified → frontend-reviewer (teammate when 2+ review agents)simplify specified → code-simplifier (always subagent, runs last)all specified → all applicable agents (tool-validator + code-simplifier as subagents, rest as teammates)parallel specified → backward-compatible no-op (teams are inherently parallel)When team mode was used (USE_TEAM=true):
# Pre-Commit Review Summary
## Scope
[Files reviewed]
## Team
- code-reviewer: [completed/timed-out]
- silent-failure-hunter: [completed/timed-out]
- [other teammates if applicable]
## Corroborated Findings (confirmed by 2+ agents)
- [SEVERITY] [description] — confirmed by [agent1, agent2] [file:line]
## Critical Issues (X found)
- [agent]: Issue description [file:line]
## Important Issues (X found)
- [agent]: Issue description [file:line]
## Suggestions (X found)
- [agent]: Suggestion [file:line]
## Disputed Findings
- [description] — [agent1] says X, [agent2] says Y
## Code Simplification
- [suggestions from code-simplifier, if enabled]
## Recommendation
[READY TO COMMIT / MINOR ISSUES FOUND / REVIEW IMPORTANT ISSUES / FIX ISSUES FIRST]
When subagent fallback was used (USE_TEAM=false or TeamCreate failed):
# Pre-Commit Review Summary
## Scope
[Files reviewed]
## Critical Issues (X found)
- [agent]: Issue description [file:line]
## Important Issues (X found)
- [agent]: Issue description [file:line]
## Suggestions (X found)
- [agent]: Suggestion [file:line]
## Recommendation
[READY TO COMMIT / MINOR ISSUES FOUND / REVIEW IMPORTANT ISSUES / FIX ISSUES FIRST]
/requirements-framework:pre-commit # Default: team (code-reviewer + silent-failure-hunter) + tool-validator subagent
/requirements-framework:pre-commit tools # Just run linting/type-checking (subagent only)
/requirements-framework:pre-commit code # Single agent: subagent fallback (no team value)
/requirements-framework:pre-commit code errors # Team: 2 teammates cross-validate
/requirements-framework:pre-commit compat # Single agent: subagent fallback
/requirements-framework:pre-commit all # Team: up to 6 review teammates + tool-validator + code-simplifier subagents
/requirements-framework:pre-commit all parallel # Same as `all` (parallel is no-op with teams)
/requirements-framework:pre-commit tests types # Team: 2 teammates cross-validate
/requirements-framework:pre-commit frontend # Single agent: subagent fallback
/requirements-framework:pre-commit frontend code errors # Team: 3 teammates cross-validate
/requirements-framework:pre-commit tools compat code # Team if 2+ review agents, else subagent
| Aspect | /pre-commit | /deep-review |
|---|---|---|
| Scope | Pre-commit changes | All branch changes |
| Default agents | code-reviewer + silent-failure-hunter | code-reviewer + silent-failure-hunter + contextual |
| Satisfies | pre_commit_review | pre_pr_review |
| Cost | Lower (fewer default agents) | Higher (more agents, broader scope) |
| Cross-validation | Yes (when 2+ review agents) | Always |
simplify only after code passes other reviewstests first to verify test quality