-
Notifications
You must be signed in to change notification settings - Fork 11
ci: add Claude Code GitHub Action for on-demand reviews #551
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
base: v0.42-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| name: Claude Code | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| jobs: | ||
| claude: | ||
| if: | | ||
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
| (github.event_name == 'issues' && github.event.action == 'assigned' && github.event.assignee.login == 'claude') | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| issues: write | ||
| id-token: write | ||
| actions: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Checkout Dash Core reference | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: dashpay/dash | ||
| path: .reference/dash | ||
| sparse-checkout: src | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Checkout Dash DIPs | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: dashpay/dips | ||
| path: .reference/dips | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Run Claude Code | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| assignee_trigger: "claude" | ||
| settings: | | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(cargo *)", | ||
| "Bash(rustup *)", | ||
| "Bash(git *)", | ||
| "Bash(gh *)" | ||
| ] | ||
| } | ||
| } | ||
|
Comment on lines
+57
to
+67
Contributor
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. 🧩 Analysis chain🌐 Web query:
💡 Result: In Claude Code, tool permissions are configured in {
"permissions": {
"allow": ["...rules..."],
"ask": ["...rules..."],
"deny": ["...rules..."]
}
}
The Claude Code Action lets you pass the same permissions either via the action’s Sources: Claude Code “Configure permissions” docs (rule syntax) [1], Claude Code settings docs (permissions in settings.json) [2], 🏁 Script executed: # Check the workflow file to understand its purpose and context
cat -n .github/workflows/claude.ymlRepository: dashpay/rust-dashcore Length of output: 7112 Overly permissive Bash command patterns for The patterns Consider restricting to explicitly needed operations:
🤖 Prompt for AI Agents |
||
| claude_args: | | ||
| --max-turns 50 | ||
| --append-system-prompt "## Code Review Guidelines | ||
|
|
||
| You are reviewing a Dash cryptocurrency protocol library written in Rust. This is security-sensitive code. | ||
|
|
||
| ### Review Process | ||
| When reviewing a PR, launch 3 independent subagents in parallel, each with a different perspective: | ||
| 1. Rust Systems Agent: focuses on correctness, error handling, type safety, memory safety, and compilation (runs cargo clippy/check). When the PR touches FFI code, also reviews C ABI safety, null pointer checks, and destroy/free pairing. | ||
| 2. Dash Protocol Agent: focuses on protocol compliance by cross-referencing changes against Dash Core C++ (.reference/dash/src/) and DIPs (.reference/dips/). Checks P2P message formats, serialization, consensus rules, and DIP adherence. When the PR does not touch protocol code, this agent should still verify the changes do not accidentally break protocol assumptions. | ||
| 3. Code Quality Agent: focuses on test coverage, code style rules (see below), visibility modifiers, import organization, duplication, and scope creep. | ||
| After all three agents complete, consolidate their findings into a single review. Deduplicate overlapping concerns, prioritize by severity, and post as one cohesive review. | ||
|
|
||
| ### Review Focus | ||
| - Correctness: verify logic, edge cases, and error handling | ||
| - Safety: check for memory safety issues especially in FFI boundaries (dash-spv-ffi, key-wallet-ffi) | ||
| - Security: flag any potential for private key leakage, command injection, or unsafe deserialization | ||
| - Code quality: verify proper error types (thiserror), no hardcoded values, correct visibility modifiers | ||
| - Tests: check that new code has adequate test coverage and that edge cases are tested | ||
| - Run cargo clippy and cargo check when reviewing Rust changes to catch compilation issues | ||
|
|
||
| ### Dash Protocol Reference | ||
| When the PR touches protocol-level code (transactions, blocks, masternodes, quorums, ChainLocks, InstantSend, special transactions, X11, P2P network messages, peer management, or any network protocol handling), cross-reference against: | ||
| - Dash Core C++ implementation at .reference/dash/src/ (especially net.cpp, net_processing.cpp, protocol.h for P2P) | ||
| - Dash Improvement Proposals at .reference/dips/ | ||
| Verify that the Rust implementation correctly follows the Dash Core P2P protocol: message formats, serialization, handshake sequences, version negotiation, inventory handling, and service flags must match the C++ reference. Flag any deviations from the protocol or the relevant DIPs. | ||
|
|
||
| ### Code Style Rules (enforce these strictly) | ||
| - Comments must document what code does, never what it fixed or replaced. No references to previous implementations or solved problems. | ||
| - Avoid numeric type suffixes (e.g., 1u32, 0usize) when the type is clear from context. | ||
| - Use the most restrictive visibility possible. Default to private (pub(crate), pub(super), or no modifier). Never use pub if pub(crate) suffices. | ||
| - All imports must be at the top of the file/module. Flag any inline fully-qualified paths (e.g., crate::foo::Bar::method()) when a top-level use import would work. | ||
| - Only add comments when they provide meaningful context that is not obvious from the code itself. Do not comment self-explanatory code or simple one-liners. | ||
| - No numbered comments or references to line numbers in comments. | ||
| - Reuse existing data structures and code. Flag duplication that could use existing types or helpers. | ||
| - Proper error handling is required. No temporary fixes, no swallowing errors, no unwrap() in non-test code without justification. | ||
| - Changes should be minimal and focused. Flag any unnecessary refactoring, feature additions, or scope creep beyond what the PR description states. | ||
|
Comment on lines
+70
to
+104
Contributor
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. 🛠️ Refactor suggestion | 🟠 Major System prompt duplicates The coding style rules in this prompt largely duplicate content from Additionally, Proposed fix: Reference AGENTS.md and add caveatAdd to the system prompt, near line 72: + IMPORTANT: Read AGENTS.md in the repository root for canonical coding guidelines and project conventions.
+
+ ### Critical Caveat
+ This library is NOT for consensus-critical validation. Do not rely on exact Dash Core consensus behavior. When cross-referencing against Dash Core C++, use it as a guide for protocol message formats and P2P behavior, not as a source of truth for consensus rules.
+
### Review ProcessThis ensures:
🤖 Prompt for AI Agents |
||
|
|
||
| ### What Not To Do | ||
| - Do not nitpick formatting if it passes cargo fmt | ||
| - Do not suggest adding emojis | ||
| - Do not use uppercase emphasis in review comments | ||
| - Do not suggest changes that are unrelated to the PR's stated purpose" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toolchain version mismatch with
rust-toolchain.toml.The project pins Rust to version
1.92.0inrust-toolchain.toml, but this workflow uses@stable. This divergence can cause inconsistentcargo clippyresults between local development and Claude's review environment.Additionally, the project's
rust-toolchain.tomlspecifiesrustfmtandclippycomponents, which aren't explicitly installed here.Proposed fix: Let dtolnay/rust-toolchain auto-detect from rust-toolchain.toml
Alternatively, if
rust-toolchain.tomlis present in the repo root, you can omit thetoolchaininput and use:This will automatically install the toolchain specified in
rust-toolchain.toml.🤖 Prompt for AI Agents