Skip to content

Commit 4755495

Browse files
Improved claude.md (#191)
* added Claude Code reviewer to Bulletin repo * simplified setup * added id-token: write * Update CLAUDE.md Co-authored-by: Francisco Aguirre <[email protected]> * Update CLAUDE.md Co-authored-by: Francisco Aguirre <[email protected]> * reverted claude code review bot --------- Co-authored-by: Francisco Aguirre <[email protected]>
1 parent b48ef2e commit 4755495

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

.claude/commands/review-pr.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Review pull request #$ARGUMENTS
2+
3+
Fetch the PR diff and details using `gh pr view` and `gh pr diff`, then analyze for:
4+
5+
1. **Code Quality**
6+
- Rust idioms and Polkadot SDK patterns
7+
- Error handling and unwrap usage
8+
- Code clarity and maintainability
9+
10+
2. **Security**
11+
- Unsafe code blocks
12+
- Input validation
13+
- Access control in pallets
14+
15+
3. **Performance**
16+
- Weight/benchmark implications
17+
- Storage access patterns
18+
- Unnecessary allocations
19+
20+
4. **Testing**
21+
- Test coverage for new code
22+
- Edge cases handled
23+
24+
5. **Breaking Changes**
25+
- API compatibility
26+
- Migration requirements
27+
28+
Provide specific feedback with file paths and line numbers.

CLAUDE.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,54 @@ The Polkadot SDK provides:
153153
- IPFS idle connection timeout: 1 hour
154154
- Node supports litep2p/Bitswap
155155
- Solochain validators need BABE and GRANDPA session keys
156+
157+
## Code Review Guidelines (Parity Standards)
158+
159+
These guidelines are used by the Claude Code review bot and should be followed by all contributors.
160+
161+
### Rust Code Quality
162+
163+
- **Error Handling**: Use `Result` types with meaningful error enums. Avoid `unwrap()` and `expect()` in production code; they are acceptable in tests.
164+
- **Arithmetic Safety**: Use `checked_*`, `saturating_*`, or `wrapping_*` arithmetic to prevent overflow. Never use raw arithmetic operators on user-provided values.
165+
- **Naming**: Follow Rust naming conventions (snake_case for functions/variables, CamelCase for types).
166+
- **Complexity**: Prefer simple, readable code. Avoid over-engineering and premature abstractions.
167+
168+
### FRAME Pallet Standards
169+
170+
- **Storage**: Use appropriate storage types (`StorageValue`, `StorageMap`, `StorageDoubleMap`, `CountedStorageMap`).
171+
- **Events**: Emit events for all state changes that external observers need to track.
172+
- **Errors**: Define descriptive error types in the pallet's `Error` enum.
173+
- **Weights**: All extrinsics must have accurate weight annotations. Update benchmarks when logic changes.
174+
- **Origins**: Use the principle of least privilege for origin checks.
175+
- **Hooks**: Be cautious with `on_initialize` and `on_finalize`; they affect block production time in solochains and can brick parachains. Never panic or do unbounded iteration in them. Always benchmark them properly.
176+
177+
### Security Considerations
178+
179+
- **No Panics in Runtime**: Runtime code must never panic. Use defensive programming.
180+
- **Bounded Collections**: Use `BoundedVec`, `BoundedBTreeMap` etc. to prevent unbounded storage growth.
181+
- **Input Validation**: Validate all user inputs at the entry point.
182+
- **Storage Deposits**: Consider requiring deposits for user-created storage items that are returned once the item is cleared.
183+
184+
### Testing Requirements
185+
186+
- **Unit Tests**: All new functionality requires unit tests.
187+
- **Edge Cases**: Test boundary conditions, error paths, and malicious inputs.
188+
- **Integration Tests**: Complex features should have integration tests using `sp-io::TestExternalities`.
189+
- **Benchmark Tests**: Features affecting weights should have benchmark tests.
190+
191+
### PR Requirements
192+
193+
- **Single Responsibility**: Each PR should address one concern.
194+
- **Tests Pass**: All CI checks must pass (`cargo test`, `cargo clippy`, `cargo fmt`).
195+
- **No Warnings**: Code should compile without warnings.
196+
- **Documentation**: Public APIs require rustdoc comments.
197+
198+
### Using the Claude Review Bot
199+
200+
The repository has a Claude Code review bot that automatically reviews PRs. You can also interact with it:
201+
202+
- **@claude** - Mention in any comment to ask questions or request help
203+
- **Assign to claude[bot]** - Assign an issue to have Claude analyze and propose solutions
204+
- **Label with `claude`** - Add the `claude` label to an issue for Claude to investigate
205+
206+
The bot enforces these guidelines and provides actionable feedback with fix suggestions.

examples/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const TX_MODE_IN_BLOCK = "in-block";
8383
export const TX_MODE_FINALIZED_BLOCK = "finalized-block";
8484
export const TX_MODE_IN_POOL = "in-tx-pool";
8585

86-
const DEFAULT_TX_TIMEOUT_MS = 60_000; // 60 seconds or 10 blocks
86+
const DEFAULT_TX_TIMEOUT_MS = 120_000; // 120 seconds or 20 blocks
8787

8888
const TX_MODE_CONFIG = {
8989
[TX_MODE_IN_BLOCK]: {

0 commit comments

Comments
 (0)