Skip to main content

add-rust-dependency

Guide for safely adding a new Rust crate dependency in torrust-tracker, starting from the latest stable crates.io version, minimizing features, documenting version rationale, and validating with cargo machete and repository quality gates. Use when introducing a new dependency, selecting a crate version, or justifying why an older version is required.

ソース情報

リポジトリ
torrust/torrust-tracker
ソースの最終更新活動
2026年5月13日 11:13
検出された SKILL.md の言語
英語
スター
536
フォーク
58

インストール方法

デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。

ソースファイルを確認

インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。

SKILL.md を表示中

SKILL.md
ソースの指示 · 読み取り専用プレビュー
name
add-rust-dependency
description
Guide for safely adding a new Rust crate dependency in torrust-tracker, starting from the latest stable crates.io version, minimizing features, documenting version rationale, and validating with cargo machete and repository quality gates. Use when introducing a new dependency, selecting a crate version, or justifying why an older version is required.
metadata
{"author":"torrust","version":"1.0","semantic-links":{"related-artifacts":["AGENTS.md",".github/agents/implementer.agent.md",".github/skills/dev/maintenance/update-dependencies/SKILL.md"]}}
# Adding a Rust Dependency Use this workflow when introducing a new crate to `Cargo.toml`. ## Goal Add only necessary dependencies, prefer the latest stable version, and keep the resulting change reviewable, justified, and maintainable. ## Skill Links - `AGENTS.md` - `.github/agents/implementer.agent.md` - `.github/skills/dev/maintenance/update-dependencies/SKILL.md` ## Workflow ### Step 1: Confirm a new dependency is necessary Before adding a crate, check whether the need can be met by: - the Rust standard library, - an existing workspace dependency, - a small local implementation with lower long-term cost. If one of these options is sufficient, do not add a new crate. ### Step 2: Check the latest stable version first Identify the latest stable crates.io version before choosing a version. ```bash cargo search <crate-name> --limit 1 ``` Start from the latest stable version by default. If you must choose an older version, document the reason in the PR/issue spec and, when useful, in a nearby code comment. ### Step 3: Choose the minimal feature set Prefer `default-features = false` when appropriate and enable only required features. ```toml [dependencies] example-crate = { version = "<latest-stable>", default-features = false, features = ["needed-feature"] } ``` Avoid broad feature enables without a concrete need. ### Step 4: Apply and verify After editing `Cargo.toml`/`Cargo.lock`: ```bash cargo update -p <crate-name> cargo machete ./contrib/dev-tools/git/hooks/pre-commit.sh --format=json ``` If the run fails and more diagnostics are needed, retry with: ```bash ./contrib/dev-tools/git/hooks/pre-commit.sh --format=text --verbosity=verbose ``` If checks fail, resolve issues or revert the dependency addition. ### Step 5: Document rationale In commit/PR/issue notes, record: - why this crate is needed, - why alternatives were not selected, - why a non-latest version is used (if applicable), - any noteworthy feature-flag choices. ## Constraints - Do not introduce a dependency without checking latest stable first. - Do not keep a non-latest version without explicit rationale. - Do not add dependency bloat when existing dependencies already solve the problem. - Do not skip `cargo machete` and pre-commit validation. ## Related Skills - Update existing dependencies: `.github/skills/dev/maintenance/update-dependencies/SKILL.md` - Commit workflow: `.github/skills/dev/git-workflow/commit-changes/SKILL.md`
GitHubで見る