home / skills / plurigrid / asi / cargo

cargo skill

/skills/cargo

This skill helps you manage Rust projects with cargo by guiding builds, dependencies, publishing, and workspace workflows for faster, error-free development.

npx playbooks add skill plurigrid/asi --skill cargo

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.7 KB
---
name: cargo
description: Rust package manager (36 subcommands).
version: 1.0.0
---


# cargo

Rust package manager (36 subcommands).

## Build

```bash
cargo build --release
cargo check
cargo test
cargo run
cargo bench
```

## Package

```bash
cargo new myproject
cargo init
cargo add serde
cargo remove tokio
```

## Dependencies

```bash
cargo tree
cargo update
cargo fetch
```

## Publish

```bash
cargo publish
cargo search regex
cargo install ripgrep
```

## Workspace

```toml
# Cargo.toml
[workspace]
members = ["crates/*"]

[dependencies]
serde = { version = "1.0", features = ["derive"] }
```

## Fix

```bash
cargo fix --edition
cargo clippy --fix
cargo fmt
```



## Scientific Skill Interleaving

This skill connects to the K-Dense-AI/claude-scientific-skills ecosystem:

### Graph Theory
- **networkx** [○] via bicomodule
  - Universal graph hub

### Bibliography References

- `general`: 734 citations in bib.duckdb



## SDF Interleaving

This skill connects to **Software Design for Flexibility** (Hanson & Sussman, 2021):

### Primary Chapter: 3. Variations on an Arithmetic Theme

**Concepts**: generic arithmetic, coercion, symbolic, numeric

### GF(3) Balanced Triad

```
cargo (+) + SDF.Ch3 (○) + [balancer] (−) = 0
```

**Skill Trit**: 1 (PLUS - generation)


### Connection Pattern

Generic arithmetic crosses type boundaries. This skill handles heterogeneous data.
## Cat# Integration

This skill maps to **Cat# = Comod(P)** as a bicomodule in the equipment structure:

```
Trit: 0 (ERGODIC)
Home: Prof
Poly Op: ⊗
Kan Role: Adj
Color: #26D826
```

### GF(3) Naturality

The skill participates in triads satisfying:
```
(-1) + (0) + (+1) ≡ 0 (mod 3)
```

This ensures compositional coherence in the Cat# equipment structure.

Overview

This skill provides concise, actionable guidance for using cargo, the Rust package manager covering its 36 subcommands and common workflows. It focuses on build/test/publish cycles, dependency management, workspace configuration, and automated fixes. The goal is to help developers run, maintain, and publish Rust projects reliably.

How this skill works

It documents the primary cargo commands and common flags for building, testing, benchmarking, and running crates, plus package creation and dependency inspection. It explains workspace layout and Cargo.toml snippets, dependency graph commands, and commands to publish or install crates. It also covers automated fixes and formatting via cargo fix, clippy, and fmt.

When to use it

  • Start a new Rust project or initialize an existing directory (cargo new, cargo init).
  • Compile, test, or benchmark code during local development (cargo build, cargo test, cargo bench).
  • Inspect and manage dependencies and dependency graphs (cargo tree, cargo update, cargo fetch).
  • Prepare and publish crates to crates.io or install binaries (cargo publish, cargo install).
  • Manage multi-crate repositories and shared dependencies via workspaces (Cargo.toml [workspace]).

Best practices

  • Use cargo check frequently for fast iteration instead of full builds.
  • Commit Cargo.lock for applications, not libraries, to ensure reproducible builds.
  • Use workspaces to centralize dependency versions and reduce rebuilds across crates.
  • Run cargo fmt and cargo clippy --fix as part of CI to keep code style and catch issues early.
  • Inspect dependency trees with cargo tree before updating to avoid unexpected version bumps.

Example use cases

  • Create a new CLI tool, add serde for serialization, build a release binary, and publish to crates.io.
  • Convert a single-repo project into a workspace with multiple crates and shared dev-dependencies.
  • Quickly iterate on code using cargo check and run targeted tests with cargo test -- --nocapture.
  • Audit transitive dependencies and resolve conflicts using cargo tree and cargo update selectively.
  • Automate style and lint fixes in CI with cargo fmt and cargo clippy --fix for consistent code quality.

FAQ

When should I commit Cargo.lock?

Commit Cargo.lock for binaries and application repositories to lock exact dependency versions; libraries should generally not commit it so downstream users can resolve appropriate versions.

How do I share dependencies across multiple crates?

Use a workspace with a top-level Cargo.toml listing members. Put shared dependency versions in each crate’s [dependencies] or centralize common tooling in workspace-level dev-dependencies where appropriate.