Skip to content
Testing
Command

/aqe-optimize

Optimize test suites using sublinear algorithms to maximize coverage while minimizing test count and execution time

From plugin
agentic-qe
436149 skills169 agents149 commands
Install
> /plugin marketplace add proffesor-for-testing/agentic-qe
> /plugin install agentic-qe-fleet@agentic-qe

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/aqe-optimize

Context preview

What this command does when you run it.

Optimize test suites using sublinear algorithms to maximize coverage while minimizing test count and execution time

Command definition

aqe-optimize.md
name: aqe-optimize
description: Optimize test suites using sublinear algorithms to maximize coverage while minimizing test count and execution time

AQE Optimize Test Suite

Optimize test suites using sublinear algorithms to maximize coverage while minimizing test count and execution time.

Usage

aqe optimize <target> [options]
# or
/aqe-optimize <target> [options]

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | `target` | string | **required** | Optimization target: suite, coverage, performance, flakiness | | `--path` | path | `./tests` | Test suite path | | `--algorithm` | string | `sublinear` | Algorithm: sublinear, genetic, greedy, heuristic | | `--objective` | string | `coverage-per-test` | Objective: coverage-per-test, execution-time, reliability | | `--budget` | number | - | Time/test budget constraint (seconds) | | `--aggressive` | boolean | `false` | Aggressive optimization (may remove tests) | | `--dry-run` | boolean | `false` | Preview optimization without applying |

Examples

Optimize Test Suite

aqe optimize suite --path tests/unit --algorithm sublinear

Optimizes test suite using sublinear algorithms for maximum efficiency.

Maximize Coverage Efficiency

aqe optimize coverage --objective coverage-per-test --aggressive

Aggressively optimizes for maximum coverage per test ratio.

Reduce Execution Time

aqe optimize performance --budget 300 --algorithm genetic

Optimizes to meet 300-second execution budget using genetic algorithm.

Remove Flaky Tests

aqe optimize flakiness --dry-run

Identifies and previews removal of flaky tests without modifying suite.

Multi-Objective Optimization

aqe optimize suite --objective coverage-per-test --budget 180

Optimizes for both coverage efficiency and time budget.

Integration with Claude Code

Spawning Optimizer Agent

// Use Claude Code's Task tool to spawn the optimizer agent
Task("Optimize test suite for efficiency", `
  Perform comprehensive test suite optimization:
  - Use sublinear algorithms for O(log n) performance
  - Maximize coverage while minimizing test count
  - Target: Reduce execution time by 30%
  - Maintain 95% coverage threshold

  Store optimization results: aqe/optimization/results
  Coordinate with test executor to validate optimized suite.
`, "qe-coverage-analyzer")

Coordinated Optimization Workflow

// Optimize suite and validate results
[Single Message]:
  Task("Optimize test suite", "Use sublinear algorithms to reduce redundancy", "qe-coverage-analyzer")
  Task("Validate optimized suite", "Ensure coverage maintained after optimization", "qe-test-executor")

  TodoWrite({ todos: [
    {content: "Analyze test redundancy", status: "in_progress", activeForm: "Analyzing redundancy"},
    {content: "Apply sublinear optimization", status: "in_progress", activeForm: "Optimizing suite"},
    {content: "Validate optimized suite", status: "pending", activeForm: "Validating optimization"},
    {content: "Measure performance improvement", status: "pending", activeForm: "Measuring improvement"}
  ]})

Agent Coordination

Primary Agent

  • **qe-coverage-analyzer**: Main agent with optimization module

Supporting Agents

  • **qe-test-executor**: Validates optimized suite
  • **qe-performance-tester**: Measures performance impact

Coordination Flow

1. Pre-Task Hook
   ├─> Retrieve test suite metadata
   ├─> Retrieve coverage matrix
   ├─> Retrieve execution history
   └─> Load optimization parameters

2. Optimization Process
   ├─> Build test-coverage matrix
   ├─> Apply sublinear optimization algorithm
   ├─> Calculate minimal test set for target coverage
   ├─> Identify redundant tests
   └─> Generate optimized suite

3. Validation Phase
   ├─> Execute optimized suite
   ├─> Verify coverage maintained
   ├─> Measure performance improvement
   └─> Compare metrics before/after

4. Post-Task Hook
   ├─> Store optimization results
   ├─> Update test suite metadata
   ├─> Train neural patterns
   └─> Notify fleet of improvements

Memory Operations

Input Memory Keys

# Retrieve test suite metadata
npx claude-flow@alpha memory retrieve --key "aqe/test-suite/${suite}"

# Retrieve coverage matrix
npx claude-flow@alpha memory retrieve --key "aqe/coverage-matrix"

# Retrieve execution history
npx claude-flow@alpha memory retrieve --key "aqe/execution-history"

Output Memory Keys

# Store optimization results
npx claude-flow@alpha memory store \
  --key "aqe/optimization/results" \
  --value '{"testsBefore": 120, "testsAfter": 85, "coverageDelta": 0.2}'

# Store optimized suite
npx claude-flow@alpha memory store \
  --key "aqe/optimized-suite" \
  --value '{"tests": ["test1.ts", "test2.ts"], "metadata": {}}'

# Store optimization metrics
npx claude-flow@alpha memory store \
  --key "aqe/optimization-metrics" \
  --value '{"timeSaved": 45, "testsRemoved": 35}'

Hooks and Coordination

Pre-Task Hook

npx claude-flow@alpha hooks pre-task \
  --description "Optimize ${target} with ${algorithm}" \
  --agent "qe-coverage-analyzer"

Post-Task Hook

npx claude-flow@alpha hooks post-task \
  --task-id "${OPT_ID}" \
  --results "${OPT_RESULTS}"

Notify Fleet

npx claude-flow@alpha hooks notify \
  --message "Optimization: ${TEST_REDUCTION}% fewer tests, ${TIME_SAVED}s saved"

Expected Outputs

Success Output

⚡ Optimizing suite...
🧮 Running sublinear optimization algorithm...

📊 Optimization Results:
   Algorithm: sublinear
   Objective: coverage-per-test

   Tests Before: 120
   Tests After: 85
   Reduction: 29.2%

   Coverage Before: 93.5%
   Coverage After: 93.7%
   Delta: +0.2%

   Time Saved: 45s per run

✅ Optimization successful! Fewer tests with improved coverage.

Dry-Run Output

🔍 Optimization Preview (D
Read more
Ships withagentic-qe

AI-powered quality engineering agents that generate tests, find coverage gaps, detect flaky tests, and learn your codebase patterns — across 11 coding agent platforms.

Get the whole plugin