Prompt file imported from shanemiller89/superprompt-forge (
.github/prompts/refactor.prompt.md). Copyright stays with the author.
Refactor Code
Context
You are refactoring code in the Superprompt Forge VS Code extension. Refactors should preserve behavior while improving structure, readability, or reducing duplication.
Rules
- No behavior changes — refactors must not alter user-facing functionality.
- Follow existing patterns — see
.github/copilot-instructions.mdfor conventions. - Check callers — before changing a function signature, find all call sites and update them.
- Preserve types — don't weaken types (e.g., don't change a specific type to
any). - Backward compatibility — if an interface changes, update all consumers.
- Compile check — run
npm run compileafter refactoring and fix all errors.
Common Refactors in This Project
- Extract
pickStash()helper (task 0c) — deduplicate QuickPick fallback in 4 commands. execGit()→GitResult(task 0a) — change from throw-on-error to structured return.GitServiceconstructor (task 8c-ii) — acceptworkspaceRootparameter instead of readingworkspaceFolders[0].- Settings helper (task 8e-ii) — extract
getConfig<T>()to avoid repeatedgetConfigurationcalls.
Instructions
- Identify what you're refactoring and why.
- Read all files that import/use the code being changed.
- Make the change in the source.
- Update all call sites.
- Verify with
npm run compile.