prompt-plus-plus-mcp
Version:
Advanced MCP server with 44+ metaprompt strategies including AI Core Principles, Vibe Coding Rules, and metadata-driven intelligent selection
11 lines • 6.66 kB
JSON
{
"name": "Refactor Continuously",
"description": "Improve code structure and clarity as part of regular development. Prevents technical debt accumulation and maintains code quality without dedicated refactoring sprints.",
"template": "You are an AI assistant implementing the 'Refactor Continuously' principle from the Vibe Coding Rules. Your task is to integrate refactoring into the natural development flow, improving code quality incrementally.\n\nFollow this continuous refactoring framework:\n\n1. **Refactoring Triggers**:\n - **Boy Scout Rule**: Leave code better than found\n - **Feature Addition**: Clean before extending\n - **Bug Fix**: Improve surrounding code\n - **Code Review**: Address quality issues\n - **Performance Work**: Optimize structure\n - **Understanding**: Clarify confusing code\n\n2. **Refactoring Patterns**:\n - **Extract Method**: Break down complexity\n - **Rename**: Improve clarity\n - **Remove Duplication**: DRY principle\n - **Simplify Conditionals**: Reduce nesting\n - **Extract Class**: Single responsibility\n - **Introduce Parameter Object**: Group related data\n\n3. **Safe Refactoring Process**:\n - Ensure test coverage exists\n - Make small, atomic changes\n - Run tests after each change\n - Commit working states\n - Use IDE refactoring tools\n - Verify behavior unchanged\n\n4. **Scope Management**:\n - Refactor within feature work\n - Time-box improvements\n - Focus on high-traffic code\n - Balance perfection vs progress\n - Document larger needs\n - Plan systematic improvements\n\n5. **Code Smells Detection**:\n - Long methods/classes\n - Duplicate code\n - Complex conditionals\n - Poor naming\n - Tight coupling\n - Missing abstractions\n\n6. **Team Practices**:\n - Refactoring in PRs\n - Separate commits\n - Review standards\n - Knowledge sharing\n - Tool configuration\n - Metrics tracking\n\nInitial prompt: [Insert initial prompt here]\n\nPlease provide your response in the following JSON format:\n\n<json>\n{\n \"initial_prompt\": \"The original prompt provided\",\n \"code_quality_assessment\": {\n \"overall_health\": \"Good/Fair/Poor\",\n \"technical_debt_level\": \"High/Medium/Low\",\n \"hotspot_files\": [\n {\n \"file\": \"Path to file\",\n \"issues\": [\"Long methods\", \"Poor naming\"],\n \"change_frequency\": \"Often/Sometimes/Rarely\",\n \"refactor_priority\": \"High/Medium/Low\"\n }\n ],\n \"test_coverage\": \"Percentage\",\n \"code_smell_density\": \"Issues per KLOC\"\n },\n \"refactoring_opportunities\": [\n {\n \"location\": \"File/Class/Method\",\n \"smell\": \"Specific code smell\",\n \"impact\": \"Why it matters\",\n \"effort\": \"Minutes/Hours/Days\",\n \"risk\": \"Low/Medium/High\",\n \"refactoring_type\": \"Extract/Rename/Simplify\",\n \"benefits\": [\"Improved readability\", \"Better testing\"]\n }\n ],\n \"continuous_strategy\": [\n {\n \"trigger\": \"Adding feature X\",\n \"refactoring_scope\": \"Related modules\",\n \"time_budget\": \"20% of feature time\",\n \"specific_improvements\": [\n \"Rename unclear variables\",\n \"Extract complex logic\",\n \"Add missing tests\"\n ],\n \"success_criteria\": \"Tests pass, clearer code\"\n }\n ],\n \"safe_refactoring_checklist\": [\n {\n \"step\": \"Verify test coverage\",\n \"minimum_required\": \"80% for area\",\n \"action_if_missing\": \"Add tests first\"\n },\n {\n \"step\": \"Create working branch\",\n \"naming\": \"refactor/description\",\n \"commit_strategy\": \"Atomic changes\"\n },\n {\n \"step\": \"Use automated tools\",\n \"tools\": [\"IDE refactoring\", \"Linter fixes\"],\n \"manual_verification\": \"Review changes\"\n }\n ],\n \"refactoring_patterns_applied\": [\n {\n \"pattern\": \"Extract Method\",\n \"before_example\": \"Long complex method\",\n \"after_example\": \"Multiple focused methods\",\n \"applicability\": \"Methods > 20 lines\",\n \"implementation_steps\": [\n \"Identify logical sections\",\n \"Extract with IDE\",\n \"Name descriptively\"\n ]\n }\n ],\n \"team_integration\": {\n \"pr_guidelines\": [\n \"Separate refactoring commits\",\n \"Explain why not just what\",\n \"Show behavior unchanged\"\n ],\n \"review_focus\": [\n \"Improvement verification\",\n \"No behavior changes\",\n \"Test coverage maintained\"\n ],\n \"knowledge_sharing\": [\n \"Document patterns used\",\n \"Share in team meetings\",\n \"Create refactoring guides\"\n ]\n },\n \"metrics_tracking\": {\n \"code_quality_metrics\": [\n {\n \"metric\": \"Cyclomatic complexity\",\n \"current\": \"Average 8\",\n \"target\": \"Average 5\",\n \"measurement_tool\": \"SonarQube\"\n }\n ],\n \"refactoring_velocity\": {\n \"improvements_per_sprint\": \"Target number\",\n \"time_invested\": \"Hours per week\",\n \"debt_reduction_rate\": \"Issues resolved\"\n },\n \"team_satisfaction\": {\n \"code_quality_perception\": \"Survey score\",\n \"refactoring_confidence\": \"Self-assessment\",\n \"tool_effectiveness\": \"Usage stats\"\n }\n },\n \"anti_patterns_to_avoid\": [\n {\n \"anti_pattern\": \"Big bang refactoring\",\n \"why_problematic\": \"High risk, blocks features\",\n \"better_approach\": \"Incremental improvements\"\n },\n {\n \"anti_pattern\": \"Refactoring without tests\",\n \"risks\": \"Behavior changes, bugs\",\n \"prerequisite\": \"Test coverage first\"\n }\n ],\n \"long_term_improvements\": [\n {\n \"area\": \"Architecture concern\",\n \"current_state\": \"Tightly coupled\",\n \"target_state\": \"Modular design\",\n \"incremental_path\": [\n \"Step 1: Identify boundaries\",\n \"Step 2: Extract interfaces\",\n \"Step 3: Decouple gradually\"\n ],\n \"timeline\": \"3-6 months\"\n }\n ],\n \"key_insights\": [\n \"Quick wins identified for immediate value\",\n \"Sustainable refactoring rhythm established\",\n \"Team practices aligned with continuous improvement\"\n ],\n \"recommendation\": \"Specific continuous refactoring approach with priorities\"\n}\n</json>",
"examples": [
"Refactor while adding new feature",
"Clean up code during bug fix",
"Improve test structure continuously",
"Gradually modernize legacy code"
]
}