rust-lean-refactor
Reorganize Elph Rust code to be lean, clean, and non-bloated: detect oversized files, functions, or modules and split them safely across existing crate/module…
от riipandi★ 34 звезды на GitHub
Установить rust-lean-refactor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Rust Lean Refactor
Language
Split by destination:
- In-chat responses, plans, summaries — follow the language the user is currently using (Indonesian, English, etc). Code, paths, identifiers, crate/lint names stay literal English.
- Any documentation edits written to files (
docs/**, permanent code comments) — always English, regardless of chat language.
Purpose
Make Rust code lean and readable through pure structural refactoring — splitting bloated files/functions/modules, isolating cohesive responsibilities, and deduplicating genuinely identical private logic — while preserving observable behavior, public API, error contracts, feature behavior, and platform behavior. Split is not delete: removing actual dead or legacy code follows a stricter, separate rule.
Relationship to rust-verify-harden: this skill owns structure (what lives where, how big things are); rust-verify-harden owns hardening (memory/deadlock/race/perf, quality gates). Don't duplicate the concurrency/memory audit here — if the user also wants that, run rust-verify-harden after this skill's structure settles, not interleaved with it.
Elph architecture baseline
Confirm the dependency direction before choosing a boundary:
elph (coding-agent app, CLI, TUI)
├── elph-agent (agent orchestration, sessions, tools)
│ └── elph-ai (LLM types, catalogs, provider adapters)
├── elph-tui (reusable iocraft components)
├── floppy (memory/storage)
└── rendown (terminal/Markdown rendering)
elph-ai and elph-agent are publishable libraries. Their crate roots are
preludes; domain APIs remain under documented modules. Do not flatten a module
or make an item public solely to make an integration test compile. Unit tests
for pub(crate) behavior belong beside the implementation.
Scope
- Default scope: the crate(s)/module(s) the user names, or the crate(s) touched by their last few messages. Do not silently expand to the whole workspace unless asked.
- Intra-module split (functions/types moved within the same crate) is the default operating mode — low risk, no
Cargo.tomlchanges. - Cross-crate split (moving code so it now lives in a different crate,
e.g.
elph-agent→elph-ai) is a bigger change: it touchesCargo.toml, may create new public surface, changes publish packaging, and risks a crate-level circular dependency. Flag it explicitly, propose the dependency/API diff, and get a go-ahead before executing.
Safety Rules
- No behavior change. Pure structural refactor: move, split, rename, dedupe, reorder. If a "clean" idea changes logic, output, or a public API contract, flag it separately instead of doing it here.
- Use repository wrappers for gates:
make fmt,make check,make lint, andmake test. Forward package selectors after--(for examplemake check -- -p elph-agent). UseSCCACHE_DISABLE=1only when the cache is unavailable and record it in the final report. - No new circular mod dependencies. After each split, confirm the new module graph is still acyclic — see Phase 4.3.
- Codegen/generated files are out of scope. Skip anything under a
generated/,*.gen.rs,build.rs-producedOUT_DIRoutput,bindings.rs,vendor/iocraft/,crates/elph-ai/models/**/*.json,schemas/, or files carrying a generated header. Use the owning generator ormake generate-modelsinstead of editing generated output. - Small, verifiable increments — one bloated unit at a time, re-verify before the next.
- Legacy/back-compat code is out of scope for silent deletion —
#[deprecated],_v1/_old/_legacysuffixes, compat shims, retired#[cfg(feature = ...)]paths. Splitting these out into their own module is fine; deleting them needs the same ask-before-remove checkpoint asrust-verify-hardenPhase 4. - Respect existing module conventions — mirror how the crate already organizes
mod.rs/file-per-module/pub(crate)boundaries rather than importing a generic style. - No unprompted new deps/tools. Use what's already available (
clippy,tokei,cargo-modules,rg,ast-grep). If a tool is absent, fall back towc -l,rg,cargo metadata, and manual inspection rather than installing it. - Do not destroy parallel work. Never use
git reset --hardor broadgit checkout --rollback commands. Preserve unrelated edits and ask when file ownership is unclear. - Git is opt-in: do not commit or push unless explicitly instructed.
- Cross-platform is part of behavior: inspect
#[cfg]branches and target-specific dependencies; do not move Unix-only helpers into code that must compile on Windows.
Workflow
Phase 1 — Baseline
- Confirm scope (crate/module) with the user's request; don't assume workspace-wide unless stated.
git status --shortandgit diff --stat; identify external or unrelated edits before planning.- Run baseline gates through
make
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл rust-lean-refactor?
Reorganize Elph Rust code to be lean, clean, and non-bloated: detect oversized files, functions, or modules and split them safely across existing crate/module boundaries without changing behavior. Guards against new circular dependencies, public API drift, feature/target regressions, and generated-file churn, then verifies the repository's make check/lint/test gates. Use when user asks to clean up, declutter, slim down, de-bloat, restructure, or split up Rust code, or complains a file/module/function is "gemuk"/too big/doing too much. Pair with rust-verify-harden for the hardening pass after structure is settled.
Как установить скилл rust-lean-refactor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rust-lean-refactor запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…