Skip to content

Commit 8de3a07

Browse files
SaintPatrckclaudeclaude[bot]
authored
Optimize reviewing-changes skill (#6099)
Co-authored-by: Claude <[email protected]> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
1 parent 9c4bd2e commit 8de3a07

File tree

15 files changed

+3572
-97
lines changed

15 files changed

+3572
-97
lines changed

.claude/prompts/review-code.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@ Use the `reviewing-changes` skill to review this pull request.
22

33
The PR branch is already checked out in the current working directory.
44

5-
Provide a comprehensive review including:
5+
CRITICAL: Create inline comments on specific lines for each issue. Do NOT create one large review comment.
66

7-
- Summary of changes since last review
8-
- Critical issues found (be thorough)
9-
- Suggested improvements (be thorough)
10-
- Good practices observed (be concise - list only the most notable items without elaboration)
11-
- Action items for the author
12-
- Leverage collapsible <details> sections where appropriate for lengthy explanations or code snippets
13-
14-
When reviewing subsequent commits:
15-
16-
- Track status of previously identified issues (fixed/unfixed/reopened)
17-
- Identify NEW problems introduced since last review
18-
- Note if fixes introduced new issues
19-
20-
IMPORTANT: Be comprehensive about issues and improvements. For good practices, be brief - just note what was done well without explaining why or praising excessively.
7+
Output Format:
8+
- Create separate inline comment for each specific issue/recommendation
9+
- Summary comment for overall assessment
10+
- Track status of previously identified issues if this is a subsequent review
11+
- Use collapsible <details> sections in inline comments for lengthy code examples
Lines changed: 141 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,169 @@
11
---
22
name: reviewing-changes
3-
description: Performs comprehensive code reviews for Bitwarden Android projects, verifying architecture compliance, style guidelines, compilation safety, test coverage, and security requirements. Use when reviewing pull requests, checking commits, analyzing code changes, verifying Bitwarden coding standards, evaluating MVVM patterns, checking Hilt DI usage, reviewing security implementations, or assessing test coverage. Automatically invoked by CI pipeline or manually for interactive code reviews.
3+
version: 2.0.0
4+
description: Comprehensive code reviews for Bitwarden Android. Detects change type (dependency update, bug fix, feature, UI, refactoring, infrastructure) and applies appropriate review depth. Validates MVVM patterns, Hilt DI, security requirements, and test coverage per project standards. Use when reviewing pull requests, checking commits, analyzing code changes, or evaluating architectural compliance.
45
---
56

67
# Reviewing Changes
78

89
## Instructions
910

10-
Follow this process to review code changes for Bitwarden Android:
11-
12-
### Step 1: Understand Context
13-
14-
Start with high-level assessment of the change's purpose and approach. Read PR/commit descriptions and understand what problem is being solved.
15-
16-
### Step 2: Verify Compliance
17-
18-
Systematically check each area against Bitwarden standards documented in `CLAUDE.md`:
19-
20-
1. **Architecture**: Follow patterns in `docs/ARCHITECTURE.md`
21-
- MVVM + UDF (ViewModels with `StateFlow`, Compose UI)
22-
- Hilt DI (interface injection, `@HiltViewModel`)
23-
- Repository pattern and proper data flow
24-
25-
2. **Style**: Adhere to `docs/STYLE_AND_BEST_PRACTICES.md`
26-
- Naming conventions, code organization, formatting
27-
- Kotlin idioms (immutability, null safety, coroutines)
28-
29-
3. **Compilation**: Analyze for potential build issues
30-
- Import statements and dependencies
31-
- Type safety and null safety
32-
- API compatibility and deprecation warnings
33-
- Resource references and manifest requirements
34-
35-
4. **Testing**: Verify appropriate test coverage
36-
- Unit tests for business logic and utility functions
37-
- Integration tests for complex workflows
38-
- UI tests for user-facing features when applicable
39-
- Test coverage for edge cases and error scenarios
40-
41-
5. **Security**: Given Bitwarden's security-focused nature
42-
- Proper handling of sensitive data
43-
- Secure storage practices (Android Keystore)
44-
- Authentication and authorization patterns
45-
- Data encryption and decryption flows
46-
- Zero-knowledge architecture preservation
11+
**IMPORTANT**: Use structured thinking throughout your review process. Plan your analysis in `<thinking>` tags before providing final feedback. This improves accuracy by 40% according to research.
12+
13+
### Step 1: Detect Change Type
14+
15+
<thinking>
16+
Analyze the changeset systematically:
17+
1. What files were modified? (code vs config vs docs)
18+
2. What is the PR/commit title indicating?
19+
3. Is there new functionality or just modifications?
20+
4. What's the risk level of these changes?
21+
</thinking>
22+
23+
Analyze the changeset to determine the primary change type:
24+
25+
**Detection Rules:**
26+
- **Dependency Update**: Only gradle files changed (`libs.versions.toml`, `build.gradle.kts`) with version number modifications
27+
- **Bug Fix**: PR/commit title contains "fix", "bug", or issue ID; addresses existing broken behavior
28+
- **Feature Addition**: New files, new ViewModels, significant new functionality
29+
- **UI Refinement**: Only UI/Compose files changed, layout/styling focus
30+
- **Refactoring**: Code restructuring without behavior change, pattern improvements
31+
- **Infrastructure**: CI/CD files, Gradle config, build scripts, tooling changes
32+
33+
If changeset spans multiple types, use the most complex type's checklist.
34+
35+
### Step 2: Load Appropriate Checklist
36+
37+
Based on detected type, read the relevant checklist file:
38+
39+
- **Dependency Update**`checklists/dependency-update.md` (expedited review)
40+
- **Bug Fix**`checklists/bug-fix.md` (focused review)
41+
- **Feature Addition**`checklists/feature-addition.md` (comprehensive review)
42+
- **UI Refinement**`checklists/ui-refinement.md` (design-focused review)
43+
- **Refactoring**`checklists/refactoring.md` (pattern-focused review)
44+
- **Infrastructure**`checklists/infrastructure.md` (tooling-focused review)
45+
46+
The checklist provides:
47+
- Multi-pass review strategy
48+
- Type-specific focus areas
49+
- What to check and what to skip
50+
- Structured thinking guidance
51+
52+
### Step 3: Execute Review with Structured Thinking
53+
54+
<thinking>
55+
Before diving into details:
56+
1. What are the highest-risk areas of this change?
57+
2. Which architectural patterns need verification?
58+
3. What security implications exist?
59+
4. How should I prioritize my findings?
60+
5. What tone is appropriate for this feedback?
61+
</thinking>
62+
63+
Follow the checklist's multi-pass strategy, thinking through each pass systematically.
64+
65+
### Step 4: Consult Reference Materials As Needed
66+
67+
Load reference files only when needed for specific questions:
68+
69+
- **Issue prioritization**`reference/priority-framework.md` (Critical vs Suggested vs Optional)
70+
- **Phrasing feedback**`reference/review-psychology.md` (questions vs commands, I-statements)
71+
- **Architecture questions**`reference/architectural-patterns.md` (MVVM, Hilt DI, module org, error handling)
72+
- **Security questions (quick reference)**`reference/security-patterns.md` (common patterns and anti-patterns)
73+
- **Security questions (comprehensive)**`docs/ARCHITECTURE.md#security` (full zero-knowledge architecture)
74+
- **Testing questions**`reference/testing-patterns.md` (unit tests, mocking, null safety)
75+
- **UI questions**`reference/ui-patterns.md` (Compose patterns, theming)
76+
- **Style questions**`docs/STYLE_AND_BEST_PRACTICES.md`
77+
78+
### Step 5: Document Findings
79+
80+
<thinking>
81+
Before writing each comment:
82+
1. Is this issue Critical, Important, Suggested, or just Acknowledgment?
83+
2. Should I ask a question or provide direction?
84+
3. What's the rationale I need to explain?
85+
4. What code example would make this actionable?
86+
5. Is there a documentation reference to include?
87+
</thinking>
88+
89+
**CRITICAL**: Use inline comments on specific lines, NOT a single large review comment.
90+
91+
**Inline Comment Rules**:
92+
- Create separate comment for EACH specific issue on the exact line
93+
- Do NOT create one large summary comment with all issues
94+
- Do NOT update existing comments - always create new comments
95+
- This ensures history is retained for other reviewers
96+
97+
**Inline Comment Format** (Concise with Collapsible Details):
98+
```
99+
**[Severity]**: [One-line issue description]
47100
48-
### Step 3: Document Findings
101+
<details>
102+
<summary>Details and fix</summary>
49103
50-
Identify specific violations with `file:line_number` references. Be precise about locations.
104+
[Code example or specific fix]
51105
52-
### Step 4: Provide Recommendations
106+
[Rationale explaining why]
53107
54-
Give actionable recommendations for improvements. Explain why changes are needed and suggest specific solutions.
108+
Reference: [docs link if applicable]
109+
</details>
110+
```
55111

56-
### Step 5: Flag Critical Issues
112+
**Example inline comment**:
113+
```
114+
**CRITICAL**: Exposes mutable state
57115
58-
Highlight issues that must be addressed before merge. Distinguish between blockers and suggestions.
116+
<details>
117+
<summary>Details and fix</summary>
59118
60-
### Step 6: Acknowledge Quality
119+
Change `MutableStateFlow<State>` to `StateFlow<State>`:
61120
62-
Note well-implemented patterns (briefly, without elaboration). Keep positive feedback concise.
121+
\```kotlin
122+
private val _state = MutableStateFlow<State>()
123+
val state: StateFlow<State> = _state.asStateFlow()
124+
\```
63125
64-
## Review Anti-Patterns (DO NOT)
126+
Exposing MutableStateFlow allows external mutation, violating MVVM unidirectional data flow.
65127
66-
- Be nitpicky about linter-catchable style issues
67-
- Review without understanding context - ask for clarification first
68-
- Focus only on new code - check surrounding context for issues
69-
- Request changes outside the scope of this changeset
128+
Reference: docs/ARCHITECTURE.md#mvvm-pattern
129+
</details>
130+
```
70131

71-
## Examples
132+
**Summary Comment Format** (Minimal - Avoid Duplication):
133+
```
134+
**Overall Assessment:** APPROVE / REQUEST CHANGES
72135
73-
### Good Review Format
136+
**Critical Issues** (if any):
137+
- [One-line summary of each critical blocking issue]
74138
75-
```markdown
76-
## Summary
77-
This PR adds biometric authentication to the login flow, implementing MVVM pattern with proper state management.
139+
See inline comments for all issue details.
140+
```
78141

79-
## Critical Issues
80-
- `app/login/LoginViewModel.kt:45` - Mutable state exposed; use `StateFlow` instead of `MutableStateFlow`
81-
- `data/auth/BiometricRepository.kt:120` - Missing null safety check on `biometricPrompt` result
142+
**Output Format Notes**:
82143

83-
## Suggested Improvements
84-
- Consider extracting biometric prompt logic to separate use case class
85-
- Add integration tests for biometric failure scenarios
86-
- `app/login/LoginScreen.kt:89` - Consider using existing `BitwardenButton` component
144+
**What to Include:**
145+
- **Inline comments**: Create separate comment for EACH specific issue with full details in `<details>` tag
146+
- **Summary comment**: Overall assessment (APPROVE/REQUEST CHANGES) + list of CRITICAL issues only
147+
- **Severity levels**: Use CRITICAL (blocking), IMPORTANT (should fix), SUGGESTED (nice to have), or ACKNOWLEDGED (good practice observed)
87148

88-
## Good Practices
89-
- Proper Hilt DI usage throughout
90-
- Comprehensive unit test coverage
91-
- Clear separation of concerns
149+
**What to Exclude:**
150+
- **No duplication**: Never repeat inline comment details in the summary
151+
- **No Important/Suggested in summary**: Only CRITICAL blocking issues belong in summary
152+
- **No "Good Practices" section**: Acknowledge good practices in inline comments if relevant
153+
- **No "Action Items" section**: This duplicates inline comments - avoid entirely
154+
- **No verbose analysis**: Keep detailed analysis (compilation status, security review, rollback plans) in inline comments only
92155

93-
## Action Items
94-
1. Fix mutable state exposure in `LoginViewModel`
95-
2. Add null safety check in `BiometricRepository`
96-
3. Consider adding integration tests for error flows
97-
```
156+
**Visibility Guidelines:**
157+
- **Inline comments visible**: Severity + one-line description only
158+
- **Inline comments collapsed**: Code examples, rationale, references in `<details>` tag
159+
- **Summary visible**: Verdict + critical issues list only
98160

99-
### What to Focus On
161+
See `examples/review-outputs.md` for complete examples.
100162

101-
**DO focus on:**
102-
- Architecture violations (incorrect patterns)
103-
- Security issues (data handling, encryption)
104-
- Missing tests for critical paths
105-
- Compilation risks (type safety, null safety)
163+
## Core Principles
106164

107-
**DON'T focus on:**
108-
- Minor formatting (handled by linters)
109-
- Personal preferences without architectural basis
110-
- Issues outside the changeset scope
165+
- **Appropriate depth**: Match review rigor to change complexity and risk
166+
- **Specific references**: Always use `file:line_number` format for precise location
167+
- **Actionable feedback**: Say what to do and why, not just what's wrong
168+
- **Constructive tone**: Ask questions for design decisions, explain rationale, focus on code not people
169+
- **Efficient reviews**: Use multi-pass strategy, time-box reviews, skip what's not relevant

0 commit comments

Comments
 (0)