Agent skill
refactoring
Stars
126
Forks
16
Install this agent skill to your Project
npx add-skill https://github.com/BA-CalderonMorales/terminal-jarvis/tree/main/.github/skills/refactoring
SKILL.md
Skill: Code Refactoring
Name: refactoring Description: Domain-based module extraction and code organization Trigger: "Refactor this file", large files (>200 lines), code organization
Objective
Break large files (>200 lines) into focused domain modules.
Domain-Based Folder Structure
src/
large_module/
mod.rs # Public interface, re-exports
domain_a.rs # First domain (focused responsibility)
domain_b.rs # Second domain (focused responsibility)
domain_c.rs # Third domain (focused responsibility)
Refactoring Workflow
- Identify domains - Group related functions/structs by responsibility
- Create new files - One file per domain
- Move code - Cut from old file, paste into new domain files
- Update mod.rs - Add
mod domain_a;andpub use domain_a::*; - Fix imports - Update
usestatements across codebase - Validate -
cargo checkafter each domain extraction - Quality gates - clippy, fmt, tests
Example: cli_logic.rs Refactoring
Before: 1,358 lines in cli_logic.rs
After: 10 focused modules
cli_logic/mod.rs- Public interface (50 lines)cli_logic/cli_logic_entry_point.rs- Main coordination (150 lines)cli_logic/cli_logic_interactive.rs- Interactive interface (200 lines)cli_logic/cli_logic_tool_execution.rs- Tool execution (120 lines)cli_logic/cli_logic_update_operations.rs- Update logic (130 lines)cli_logic/cli_logic_info_operations.rs- Info display (90 lines)cli_logic/cli_logic_list_operations.rs- List operations (80 lines)
Benefits
- Each file has single, clear responsibility
- Easy to navigate and understand
- Easier to test in isolation
- Reduced merge conflicts
- Better code organization
Validation After Each Step
bash
cargo check # Must compile
cargo clippy -- -D warnings # No warnings
cargo fmt --all # Properly formatted
cargo test # Tests pass
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
versioning
126
16
Explore
release
126
16
Explore
multi-repo
126
16
Explore
tool-config
126
16
Explore
testing
126
16
Explore
token-budget
126
16
Explore
Didn't find tool you were looking for?