Prompt file imported from diabolo-68/apache-ant-manager (
.github/prompts/refactor.prompt.md). Copyright stays with the author.
Refactor the specified code while preserving existing behavior and architecture patterns.
Rules
- No behavior changes: Refactoring must not change what the code does, only how it's organized
- Preserve patterns: Maintain the project's established patterns:
- Singleton panels with
createOrShow() - Service DI from
extension.ts - Webview message passing protocol
- Path resolution via
toWorkspaceRelativePath()/resolveWorkspacePath()
- Singleton panels with
- Run tests:
npm testbefore AND after refactoring - Run lint:
npm run lintafter refactoring - Run build:
npm run compileto verify webpack bundles correctly
Common Refactoring Targets
- Extract helper methods from long panel
_getHtmlForWebview()methods - Extract message type interfaces for type-safe webview communication
- Split large service methods into smaller focused functions
- Extract shared utilities from panels or services
- Consolidate duplicate error handling patterns
Do NOT
- Move services into panels
- Break the singleton panel pattern
- Change the webview message protocol without updating both sides
- Refactor Java and TypeScript types independently (must stay in sync)