danieldekay/ai-ops/refactor-plan
- community
Checking that the SKILL.md file is still in the repository.
Plan a multi-file refactor, then execute it with lean-ctx. Use when the user asks to plan, sequence, scope, rename, move, inline, safe-delete, or safely execute a refactor — including any use of ctx_refactor, ctx_impact, or a project-wide symbol rename.
Install
npx vskill@latest install danieldekay/ai-ops/refactor-planSKILL.md
Refactor Plan
Create a detailed plan before making any code changes using efficient tools first.
Repo parameter: substitute<alias>below with your repository's SymDex index alias (e.g. the repo name). The MCP server prefix (mcp_symdex-mcp_*) may vary per harness — keep the tool family, adjust the prefix to what your environment exposes.
Mandatory Toolchain
DO NOT use raw read_file/grep_search for exploration. Use these in order:
Primary: SymDex (preferred)
| Step | Tool | Purpose | |
|---|---|---|---|
| 1 | mcp_symdex-mcp_build_context_pack(repo="<alias>", query="...") | Broad evidence bundle | |
| 2 | mcp_symdex-mcp_get_callers(repo="<alias>", name="symbol") | Who calls this? | |
| 3 | mcp_symdex-mcp_get_callees(repo="<alias>", name="symbol") | What does this call? | |
| 4 | mcp_symdex-mcp_get_file_outline(repo="<alias>", file="path") | File structure without full read | |
| 5 | mcp_symdex-mcp_search_symbols(repo="<alias>", query="name") | Find symbol by name | |
| 6 | mcp_symdex-mcp_semantic_search(repo="<alias>", query="intent") | Find code by meaning | |
| 7 | mcp_symdex-mcp_get_repo_stats(repo="<alias>") | Repo-level metrics | |
| 8 | mcp_symdex-mcp_find_circular_deps(repo="<alias>") | Detect circular dependencies |
Alternative: LeanCTX (when SymDex unavailable or for AST-precise reads)
| Step | Tool | Purpose | |
|---|---|---|---|
| 1 | ctx_compose task="..." | Ranked files with inline symbols — replaces 3-5 tool calls | |
| 2 | ctx_read mode=signatures | All fn/class/type sigs via tree-sitter AST | |
| 3 | ctx_read mode=map | Deps + exports + API signatures (85-95% savings) | |
| 4 | ctx_callgraph action=callers | Who calls this function (tree-sitter) | |
| 5 | ctx_callgraph action=callees | What this function calls (tree-sitter) | |
| 6 | ctx_search action=symbol | AST-precise symbol lookup | |
| 7 | ctx_search action=semantic | BM25 search by meaning | |
| 8 | ctx_graph action=related | BFS blast radius from a file | |
| 9 | ctx_graph action=impact | Reverse dep analysis | |
| 10 | ctx_call name=ctx_impact action=analyze | File blast radius before editing | |
| 11 | ctx_call name=ctx_refactor | Symbol navigation and mutation (see below) | |
| 12 | ctx_review action=review | Full review: impact + callers + test discovery | |
| 13 | ctx_quality action=report | Project health score + hotspots |
Alternative: LeanCTX CLI (when MCP unavailable)
Fallback: If neither SymDex nor LeanCTX is available, use grep_search / read_file only for the specific files identified.
Instructions
- Do not edit files while preparing the plan.
- Build context pack —
build_context_pack(repo="<alias>", query="{{task_description}}")for broad evidence. - Trace call graph — For each symbol being refactored:
get_callers+get_calleesto find all affected code. - Get file outlines —
get_file_outlinefor each affected file (not full reads). - Check for circular deps —
find_circular_deps(repo="<alias>")to detect cycles. - Identify affected files, ownership boundaries, dependencies, and likely hidden coupling using call graph evidence.
- Plan changes in a safe sequence: contracts/types first → implementations → callers → tests → cleanup.
- Include verification steps between phases and a final validation command.
- Include rollback or recovery steps for the riskiest phases.
- Output the complete plan using the format below.
- Stop after the plan and ask for confirmation before implementing.
If the request is too ambiguous to plan safely, ask concise clarifying questions instead of editing files.
Output Format
Execute only after the plan is confirmed
ctx_refactor is not in the default MCP tool list. Call it with ctx_call. It renames, moves, and deletes symbols. It does not discover them — use ctx_search action=symbol or ctx_compose for that. A one-file text swap belongs in ctx_edit or the host editor.
select_backend picks one of three paths per call:
| Backend | Available when | Use it for | |
|---|---|---|---|
| Headless | Always | symbols_overview (tree-sitter). Body writes: replace_symbol_body, insert_before_symbol, insert_after_symbol. | |
| Language server | A server is running | references, definition, implementations. | |
| JetBrains plugin | Port file exists, PID is alive, and GET /health succeeds | rename, move, safe_delete, inline (preview and apply), reformat, inspections, declaration. |
Project-wide rename, move, safe delete, and inline have no headless path. If the IDE check fails they return BACKEND_REQUIRED. The message says "rename requires a running JetBrains IDE" for delete and inline too. Do not retry the apply. Say the IDE path is down and edit the declaration plus the callers you already listed.
Coordinates and hashes
lineis 1-based.columnis 0-based and points at the symbol name.referenceswith nocolumncan return no results even when the symbol exists. Always passcolumn.- Body writes take
new_text(notnew_body) andexpected_hash, the BLAKE3 of the current range. A mismatch isCONFLICT. - Address a body edit with
name_path(Class/methodor a bare name). If the name is ambiguous, passfileor qualify it.AMBIGUOUS_SYMBOLandNO_SYMBOLmean the path matched more than one symbol or none. move_previewrequireslineeven whenpathis set. Argument checks run before the backend check.
Two-phase writes
rename, move, safe_delete, and inline are preview, then apply.
- Preview collects usages and conflicts and returns
plan_hash. - Apply sends that hash and writes every touched file as one transaction.
- Hash drift, or conflicts with
forceleft false, returnsCONFLICT. inlinecannot be forced.safe_deletewithpropagate=truealso removes unreferenced dependencies.search_commentsandsearch_text_occurrencesextend a rename into comments and non-code text.
Show the preview (usages, conflicts, plan_hash) and wait for confirmation before apply.
Python language server (verified lean-ctx 3.11.4, 2026-10-20)
pylsp is auto-detected. basedpyright on PATH is not what ctx_refactor calls. There may be no [lsp] block in config.
implementations→UNSUPPORTED(notextDocument/implementation).type_hierarchyis attempted on pylsp and fails (noprepareTypeHierarchy). That is not evidence of zero subtypes. Docs call this JetBrains-only; usectx_callgraphor a text search of the base class instead.declarationandinspectionsrequire JetBrains.ctx_impact action=analyzeis file-level. Its file list and its "semantic check" count are different numbers. The count is a pylsp spot-check, not the length of the file list. Use the file list for blast radius andreferences(withcolumn) for symbol occurrences.
Order after confirmation
ctx_impact action=analyzeon each file you will change (depthdefault 5;diffcompares git refs;chaintraces from one file to another).ctx_refactor action=referenceswithlineandcolumnbefore any rename.- JetBrains up:
rename_preview(ormove_preview/safe_delete_preview/inline_preview) → show the plan → apply withplan_hash. - JetBrains down: headless body edit with
expected_hash, or a host edit of the declaration and the callers from the plan. Do not claim a project-wide rename happened. - Re-run
referencesorctx_impact, then the project's tests.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/refactor-plan/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/danieldekay/ai-ops/refactor-plan)