-
Notifications
You must be signed in to change notification settings - Fork 20
PM-26544 - Initial create of a CLAUDE.md and a code review action #493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: Review code | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
review: | ||
name: Review | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
contents: read | ||
id-token: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Check for Vault team changes | ||
id: check_changes | ||
run: | | ||
# Ensure we have the base branch | ||
git fetch origin ${{ github.base_ref }} | ||
|
||
echo "Comparing changes between origin/${{ github.base_ref }} and HEAD" | ||
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) | ||
|
||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "Zero files changed" | ||
echo "vault_team_changes=false" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
|
||
# Handle variations in spacing and multiple teams | ||
VAULT_PATTERNS=$(grep -E "@bitwarden/team-vault-dev(\s|$)" .github/CODEOWNERS 2>/dev/null | awk '{print $1}') | ||
|
||
if [ -z "$VAULT_PATTERNS" ]; then | ||
echo "โ ๏ธ No patterns found for @bitwarden/team-vault-dev in CODEOWNERS" | ||
echo "vault_team_changes=false" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
|
||
vault_team_changes=false | ||
for pattern in $VAULT_PATTERNS; do | ||
echo "Checking pattern: $pattern" | ||
|
||
# Handle **/directory patterns | ||
if [[ "$pattern" == "**/"* ]]; then | ||
# Remove the **/ prefix | ||
dir_pattern="${pattern#\*\*/}" | ||
# Check if any file contains this directory in its path | ||
if echo "$CHANGED_FILES" | grep -qE "(^|/)${dir_pattern}(/|$)"; then | ||
vault_team_changes=true | ||
echo "โ Found files matching pattern: $pattern" | ||
echo "$CHANGED_FILES" | grep -E "(^|/)${dir_pattern}(/|$)" | sed 's/^/ - /' | ||
break | ||
fi | ||
else | ||
# Handle other patterns (shouldn't happen based on your CODEOWNERS) | ||
if echo "$CHANGED_FILES" | grep -q "$pattern"; then | ||
vault_team_changes=true | ||
echo "โ Found files matching pattern: $pattern" | ||
echo "$CHANGED_FILES" | grep "$pattern" | sed 's/^/ - /' | ||
break | ||
fi | ||
fi | ||
done | ||
|
||
echo "vault_team_changes=$vault_team_changes" >> $GITHUB_OUTPUT | ||
|
||
if [ "$vault_team_changes" = "true" ]; then | ||
echo "" | ||
echo "โ Vault team changes detected - proceeding with review" | ||
else | ||
echo "" | ||
echo "โ No Vault team changes detected - skipping review" | ||
fi | ||
|
||
- name: Review with Claude Code | ||
if: steps.check_changes.outputs.vault_team_changes == 'true' | ||
uses: anthropics/claude-code-action@a5528eec7426a4f0c9c1ac96018daa53ebd05bc4 # v1.0.7 | ||
with: | ||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
track_progress: true | ||
prompt: | | ||
REPO: ${{ github.repository }} | ||
PR NUMBER: ${{ github.event.pull_request.number }} | ||
TITLE: ${{ github.event.pull_request.title }} | ||
BODY: ${{ github.event.pull_request.body }} | ||
AUTHOR: ${{ github.event.pull_request.user.login }} | ||
|
||
Please review this pull request with a focus on: | ||
- Code quality and best practices | ||
- Potential bugs or issues | ||
- Security implications | ||
- Performance considerations | ||
|
||
Note: The PR branch is already checked out in the current working directory. | ||
|
||
Provide detailed feedback using inline comments for specific issues. | ||
|
||
claude_args: | | ||
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Bitwarden Internal SDK | ||
|
||
Rust SDK centralizing business logic. You're reviewing code as a senior Rust engineer mentoring | ||
teammates. | ||
|
||
## Client Pattern | ||
|
||
PasswordManagerClient ([bitwarden-pm](crates/bitwarden-pm/src/lib.rs)) wraps | ||
[bitwarden_core::Client](crates/bitwarden-core/src/client/client.rs) and exposes sub-clients: | ||
`auth()`, `vault()`, `crypto()`, `sends()`, `generators()`, `exporters()`. | ||
|
||
**Lifecycle** | ||
|
||
- Init โ Lock/Unlock โ Logout (drops instance). Memento pattern for state resurrection. | ||
|
||
**Storage** | ||
|
||
- Consuming apps use `HashMap<UserId, PasswordManagerClient>`. | ||
|
||
## Issues necessitating comments | ||
|
||
**Auto-generated code changes** | ||
|
||
- Changes to `bitwarden-api-api/` or `bitwarden-api-identity/` are generally discouraged. These are | ||
auto-generated from swagger specs. | ||
|
||
**Secrets in logs/errors** | ||
|
||
- Do not log keys, passwords, or vault data in logs or error paths. Redact sensitive data. | ||
|
||
**Business logic in WASM** | ||
|
||
- `bitwarden-wasm-internal` contains only thin bindings. Move business logic to feature crates. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably expand this section to be something like:
By application crates, I mean the ones that are meant to be directly used by our applications (web, mobile, cli) |
||
|
||
**Unsafe without justification** | ||
|
||
- Any `unsafe` block needs a comment explaining why it's safe and what invariants are being upheld. | ||
|
||
**Changes to `bitwarden-crypto/` core functionality** | ||
|
||
- Generally speaking, this crate should not be modified. Changes need a comment explaining why. | ||
|
||
**New crypto algorithms or key derivation** | ||
theMickster marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Detailed description, review and audit trail required. Document algorithm choice rationale and | ||
test vectors. | ||
|
||
**Encryption/decryption modifications** | ||
|
||
- Verify backward compatibility. Existing encrypted data must remain decryptable. | ||
|
||
**Breaking serialization** | ||
|
||
- Backward compatibility required. Users must decrypt vaults from older versions. | ||
|
||
**Breaking API changes** | ||
|
||
- Document migration path for clients. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.