arabelatso/lsp-refactoring
Intelligent code refactoring using IDE-level tools (rename, find-references, go-to-definition), AST-aware pattern matching, and TDD verification. Use for safe, large-scale refactoring with precision.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill lsp-refactoring
Refactoring workflow that combines language server capabilities with code search and test-driven verification for safe, precise code transformations.
# Find all usages of a function
grep -rn "getUserData" src/ --include="*.ts"
# Find pattern across codebase with AST-aware tools (if available)
# e.g., ast-grep, semgrep, or comby
ast-grep --pattern 'console.log($MSG)' --lang typescript
For renames (use IDE/editor capabilities when available):
# Using sed for simple renames
find src/ -name "*.ts" -exec sed -i '' 's/getUserData/fetchUserProfile/g' {} +
# Or use language-specific tools
# TypeScript: ts-morph, jscodeshift
# Python: rope, bowler
# Go: gorename
For pattern-based transformations:
# Using ast-grep (if installed)
ast-grep --pattern 'console.log($MSG)' --rewrite 'logger.info($MSG)' --lang typescript
# Using comby
comby 'console.log(:[msg])' 'logger.info(:[msg])' .ts
For structural changes (extract/move):
npx tsc --noEmit # TypeScript
mypy src/ # Python
go vet ./... # Go
git diff to review the complete changes for unintended modificationsIf any check fails:
git checkout -- .| Language | Rename Tool | Pattern Search | Type Check |
|----------|-------------|----------------|------------|
| TypeScript | ts-morph, jscodeshift | ast-grep, semgrep | tsc --noEmit |
| Python | rope, bowler | ast-grep, semgrep | mypy, pyright |
| Go | gorename, gopls | ast-grep, semgrep | go vet |
| Java | IntelliJ refactor, openrewrite | semgrep | javac |
| Rust | rust-analyzer | ast-grep | cargo check |
User: "Rename getUserData to fetchUserProfile across the project"
Output:
grep -rn finds 23 usages across 8 filestsc --noEmit passes with no errorsnpm test — 47 tests passgit diff shows clean, focused changesInspired by: oh-my-opencode /refactor command
Take arabelatso/lsp-refactoring from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference npx.
Without those the skill loads but fails at the first command.