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 언어
영어
스타
533
포크
56

설치 방법

기본적으로 소스를 먼저 확인하는 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에서 보기