← スキル一覧に戻る

rust-refactor-verify
by pplmx
⭐ 1🍴 0📅 2026年1月24日
SKILL.md
name: rust-refactor-verify description: Expert workflow for refactoring large Rust codebases, modularizing monolithic files, and establishing a robust quality gate using Clippy, formatting, and a comprehensive test suite (unit + integration). Use when Claude needs to: (1) Split large .rs files into modules, (2) Fix multiple Clippy warnings systematically, (3) Set up integration tests, or (4) Configure Git hooks (Husky) for quality enforcement.
Rust Refactor & Verify Skill
This skill provides a systematic workflow for improving Rust codebase quality and maintainability.
Core Workflows
1. Systematic Modularization
When a file (like app.rs or main.rs) exceeds 500+ lines, it should be split:
- Identify Logical Boundaries: Group fields and methods into functional areas (e.g.,
state,ui,input,logic). - Create Module Directory:
mkdir src/<module_name>. - Split Files:
state.rs: Struct definition andnew()implementation.logic.rs/input.rs: Action handlers and update logic.render.rs: UI-specific code.mod.rs: Re-export common types and implement high-levelrunloop.
- Fix Imports: Update
crate::...paths and ensurepubvisibility where needed. - Verify: Run
cargo checkfrequently during the split.
2. The Quality Gate (Clippy & Fmt)
Always run the full quality suite before committing:
cargo fmt --all && cargo clippy --all-targets --all-features -- -D warnings
- systematic_fix: Don't just fix one warning. Look for patterns (e.g.,
manual_flattenacross the whole repo). - idiomatic_rust: Prefer
.clamp(),.map_while(), andimpl Defaultwhere Clippy suggests.
3. Testing Strategy
- Unit Tests: Place in the same file within a
mod testsblock. Focus on internal logic. - Integration Tests: Place in
tests/*.rs. Focus on public API and component interaction.- Crucial: Always check for required environment setup (like log directories) in tests.
4. Git Hooks (Husky)
Enforce quality via .husky/hooks/:
- pre-commit:
cargo test+cargo fmt --check+cargo clippy. - commit-msg: Enforce Conventional Commits (
feat:,fix:,refactor:, etc.).
Best Practices
- Atomic Changes: One refactor unit per commit.
- Regression Testing: Run the full test suite after every module split.
- Avoid
as anyor@ts-ignorestyle hacks: Use proper Rust type safety (traits, enums).
5. Efficient Exploration
- Search: Prefer
rg(ripgrep) overgrep. - Find: Prefer
fd(orfdfind) overfind. - Platform Agnostic: Use standard bash-compatible flags and avoid PowerShell-specific syntax to ensure consistency across environments.
スコア
総合スコア
60/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です