optimize-loop

Iteratively refine code modules or SQL queries under correctness constraints.

150|19|Updated Jun 15, 2026
One-click install
npx skills add https://github.com/gaasher/Agent-Loop-Skills --skill optimize-loop-gaasher
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: optimize-loop
Source: https://github.com/gaasher/Agent-Loop-Skills/tree/main/loops/optimize-loop
Command: npx skills add https://github.com/gaasher/Agent-Loop-Skills --skill optimize-loop-gaasher

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires python:3.9+, and includes scripts (resource) and references (resource) components.

What problem does it solve?

The optimize-loop Skill unit helps users iteratively refine code modules or SQL queries to improve performance while maintaining strict correctness constraints.

Core Features & Use Cases

  • Iterative Refinement: Apply focused changes to an artifact (code or SQL) to improve performance while keeping tests green.
  • Correctness and Performance: Utilize pluggable correctness gates and metrics to ensure improvements are valid and impactful.
  • Use Case: Optimize a complex SQL query to reduce execution time without changing the result set.

Quick Start

Run the optimize-loop skill on your SQL query file using optimize-loop ./query.sql.

Frequently Asked Questions about optimize-loop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize SQL queries to reduce execution time without changing the result set?

SQL optimization reduces query execution time through iterative refinement while enforcing strict correctness gates to ensure the result set remains unchanged. You apply focused changes to the SQL artifact and validate performance metrics against pluggable constraints.

What is iterative code refinement and how does it handle performance constraints?

Iterative code refinement improves module performance by applying focused changes sequentially. It utilizes pluggable correctness gates and metrics to validate that each iteration reduces complexity without breaking existing tests or altering functional behavior.

Can I use Python 3.9+ tools to refactor code and reduce complexity under correctness gates?

Yes, Python 3.9+ tools support code refactoring to reduce complexity under strict correctness constraints. You configure pluggable correctness gates to run tests and validate that your iterative performance improvements do not break functionality.

What is the best way to ensure code optimization does not alter existing test results?

The best way to ensure code optimization preserves functionality is using pluggable correctness gates. These gates validate each iterative refinement against your existing tests, guaranteeing that performance improvements maintain strict correctness.

Do I need pluggable metrics to validate SQL query optimization improvements?

Yes, pluggable metrics are required to validate SQL query optimization and confirm improvements are impactful. They measure execution time reductions during iterative refinement, while correctness gates ensure the result set remains completely unchanged.

When should I not use iterative refinement for performance improvement?

You should avoid iterative refinement for performance improvement if your artifact lacks defined tests or pluggable correctness gates. Without strict validation metrics, iterative changes risk altering the result set or breaking existing module functionality.