You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,3 +153,54 @@ The Polkadot SDK provides:
153
153
- IPFS idle connection timeout: 1 hour
154
154
- Node supports litep2p/Bitswap
155
155
- 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.
0 commit comments