| name | format |
| description | Format Rust and Meson code using justfile tasks (just fmt-rs, just fmt-meson). Use when editing .rs or meson files, mentions formatting, code style, rustfmt, cleanup, or before commits/PRs. Ensures consistent code style across the codebase. |
| allowed-tools | Bash(just --list:*), Bash(just fmt-rs:*), Bash(just fmt-rs-check:*), Bash(just fmt-meson:*), Bash(just fmt-meson-check:*) |
Code Formatting Skill
This skill provides code formatting operations for the nx-std monorepo, which is a Rust workspace with Meson build system.
When to Use This Skill
Use this skill when you need to:
- Format code after editing Rust or Meson files
- Check if code meets formatting standards
- Ensure code formatting compliance before commits
Available Commands
Format Rust Code
just fmt-rs
Formats all Rust code using cargo fmt --all. This is the primary formatting command for Rust.
Alias: just fmt (same as fmt-rs)
Check Rust Formatting
just fmt-rs-check
Checks Rust code formatting without making changes using cargo fmt --all -- --check.
Alias: just fmt-check (same as fmt-rs-check)
Format Meson Files
just fmt-meson
Formats all Meson build files (meson.build, meson.options, justfile).
Check Meson Formatting
just fmt-meson-check
Checks Meson file formatting without making changes.
Important Guidelines
MANDATORY: Format After Every Edit
You MUST run formatting immediately after editing ANY Rust or Meson file.
This is a critical requirement from the project's development workflow:
- Never skip formatting after file edits
- Format Rust files with
just fmt-rsafter editing.rsfiles - Format Meson files with
just fmt-mesonafter editingmeson.build,meson.options, orjustfile - Run formatting before any check or test commands
Example Workflow
After editing Rust file:
- Edit a Rust file:
crates/nx-alloc/src/lib.rs - IMMEDIATELY run:
just fmt-rs - Then run checks:
just check-rs
After editing Meson file:
- Edit a Meson file:
subprojects/libnx/meson.build - IMMEDIATELY run:
just fmt-meson - Then run checks:
just configure
Common Mistakes to Avoid
❌ Anti-patterns
- Never run
cargo fmtdirectly - Usejust fmt-rs - Never run
rustfmtdirectly - The justfile includes proper configuration - Never skip formatting - Even "minor" edits need formatting
- Never format after multiple edits - Format after EACH file type edit
- Never commit unformatted code - Always run
just fmt-rs-checkandjust fmt-meson-checkbefore commits
✅ Best Practices
- Format immediately after each edit
- Run
just fmt-rsafter editing Rust files - Run
just fmt-mesonafter editing Meson/justfile files - Run
just fmt-rs-checkandjust fmt-meson-checkto verify formatting before commits - Format before running build, check, or test commands
Formatting Configuration
Rust Formatting
Rust formatting uses:
- Nightly rustfmt (specified in
rust-toolchain.toml) - Configuration in
rustfmt.tomlwith unstable features - Import grouping: std, external crates, local
- Import granularity at crate level
Meson Formatting
Meson formatting:
- Consistent indentation and style
- Applied to
meson.build,meson.options, andjustfile
Next Steps
After formatting your code:
- Check compilation → Run
just check-rsfor Rust - Run clippy → Run
just clippyfor linting - Build targets → See
.claude/skills/build/SKILL.md - Run tests → Run
just build-tests