Code Refactor Pack
★Trustedv1.0.0MIT✔Verified88by AgentNode · published 22 days ago · toolpack
Refactor code to improve readability, performance, and maintainability.
Apply DRY principles, extract functions, improve naming, simplify conditionals, and remove dead code. Supports Python, JavaScript, TypeScript, and Go.
Quick Start
agentnode install code-refactor-packUsage
From packagefrom code_refactor_pack.tool import run
result = run(
capability="refactor_code",
params={
"path": "./src/services/order_processor.py",
"refactors": [
{
"type": "extract_function",
"source_lines": [45, 78],
"new_function_name": "validate_order_items"
},
{
"type": "simplify_conditionals",
"scope": "function:process_order"
}
]
}
)
print(f"Refactors applied: {result['refactors_applied']}")
print(f"Lines changed: {result['lines_changed']}")
for change in result["changes"]:
print(f" {change['type']}: {change['description']}")Verification
Package installs and imports correctly. runtime checks passed.
This package was executed and validated by AgentNode before listing. Install, import, and runtime checks passed.
Last verified 18d ago· Runner v2.0.0
Use this when you need to...
- ›Extract long functions into smaller composable units
- ›Rename variables and functions across a codebase
- ›Convert callback-based code to async/await patterns
- ›Remove dead code and unused imports
- ›Simplify deeply nested conditional logic
README
Code Refactor Pack
Refactor code to improve readability, performance, and maintainability. Extract functions, simplify logic, remove dead code, and rename symbols across files.
Quick Start
agentnode install code-refactor-pack
from code_refactor_pack.tool import run
result = run(
capability="refactor_code",
params={
"path": "./src/main.py",
"refactors": [{"type": "remove_unused_imports"}]
}
)
print(f"Removed {result['imports_removed']} unused imports")
Usage
Extract a function from a long method
result = run(
capability="refactor_code",
params={
"path": "./src/services/payment.py",
"refactors": [{
"type": "extract_function",
"source_lines": [120, 155],
"new_function_name": "calculate_tax"
}]
}
)
print(result["changes"][0]["description"])
Clean up an entire directory
result = run(
capability="refactor_code",
params={
"path": "./src/",
"refactors": [
{"type": "remove_unused_imports"},
{"type": "remove_dead_code"},
{"type": "simplify_conditionals"}
],
"recursive": True
}
)
print(f"{result['files_modified']} files cleaned up")
Rename a symbol across files
result = run(
capability="refactor_code",
params={
"path": "./src/",
"refactors": [{
"type": "rename",
"old_name": "processData",
"new_name": "transform_records",
"scope": "project"
}],
"recursive": True
}
)
API Reference
| Capability | Description |
|---|---|
refactor_code | Apply refactoring operations to source files |
Refactor types: extract_function, rename, remove_unused_imports, remove_dead_code, simplify_conditionals, convert_to_async, inline_variable.
Parameters: path (required), refactors (required), recursive, dry_run.
Returns: refactors_applied, lines_changed, files_modified, changes, modified_files.
Requirements
No environment variables required. Source files must be writable in the workspace.
License
MIT
Version History
Capabilities
Permissions
This package declares the following access levels. Review before installing.
agentnode install code-refactor-packFiles (3)
License
MITStats
Compatibility
Frameworks
Runtime
pythonPython Version
>=3.10Trust & Security
Publisher
AgentNode
@agentnode