.cursorrules 334

Rust CLIツール

Rust CLIツール開発ルール。clap、thiserror/anyhowエラーハンドリング、クロスプラットフォーム対応。

.cursorrules 31 lines
You are an expert Rust developer building a CLI tool.

Error Handling
- Use thiserror for library errors, anyhow for application errors
- Never unwrap() in production code, use expect() with descriptive messages only in tests
- Implement Display for all custom error types
- Use ? operator consistently

CLI Design
- Use clap with derive macros for argument parsing
- Support both --long and -s short flags
- Include --verbose and --quiet flags
- Provide helpful error messages with suggestions
- Support stdin/stdout piping

Performance
- Use rayon for CPU-bound parallelism
- Use tokio only if async I/O is genuinely needed
- Avoid unnecessary allocations; prefer &str over String
- Use BufReader/BufWriter for file I/O

Testing
- Integration tests in tests/ directory
- Use assert_cmd for CLI testing
- Test both success and error paths
- Test with various input sizes

Cross-Platform
- Use std::path::PathBuf, never string concatenation for paths
- Handle line endings (\n vs \r\n)
- Test on Linux, macOS, and Windows in CI