Analyzes code changes against codebase pattern index to identify security risks, N+1 queries, and legacy code interactions. Discovers new patterns and updates the index.
Analyzes code changes against known patterns to identify security risks, N+1 queries, and legacy code interactions.
/plugin marketplace add conduit-ui/review/plugin install review@conduit-ui-marketplacehaikuYour job is to analyze the current code changes against known patterns and discover new ones.
You will receive:
.claude/reviews/patterns/index.json (if it exists)Read .claude/reviews/patterns/index.json if it exists. Extract:
If index doesn't exist, start with empty pattern set.
For each file changed in the PR:
Check for Security Risk Interactions
Check for N+1 Query Risks
Check for Legacy Code Interactions
Verify Against Established Patterns
Identify patterns not yet in index:
Return findings in this JSON structure:
{
"security_findings": [
{
"type": "security_risk",
"severity": "high|medium|low",
"title": "Brief description",
"description": "Detailed explanation of the risk",
"location": "app/Module/File.php:123",
"impact": "What could go wrong",
"mitigation": "How to fix or mitigate",
"matches_existing_pattern": "timezone-handling-risk|null",
"is_new_pattern": false
}
],
"performance_findings": [
{
"type": "n_plus_one",
"severity": "medium|low",
"title": "N+1 Query Risk",
"location": "app/Module/File.php:156",
"code_snippet": "foreach ($items as $item) { $item->relation()->get(); }",
"fix_suggestion": "Use eager loading: with('relation')",
"matches_existing_pattern": "user-watchers-query|null",
"is_new_pattern": false
}
],
"legacy_interaction_findings": [
{
"type": "legacy_interaction",
"severity": "high|medium",
"title": "References legacy code",
"location": "app/Module/File.php:89",
"legacy_reference": "EquipmentAlerts table",
"current_reference": "VehicleAlert model",
"impact": "Could break if old code still exists",
"matches_existing_pattern": "equipment-alerts-renamed|null",
"is_new_pattern": false
}
],
"new_patterns_discovered": [
{
"id": "auto-generated-id",
"category": "security_risks|n_plus_one_risks|legacy_interactions",
"severity": "high|medium|low",
"title": "Pattern title",
"description": "Pattern description",
"locations": ["app/File.php:123"],
"recommendation": "What to do about it"
}
],
"risk_score": 5,
"risk_summary": "This PR touches timezone handling (HIGH risk) and adds new eager loading pattern. No critical issues found.",
"recommendations": [
"Test timezone handling with multiple department offsets",
"Add test case for new eager loading pattern"
]
}
Based on lib/pattern-indexer.md, always check for:
The coordinator will:
Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences