refactor-code
Refactor code snippets by applying specific instructions, using optional file context for precision. Supports multiple programming languages to enhance code quality and maintainability.
Instructions
Refactors a given code snippet based on specific instructions, optionally using surrounding file context.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
codeContent | Yes | The actual code snippet to be refactored. | |
contextFilePath | No | Optional relative path to a file whose content provides broader context for the refactoring task. | |
language | Yes | The programming language of the code snippet (e.g., 'typescript', 'python', 'javascript') | |
refactoringInstructions | Yes | Specific instructions on how the code should be refactored (e.g., 'extract the loop into a separate function', 'improve variable names', 'add error handling', 'convert promises to async/await'). |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"codeContent": {
"description": "The actual code snippet to be refactored.",
"minLength": 1,
"type": "string"
},
"contextFilePath": {
"description": "Optional relative path to a file whose content provides broader context for the refactoring task.",
"type": "string"
},
"language": {
"description": "The programming language of the code snippet (e.g., 'typescript', 'python', 'javascript')",
"minLength": 1,
"type": "string"
},
"refactoringInstructions": {
"description": "Specific instructions on how the code should be refactored (e.g., 'extract the loop into a separate function', 'improve variable names', 'add error handling', 'convert promises to async/await').",
"minLength": 1,
"type": "string"
}
},
"required": [
"language",
"codeContent",
"refactoringInstructions"
],
"type": "object"
}