vibe-style
Rust style checker with syntax and semantic analysis, plus a safe auto-fixer for deterministic, rule-driven code layout.
Overview
vibe-style enforces a strict Rust style contract with stable rule IDs (RUST-STYLE-*).
It supports:
curate: check and report violations.tune: apply safe automatic fixes, then re-check.coverage: print implemented rule IDs.
The checker implementation is the source of truth for parser- and AST-level edge cases.
Installation
Methods are listed from easiest to most advanced.
Install prebuilt binaries (curl)
Unix (Linux/macOS)
VERSION=""
OS=""
ARCH=""
ASSET="vibe-style--.tgz"
INSTALL_DIR="/.cargo/bin"
Windows (PowerShell)
$Repo = "hack-ink/vibe-style"
$Version = (Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest").tag_name
$Target = "x86_64-pc-windows-msvc"
$Asset = "vibe-style-$Target-$Version.zip"
Invoke-WebRequest -Uri "https://github.com/$Repo/releases/download/$Version/$Asset" -OutFile $Asset
Expand-Archive -Path $Asset -DestinationPath .
$InstallDir = "$env:USERPROFILE\.cargo\bin"
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Copy-Item "vibe-style-$Target-$Version\vstyle.exe" "$InstallDir\vstyle.exe" -Force
Copy-Item "vibe-style-$Target-$Version\cargo-vstyle.exe" "$InstallDir\cargo-vstyle.exe" -Force
setx PATH "$env:PATH;$InstallDir"
Open a new terminal after running setx.
Supported prebuilt targets:
x86_64-unknown-linux-gnuaarch64-apple-darwinx86_64-pc-windows-msvc
Install from crates.io (requires Rust/Cargo)
# Install both binaries (`vstyle` and `cargo-vstyle`).
After installation, you can use both vstyle ... and cargo vstyle ....
Install prebuilt binaries (cargo-binstall, requires Rust/Cargo)
# Optional: install cargo-binstall once.
# Then install prebuilt binaries for this crate.
Build from source
Binaries:
target/release/vstyletarget/release/cargo-vstyle
Install as a cargo subcommand (local source)
After installation, you can run cargo vstyle ....
Usage
Basic commands
# Check style.
# Apply safe fixes, then re-check.
# Same as tune, but fail if violations remain.
# Print implemented rule IDs.
Cargo-like target selection
# Workspace-wide.
# Selected packages.
# Feature flags.
Exit behavior
curate- Exit
0: no violations. - Exit
1: violations found.
- Exit
tune- Exit
0: even if unresolved violations remain. - Exit
1: unresolved violations remain and--strictis used.
- Exit
By default, curate and tune follow cargo default package selection and scan git-tracked *.rs
files inside that package scope.
Configuration
There is currently no user configuration file. Rules are built into the checker.
Rule Catalog
File structure
RUST-STYLE-FILE-001: Do not usemod.rs; use flat module files.
Module layout
RUST-STYLE-MOD-001: Keep top-level item order asmod,use,macro_rules!,type,const,static,trait,enum,struct,impl,fn.RUST-STYLE-MOD-002: Placepubitems before non-pubitems within the same kind. Visibility boundaries define separate batches and must be separated by exactly one blank line.RUST-STYLE-MOD-003: Place non-asyncfunctions beforeasyncfunctions at the same visibility.RUST-STYLE-MOD-005: Keep each type adjacent to relatedimplblocks, with no blank line between the type and its firstimpl.
Serde
RUST-STYLE-SERDE-001: Do not use#[serde(default)]onOption<T>fields.
Imports and paths
RUST-STYLE-IMPORT-001: Group imports in this order: standard library, third-party, self/workspace/local-module roots.RUST-STYLE-IMPORT-002: Use exactly one blank line between groups; do not use import-group header comments; normalizeuse a::{b, b::c}touse a::{b::{self, c}}.RUST-STYLE-IMPORT-003: Do not alias imports, exceptas _keep-alive imports. Trait imports used only for method resolution must useas _.RUST-STYLE-IMPORT-004: Do not import free functions or macros into scope; use qualified paths. If imported symbols are ambiguous, use fully qualified paths.RUST-STYLE-IMPORT-005: Inerror.rs, do not adduseimports.RUST-STYLE-IMPORT-008: For non-function, non-macro symbols in type paths, prefer unqualified usage withuseimports when unambiguous; keep fully qualified paths when ambiguous.RUST-STYLE-IMPORT-009: If a symbol is both imported and also used via other qualified type paths, stop importing that symbol and use fully qualified paths consistently.RUST-STYLE-IMPORT-007: Do not use glob imports (use ...::*or equivalent). Use explicit imports only.RUST-STYLE-IMPORT-010: Do not usesuperimports; rewrite to crate-absolute imports (use crate::...) when module depth allows it.
Types and generics
RUST-STYLE-IMPL-001: UseSelfinstead of concrete type names inimplmethod signatures.RUST-STYLE-IMPL-003: Keepimplblocks contiguous and ordered as inherent, standard-library traits, third-party traits, then workspace-member traits.RUST-STYLE-GENERICS-001: Move trait bounds towhere; do not use inline bounds.
Logging and runtime safety
RUST-STYLE-LOG-002: Use structured logging fields and complete-sentence log messages.RUST-STYLE-RUNTIME-001: Do not useunwrap()in non-test code.RUST-STYLE-RUNTIME-002:expect()must use a clear, user-actionable string literal message.
Numeric literals
RUST-STYLE-NUM-001: Separate numeric literal suffixes with an underscore (for example,10_f32).RUST-STYLE-NUM-002: Use underscore grouping for integers with more than three digits.
Readability and spacing
RUST-STYLE-READ-002: Keep functions at or under 120 lines.RUST-STYLE-SPACE-003: Do not insert blank lines within the same statement type. Use exactly one blank line between different statement types. Keep constant declaration groups compact only within the same visibility batch.RUST-STYLE-SPACE-004: Insert exactly one blank line before eachreturnand before final tail expressions unless the body is a single expression.
Tests
RUST-STYLE-TEST-001: Use descriptivesnake_casetest names.RUST-STYLE-TEST-002: Reserve#[cfg(test)] mod _testfor keep-alive imports only.
Development
This repository uses cargo make tasks from Makefile.toml.
# Format.
# Lint (clippy + vibe-style).
# Rust-only clippy.
# vibe-style only.
# Rust tests.
# Full checks.
License
Licensed under GPL-3.0.