mcpField
Q
qe-iterative-loop

qe-iterative-loop

github.com/proffesor-for-testingテスト・品質51991 回インストール今日更新
リポジトリ

qe-iterative-loop について

qe-iterative-loopは、測定可能な目標に基づいてAIエージェントが品質改善を繰り返す、品質エンジニアリング向けスキルです。テスト、カバレッジ、品質ゲート、不安定なテスト、契約検証を扱い、AQE v3 Fleetのパターンを示します。

主な機能

  1. 01テスト修正の反復
  2. 02カバレッジ目標の改善
  3. 03品質ゲートへの準拠
  4. 04不安定なテストの安定化
  5. 05API契約の検証

活用シーン

  1. 01テストスイートが通るまで失敗を修正
  2. 02カバレッジを指定目標まで引き上げる
  3. 03デプロイ前の品質ゲート失敗を解消
  4. 04結果が不安定なテストを特定して安定化

MCP 対応

AQE MCPを使った品質エンジニアリングの反復パターンの保存・検索と、カバレッジ状況の確認方法を説明します。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill qe-iterative-loop

インストール後、Claude Code で/qe-iterative-loopを入力して読み込まれたか確認します。

同梱ファイルschemas/output.jsonscripts/validate-config.json

詳細

QE の反復ループ

概要

QE の反復ループは、品質エンジニアリングのワークフローに特化して Ralph Wiggum テクニックを応用したものです。テストの合格、カバレッジ目標の達成、品質ゲートの通過、不安定なテストの安定化など、品質目標が達成されるまで AI エージェントが反復する、自律的で自己修正可能な品質サイクルを実現します。

QE が反復の恩恵を受ける理由

品質エンジニアリングには、客観的で測定可能な成功基準があります。

  • テストは合格または失敗のいずれかです(終了コード 0 と 0 以外)
  • カバレッジは数値で測定できます(目標 80% に対して 78.5%)
  • 品質ゲートの結果は二値です(合格/不合格)
  • コントラクトの検証には明確なスキーマがあります

このため、QE は反復ループに最適です。完了の条件が正確にわかるからです。

前提条件

  • AQE v3 フリートが初期化されている
  • テストフレームワークが設定されている(Jest、Vitest、Pytest など)
  • カバレッジツールがある(c8、istanbul、coverage.py)
  • 品質ゲートが定義されている

クイックスタート

パターン 1:テスト修正の反復
# Task: Fix all failing tests
/qe-loop "Run npm test and fix all failing tests.
Success: npm test exits with code 0
Output <promise>TESTS_GREEN</promise> when all tests pass."
パターン 2:カバレッジ目標の反復
# Task: Achieve 80% coverage
/qe-loop "Increase test coverage to 80%.
Success: Coverage report shows >= 80%
Output <promise>COVERAGE_MET</promise> when target achieved."
パターン 3:品質ゲートの反復
# Task: Pass all quality gates
/qe-loop "Pass all quality gates for deployment.
Gates:
- Unit tests: pass
- Integration tests: pass
- Coverage: >= 80%
- No critical vulnerabilities
- Performance < 200ms P95
Output <promise>QUALITY_GATES_PASSED</promise> when all pass."

QE の反復パターン

パターン 1:テスト修正の反復ループ

目標:すべてのテストに合格する

## QE Test-Fix Loop

### Success Criteria
- `npm test` (or test command) returns exit code 0
- No skipped tests (unless explicitly allowed)
- No pending tests

### Iteration Steps
1. Run full test suite
2. Parse output for failures
3. Analyze first failure:
   - Identify failing test file
   - Understand assertion that failed
   - Check if production code or test is wrong
4. Fix the issue
5. Re-run failed test file only (faster feedback)
6. If file passes, run full suite
7. If all pass -> output <promise>TESTS_GREEN</promise>
8. If failures remain -> continue to next failure

### Safety
- Max iterations: 30
- After 10 iterations: report remaining failures
- Stop if same test fails 5 times (possible design issue)
パターン 2:カバレッジ改善ループ

目標:カバレッジ目標を達成する

## QE Coverage Loop

### Success Criteria
- Line coverage >= {target}%
- Branch coverage >= {target - 5}% (typically lower target)
- No critical paths uncovered

### Iteration Steps
1. Run tests with coverage: `npm test -- --coverage`
2. Parse coverage report
3. If target met -> output <promise>COVERAGE_MET</promise>
4. Identify uncovered files, sorted by:
   - Critical business logic (highest priority)
   - Lines uncovered (most impact)
   - Complexity (McCabe score)
5. Generate test for highest-impact uncovered code
6. Run tests to verify new test passes
7. Check coverage improvement
8. Continue until target met

### Intelligence Integration
- Store successful test patterns in memory
- Learn from coverage achievements
- Predict best coverage strategies

### Commands
```bash
# Check coverage status (via AQE MCP)
aqe memory get --key "coverage-status" --namespace "coverage"

# Store coverage achievement pattern (via AQE MCP)
aqe memory store \
  --key "coverage-pattern-auth" \
  --value '{"approach": "mock external deps", "improvement": "12%"}' \
  --namespace "coverage-patterns"

### Pattern 3: Quality Gate Compliance Loop

**Goal**: Pass all quality gates

```markdown
## QE Quality Gate Loop

### Gate Definitions
| Gate | Criteria | Priority |
|------|----------|----------|
| unit-tests | All pass | P0 |
| integration-tests | All pass | P0 |
| coverage | >= 80% | P1 |
| lint | No errors | P1 |
| typecheck | No errors | P1 |
| security | No critical/high CVEs | P0 |
| performance | P95 < 200ms | P2 |

### Iteration Strategy
1. Run all gate checks
2. Identify failing gates (sorted by priority)
3. Fix highest-priority failing gate
4. Re-run that gate to verify
5. When gate passes, move to next failing gate
6. When all pass -> output <promise>QUALITY_GATES_PASSED</promise>

### Gate Check Commands
```bash
# Check all gates
npm test && npm run lint && npm run typecheck && npm run coverage && npm audit

# Individual gate checks
npm test                        # unit-tests
npm run test:integration        # integration-tests
npm run coverage               # coverage
npm run lint                   # lint
npx tsc --noEmit               # typecheck
npm audit --audit-level=high   # security
npm run benchmark              # performance
AQE v3 との統合
# Submit quality gate assessment task
aqe quality --runGate true

# Task orchestration for gate compliance
aqe task submit --task "Pass all quality gates" --strategy adaptive

### Pattern 4: Flaky Test Stabilization Loop

**Goal**: Eliminate test flakiness

```markdown
## QE Flaky Test Loop

### Flakiness Detection
1. Run test suite N times (e.g., 5 runs)
2. Identify tests that pass/fail inconsistently
3. Calculate flakiness score: (inconsistent runs / total runs)

### Iteration Steps
1. Run: `for i in {1..5}; do npm test; done`
2. Aggregate results per test
3. Identify flaky tests (passed some, failed some)
4. For each flaky test:
   - Analyze failure modes
   - Common causes:
     - Timing issues (add retries/waits)
     - Shared state (isolate test data)
     - Network calls (mock external services)
     - Random data (use deterministic seeds)
   - Apply appropriate fix
   - Re-run 5 times to verify stability
5. When all tests stable -> output <promise>TESTS_STABLE</promise>

### AQE v3 Flaky Detection
```bash
# Use qe-flaky-hunter agent
Task("Hunt flaky tests", "Detect and stabilize flaky tests", "qe-flaky-hunter")

# Or submit flaky detection task
aqe task submit --type "flaky-detection" --priority "p1"

### Pattern 5: Contract Validation Loop

**Goal**: API contracts aligned

```markdown
## QE Contract Loop

### Success Criteria
- Provider implements all consumer contracts
- No breaking changes detected
- Schema validation passes

### Iteration Steps
1. Run contract tests: `npm run test:contracts`
2. Parse contract violations
3. For each violation:
   - Determine if provider or consumer needs update
   - Update appropriate side
   - Re-run contract tests
4. When all contracts valid -> output <promise>CONTRACTS_VALID</promise>

### AQE v3 Integration
```bash
# Validate contracts
aqe test contract --contractPath "./contracts"

# Or use specialized agent
Task("Validate API contracts", "Check consumer-provider alignment", "qe-contract-validator")

---

## AQE v3 Fleet Integration

### Spawning QE Iteration Agents

```bash
# Initialize AQE fleet for QE iteration
aqe fleet init --topology "hierarchical" --maxAgents 8

# Spawn specialized QE iterators using Task tool
Task("Fix failing tests", "Iterate until all tests pass", "qe-tdd-green", {run_in_background: true})
Task("Improve coverage", "Iterate until 80% coverage", "qe-coverage-analyzer", {run_in_background: true})
Task("Fix security issues", "Iterate until security scan passes", "qe-security-scanner", {run_in_background: true})
Task("Stabilize flaky tests", "Iterate until tests stable", "qe-flaky-hunter", {run_in_background: true})
メモリーを活用した QE の反復
# Store iteration patterns for learning (via AQE MCP)
aqe memory store \
  --key "qe-iteration-test-fix" \
  --value '{"approach": "mock external deps", "success_rate": 0.85}' \
  --namespace "qe-patterns"

# Search for relevant QE patterns (via AQE MCP)
aqe memory search \
  --pattern "test-fix-*" \
  --namespace "qe-patterns"

# Record successful iteration completion (via AQE task tracking)
aqe task status --taskId "test-fix-iteration"
QE タスクに応じたエージェントのルーティング
QE タスク推奨エージェント反復の目標
テストの修正qe-tdd-greenすべてのテストに合格する
カバレッジの不足qe-coverage-analyzerカバレッジ目標を達成する
品質ゲートqe-quality-gateすべてのゲートに合格する
不安定なテストqe-flaky-hunterテストが安定する
コントラクトの検証qe-contract-validatorコントラクトが整合する
セキュリティの修正qe-security-scanner脆弱性がない
パフォーマンスqe-performance-validatorベンチマークに合格する

QE の完了条件

標準的な QE の完了条件
# Test-related
<promise>TESTS_GREEN</promise>       # All tests pass
<promise>TESTS_STABLE</promise>      # Flaky tests fixed
<promise>TDD_COMPLETE</promise>      # TDD cycle done

# Coverage-related
<promise>COVERAGE_MET</promise>      # Target coverage achieved
<promise>GAPS_FILLED</promise>       # Coverage gaps addressed

# Quality gates
<promise>QUALITY_GATES_PASSED</promise>  # All gates pass
<promise>DEPLOYMENT_READY</promise>      # Ready for deploy

# Contract/API
<promise>CONTRACTS_VALID</promise>   # Contracts aligned
<promise>API_COMPLIANT</promise>     # API matches spec

# Security
<promise>SECURITY_CLEARED</promise>  # No vulnerabilities
<promise>COMPLIANCE_MET</promise>    # Compliance requirements met

# Performance
<promise>PERF_TARGET_MET</promise>   # Benchmarks satisfied

例:QE の反復ワークフロー全体

## Complete QE Iteration Task

### Objective
Achieve deployment readiness through iterative quality improvement

### Phase 1: Test Health (Priority)
1. Run `npm test`
2. Fix failing tests iteratively
3. Success: <promise>TESTS_GREEN</promise>

### Phase 2: Coverage (After Phase 1)
1. Run `npm test -- --coverage`
2. Write tests for uncovered critical paths
3. Success: Coverage >= 80% -> <promise>COVERAGE_MET</promise>

### Phase 3: Quality Gates (After Phase 2)
1. Run lint: `npm run lint`
2. Run typecheck: `npx tsc --noEmit`
3. Fix any violations
4. Success: <promise>LINT_PASS</promise> + <promise>TYPES_PASS</promise>

### Phase 4: Security (Parallel with Phase 3)
1. Run `npm audit`
2. Fix critical/high vulnerabilities
3. Success: <promise>SECURITY_CLEARED</promise>

### Phase 5: Integration
1. Run `npm run test:integration`
2. Fix any integration failures
3. Success: <promise>INTEGRATION_PASS</promise>

### Final Gate
When ALL phases complete -> <promise>DEPLOYMENT_READY</promise>

### Safety Limits
- Max iterations per phase: 15
- Total max iterations: 50
- Stuck detection: 5 iterations without progress triggers escalation

トラブルシューティング

問題:同じアサーションでテストが失敗し続ける

原因:実装のバグではなく、設計上の問題である可能性があります

解決策:

  1. 同じテストで 5 回試行したら反復を停止する
  2. テストの期待値が正しいか分析する
  3. 本番環境の動作が設計どおりか確認する
  4. 判断が難しい場合は、人によるレビューにエスカレーションする
問題:カバレッジが頭打ちになる

原因:カバレッジされていない残りのコードが複雑、または条件付きです

解決策:

  1. カバレッジされていない分岐を特定する(行だけでなく)
  2. エッジケースのテストを生成する
  3. カバレッジされていないコードがデッドコードかどうか検討する
  4. 本当にテストできないコードについては、目標を引き下げる
問題:不安定なテストが安定しない

原因:タイミングや状態に関する根深い問題があります

解決策:

  1. 明示的な待機や再試行を追加する
  2. 時間に依存する動作をモックする
  3. テスト環境を分離する
  4. 説明を添えてスキップ対象にすることを検討する

関連スキル

リソース


起源:Ralph Wiggum プラグイン(anthropics/claude-code)を応用 特化対象:60 の QE エージェントを備えた Agentic QE v3 フリート 領域:test-generation、test-execution、coverage-analysis、quality-assessment

コメント