agentleFS
saizulsaizul/rust-dev-skills/skills/rust-crates-publish/SKILL.md

rust-crates-publish

Skill0 starsChanged 3 days agoMITView on GitHub

Release and publish Rust crates to crates.io safely - required and recommended Cargo.toml metadata, SemVer and breaking-change checks with cargo-semver-checks, CHANGELOG and git tags, cargo package --list and publish --dry-run, publishing workspace crates in dependency order, crates.io trusted publishing or scoped tokens from CI, yanking, and release-plz or cargo-release automation. Includes an offline pre-flight script that checks description and license, keywords and categories against crates.io limits, SemVer version, path, git and wildcard dependencies that crates.io rejects, estimated package size against the 10 MB limit, the CHANGELOG entry and the release tag. Use when the user wants to publish a crate, cut a release, bump a version, check for breaking changes, fix "cargo publish" errors, or automate releases.

  • Reads credentials
  • Installs packages
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If it reports breaking changes, the version must be a major bump (or minor for 0.x).

    line 47
  2. Very specific:

    Stop if --list shows anything private.

    line 57
  3. Distinctive:

    Prefer that the user runs it, or that CI does via trusted publishing.

    line 59
  4. Very specific:

    After publishing: check the crates.io page and the docs.rs build, create the GitHub release from the changelog section.

    line 67

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Publishing to crates.io

Goal: a release that builds for users exactly as tested, with correct metadata, a SemVer-correct version, a changelog entry and a matching tag. Publishing is permanent (versions can be yanked, never deleted or overwritten), so every step before cargo publish is a dry run.

Paths below are relative to this skill's folder (in Claude Code: ${CLAUDE_SKILL_DIR}).

When to use

  • "Publish this crate", "release 0.3.0", "what version should this be?"
  • cargo publish errors: missing description/license, path or git dependencies, "all dependencies must have a version requirement specified", package too large
  • Releasing several workspace crates, automating releases from CI

When not to use

  • Dependency hygiene before a release: rust-dependency-audit (run it first)
  • CI for tests and lints: rust-lint-ci
  • Workspace layout and inheritance: rust-workspace-setup

Workflow

  1. Pre-flight (read-only, offline), per crate to publish:
    python3 scripts/publish_check.py crates/mycrate
    python3 scripts/publish_check.py crates/mycrate --tag v0.3.0 --json
    Fix every high and medium finding; field reference in references/release.md.
  2. Pick the version with SemVer rules for Rust (0.x: minor = breaking), then check:
    cargo install --locked cargo-semver-checks   # ask before installing
    cargo semver-checks check-release -p mycrate
    If it reports breaking changes, the version must be a major bump (or minor for 0.x). Breaking-change table in references/release.md.
  3. Update version, the CHANGELOG section (date, Added/Changed/Fixed/Removed) and README examples. Show the diff to the user.
  4. Build exactly what will be uploaded:
    cargo package --list -p mycrate        # files in the .crate; look for test data, secrets, .env
    cargo publish --dry-run -p mycrate     # builds the packaged crate from a clean copy
    cargo test --workspace --all-features && cargo doc --no-deps -p mycrate
    Stop if --list shows anything private.
  5. Publish only with explicit confirmation from the user, naming crate and version. Prefer that the user runs it, or that CI does via trusted publishing. Never ask for, print or store a crates.io token.
    cargo publish -p mycrate               # user runs this, or CI on tag push
    git tag v0.3.0 && git push origin v0.3.0
    Workspaces: publish in dependency order (leaf crates first); recent cargo can publish several packages at once (cargo publish --workspace), check your version.
  6. After publishing: check the crates.io page and the docs.rs build, create the GitHub release from the changelog section. If the release is broken, publish a fix and cargo yank --version 0.3.0 mycrate (yank stops new lockfiles from picking it; it does not delete anything).

Automation options

ToolWhat it does
release-plzopens a release PR with version bumps + changelog from conventional commits, publishes on merge
cargo-releaselocal cargo release minor --execute: bump, commit, tag, publish, push
plain CItag push -> workflow runs tests, cargo publish with trusted publishing

Workflow sketches and the trusted-publishing setup are in references/release.md.

Output

publish_check tiny-slug 1.2.0: READY (1 info)
semver-checks: no breaking changes since 1.1.0 -> minor bump is correct
cargo package --list: 9 files, 14 KiB; cargo publish --dry-run: ok
Next (needs your confirmation): cargo publish -p tiny-slug && git tag v1.2.0 && git push origin v1.2.0

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.