-
Notifications
You must be signed in to change notification settings - Fork 67
Implement reusable Claude code review and response workflow #1359
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
Open
theMickster
wants to merge
8
commits into
main
Choose a base branch
from
arch/pm-26935/reusable-code-review-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+205
โ0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a13c4a3
Implement reusable Claude code review and response workflow
theMickster 1f9e426
Remove the TODO
theMickster 0e993bd
Enhance the CLAUDE.md
theMickster bd5bbfd
Set Claude code owners
theMickster 29bebe3
Revert cargo.lock
theMickster 3ee64fd
Refactorings to better guide claude
theMickster 640c017
[PM-27181] - Grant additional permissions for review code
theMickster 16e5e61
Update code owner for workflows
theMickster 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,124 @@ | ||
| # Bitwarden Secrets Manager SDK | ||
|
|
||
| ## Crates | ||
|
|
||
| The project is structured as a monorepo using cargo workspaces. Some of the more noteworthy crates | ||
| are: | ||
|
|
||
| - [`bitwarden`](./crates/bitwarden/): Rust-friendly API for interacting with the secrets manager. | ||
| - [`bitwarden-c`](./crates/bitwarden-c/): C bindings for FFI interop. | ||
| - [`bitwarden-json`](./crates/bitwarden-json/): JSON wrapper around the `bitwarden` crate. Powers | ||
| the other language bindings. | ||
| - [`bitwarden-napi`](./crates/bitwarden-napi/): Node-API bindings for Node.js/TypeScript. | ||
| - [`bitwarden-wasm`](./crates/bitwarden-wasm/): WebAssembly bindings. | ||
| - [`bws`](./crates/bws/): CLI for interacting with the [Bitwarden Secrets Manager][secrets-manager]. | ||
| Review the [CLI documentation][bws-help]. | ||
| - [`sdk-schemas`](./crates/sdk-schemas/): Generator for the _json schemas_. | ||
| - [`fake-server`](./crates/fake-server/): Development/testing server that emulates Bitwarden API | ||
| endpoints for local testing without a real server instance. | ||
|
|
||
| ### Language Bindings | ||
|
|
||
| The SDK provides bindings in the `/languages/` directory: C++, C#, Go, Java, JavaScript/TypeScript, | ||
| PHP, Python, and Ruby. All bindings share a consistent API for projects and secrets management. | ||
|
|
||
| ## Schemas | ||
|
|
||
| To minimize the amount of work required to support additional bindings the project is structured | ||
| around a `json` based API, beginning with every binding only needing to implement one method, namely | ||
| a `run_command`. Additional work may be required to implement other functions, like a `free` command | ||
| for languages that require manual memory management. Additional language-specific implementation | ||
| details will apply based on the language. | ||
|
|
||
| To ensure type safety in the API, _json schemas_ are generated from the rust structs in `bitwarden` | ||
| using [schemars](https://crates.io/crates/schemars). The _json schemas_ are later used to generate | ||
| the API bindings for each language using [QuickType](https://github.com/quicktype/quicktype). | ||
|
|
||
| ```bash | ||
| npm run schemas | ||
| ``` | ||
|
|
||
| ## Key Concepts | ||
|
|
||
| ### Architecture | ||
|
|
||
| The SDK uses a **layered architecture** to support multiple languages efficiently: | ||
|
|
||
| 1. **Core Layer**: External Rust dependencies from | ||
| [sdk-internal](https://github.com/bitwarden/sdk-internal) repository contain the core business | ||
| logic and cryptography. The `Cargo.toml` file **must** be inspected for these dependencies. | ||
| 2. **Public API Layer**: The public `bitwarden` crate provides the Rust API. | ||
| 3. **JSON API Layer**: `bitwarden-json` wraps the Rust API with a single `run_command` method. | ||
| 4. **Language Bindings**: All language bindings call `run_command` with JSON requests/responses. | ||
|
|
||
| This architecture means adding a new language or updating the API requires minimal per-language | ||
| work, as the heavy lifting is done in Rust and exposed via JSON schemas. | ||
|
|
||
| ### Authentication | ||
|
|
||
| The SDK uses **access tokens** for authentication. All language bindings provide an authentication | ||
| method (named according to each language's conventions, such as `login_access_token`, | ||
| `accessTokenLogin`, or `LoginAccessToken`) to authenticate with the Secrets Manager API. | ||
|
|
||
| ### State Files | ||
|
|
||
| The SDK supports optional **state files** for caching, improving performance by avoiding | ||
| re-authentication. State files can be specified when calling the authentication method or omitted by | ||
| passing `None`/`null`. | ||
|
|
||
| ### Feature Flags | ||
|
|
||
| Key feature flags include: | ||
|
|
||
| - `secrets` (default): Enables Secrets Manager API | ||
| - `no-memory-hardening`: Disables memory security hardening features | ||
| - `wasm`: Enables WebAssembly support | ||
|
|
||
| ## Development Workflows | ||
|
|
||
| ### Generating Schemas | ||
|
|
||
| When you modify the Rust API structs, regenerate the JSON schemas and language bindings: | ||
|
|
||
| ```bash | ||
| npm run schemas | ||
| ``` | ||
|
|
||
| This generates JSON schemas from Rust structs and updates all language binding code using QuickType. | ||
|
|
||
| ### Local Testing with Fake Server | ||
|
|
||
| Use the `fake-server` crate to test locally without a real Bitwarden instance: | ||
|
|
||
| ```bash | ||
| cargo run -p fake-server | ||
| # Then use bws or other clients against http://localhost:3000 (default port) | ||
| ``` | ||
|
|
||
| The fake server provides minimal CRUD operations for secrets and projects. | ||
|
|
||
| ### Building Language Bindings | ||
|
|
||
| - **Python**: Requires Python 3 and `maturin` (`pip install maturin`) | ||
| - **Node.js**: Uses `napi-rs` for native addons | ||
| - **WebAssembly**: Requires `wasm32-unknown-unknown` target and `wasm-bindgen-cli` | ||
|
|
||
| ### Code Quality | ||
|
|
||
| - **Formatting**: Requires nightly toolchain: `cargo +nightly fmt` | ||
| - **Linting**: `cargo clippy --all-features --tests` (workspace lints deny unwrap_used and | ||
| unused_async) | ||
| - **MSRV**: Minimum Supported Rust Version is 1.85 | ||
|
|
||
| ## References | ||
|
|
||
| - [SDK Architecture](https://contributing.bitwarden.com/architecture/sdk/secrets-manager/) | ||
| - [Secrets Manager SDK Documentation](https://bitwarden.com/help/secrets-manager-sdk/) | ||
| - [Secrets Manager CLI Documentation](https://bitwarden.com/help/secrets-manager-cli/) | ||
| - [Secrets Manager Overview](https://bitwarden.com/help/secrets-manager-overview/) | ||
| - [Architectural Decision Records (ADRs)](https://contributing.bitwarden.com/architecture/adr/) | ||
| - [Contributing Guidelines](https://contributing.bitwarden.com/contributing/) | ||
| - [Setup Guide](https://contributing.bitwarden.com/getting-started/sdk/secrets-manager/) | ||
| - [Code Style](https://contributing.bitwarden.com/contributing/code-style/) | ||
| - [Security Whitepaper](https://bitwarden.com/help/bitwarden-security-white-paper/) | ||
| - [Security Definitions](https://contributing.bitwarden.com/architecture/security/definitions) | ||
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,27 @@ | ||
| 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 a comprehensive review including: | ||
|
|
||
| - Summary of changes since last review | ||
| - Critical issues found (be thorough) | ||
| - Suggested improvements (be thorough) | ||
| - Good practices observed (be concise - list only the most notable items without elaboration) | ||
| - Action items for the author | ||
| - Leverage collapsible <details> sections where appropriate for lengthy explanations or code | ||
| snippets to enhance human readability | ||
|
|
||
| When reviewing subsequent commits: | ||
|
|
||
| - Track status of previously identified issues (fixed/unfixed/reopened) | ||
| - Identify NEW problems introduced since last review | ||
| - Note if fixes introduced new issues | ||
|
|
||
| IMPORTANT: Be comprehensive about issues and improvements. For good practices, be brief - just note | ||
| what was done well without explaining why or praising excessively. |
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
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,28 @@ | ||
| name: Respond | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| respond: | ||
| name: Respond | ||
| uses: bitwarden/gh-actions/.github/workflows/_respond.yml@main | ||
| secrets: | ||
| AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
| AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
| AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
| permissions: | ||
| actions: read | ||
| contents: write | ||
| id-token: write | ||
| issues: write | ||
| pull-requests: write |
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,21 @@ | ||
| name: Code Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| review: | ||
| name: Review | ||
| uses: bitwarden/gh-actions/.github/workflows/_review-code.yml@main | ||
| secrets: | ||
| AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
| AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
| AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| id-token: write | ||
| pull-requests: write |
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.