Code Quality Until A Grade
A prompt-only loop designed to iteratively improve code quality and maintainability until a specified quality gate passes. The agent analyzes the codebase, identifies quality issues, and applies targeted fixes to achieve an 'A' grade quality score.
Goal
Improve maintainability
How to Run
Automate code quality improvements by iterating through analysis, fixing, and validation cycles using a quality gate check.
- 01
Step 1: Initiate Loop
Begin by providing the kickoff prompt in your preferred tool (Cursor, Claude Code, etc.) to start the agent's quality assessment process.
- 02
Step 2: Execute Check Command
After each improvement step, run the configured quality gate check command to evaluate current code quality status.
- 03
Step 3: Review Results & Iterate
If the quality gate fails, the agent will automatically identify areas needing improvement and apply necessary changes before re-checking.
Workflow Steps
- 01
Assess Current Code Quality
Run initial static analysis and quality gate check to establish baseline metrics and identify failing criteria.
- 02
Analyze Quality Gate Results
Examine detailed output from quality checks to determine specific modules/functions requiring attention.
- 03
Apply Targeted Fixes
Modify identified problematic code with emphasis on improving structure, reducing complexity, and enhancing clarity.
- 04
Validate Improvements
Re-run quality gate check to verify that changes have positively impacted maintainability metrics.
- 05
Repeat Until Pass
Continue iteration cycle until quality gate passes or maximum iterations are reached, ensuring continuous refinement.
Kickoff Prompt
Start the "Code Quality Until A Grade" loop. Goal: Improve maintainability Max iterations: 10 Between iterations run: quality gate Exit when: Quality gate passes Analyze the entire codebase for maintainability issues. Run the quality gate check and review the results. Identify the lowest-scoring components based on code complexity, duplication, and style violations. For each identified issue, apply concrete improvements focusing on reducing cognitive complexity, eliminating code duplication, and aligning with project conventions. After every set of changes, re-run the quality gate check. Stop when the quality gate passes or after 10 iterations. Prioritize changes that have the highest impact on overall code health. Self-pace this loop. After each iteration, run `quality gate` and evaluate the output, and only continue if the exit condition is not met (Quality gate passes). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.
Guardrails
hardcoded- ·Ensure all changes maintain backward compatibility with existing APIs and interfaces.
- ·Preserve or improve existing test coverage with each modification.
- ·Adhere to established coding standards and style guides for the project.
- ·Avoid introducing new technical debt or circumventing quality checks.
- ·Focus improvements on maintainability, readability, and performance bottlenecks.
Flow Diagram
Related loops — Quality
Quality
Dead Code Eliminator
Automatically identifies and removes unused code to improve codebase quality and maintainability. This loop performs iterative scans for dead code, removes it gradually, and ensures no regressions are introduced.
Quality
Lint Until Clean
Automatically iterates through lint error detection and resolution until the codebase passes linting with zero issues. This loop ensures code quality and consistency by having the agent fix problems as they are identified.
Quality
Refactor Safely
This loop systematically refactors your codebase to improve structure while maintaining test coverage. The agent identifies opportunities for cleaner code without breaking existing functionality.