Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
381 changes: 381 additions & 0 deletions .agents/skills/ub-rust/SKILL.md

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .agents/skills/ub-rust/assets/lints-template/Cargo-lints.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# UB Rust starter lint profile.
# Merge material for Cargo.toml; not a standalone config file.
#
# Workspaces: put these tables under [workspace.lints.rust] and
# [workspace.lints.clippy] in the root manifest, then add
# `[lints] workspace = true` to each member crate.
# Single crates: use them as [lints.rust] and [lints.clippy] directly.
#
# Starter only: adapt levels to repo truth before enforcing in CI.

[lints.rust]
# Keep idiom migration lints visible; priority -1 lets specific
# lints below override members of this group.
rust-2018-idioms = { level = "warn", priority = -1 }
unreachable_pub = "warn"
unused_must_use = "warn"

[lints.clippy]
# Baseline correctness/style/complexity/perf groups at warn; specific
# lints below override members of the groups.
all = { level = "warn", priority = -1 }
# High-signal additions beyond the default groups.
dbg_macro = "warn"
todo = "warn"
unimplemented = "warn"
# Production-path discipline; relax in tests with scoped, justified
# expect/allow attributes instead of removing the lint.
unwrap_used = "warn"
70 changes: 70 additions & 0 deletions .agents/skills/ub-rust/references/cargo-lints-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Cargo Lint Policy Resolution

Use this reference when deciding what lint policy actually applies in a target
repository and whether the bundled lint-table starter should be adopted.

## Resolution Order

1. `[workspace.lints]` in the workspace root `Cargo.toml`, inherited by
member crates that declare `[lints] workspace = true`, is the broadest
policy surface.
2. A per-crate `[lints]` table overrides nothing silently: a crate either
inherits the workspace table or defines its own.
3. `clippy.toml` configures individual clippy lint behavior (thresholds,
allowed names) but does not set lint levels.
4. `rustfmt.toml` (or `.rustfmt.toml`) owns formatting; it is separate from
lint policy.
5. CI flags (for example `cargo clippy -- -D warnings`) and environment
`RUSTFLAGS` can tighten enforcement beyond the manifest tables; check CI
before declaring the real gate.

Treat the combination of manifest tables plus CI flags as the repository's
real lint policy. Do not present the bundled starter as active policy when
any explicit policy already exists.

## Toolchain Floor Awareness

- The manifest `[lints]` table requires a toolchain generation that supports
it; verify the repo's minimum supported Rust version before recommending
it.
- For repos below that floor, keep lint levels in CI flags and recommend the
manifest table as part of the upgrade path.

## What Counts As Real Policy

1. the discovered `[lints]`/`[workspace.lints]` tables and their levels
2. `clippy.toml` settings
3. CI lint invocations and deny levels
4. inline lint-expectation or narrowly scoped allow attributes with reasons,
as bounded local exceptions

## Starter Adoption (Reviewed Edit, Not A Script)

The starter lives at `assets/lints-template/Cargo-lints.toml`. Its merge
target (`Cargo.toml`) always already exists, so this skill intentionally
ships no scaffolding script: adoption must stay a deliberate, reviewed edit.

Adopt it only when:

1. no explicit lint policy exists in manifests, `clippy.toml`, or CI, and
2. the adopting repository wants this catalog's starter baseline

Adoption steps:

1. for workspaces, place the table contents under `[workspace.lints]` in the
root manifest and add `[lints] workspace = true` to member crates
2. for single crates, place the contents under `[lints]` in `Cargo.toml`
3. show the resulting diff to the user before finalizing
4. run the repo's clippy command and review new findings together instead of
silencing them wholesale

## Adaptation Points After Adoption

1. tune lint levels to repo noise tolerance; promote to `deny` only where the
team agrees
2. relax test-only ergonomics (for example unwrap-style lints) with scoped,
justified attributes rather than global allows
3. wire the clippy command into the repo's task runner or CI so the policy is
actually enforced
4. document the lint policy decision where the repo keeps its engineering
conventions
102 changes: 102 additions & 0 deletions .agents/skills/ub-rust/references/repository-rust-workflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Repository Rust Workflows

Use this reference to resolve a repository's actual Rust toolchain, workspace,
and validation truth before recommending commands or tooling.

It should help the agent inspect local reality, not hardcode one repository's
workflow into a distributable skill.

## Toolchain and Workspace Baseline

Inspect the target repository for:

1. `edition` and `rust-version` in `Cargo.toml`, plus `rust-toolchain.toml`
channel pinning
2. workspace layout: single crate, virtual workspace, member globs, and
workspace-inherited dependencies or lints
3. whether the repo is an application, a library, a CLI tool, an FFI crate,
or a mixed workspace
4. the active lint policy: `[lints]`/`[workspace.lints]` tables,
`clippy.toml`, `rustfmt.toml`, and CI lint flags
5. feature flags and cfg matrices that change what compiles
6. `build.rs` scripts, code generation, and vendored or patched dependencies
7. `.cargo/config.toml` for aliases, target settings, and registry
configuration

## Enforced Validation Baseline

Treat the repository's wired checks as the real baseline.
Inspect task runners, Makefiles, CI, and pre-commit hooks for the actual
Rust-oriented gates.

Common examples:

1. `cargo fmt --check`
2. `cargo clippy` with explicit deny/warn levels
3. targeted or full `cargo test` commands, including doc tests
4. `cargo deny check` or `cargo audit` supply-chain runs
5. build matrix checks across targets, features, or toolchain versions
6. MSRV verification jobs

## Not Yet Repository-Wired

Recommend extra tools only as explicit gaps when they are not already wired
into the repository.

Typical examples:

1. clippy in CI
2. an explicit `[lints]` policy
3. cargo-deny or cargo-audit
4. Miri for unsafe-heavy crates

When advising users inside any repository:

1. treat the detected edition and `rust-version` as the shipping constraint
even when official docs describe newer features
2. recommend missing tools as improvements, not as if they were already part
of the enforced baseline
3. keep guidance consistent with the repo's actual workload instead of
assuming a service-backend shape
4. do not recommend syntax or standard library APIs above the crate's floor
as if they were currently shippable

## Practical Command Patterns

Use the command shape that matches the target repository's tooling.

Recommended resolution order:

1. a repo wrapper such as `task`, `make`, `just`, or a documented cargo alias
2. direct cargo commands scoped to touched crates first
(`cargo check -p <crate>`, `cargo test -p <crate>`)
3. lint and audit commands (`cargo clippy`, `cargo deny check`) only after
confirming they are installed or wired locally

Scoping guidance:

1. prefer `cargo check` for fast iteration before full builds
2. run doc tests when public API docs changed
3. run the full workspace only when failures indicate cross-crate impact
4. respect feature matrices: test with the feature set CI actually uses

## Starter Lint Policy

This skill ships a reusable lint-table starter:

1. `assets/lints-template/Cargo-lints.toml`

It is merge material for `Cargo.toml`, applied as a reviewed edit. Use it only
when a target repository wants this lint baseline and has no explicit lint
policy yet. See `references/cargo-lints-resolution.md` for adoption steps.

## Packaging and Release Guidance

Because adopting repositories range from libraries to services to CLI tools:

1. keep binary crates thin; put logic in library crates so it stays testable
2. use workspace dependency inheritance to keep versions consistent
3. for published crates, keep `rust-version` accurate and document the MSRV
policy
4. align generated Rust with the active lint policy, including clippy levels
and rustfmt configuration
Loading