本文へ移動
cccskills
無料GitHub で公開日本語紹介

style

Rustのコードやドキュメントを編集するときに、モジュール構成、依存関係、文章表現、テスト設計などプロジェクトの規約に沿う方法を示します。

原文原文の説明を見る

Always use this skill before writing or editing Rust code or documentation in the Topcoat repository

tokio-rs/topcoatスター 6,226(GitHub 6,226 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • Rustコードを規約に沿って編集したいとき
  • 利用者向けの説明文を書きたいとき
  • テストの目的を見直したいとき

日本語での紹介

できること

Rustのコードやドキュメントを編集する際に、プロジェクト内でそろえる構成や書き方を案内します。構造体の直後にその実装やトレイト実装を置くこと、テストモジュールをファイル末尾に置くこと、モジュールのファイル名や再エクスポートの扱いなどが含まれます。依存クレートはワークスペースのCargo.tomlで宣言し、利用側で必要な機能を指定する方針も示します。ドキュメントは平易な英語で対象の役割や使い方を説明し、実装の細部や変わりやすい列挙を避けます。テストでは、固定文字列の確認にとどまらず、どの誤動作を検出するかを明確にします。

こんなときに便利

Rustの変更を始める前に、既存プロジェクトの規約を把握したいときに向いています。モジュールの分け方や依存関係の追加方法、利用者向けドキュメントの書き方を確認したい場合にも使えます。

使い方の例

  • 「このRustコードをプロジェクトのスタイルに合わせて整理してください」
  • 「この型のドキュメントを利用者向けに簡潔な英語で書いてください」
  • 「このテストが具体的な誤動作を検出できるか確認してください」

注意点

資料では、RustのコードとドキュメントにASCII文字のみを使うよう定めています。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md2.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Code Style

General

  • Keep related code together: a struct is immediately followed by its inherent impl and then its trait impls, before the next struct in the file. Unit tests (#[cfg(test)] mod tests) go at the very bottom of the file.
  • Free functions are allowed, but first consider whether a more idiomatic Rust grouping onto a struct exists.
  • Unsafe code is not allowed in this project, unless wrapped by a reputable dependency.
  • Avoid needless allocations, it is reasonable to refactor the code a bit to make it faster.

Barrel files

Name a module's file after the module and place it alongside its directory (foo.rs next to foo/), never foo/mod.rs. A barrel file declares all submodules and re-exports each with a glob; only third-party items are re-exported by name.

mod content;
mod error;
mod request;

pub use content::*;
pub use error::*;
pub use request::*;

pub use http::Method;

When a module's submodules are peers that make up a whole (the CLI commands fmt, dev, asset; the macros expr, procedure, shard), put anything shared between them in a common submodule so it does not read as another peer.

Dependencies

  • Declare every dependency in the top-level Cargo.toml under [workspace.dependencies] with only a version and no features. Crates pull it in with workspace = true and opt into features there.

Documentation

  • Write in plain english. No fancy sentence structure.
  • Item docs describe what something is/does and how to use it. Avoid implementation details unless relevant to a caller.
  • Describe the current state only; never reference previous iterations ("this used to be A but is now B").
  • Avoid exhaustively listig specific implementations or uses that could evolve over time and go stale. Keep documentation robust to changes.
  • Avoid mentioning unrelated items, like "this is used by X to do Y". Focus on describing only the item itself.
  • Use only ASCII characters in both code and documentation, e.g. -> instead of unicode arrow or ... instead of ellipsis character.
  • Avoid em-dashes entirely. Use colons and semicolons sparingly.
  • Avoid using ignore for code snippets to keep them type-checked.

Tests

  • Do not write tests that only verify hardcoded values. Make the tests insensitive to the exact wording of strings or error messages.
  • Every test must protect a specific behavior or catch a plausible bug. Before writing it, identify what incorrect behavior would make it fail.
  • Derive expected results from the intended behavior. Do not calculate them by repeating the implementation or calling the same code being tested.
  • Keep tests sensitive to broken behavior and tolerant of implementation changes that preserve correct behavior.
  • If a test is useless, delete it.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

check

無料概要あり

Rustやブラウザー関連の変更を、TopcoatのCIに合わせた書式チェック、Lint、テスト、ドキュメント生成でローカル検証し、コミットやPRの前に問題を見つけます。

  • Rustの変更をコミット前に検証したいとき
  • ブラウザー部分のビルドとテストを確認したいとき
  • CI相当のドキュメント生成を行いたいとき
tokio-rs/topcoat6,2262026年10月25日 更新

commit

無料概要あり

変更内容に合ったConventional Commits形式のコミットメッセージを作り、変更種別に応じたリリースノートやバージョン更新に役立つ履歴を残します。

  • 変更に合うコミットメッセージを作りたいとき
  • コミットの種別やスコープを選びたいとき
  • 破壊的変更と移行方法を記録したいとき
tokio-rs/topcoat6,2262026年10月25日 更新

macro

無料概要あり

Topcoat向けのRust手続きマクロを設計する際に、構文情報を保つAST、解析処理、マクロの入口とコード生成の分担を整理します。

  • 手続きマクロのASTを設計したいとき
  • 入力構文を保ったまま解析したいとき
  • 解析とコード生成の役割を分けたいとき
tokio-rs/topcoat6,2262026年10月25日 更新

pr

無料概要あり

Topcoatのプルリクエストについて、ブランチ全体の差分に基づくタイトルと本文を作り、変更内容や検証方法を簡潔に伝えます。

  • ブランチ全体の差分からPR本文を作りたいとき
  • 変更概要と確認方法を簡潔に伝えたいとき
  • AIエージェントによるPRの説明を添えたいとき
tokio-rs/topcoat6,2262026年10月25日 更新

prose

無料概要あり

TopcoatのMarkdownガイドを、配置場所や構成、平易な英語での書き方に沿って整理し、読みやすく保守しやすいドキュメントにまとめます。

  • Topcoatの利用ガイドを新しく書きたいとき
  • 既存のMarkdown説明を読みやすく整えたいとき
  • 文書の配置場所と参照先を整理したいとき
tokio-rs/topcoat6,2262026年10月25日 更新

tokio-rs のスキルをすべて見る

このスキルの問題を報告する