npx claudepluginhub aiiware/aii-skillsThis skill is limited to using the following tools:
Refactor the specified code to improve its structure, readability, or performance while preserving existing behavior.
$ARGUMENTS should specify the target (file path, function name, or directory) and optionally the refactoring goal. Examples:
src/utils.ts — General cleanupsrc/auth.ts extract-function — Extract reusable functionssrc/api/ simplify — Simplify API layersrc/parser.ts rename — Improve naming throughoutBefore making changes, clearly state:
Apply transformations incrementally:
Detect and run the project's test command:
| Language | Test Commands |
|---|---|
| TypeScript/JavaScript | npm test, npx vitest, npx jest, bun test |
| Python | pytest, python -m unittest |
| Go | go test ./... |
| Rust | cargo test |
| Java | mvn test, gradle test |
| C# | dotnet test |
| C/C++ | ctest, make test |
| Ruby | bundle exec rspec, rake test |
| PHP | ./vendor/bin/phpunit, ./vendor/bin/pest |
| Swift | swift test |
| Elixir | mix test |
| Dart | dart test, flutter test |
| Language | Common Refactorings |
|---|---|
| TypeScript/JS | Replace callbacks with async/await; use optional chaining (?.); replace any with proper types |
| Python | Replace loops with comprehensions; use dataclasses/NamedTuple; replace **kwargs with typed params |
| Go | Replace error string checks with sentinel errors; use interfaces for testability; replace mutex with channels where appropriate |
| Rust | Replace unwrap() with proper error handling (?); use impl Trait over generics when possible; replace clone() with borrows |
| Java/Kotlin | Replace anonymous classes with lambdas; use sealed classes; use records/data classes for DTOs |
| C/C++ | Replace raw pointers with smart pointers; use RAII patterns; replace macros with constexpr/templates |
| C# | Replace event handlers with delegates; use pattern matching; use using for disposables |
| Swift | Replace force unwraps (!) with optional binding; use value types (struct) over reference types where appropriate |
| Ruby | Replace conditionals with guard clauses; use &. (safe navigation); extract service objects from fat models |
| PHP | Replace arrays with typed DTOs; use constructor promotion; replace static calls with dependency injection |
When presenting refactoring changes, show the transformation clearly:
BEFORE AFTER
───────────────────── ─────────────────────
function process(data) { function process(data) {
if (data) { if (!data) return null;
if (data.valid) { if (!data.valid) return error;
// ... 50 lines return doWork(data);
} else { }
return error;
} function doWork(data) {
} else { // ... focused logic
return null; }
}
}
Use this format to make the improvement visible. Show the structural change, not just the diff.