Complexity Reducer
This loop iteratively analyzes and reduces code complexity by generating complexity reports, identifying high-complexity areas, and applying refactoring tech…
This loop is republished with attribution. Full credit and the original content belong to the source linked above.
AI Skill Market Insights
Real data. Real impact.
Emerging
Developers
Kickoff Prompt
Copy this prompt and run it with your agent to start the loop.
Start the "Complexity Reducer" loop.
Goal: Lower code complexity to meet specified thresholds through automated analysis and refactoring
Max iterations: 10
Between iterations run: complexity report
Exit when: Average cyclomatic complexity below target threshold (e.g., 10) OR all functions under individual complexity threshold (e.g., 20)
Please analyze the complexity of my code and iteratively reduce it. Start by running a comprehensive complexity report on the target codebase. Once you have the baseline metrics, identify the highest-complexity functions and apply appropriate refactoring techniques. Continue this analyze-refactor cycle until the average cyclomatic complexity is below 10 or no further meaningful reductions are possible. Focus on breaking down large functions, simplifying conditional logic, and improving overall maintainability without changing the program's behavior.
Self-pace this loop. After each iteration, run `complexity report` and evaluate the output, and only continue if the exit condition is not met (Average cyclomatic complexity below target threshold (e.g., 10) OR all functions under individual complexity threshold (e.g., 20)). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.