git clone https://github.com/copyleftdev/zgrok.git
cd zgrok
cargo build
cargo testComments explaining what code does are prohibited. Code must be self-documenting.
// BAD
let count = 0; // Initialize counter to zero
// BAD
// Loop through items and process each one
for item in items { process(item); }
// GOOD - no comment needed
let active_connections = 0;
for connection in connections { connection.process(); }
// GOOD - explains why, not what
// Subtract 1 because stream IDs are 1-indexed in the protocol
let index = stream_id - 1;Allowed comments:
TODO,FIXMESAFETY:for unsafe blocks- Doc comments (
///) for public APIs - Non-obvious "why" explanations
- Use
thiserrorfor library errors - Use
anyhowfor binary errors - No
.unwrap()in library code - Propagate errors with
?
- Tokio runtime
- Prefer
async fnover manualFutureimplementations - Use
tokio::select!for concurrent operations
Group in order:
std- External crates
- Workspace crates
crate::super::,self::
# 1. Start from main
git checkout main && git pull
# 2. Create feature branch
git checkout -b feat/short-description
# 3. Make changes, then verify
cargo test && cargo clippy -- -D warnings && cargo fmt --check
# 4. Commit
git add -A && git commit -m "feat(component): description"
# 5. Push and create PR
git push -u origin feat/short-description
gh pr create --fill
# 6. Merge after review
gh pr merge --squash --delete-branch
# 7. Return to main
git checkout main && git pullFormat: type(scope): description
Types:
feat- New featurefix- Bug fixrefactor- Code change that neither fixes a bug nor adds a featuredocs- Documentation onlytest- Adding or fixing testschore- Maintenance tasks
Examples:
feat(agent): add TCP tunnel support
fix(edge): handle connection timeout gracefully
refactor(protocol): simplify frame encoding
# All tests
cargo test
# Single crate
cargo test -p zgrok-protocol
# Single test
cargo test test_name
# With output
cargo test -- --nocaptureWrite tests alongside code in #[cfg(test)] modules.
- Tests pass:
cargo test - No warnings:
cargo clippy -- -D warnings - Formatted:
cargo fmt --check - No tutorial comments
- Commit message follows convention