rust-coding-conventions
Skill1 starsChanged 49 days agoMITView on GitHub
Mastering Rust/Win32 development by enforcing strict layered architecture (GUI -> App -> Domain <- Infra) and Win32 API isolation. This skill mandates pure Rust domains, RAII-based resource management to prevent GDI leaks, and explicit safety comments for unsafe blocks. Use during code implementation or review to ensure dependency direction and memory safety.
In this repository24 other files it gives its agents.
- accessing-microsoft-learn-docsSkill
- architecture-validatorSkill
- autonomous-researcherSkill
- clean-up-stale-inline-review-notesSkill
- create-artifactsSkill
- create-worktreeSkill
- github-check-pr-review-comments-graphqlSkill
- github-create-draft-prSkill
- github-creating-issuesSkill
- github-replying-to-pr-threadsSkill
- github-sub-issue-creatorSkill
- gitlab-check-mr-review-commentsSkill
- gitlab-create-issueSkill
- gitlab-create-mrSkill
- gitlab-reply-mr-threadsSkill
- gitlab-sub-issue-linkerSkill
- hypothesis-driven-planningSkill
- japanese-writingSkill
- load-inline-review-notesSkill
- operating-gitSkill
- operating-jetbrains-projectsSkill
- referencing-commit-conventionSkill
- sequential-thinkingSkill
- web-artifacts-builderSkill
The file
Files
Rust/Win32 コーディング規約
命名規則
| 対象 | 形式 | 例 |
| 変数・関数・モジュール | snake_case | cursor_position_x |
| 型 (Struct, Enum, Trait) | PascalCase | TerminalWorkflow |
| 定数 | SCREAMING_SNAKE_CASE | MAX_BUFFER_SIZE |
| ファイル名 | 構造体名のsnake_case | terminal_service.rs |
| bool型 | 述語形式 | is_visible, has_focus, can_scroll |
例外: Win32 API FFI境界(DllMain, OnCommand等)のみPascalCase/CamelCaseを許容。lib.rs内に限定。
アーキテクチャ
依存方向: 外側 → 内側
GUI → Application → Domain ← Infrastructureレイヤー責務
| レイヤー | 責務 | 制約 |
Domain (src/domain/) | 状態、データ表現、Repository Trait定義 | windowsクレート依存禁止 |
Application (src/application/) | ユースケース、レイヤー間調整 | 具体的な描画方法を知らない |
Infrastructure (src/infra/) | OS/外部システムとの対話 | Win32 APIをここに閉じ込める |
GUI (src/gui/) | 描画、ユーザー入力受け取り | 巨大関数を作らない |
データモデリング
プリミティブ型の羅列を避け、意味のある構造体を定義する。
// Bad
fn handle_key(vk_code: u16, ctrl: bool, shift: bool)
// Good
fn handle_key(key: InputKey)
// where struct InputKey { code: KeyCode, modifiers: Modifiers }安全性ガイドライン
unsafeの局所化: 最小限に抑える- Safety Comment必須: なぜ
unsafeが必要か、なぜ安全かを記述 - FFI境界: 生ポインタは即座に安全なRust型に変換
- リソース管理:
DropトレイトでRAIIパターンを使用(GDIオブジェクトのリーク防止) - Panic禁止:
unwrap()/expect()を避け、Resultを返す
ファイルサイズ
1ファイル300行制限: 超えたら設計見直しを検討
テスト戦略
| レイヤー | 目標 |
| Domain | カバレッジ90%以上 |
| Application | ドメインとの協調をテスト、必要に応じてモック |
| Infrastructure/GUI | ロジックを分離し、純粋な計算部分のみテスト |
必須ツール
cargo fmt # フォーマット
cargo clippy # 警告は全て修正Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

