jpskill.com
🛠️ 開発・MCP コミュニティ

rust-development

Gutsプロジェクトにおいて、Rustの慣用的なコーディング、エラー処理、非同期処理パターン、そして共通コンポーネントの統合といった、開発におけるベストプラクティスを実践するSkill。

📜 元の英語説明(参考)

Rust development best practices for the Guts project - idiomatic code, error handling, async patterns, and commonware integration

🇯🇵 日本人クリエイター向け解説

一言でいうと

Gutsプロジェクトにおいて、Rustの慣用的なコーディング、エラー処理、非同期処理パターン、そして共通コンポーネントの統合といった、開発におけるベストプラクティスを実践するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o rust-development.zip https://jpskill.com/download/8808.zip && unzip -o rust-development.zip && rm rust-development.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/8808.zip -OutFile "$d\rust-development.zip"; Expand-Archive "$d\rust-development.zip" -DestinationPath $d -Force; ri "$d\rust-development.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して rust-development.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → rust-development フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Guts 用 Rust 開発スキル

分散型インフラストラクチャ用の commonware プリミティブを使用して Rust プロジェクトを開発しています。

コードスタイルガイドライン

一般原則

  1. 慣用的な Rust: Rust のイディオムと慣習に従ってください
  2. メモリ安全性: ボローチェッカーを活用し、どうしても必要な場合を除き unsafe を避けてください
  3. エラー処理: ライブラリのエラーには thiserror を、アプリケーションには anyhow を使用してください
  4. ドキュメント: すべての公開アイテムには、例を含むドキュメントが必要です

フォーマットとリンティング

# コミット前に必ず実行してください
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings

エラー処理パターン

use thiserror::Error;

#[derive(Debug, Error)]
pub enum RepositoryError {
    #[error("repository not found: {0}")]
    NotFound(String),

    #[error("permission denied for repository: {0}")]
    PermissionDenied(String),

    #[error("storage error: {0}")]
    Storage(#[from] StorageError),
}

pub type Result<T> = std::result::Result<T, RepositoryError>;

Async パターン

構造化された並行性を持つ非同期ランタイムには Tokio を使用します。

use tokio::sync::{mpsc, oneshot};

// 共有状態よりもチャネルを優先します
pub struct Service {
    tx: mpsc::Sender<Command>,
}

impl Service {
    pub async fn query(&self, request: Request) -> Result<Response> {
        let (tx, rx) = oneshot::channel();
        self.tx.send(Command::Query { request, reply: tx }).await?;
        rx.await?
    }
}

モジュール構造

// lib.rs - 公開 API を再エクスポートします
pub mod error;
pub mod types;
pub mod service;

pub use error::{Error, Result};
pub use types::*;
pub use service::Service;

テスト

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_feature() {
        // Arrange
        let service = Service::new().await;

        // Act
        let result = service.do_something().await;

        // Assert
        assert!(result.is_ok());
    }
}

Commonware 統合

主要なクレート

  • commonware-cryptography: Ed25519 署名に使用します
  • commonware-p2p: ピアツーピアネットワークに使用します
  • commonware-consensus: BFT コンセンサスに使用します
  • commonware-storage: 永続ストレージに使用します
  • commonware-codec: シリアライゼーションに使用します

例: 暗号の使用

use commonware_cryptography::{Ed25519, Signer, Verifier};

pub struct Identity {
    keypair: Ed25519,
}

impl Identity {
    pub fn new() -> Self {
        Self {
            keypair: Ed25519::generate(),
        }
    }

    pub fn sign(&self, message: &[u8]) -> Signature {
        self.keypair.sign(message)
    }
}

Cargo.toml のベストプラクティス

[package]
name = "guts-core"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
license = "MIT OR Apache-2.0"
description = "Core types and traits for Guts"
repository = "https://github.com/AbdelStark/guts"
keywords = ["decentralized", "git", "p2p"]
categories = ["development-tools"]

[dependencies]
# ワークスペースの依存関係を使用します
thiserror = { workspace = true }
tokio = { workspace = true }

[dev-dependencies]
tokio-test = { workspace = true }

[lints.rust]
unsafe_code = "deny"
missing_docs = "warn"

[lints.clippy]
all = "warn"
pedantic = "warn"
nursery = "warn"

パフォーマンスに関する考慮事項

  1. 非同期タスク間で共有所有権を得るには Arc を使用します
  2. ゼロコピーネットワーキングには bytes::Bytes を優先します
  3. 並行ハッシュマップには dashmap を使用します
  4. 最適化する前に flamegraph でプロファイルします
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Rust Development Skill for Guts

You are developing a Rust project using commonware primitives for decentralized infrastructure.

Code Style Guidelines

General Principles

  1. Idiomatic Rust: Follow Rust idioms and conventions
  2. Memory Safety: Leverage the borrow checker, avoid unsafe unless absolutely necessary
  3. Error Handling: Use thiserror for library errors, anyhow for applications
  4. Documentation: Every public item needs docs with examples

Formatting & Linting

# Always run before committing
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings

Error Handling Pattern

use thiserror::Error;

#[derive(Debug, Error)]
pub enum RepositoryError {
    #[error("repository not found: {0}")]
    NotFound(String),

    #[error("permission denied for repository: {0}")]
    PermissionDenied(String),

    #[error("storage error: {0}")]
    Storage(#[from] StorageError),
}

pub type Result<T> = std::result::Result<T, RepositoryError>;

Async Patterns

Use Tokio for async runtime with structured concurrency:

use tokio::sync::{mpsc, oneshot};

// Prefer channels over shared state
pub struct Service {
    tx: mpsc::Sender<Command>,
}

impl Service {
    pub async fn query(&self, request: Request) -> Result<Response> {
        let (tx, rx) = oneshot::channel();
        self.tx.send(Command::Query { request, reply: tx }).await?;
        rx.await?
    }
}

Module Structure

// lib.rs - re-export public API
pub mod error;
pub mod types;
pub mod service;

pub use error::{Error, Result};
pub use types::*;
pub use service::Service;

Testing

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_feature() {
        // Arrange
        let service = Service::new().await;

        // Act
        let result = service.do_something().await;

        // Assert
        assert!(result.is_ok());
    }
}

Commonware Integration

Key Crates

  • commonware-cryptography: Use for Ed25519 signatures
  • commonware-p2p: Use for peer-to-peer networking
  • commonware-consensus: Use for BFT consensus
  • commonware-storage: Use for persistent storage
  • commonware-codec: Use for serialization

Example: Using Cryptography

use commonware_cryptography::{Ed25519, Signer, Verifier};

pub struct Identity {
    keypair: Ed25519,
}

impl Identity {
    pub fn new() -> Self {
        Self {
            keypair: Ed25519::generate(),
        }
    }

    pub fn sign(&self, message: &[u8]) -> Signature {
        self.keypair.sign(message)
    }
}

Cargo.toml Best Practices

[package]
name = "guts-core"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
license = "MIT OR Apache-2.0"
description = "Core types and traits for Guts"
repository = "https://github.com/AbdelStark/guts"
keywords = ["decentralized", "git", "p2p"]
categories = ["development-tools"]

[dependencies]
# Use workspace dependencies
thiserror = { workspace = true }
tokio = { workspace = true }

[dev-dependencies]
tokio-test = { workspace = true }

[lints.rust]
unsafe_code = "deny"
missing_docs = "warn"

[lints.clippy]
all = "warn"
pedantic = "warn"
nursery = "warn"

Performance Considerations

  1. Use Arc for shared ownership across async tasks
  2. Prefer bytes::Bytes for zero-copy networking
  3. Use dashmap for concurrent hash maps
  4. Profile with flamegraph before optimizing