notque/vexjoy-agent / skills/programming/programming
programming
FlaggedLanguage rules, workflows, and tooling: Go, Python, Rust, Kotlin, Swift, PHP, TypeScript type checks and debugging, OpenStack Python, MCP local-docs servers, Node.js backend APIs.
references/rust-general/rust-verification-workflow.md
View on GitHub# Rust Verification Workflow
Toolkit-specific verification: rust-analyzer ordering, crate-source checks, rebuilt-binary and render-time verification, dead-code analysis. Load for any Rust edit, review, or cleanup task.
## rust-analyzer Tool Order
Available when rust-analyzer is configured in the editor or via LSP.
| Tool | When (mandatory ordering) |
|------|---------------------------|
| Confirm compilation baseline | First action of every Rust session: run `cargo check --workspace` |
| Check crate metadata | After reading `Cargo.toml`: note `edition`, `rust-version`, workspace members |
| go-to-definition / find-references | Before modifying any public item |
| `cargo check` | After every code edit; surfaces type errors before the full test suite |
| `cargo clippy --workspace --all-targets -- -D warnings` | After `cargo check` passes; re-run after applying fixes |
| `cargo test --workspace` | After clippy passes; paste full output |
| `cargo +nightly udeps --workspace` | During cleanup or refactoring tasks to find unused dependencies (requires nightly; use `cargo machete` as the stable alternative) |
Fallback without rust-analyzer: `Grep` for symbols, `cargo check` / `cargo clippy` / `cargo test` for diagnostics. rust-analyzer understands types and trait bounds where grep sees text — check references before renaming any public item.
## Verify the Crate, Not the Protocol
**What it looks like**: "sqlx will automatically roll back the transaction if you drop it, so this is safe."
**Why wrong**: Protocol-level behavior and crate-level behavior are not the same. LLMs reason from training data about protocols, not from reading the specific crate version in `Cargo.lock`.
**Do instead**: Read the crate source in `~/.cargo/registry/src/`. The question is not "how does PostgreSQL work?" but "how does THIS `sqlx` version implement `Transaction::drop`?"
```bash
# Find the crate source path
ls ~/.cargo/registry/src/
# Read a specific file
cat ~/.cargo/registry/src/index.crates.io-*/sqlx-core-0.8.*/src/transaction.rs
```
## Rebuilt Binary Check
When testing a fix to a CLI binary, confirm the binary you're running matches the fix. Check the modification time of `target/debug/<bin>` vs the fix time:
```bash
# macOS
stat -f "%m %Sm" target/debug/my-binary
# Linux
stat -c "%Y %n" target/debug/my-binary
# Or compare version output against what's in Cargo.toml
./target/debug/my-binary --version
grep '^version' Cargo.toml
```
A stale binary silently passes tests against the old (broken) code path.
## Render-Time Fixes Need Render-Time Verification
Bugs that manifest at output-render time (table layout, tracing output, template expansion) slip past compile + `cargo test`. Build a small standalone reproducer under `/tmp` with realistic fake data, run it, and compare before/after output.
```bash
cd /tmp
cargo new reproducer --edition 2024
cd reproducer
# Add the workspace crate as a path dependency in Cargo.toml:
# [dependencies]
# my-crate = { path = "/path/to/workspace/my-crate" }
cargo run
```
Use a path dependency to the workspace crate rather than copying source.
## Pre-Handoff Command Sequence
Run in this order on every Rust change; each must be clean before you report done. Paste the real output.
```bash
cargo fmt --check # exit 0 = formatted; fix with cargo fmt
cargo check --workspace # exit 0 = compiles
cargo clippy --workspace --all-targets -- -D warnings # exit 0 = no warnings; fix each one
cargo test --workspace # paste full output
```
Optional: add `--release` to `cargo clippy` and `cargo test` to catch optimisation-dependent issues.
A `cargo audit` run is recommended when `Cargo.lock` changes:
```bash
cargo install cargo-audit # one-time
cargo audit
```
## Dead Code and Unused Dependency Analysis
`cargo-udeps` finds crates listed in `Cargo.toml` that are never `use`d in the final build. Run during cleanup, review, or refactoring tasks; skip when the question is only "does this build and pass tests?"
```bash
# Requires nightly for the unstable flag
cargo +nightly udeps --workspace
# For stable toolchain, use cargo-machete (no nightly needed):
cargo install cargo-machete
cargo machete
```
Known false positives:
| Finding | Cause | Fix |
|---------|-------|-----|
| Dev-dependency flagged | Used only in `#[test]` or `tests/` | Add to `[dev-dependencies]`, not `[dependencies]` |
| Feature-gated crate flagged | Crate only activated via a feature flag | Check `Cargo.toml` for `optional = true` and `#[cfg(feature = "...")]` in source |
| Proc-macro crate flagged | `cargo-udeps` cannot always track proc-macro usage | Verify manually: remove and see if the build still passes |
For dead code analysis at the function level, add `#[allow(dead_code)]` to intentionally unused items with a comment explaining why; do not suppress the warning globally.
```bash
# Find dead code that the compiler warns about
cargo check --workspace 2>&1 | grep "warning: .* is never used"
# More thorough: unused public items in library crates
cargo clippy --workspace -- -W clippy::unused_self -W clippy::unused_async
```
**Tooling decision**: rust-analyzer + `cargo check` + `grep` cover all Rust use cases for reference lookup, impact analysis, and code review. `cargo-udeps` / `cargo machete` add dependency hygiene on top. For call graph analysis before large refactors, use rust-analyzer's find-references rather than a static call graph tool — it handles trait dispatch and generics correctly.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 469k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 197k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |