name: srcx-extract description: "Extract code into a new function or class. Use when the user says 'extract this' or wants to refactor by pulling out code." metadata: version: "1.0.0"
<!-- openspec-gradle:0.33.0 -->
Extract a block of code into a new function or class.
Steps
- Identify the code to extract (file path, start line, end line)
- Run:
./gradlew srcx-extract -PsourceFile=path/File.kt -PstartLine=10 -PendLine=25 -PnewName=doSomething - Review
.opsx/extract.md — it shows:
- The extracted code block
- Detected free variables (potential parameters)
- Suggested function signature
- Call site replacement
- Adjust the suggestion: fix parameter types, return type, visibility
- Apply the refactoring manually based on the suggestion
- Run
./gradlew srcx-usages -Psymbol=doSomething to verify
Notes
- The task suggests but does NOT auto-apply (extraction needs human judgment)
- Free variable detection is heuristic — review the parameter list
- Works best with Kotlin; Java support is basic