
from agent-lsp49
Extract a selected block of code into a named function using LSP code actions when available, with a manual fallback that analyzes captured variables, return va
This skill lets an agent restructure existing source code by extracting a selected range of lines into a new, named function. It prefers the language server's native extract-function code action (when supported), and falls back to a manual analysis-and-edit flow that identifies captured variables, return values, and applies sequential edits safely. The skill includes validation steps — diagnostics checks and formatting — to ensure the code compiles after extraction.
Use this skill when you need to refactor existing code: for isolating logic, reducing duplication, improving readability, or preparing code for reuse. Trigger it when you can provide a file path and a precise start/end line range, and when you want automated, verifiable edits rather than freeform generation. Ideal for Go, TypeScript/JavaScript, and other languages with LSP support; Python uses the manual fallback more often.
references/ contains diagnostic patterns and guidance used by the skill.Designed for agents that can call MCP LSP server tools (mcp__lsp__*) such as agents integrated with agent-lsp; works with Claude Code, Copilot-style agents, and other tooling that can invoke MCP server RPCs.
This skill has not been reviewed by our automated audit pipeline yet.