Code Formatting Skill
This skill provides code formatting operations for the tools workspace (cargo-nx + netloader).
When to Use This Skill
Use this skill when you need to:
- Format code after editing Rust files
- Check if code meets formatting standards
- Ensure code formatting compliance before commits
Command Selection Rules
This is a small 2-crate workspace. Always use the global format command:
| Scope | Command | Rationale |
|---|---|---|
| Any edit | just fmt |
Workspace is small; global format is always fast |
Available Commands
Format Rust Code
just fmt
Formats all Rust code using cargo +nightly fmt --all. Nightly is required because rustfmt.toml uses unstable features (imports_granularity, group_imports).
Check Rust Formatting
just fmt-check
Checks Rust code formatting without making changes using cargo +nightly fmt --all -- --check.
Important Guidelines
Format Before Checks/Commit
Format code when you finish a coherent chunk of work and before running checks or committing.
This is a critical requirement from the project's development workflow:
- Do not skip formatting before checks/commit
- Run formatting before any check or test commands
Example Workflow
- Edit Rust files
- When ready to validate, run:
just fmt - Then run checks (use
/code-checkskill)
Common Mistakes to Avoid
Anti-patterns
- Never run
cargo fmtdirectly - Usejust fmt(ensures nightly toolchain) - Never run
rustfmtdirectly - The justfile includes proper flags - Never skip formatting before checks/commit - Even "minor" edits need formatting
Best Practices
- Format before running checks/tests or before committing
- Run
just fmt-checkto verify formatting before commits
Pre-approved Commands
These commands can run without user permission:
just fmt- Safe formatting operationjust fmt-check- Safe, read-only format check
Next Steps
After formatting your code:
- Check compilation - Use
/code-checkskill - Run clippy - Use
/code-checkskill - Run tests when warranted - Use
/code-testskill
Converted and distributed by TomeVault — claim your Tome and manage your conversions.