Cfn perf gate

From masharratt/claude-flow-novice · View interactive version

Cfn perf gate is an AI agent skill from the GitHub repository masharratt/claude-flow-novice. Performance regression gate. Runs a configurable benchmark command, compares results against a stored baseline, and emits a cfn-vote-implement manifest for every path that regressed beyond CFN_PERF_THRESHOLD_PCT. Set CFN_PERF_BENCH_CMD to a command that outputs {name: number} JSON. Never auto-fixes.

How to use this skill

Skill file

CFN Performance Gate

Purpose: Detect performance regressions before merge. Runs your project benchmark, compares against a stored baseline, and emits a structured manifest that feeds cfn-vote-implement for 3-agent voting. Findings route through voting. This skill never auto-fixes.

When to Use (gate)

Run before merging any change that touches:

If no benchmark exists for this project, skip this gate or set one up first.

Benchmark Command Format

CFN_PERF_BENCH_CMD must output a flat JSON object where each key is a named benchmark and each value is a numeric measurement (milliseconds or any consistent unit):

{"api_endpoint": 120, "db_query": 45, "build_time": 8200}

All values must be numbers. All runs must use the same unit. Keys present in the baseline but missing from the current run are skipped (not flagged as regressions).

Baseline Workflow

  1. Before your change: run execute.sh with no baseline present. The script records the current benchmark as the baseline and exits 0.
  2. Make your change.
  3. Run execute.sh again. It compares current results against the baseline and flags regressions.
  4. If regressions are found: manifest is emitted, exit code 2, run /cfn-vote-implement latest.
  5. After fixing regressions: run execute.sh --update-baseline to promote the current results to the new baseline.

Inputs

Environment variables:

| Variable | Default | Description |

|----------|---------|-------------|

| CFN_PERF_BENCH_CMD | (required) | Shell command that outputs benchmark JSON. Gate cannot run without this. |

| CFN_PERF_THRESHOLD_PCT | 10 | Percent slower than baseline before a path is flagged as a regression. |

Flags:

| Flag | Effect |

|------|--------|

| --update-baseline | Run benchmark, write results as new baseline, exit 0. No comparison. |

Outputs

Exit Codes

| Code | Meaning |

|------|---------|

| 0 | No regressions found, OR baseline recorded (first run or --update-baseline). |

| 1 | Config or execution error: CFN_PERF_BENCH_CMD not set, benchmark command failed, output is not valid JSON. |

| 2 | Regressions found. Manifest emitted. Run /cfn-vote-implement latest. |

Usage

# 1. Record baseline (before your change)
CFN_PERF_BENCH_CMD='./scripts/bench.sh' ./.claude/skills/cfn-perf-gate/execute.sh

# 2. Make your change, then run the gate
CFN_PERF_BENCH_CMD='./scripts/bench.sh' ./.claude/skills/cfn-perf-gate/execute.sh

# 3. If exit code 2, route findings through voting
/cfn-vote-implement latest

# 4. After fixes, promote new baseline
CFN_PERF_BENCH_CMD='./scripts/bench.sh' ./.claude/skills/cfn-perf-gate/execute.sh --update-baseline

# Override threshold (flag if >5% slower)
CFN_PERF_THRESHOLD_PCT=5 CFN_PERF_BENCH_CMD='./scripts/bench.sh' ./.claude/skills/cfn-perf-gate/execute.sh

Manifest Schema (shared with cfn-vote-implement)

{
  "review_id": "perf-gate-<ns>",
  "source": "cfn-perf-gate",
  "generated_at": "ISO-8601",
  "threshold_pct": 10,
  "baseline_file": "<project-root>/.cfn-cache/perf-baseline.json",
  "regression_count": 1,
  "suggestions": [
    {
      "id": "S001",
      "category": "perf_regression",
      "tag": "fix",
      "one_liner": "api_endpoint: regressed 60% (baseline 100, current 160)",
      "title": "perf regression: api_endpoint",
      "description": "api_endpoint regressed 60% above the 10% threshold. Baseline: 100. Current: 160.",
      "files": [],
      "impact": "high | medium | low",
      "effort": "medium",
      "suggested_approach": "Profile api_endpoint to identify the regression. Compare the diff since baseline was recorded. Optimize the hot path or revert the regressing change.",
      "related_suggestions": []
    }
  ]
}

Impact tiers: high (>50% regression), medium (>20%), low (above threshold, below 20%).

Rules

Related

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.