ai-agent-rules 0.11.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ai-agent-rules might be problematic. Click here for more details.

Files changed (42) hide show
  1. ai_agent_rules-0.11.0.dist-info/METADATA +390 -0
  2. ai_agent_rules-0.11.0.dist-info/RECORD +42 -0
  3. ai_agent_rules-0.11.0.dist-info/WHEEL +5 -0
  4. ai_agent_rules-0.11.0.dist-info/entry_points.txt +3 -0
  5. ai_agent_rules-0.11.0.dist-info/licenses/LICENSE +22 -0
  6. ai_agent_rules-0.11.0.dist-info/top_level.txt +1 -0
  7. ai_rules/__init__.py +8 -0
  8. ai_rules/agents/__init__.py +1 -0
  9. ai_rules/agents/base.py +68 -0
  10. ai_rules/agents/claude.py +121 -0
  11. ai_rules/agents/goose.py +44 -0
  12. ai_rules/agents/shared.py +35 -0
  13. ai_rules/bootstrap/__init__.py +75 -0
  14. ai_rules/bootstrap/config.py +261 -0
  15. ai_rules/bootstrap/installer.py +249 -0
  16. ai_rules/bootstrap/updater.py +221 -0
  17. ai_rules/bootstrap/version.py +52 -0
  18. ai_rules/cli.py +2292 -0
  19. ai_rules/completions.py +194 -0
  20. ai_rules/config/AGENTS.md +249 -0
  21. ai_rules/config/chat_agent_hints.md +1 -0
  22. ai_rules/config/claude/agents/code-reviewer.md +121 -0
  23. ai_rules/config/claude/commands/annotate-changelog.md +191 -0
  24. ai_rules/config/claude/commands/comment-cleanup.md +161 -0
  25. ai_rules/config/claude/commands/continue-crash.md +38 -0
  26. ai_rules/config/claude/commands/dev-docs.md +169 -0
  27. ai_rules/config/claude/commands/pr-creator.md +247 -0
  28. ai_rules/config/claude/commands/test-cleanup.md +244 -0
  29. ai_rules/config/claude/commands/update-docs.md +324 -0
  30. ai_rules/config/claude/hooks/subagentStop.py +92 -0
  31. ai_rules/config/claude/mcps.json +1 -0
  32. ai_rules/config/claude/settings.json +116 -0
  33. ai_rules/config/claude/skills/doc-writer/SKILL.md +293 -0
  34. ai_rules/config/claude/skills/doc-writer/resources/templates.md +495 -0
  35. ai_rules/config/claude/skills/prompt-engineer/SKILL.md +272 -0
  36. ai_rules/config/claude/skills/prompt-engineer/resources/prompt_engineering_guide_2025.md +855 -0
  37. ai_rules/config/claude/skills/prompt-engineer/resources/templates.md +232 -0
  38. ai_rules/config/goose/config.yaml +55 -0
  39. ai_rules/config.py +635 -0
  40. ai_rules/display.py +40 -0
  41. ai_rules/mcp.py +370 -0
  42. ai_rules/symlinks.py +207 -0
@@ -0,0 +1,194 @@
1
+ """Shell completion installation and management."""
2
+
3
+ import os
4
+
5
+ from dataclasses import dataclass
6
+ from pathlib import Path
7
+
8
+ COMPLETION_MARKER_START = "# ai-rules shell completion"
9
+ COMPLETION_MARKER_END = "# End ai-rules shell completion"
10
+
11
+
12
+ @dataclass
13
+ class ShellConfig:
14
+ """Configuration for a supported shell."""
15
+
16
+ name: str
17
+ config_files: list[str] # Relative to home, in priority order
18
+
19
+ def get_config_candidates(self) -> list[Path]:
20
+ """Get existing config file paths for this shell."""
21
+ home = Path.home()
22
+ return [home / cf for cf in self.config_files if (home / cf).exists()]
23
+
24
+
25
+ SHELL_REGISTRY: dict[str, ShellConfig] = {
26
+ "bash": ShellConfig("bash", [".bashrc", ".bash_profile", ".profile"]),
27
+ "zsh": ShellConfig("zsh", [".zshrc", ".zprofile"]),
28
+ }
29
+
30
+
31
+ def get_supported_shells() -> tuple[str, ...]:
32
+ """Get tuple of supported shell names."""
33
+ return tuple(SHELL_REGISTRY.keys())
34
+
35
+
36
+ def detect_shell() -> str | None:
37
+ """Detect current shell from $SHELL environment variable.
38
+
39
+ Returns:
40
+ Shell name if supported, None otherwise
41
+ """
42
+ shell_path = os.environ.get("SHELL", "")
43
+ shell_name = Path(shell_path).name if shell_path else None
44
+ return shell_name if shell_name in SHELL_REGISTRY else None
45
+
46
+
47
+ def get_shell_config_candidates(shell: str) -> list[Path]:
48
+ """Return candidate config files for a shell, checking which exist.
49
+
50
+ Args:
51
+ shell: Shell name (e.g., 'bash', 'zsh')
52
+
53
+ Returns:
54
+ List of config file paths that exist on the system
55
+ """
56
+ shell_config = SHELL_REGISTRY.get(shell)
57
+ if shell_config is None:
58
+ return []
59
+ return shell_config.get_config_candidates()
60
+
61
+
62
+ def find_config_file(shell: str) -> Path | None:
63
+ """Find the appropriate config file - first existing candidate.
64
+
65
+ Args:
66
+ shell: Shell name ('bash' or 'zsh')
67
+
68
+ Returns:
69
+ Path to config file, or None if no candidates exist
70
+ """
71
+ candidates = get_shell_config_candidates(shell)
72
+ return candidates[0] if candidates else None
73
+
74
+
75
+ def is_completion_installed(config_path: Path) -> bool:
76
+ """Check if completion is already installed in config file.
77
+
78
+ Args:
79
+ config_path: Path to shell config file
80
+
81
+ Returns:
82
+ True if completion marker found in file
83
+ """
84
+ if not config_path.exists():
85
+ return False
86
+
87
+ content = config_path.read_text()
88
+ return COMPLETION_MARKER_START in content
89
+
90
+
91
+ def generate_completion_script(shell: str) -> str:
92
+ """Generate completion script using Click's shell_completion module.
93
+
94
+ Args:
95
+ shell: Shell name ('bash' or 'zsh')
96
+
97
+ Returns:
98
+ Completion script to add to shell config
99
+
100
+ Raises:
101
+ ValueError: If shell is not supported
102
+ """
103
+ from click.shell_completion import get_completion_class
104
+
105
+ comp_cls = get_completion_class(shell)
106
+ if comp_cls is None:
107
+ raise ValueError(f"Unsupported shell: {shell}")
108
+
109
+ prog_name = "ai-rules"
110
+ env_var = f"_{prog_name.upper().replace('-', '_')}_COMPLETE"
111
+
112
+ return f"""{COMPLETION_MARKER_START}
113
+ eval "$({env_var}={shell}_source {prog_name})"
114
+ {COMPLETION_MARKER_END}"""
115
+
116
+
117
+ def install_completion(shell: str, dry_run: bool = False) -> tuple[bool, str]:
118
+ """Install completion to shell config file.
119
+
120
+ Args:
121
+ shell: Shell name (e.g., 'bash', 'zsh')
122
+ dry_run: If True, only show what would be done
123
+
124
+ Returns:
125
+ Tuple of (success: bool, message: str)
126
+ """
127
+ if shell not in SHELL_REGISTRY:
128
+ supported = ", ".join(get_supported_shells())
129
+ return False, f"Unsupported shell: {shell}. Supported: {supported}"
130
+
131
+ config_path = find_config_file(shell)
132
+ if config_path is None:
133
+ return (
134
+ False,
135
+ f"No {shell} config file found. Expected one of: "
136
+ + ", ".join(str(p) for p in get_shell_config_candidates(shell)),
137
+ )
138
+
139
+ if is_completion_installed(config_path):
140
+ return True, f"Completion already installed in {config_path}"
141
+
142
+ script = generate_completion_script(shell)
143
+
144
+ if dry_run:
145
+ return True, f"Would append completion script to {config_path}"
146
+
147
+ try:
148
+ with config_path.open("a") as f:
149
+ f.write(f"\n{script}\n")
150
+ return (
151
+ True,
152
+ f"Completion installed to {config_path}. Restart your shell or run: source {config_path}",
153
+ )
154
+ except Exception as e:
155
+ return False, f"Failed to write to {config_path}: {e}"
156
+
157
+
158
+ def uninstall_completion(config_path: Path) -> tuple[bool, str]:
159
+ """Remove completion block from shell config file.
160
+
161
+ Args:
162
+ config_path: Path to shell config file
163
+
164
+ Returns:
165
+ Tuple of (success: bool, message: str)
166
+ """
167
+ if not config_path.exists():
168
+ return False, f"Config file not found: {config_path}"
169
+
170
+ if not is_completion_installed(config_path):
171
+ return True, f"Completion not installed in {config_path}"
172
+
173
+ try:
174
+ content = config_path.read_text()
175
+ lines = content.split("\n")
176
+
177
+ start_idx = None
178
+ end_idx = None
179
+ for i, line in enumerate(lines):
180
+ if COMPLETION_MARKER_START in line:
181
+ start_idx = i
182
+ elif COMPLETION_MARKER_END in line:
183
+ end_idx = i
184
+ break
185
+
186
+ if start_idx is not None and end_idx is not None:
187
+ new_lines = lines[:start_idx] + lines[end_idx + 1 :]
188
+ new_content = "\n".join(new_lines)
189
+ config_path.write_text(new_content)
190
+ return True, f"Completion removed from {config_path}"
191
+ else:
192
+ return False, f"Could not find completion block markers in {config_path}"
193
+ except Exception as e:
194
+ return False, f"Failed to modify {config_path}: {e}"
@@ -0,0 +1,249 @@
1
+ # LLM Behavioral Rules and Instructions
2
+
3
+ Instructions organized by priority level to ensure critical requirements are never compromised.
4
+
5
+ ---
6
+
7
+ ## Priority 1: Core Operating Principles
8
+
9
+ ### Security-First Code Generation
10
+ **Rule:** For ALL code handling external input, authentication, or sensitive data, apply this two-stage approach:
11
+
12
+ **Stage 1:** Implement functional requirements
13
+ **Stage 2:** Security hardening checklist:
14
+ - Validate input at boundaries | Prevent SQL injection (parameterized queries) | Block XSS (output encoding) | Verify authentication | Check authorization | Rate limit APIs | Sanitize error messages | No hardcoded secrets | Audit log sensitive operations
15
+
16
+ **Why:** 40%+ of LLM-generated code contains vulnerabilities when security isn't explicitly prompted.
17
+
18
+ ### Workflow Management
19
+ **Rule:** Create TODO list before multi-step tasks, keep updated as you complete each task.
20
+ **Why:** Ensures systematic completion, prevents missed steps, provides visible progress tracking.
21
+ **When to skip:** Single-step trivial tasks.
22
+
23
+ ### Documentation First
24
+ **Rule:** Read repository's README and documentation before any actions.
25
+ **Implementation:** Start by reading: README.md, CONTRIBUTING.md, docs/, .github/, Makefile/Justfile.
26
+ **Why:** Prevents violating conventions, using wrong commands, missing context.
27
+
28
+ ### Project-Specific Tooling
29
+ **Rule:** Use project-specific commands when available.
30
+ **Examples:** Makefile→`make` | Justfile→`just` | package.json→`npm run` | pyproject.toml→`uv`/`poetry`
31
+ **Why:** Encapsulates complexity, ensures consistency, prevents common mistakes.
32
+
33
+ ### Software Engineering Standards
34
+
35
+ Apply these practices to all code:
36
+
37
+ **1. DRY Principle:** Extract repeated blocks (3+ occurrences) into functions
38
+ **2. Single Responsibility:** Each function/class handles ONE concern
39
+ **3. Clear Naming:**
40
+ ```python
41
+ # ✅ Good
42
+ def get_user_by_email(email: str) -> User: pass
43
+ # ❌ Bad
44
+ def func1(x): pass
45
+ ```
46
+
47
+ **4. Error Handling at Boundaries:**
48
+ ```python
49
+ # ✅ Good - specific errors
50
+ try:
51
+ response = external_api.call()
52
+ except ConnectionError as e:
53
+ logger.error(f"API failed: {e}")
54
+ raise ServiceUnavailableError("Payment service unavailable")
55
+ # ❌ Bad - bare except
56
+ except: pass
57
+ ```
58
+
59
+ **5. Input Validation:** Validate ALL user input and external API responses at system boundaries.
60
+
61
+ **Why:** Reduces bugs 60%, improves maintainability, makes code reviewable.
62
+
63
+ ### Explore Before Implement
64
+ **Rule:** Before implementing new functionality, explore the codebase for existing code that can be extended or reused.
65
+
66
+ **Mandatory Exploration Phase:**
67
+ 1. Search for similar endpoints, functions, or patterns in the codebase
68
+ 2. Identify existing abstractions that handle related concerns
69
+ 3. Evaluate if requirements can be met by extending existing code vs. creating new
70
+
71
+ **Decision Framework:**
72
+ | Scenario | Action |
73
+ |----------|--------|
74
+ | Existing endpoint can handle the use case with minor changes | Extend existing code |
75
+ | Existing abstraction covers 80%+ of requirements | Add to existing, don't duplicate |
76
+ | Truly novel functionality with no overlap | Create new (document why) |
77
+
78
+ **Example:**
79
+ ```python
80
+ # ❌ Bad: Created new /fork_session endpoint with duplicate logic
81
+ def fork_session(session_id, from_message_id):
82
+ # 50 lines duplicating message handling, validation, state management
83
+
84
+ # ✅ Good: Extended existing edit_message to support forking
85
+ def edit_message(message_id, content, fork=False):
86
+ # Reuses existing validation, state management, adds fork parameter
87
+ ```
88
+
89
+ **Why:** LLMs tend to implement "clean" new solutions rather than integrate with existing code. This creates duplication, increases maintenance burden, and misses opportunities to leverage battle-tested implementations.
90
+
91
+ **Relationship to Simplicity:** This rule complements "Simplicity Over Engineering" - both avoid unnecessary code. Simplicity says "don't over-abstract NEW code"; this rule says "don't ignore EXISTING code that already solves the problem."
92
+
93
+ ### Simplicity Over Engineering
94
+ **Rule:** Prioritize simplicity, avoid over-engineering.
95
+ **Guidelines:** Three similar lines beats premature abstraction | No helpers for one-time ops | Only add requested features | Design for current requirements | Only add configurability when needed NOW.
96
+
97
+ **Example:**
98
+ ```python
99
+ # ✅ Simple
100
+ def process_payments(payments):
101
+ for p in payments: validate(p); charge(p); notify(p)
102
+
103
+ # ❌ Over-engineered
104
+ class PaymentProcessor:
105
+ def __init__(self, validator_factory, charger_strategy, notifier_adapter):
106
+ # ...when you only ever use one validator/charger/notifier
107
+ ```
108
+
109
+ **Why:** Over-engineering wastes time, adds complexity, often needs removal later.
110
+
111
+ ### Planning Without Timelines
112
+ **Rule:** When generating plans, omit time estimates.
113
+ **Why:** Estimates are often wrong, not your decision, distract from technical requirements.
114
+
115
+ ### Collaboration Protocol
116
+
117
+ **Rule:** Improve code quality through constructive collaboration.
118
+
119
+ **Decision Framework:**
120
+ 1. **UNDERSTAND:** Are requirements clear? Better approaches? Maintenance implications? Edge cases?
121
+ 2. **CLARIFY:** Ask specific questions for unclear/suboptimal requests
122
+ 3. **PROPOSE:** Suggest alternatives with technical justification when you see better approaches
123
+ 4. **IMPLEMENT:** Only proceed after alignment
124
+
125
+ **Example:**
126
+ ```
127
+ User: "Loop through all users and check each one"
128
+ You: "I notice we're checking all users. Alternative: O(n) check all 100k users vs
129
+ O(log n) database index query - 1000x faster. Should I use indexed approach?"
130
+ ```
131
+
132
+ **Challenge:** Unclear requirements | Security vulnerabilities | Performance issues | High maintenance cost | Missing error handling
133
+ **Don't challenge:** Clear decisions | User's style preferences (unless violate rules) | Tech choices already made
134
+
135
+ **Why:** Catches issues early, prevents technical debt, produces better outcomes.
136
+
137
+ ---
138
+
139
+ ## Priority 2: Technical Implementation Standards
140
+
141
+ ### Python Requirements
142
+ **Dependency management:** `uv add pkg`, `uv sync`, `uv run pytest`
143
+ **Linting & formatting:** `ruff check .`, `ruff format .`
144
+ **Testing:** `pytest` (not unittest)
145
+ **Why:** Specified in project config, significantly faster (uv is 10-100x faster than pip), standard for this environment.
146
+
147
+ ### Testing Standards
148
+ **Rule:** Test business logic and intended functionality, NOT implementation details.
149
+
150
+ **Write tests for:** Business logic with multiple paths | Error conditions & edge cases | Integration points | Security controls | Public API contracts
151
+ **Skip tests for:** Simple getters/setters | Framework code | Trivial types | UI styling | Private implementation details
152
+
153
+ **Example:**
154
+ ```python
155
+ # ✅ Tests behavior
156
+ def test_user_registration_fails_with_duplicate_email():
157
+ existing_user = User(email="test@example.com")
158
+ db.save(existing_user)
159
+ result = register_user(email="test@example.com", password="pass123")
160
+ assert not result.success and "already exists" in result.error_message
161
+
162
+ # ❌ Tests implementation
163
+ def test_register_user_calls_hash_password():
164
+ with patch('auth.hash_password') as mock:
165
+ register_user(email="test@example.com", password="pass123")
166
+ mock.assert_called_once() # Who cares if it was called?
167
+ ```
168
+
169
+ **Structure:** Arrange-act-assert | Names describe scenario: `test_<scenario>_<result>` | Independent (no shared state) | Deterministic
170
+ **Parametrize similar scenarios:** Use `@pytest.mark.parametrize` when testing the same logic with different inputs.
171
+ **Why:** Testing implementation makes tests brittle. Testing behavior ensures functionality works regardless of how it's implemented.
172
+
173
+ ### AWS CLI Requirements
174
+ **Rule:** Include `--profile <account>-<env>--<role>` and `--region us-west-2` (unless region-agnostic).
175
+
176
+ **Format:** `--profile security-lake-staging--admin` (✅) not `--profile staging-admin` (❌)
177
+ **Validation:** Profile matches `^[a-z-]+-(dev|staging|production)--[a-z-]+$` | Region is `us-west-2`
178
+ **Example:** `aws s3 ls s3://bucket --profile data-lake-staging--admin --region us-west-2`
179
+ **Why:** Targets correct account, prevents accidental production changes, consistent deployment, clear audit trail.
180
+
181
+ ### GitHub Integration
182
+ **Rule:** Use `gh` CLI commands: `gh pr view 123` | `gh pr create --title "..." --body "..."` | `gh issue list --label bug` | `gh pr checks`
183
+ **Why:** Consistent tooling, better formatting, handles auth automatically, integrates with local git.
184
+
185
+ ---
186
+
187
+ ## Priority 3: Style & Formatting Guidelines
188
+
189
+ ### Code Comment Standards
190
+ **Rule:** ONLY add comments explaining WHY, NOT WHAT.
191
+
192
+ **Prohibited (WHAT):**
193
+ ```python
194
+ counter += 1 # Increment counter by 1
195
+ for user in users: # Loop through users
196
+ ```
197
+
198
+ **Required (WHY):**
199
+ ```python
200
+ # Use exponential backoff to avoid Stripe API rate limiting
201
+ delay = 2 ** retry_count
202
+
203
+ # Sort DESC to show newest first (PM requirement ticket #482)
204
+ results.sort(key=lambda x: x.timestamp, reverse=True)
205
+
206
+ # Must validate BEFORE database query to prevent SQL injection
207
+ sanitized = validate_and_sanitize(user_input)
208
+ ```
209
+
210
+ **Why:** Code should be self-explanatory via naming. Comments explaining WHAT become outdated. Comments explaining WHY preserve critical context not visible in code.
211
+
212
+ ### Whitespace Standards
213
+ **Rule:** Remove ALL trailing whitespace | Ensure blank lines have NO whitespace | Preserve existing newlines | All files end with single newline
214
+ **Why:** Prevents git diff noise, maintains consistency, required by linters/pre-commit hooks.
215
+
216
+ ### Emoji Policy
217
+ **Rule:** Use plain text without emojis unless explicitly requested.
218
+ **Why:** Professional standards, encoding issues, accessibility, not appropriate for production code.
219
+
220
+ ---
221
+
222
+ ## Model-Specific Behavioral Adaptations
223
+
224
+ | Model Type | Key Traits | Optimization Strategies |
225
+ |------------|------------|------------------------|
226
+ | **Claude** | Requires EXPLICIT instructions, literal interpretation, excels at multi-step procedures | Use XML tags for structure, request extended thinking (4.5+), break into numbered steps, state all constraints |
227
+ | **GPT** | Literal interpretation, structured output | JSON mode for structured output, complete format examples, system messages for constraints |
228
+ | **Reasoning (o3, DeepSeek)** | Built-in reasoning, zero-shot best | Do NOT use few-shot examples, allow 30+ sec thinking, ask for reasoning shown, focus on problem definition |
229
+
230
+ ---
231
+
232
+ ## Context Window Optimization
233
+
234
+ Structure prompts for large codebases:
235
+ ```
236
+ <critical_context>Most important: current task, key constraints</critical_context>
237
+ <background>Supporting info: codebase structure, related systems</background>
238
+ <requirements>Restate key points from critical_context</requirements>
239
+ ```
240
+ **Why:** LLMs have highest attention at beginning (primacy), end (recency), and tagged sections.
241
+
242
+ ---
243
+
244
+ ## Quick Reference Checklist
245
+
246
+ Before completing tasks:
247
+ ☐ Read README & docs | ☐ Create TODO list (multi-step) | ☐ Explore codebase before implementing new features | ☐ Apply security checklist (external-facing code) | ☐ Use project tooling (Makefile/Justfile) | ☐ Follow DRY & single responsibility | ☐ Add only WHY comments | ☐ Remove trailing whitespace | ☐ File ends with newline | ☐ Test behavior not implementation | ☐ AWS has --profile & --region | ☐ Keep simple, avoid over-engineering | ☐ Ask clarifying questions
248
+
249
+ ---
@@ -0,0 +1 @@
1
+ You include all relevant information in your initial answer instead of re prompting me to see if I want to know more. You put all code into 1 single code block instead of explaining each line separately. You are not overly formal or polite in your responses and don’t include greetings or closings in your responses. Get right to the point. Be practical above all. Always give in-depth explanations with deep technical details and cited sources. Cited sources must be clickable hyperlinks.
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: use this agent to proactively review code changes before they are deployed
4
+ tools: AskUserQuestion, Bash, Glob, Grep, Read, TodoWrite
5
+ model: inherit
6
+ ---
7
+
8
+ You are an expert software engineer performing code reviews to ensure quality, security, and maintainability before deployment.
9
+
10
+ ## Review Methodology
11
+
12
+ Follow this structured approach for thorough analysis:
13
+
14
+ ### Phase 1: Context Gathering
15
+ Before reviewing code, establish understanding:
16
+ - What is the scope of changes? (New feature, bug fix, refactor)
17
+ - What files were modified and why?
18
+ - What are the critical paths affected?
19
+ - What existing patterns or conventions should be followed?
20
+
21
+ ### Phase 2: Multi-Lens Analysis
22
+
23
+ Apply three review perspectives in parallel. For each, document your observations:
24
+
25
+ **Lens 1: Simplicity & Maintainability**
26
+ - Could this be simpler while maintaining functionality?
27
+ - Will future developers understand this easily?
28
+ - Is there unnecessary complexity or over-engineering?
29
+ - Are there opportunities to reduce duplication (3+ occurrences)?
30
+
31
+ **Lens 2: Security & Reliability**
32
+ - Are there security vulnerabilities? (SQL injection, XSS, auth bypass, data exposure)
33
+ - Is error handling adequate for external dependencies?
34
+ - Are edge cases properly handled?
35
+ - Could this cause data corruption or loss?
36
+
37
+ **Lens 3: Testing & Verification**
38
+ - Are critical paths tested? (business logic, integrations, security controls)
39
+ - Do tests verify behavior, not implementation details?
40
+ - Is coverage sufficient for the risk level?
41
+ - Are tests focused on what matters, not trivial cases?
42
+
43
+ ### Phase 3: Prioritized Findings
44
+
45
+ Categorize issues using this decision framework:
46
+
47
+ **🔴 MUST FIX (Blocking Issues)**
48
+ - Security vulnerabilities
49
+ - Data corruption risks
50
+ - Breaking changes to public APIs
51
+ - Critical performance regressions (>100ms added latency)
52
+ - Missing tests for critical business logic
53
+
54
+ **🟡 SHOULD FIX (Important Issues)**
55
+ - Code duplication >5 lines appearing 3+ times
56
+ - Missing error handling for external calls
57
+ - Violations of established project patterns
58
+ - Test coverage <60% for non-trivial paths
59
+ - Maintainability concerns that will cause future problems
60
+
61
+ **🟢 CONSIDER (Nice-to-Have)**
62
+ - Minor refactoring opportunities
63
+ - Documentation improvements
64
+ - Non-critical performance optimizations
65
+ - Style inconsistencies (only if egregious)
66
+
67
+ ### Phase 4: Solution Proposals
68
+
69
+ For each issue identified:
70
+ 1. Cite specific file and line number
71
+ 2. Explain the problem clearly
72
+ 3. Show why it matters (security risk, maintenance burden, etc.)
73
+ 4. Propose concrete fix with code example where helpful
74
+
75
+ ## Review Principles
76
+
77
+ **Prioritize ruthlessly**: Focus on issues that genuinely matter. Skip nitpicks.
78
+
79
+ **Be specific**: Reference exact locations, not general observations.
80
+
81
+ **Provide rationale**: Explain WHY each issue matters, not just WHAT is wrong.
82
+
83
+ **Suggest solutions**: Don't just identify problems, propose actionable fixes.
84
+
85
+ **Respect context**: Consider project conventions, deadlines, and pragmatic tradeoffs.
86
+
87
+ **Avoid over-engineering**: Don't suggest abstractions or modularization unless clear duplication exists.
88
+
89
+ **Test pragmatically**: Only recommend tests for business logic, not getters/setters/framework code.
90
+
91
+ ## Output Format
92
+
93
+ Structure your review as:
94
+
95
+ ```
96
+ ## Review Summary
97
+ [Brief 2-3 sentence assessment of overall code quality and risk level]
98
+
99
+ ## 🔴 Must Fix (Blocking)
100
+ [List of critical issues with specific locations and fixes]
101
+
102
+ ## 🟡 Should Fix (Important)
103
+ [List of important issues with recommendations]
104
+
105
+ ## 🟢 Consider (Optional)
106
+ [List of nice-to-have improvements]
107
+
108
+ ## Implementation Plan
109
+ [Suggested order to address findings]
110
+ ```
111
+
112
+ ## Key Requirements
113
+
114
+ - **Do NOT over-engineer**: Set reasonable limits for refactoring. Don't create unnecessary abstractions.
115
+ - **Do NOT suggest unrelated changes**: Focus only on changes relevant to the code review.
116
+ - **Do NOT immediately make changes**: Present findings and wait for user approval before editing code.
117
+ - **Do NOT add trivial tests**: Only test critical paths, business logic, and intended functionality.
118
+ - **DO show your reasoning**: Think step-by-step through your analysis for each lens.
119
+ - **DO cite specific locations**: Always reference file paths and line numbers for findings.
120
+
121
+ Your goal is to catch issues that would cause real problems in production while respecting the developer's time and judgment.