Draft
Conversation
- Create AGENTS.md with detailed Rust style guide and architecture overview - Document principled error handling approach: panic for bugs, Result - Include decision framework and real-world examples for when to use .expect() vs Result for recoverable errors - Add symlinks for CLAUDE.md and .cursorrules for compatibility with different AI tools - Cover essential commands, testing patterns, and development workflow
perryqh
reviewed
Sep 2, 2025
| This codebase follows a principled approach to error handling: **panic for programming bugs, Result for recoverable errors**. | ||
|
|
||
| #### When to Use `.expect()` or `.unwrap()` (Panic) | ||
| Use panics for programming bugs - situations that should never happen if the code is written correctly: |
Contributor
There was a problem hiding this comment.
I've been avoiding panic and instead propagating errors with Result return types. I could see the packs gem wrapping pks in the future. It would be a benefit for clients to decide how they want to handle errors.
Contributor
|
This is a good start. Thanks! I just have the comment regarding panicking. A nice to have would be for the AI assistant to be aware of https://rust-unofficial.github.io/patterns/patterns/index.html. These patterns are useful and I find myself needing to frequently review them. It'd be nice to get some AI assistance. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hey team! I'm trying to see how we can use tools like Claude Code and Cursor to make our Rust projects (pks and codeowners-rs) easier for contributors who are productive in other languages already, but haven't used Rust extensively.
What's Changed
I added an
AGENTS.mdfile to serve as agent-agnostic guidance for writing idiomatic Rust. I'm not an expert here so I want to invite some feedback.Key Areas for Alignment
1. Error Handling Philosophy: "Panic for Programming Bugs, Result for Recoverable Errors"
My back-and-forth with Claude Code and some Googling led to a "principled approach" to error handling that I'd like some feedback on:
When to panic (
.expect()/.unwrap()):debug_assert!for development-time invariant checkingWhen to use
Resultand?:Decision framework:
Alternative:
No-Panic Rust: A Nice Technique for Systems Programming or at least, almost no-panic Rust sounds applicable for projects intended to be used as libraries, like with codeowners-rs which we now embed into a Ruby gem (I can see us shipping libraries for other languages too).
2. Rust Idioms We Emphasize
As I worked on #20, I asked Claude Code to expand on
AGENTS.mdbased on the feedback I gave it as well as feedback from the PR review. I further asked it to expand on Rust idioms and best practices and it distilled this down to:matchinstead of if-else chains when handling all variantsif letfor single pattern matching - Cleaner than verbose match statementsQuestions for the Team
Benefits
Looking forward to your feedback! 💛 ✨