一键导入
dependency-management
Dependency Management guidance for Fortress Rollback. Use when Evaluating dependencies, supply chain security, cargo-deny.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Dependency Management guidance for Fortress Rollback. Use when Evaluating dependencies, supply chain security, cargo-deny.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | dependency-management |
| description | Dependency Management guidance for Fortress Rollback. Use when Evaluating dependencies, supply chain security, cargo-deny. |
Every dependency is a liability: compile time, binary size, attack surface, maintenance burden.
Before adding any dependency:
Complex domains (crypto, compression, parsing), battle-tested code (serde, tokio), security-sensitive implementations, expertise gaps.
| Resource | Purpose |
|---|---|
| blessed.rs | Curated recommended crates |
| lib.rs | Better crate discovery |
| RustSec | Security advisories |
cargo tree # Full dependency graph
cargo tree -d # Duplicate dependencies
cargo tree -f "{p} {f}" # Show features per package
cargo tree -i some_crate # Why is this crate included?
cargo tree -e features # Feature graph
cargo +nightly udeps # Unused dependencies
cargo outdated # Newer versions available
# Use semver ranges -- NEVER pin exact versions
serde = "1.0" # Gets 1.0.x patches
tokio = "1" # Gets 1.x.x updates
# AVOID
serde = "=1.0.152" # Locked, misses security fixes
Pre-1.0 crates (0.x.y) can break in minor versions. Prefer 1.0+ when available.
cargo update # Update all compatible
cargo update -p crate_name # Update specific crate
cargo update -p crate_name --precise X # Update to specific version
# Disable unnecessary defaults
tokio = { version = "1", default-features = false, features = ["rt", "net"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
# Audit enabled features
cargo tree -f "{p} {f}"
cargo tree -f "{p} {f}" -i tokio # Why is a feature enabled?
[features]
default = ["std"]
std = ["serde/std", "dep-crate/std"]
serde = ["dep:serde"] # Optional via feature
[dependencies]
serde = { version = "1.0", optional = true }
cargo audit # Check RustSec advisories
cargo audit fix # Auto-fix if possible
cargo deny init # Initialize config
cargo deny check # Run all checks
# deny.toml
[advisories]
vulnerability = "deny"
unmaintained = "warn"
yanked = "warn"
[licenses]
unlicensed = "deny"
allow = ["MIT", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "ISC", "Zlib"]
[bans]
multiple-versions = "warn"
wildcards = "deny"
deny = [
{ name = "openssl" }, # Prefer rustls
{ name = "openssl-sys" },
]
[sources]
unknown-registry = "deny"
unknown-git = "warn"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
| Safe | Caution | Avoid |
|---|---|---|
| MIT, Apache-2.0, BSD, ISC, Zlib | MPL-2.0, LGPL | GPL, AGPL |
cargo geiger # Shows unsafe usage per crate
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo install cargo-audit cargo-deny
- run: cargo audit
- run: cargo deny check
# Root Cargo.toml -- define versions once
[workspace.dependencies]
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
my-core = { path = "crates/my-core" }
# Member Cargo.toml -- inherit
[dependencies]
serde = { workspace = true }
my-core = { workspace = true }
# Can override features while inheriting version
tracing = { workspace = true, features = ["log"] }
Benefits: consistent versions, single update point, cleaner manifests.
# Use for: unreleased fixes, forks with patches, private crates
some-crate = { git = "https://github.com/org/repo", rev = "abc123" }
# Prefer rev= for reproducibility; branch= is not reproducible
# Cannot publish to crates.io with git dependencies
Replace dependencies proactively when: deprecated, unmaintained (1+ year), unpatched vulnerabilities, better alternatives exist, too many transitive deps.
All new dependencies must:
cargo deny checkno_std (or be behind a feature flag)| Purpose | Crate | Notes |
|---|---|---|
| Serialization | serde, bincode | Network protocol, save states |
| Hashing | ahash, xxhash-rust | Deterministic, fast |
| Compression | lz4_flex | Fast, pure Rust |
| Networking | quinn, laminar | QUIC, game UDP |
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule: { interval: "weekly" }
groups:
rust-dependencies:
patterns: ["*"]
update-types: ["minor", "patch"]
open-pull-requests-limit: 10
cargo audit -- no advisoriescargo tree -- reviewed transitivescargo clippy cleancargo deny check passesCrate Publishing guidance for Fortress Rollback. Use when Publishing to crates.io, version bumps, release checklist.
Changelog Practices guidance for Fortress Rollback. Use when Writing CHANGELOG entries, deciding what to document.
Design Decision Log Pattern guidance for Fortress Rollback. Use when Architectural decisions, design alternatives, superseding prior choices.
Repository-wide engineering policy and project context for Fortress Rollback. Use when implementing, diagnosing, reviewing, testing, documenting, or releasing changes in this repository.
GitHub Actions Best Practices guidance for Fortress Rollback. Use when Writing GitHub Actions workflows, CI debugging, actionlint, caching.
Workspace Organization guidance for Fortress Rollback. Use when Organizing workspace, splitting crates, module structure decisions.