Skip to main content
Glama

Audit tests for flake risks

audit-tests
Destructive

Detect flake risks in Playwright test code, rank files by historical flakiness, and optionally auto-fix mechanical issues with re-run and revert on failure.

Instructions

Audit the Playwright test code for flake risks (hard waits, one-shot assertions instead of web-first ones, missing awaits, .only, force clicks, networkidle, element handles, layout selectors, acting right after goto on a server-rendered app before it hydrates) and rank files by how flaky their tests have been in the run history. fix: true rewrites the mechanical ones, re-runs the touched files and restores them if the run fails. TS/JS specs and pytest-playwright modules.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "audit-tests"
  }
}

Input Schema

NameRequiredDescriptionDefault
fixNoRewrite the mechanical findings (web-first assertions, missing awaits, .only), re-run the touched files and restore them if the run fails
limitNoMax findings to list (default 50); the summary counts all
configNoplaywright.config path or 1-based index, for the verify run
filterNoCase-insensitive substring filter on the file path
verifyNoWith fix: re-run the touched files (default true)
testDirNoAudit only this directory (inside the project); defaults to the config testDir
timeoutMsNoWall-clock limit for the verify run
historyRunsNoHow many recent runs of the local history to weigh in (default 50)
minSeverityNoReport findings at or above this severity (default low)
projectRootNoProject directory; defaults to the server working directory

Output Schema

NameRequiredDescriptionDefault
okYesfalse when the call failed (see error) or the tests it ran failed
errorNo
totalNo
appliedNo
findingsNo
verifiedNo
truncatedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.13.0
    • removedInput schema / $schema
      Removed value: -"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -{}
  2. Addedv0.6.1

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare destructiveHint=true and readOnlyHint=false, and the description earns credit by explaining exactly what the mutation is: fix=true rewrites files, re-runs the touched files, and restores them if the run fails. It also implies a subprocess verify run bounded by a timeout. It stops short of stating the default for fix (i.e., that the tool is read-only unless opted in) or what happens if the process is interrupted mid-rewrite.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the audit scope and risk taxonomy before the fix-mode caveat; the long parenthetical is dense but every item is a distinct detectable pattern. No filler or restatement of the title beyond the opening verb.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter, mutating analysis tool with an output schema, the description covers purpose, detection scope, fix semantics, and supported ecosystems (TS/JS specs and pytest-playwright). Remaining gaps are prerequisites such as needing existing run history for the ranking and whether a config must be resolvable, which the agent cannot learn from the description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description paraphrases the fix parameter but adds the useful nuance that only 'mechanical' findings are auto-fixable, implying pattern/semantic findings are report-only; however limit, filter, minSeverity, historyRuns, projectRoot, and testDir are left entirely to the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Audit the Playwright test code') and then enumerates the exact risk classes it detects (hard waits, one-shot assertions, missing awaits, .only, force clicks, networkidle, element handles, layout selectors, post-goto hydration timing), plus a second function: ranking files by historical flakiness. That enumeration clearly separates it from siblings like diagnose-flaky, suggest-fix, or quarantine, which do not scan source for these patterns.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Makes the usage context clear (static audit of spec files for flake-prone patterns, cross-referenced with run history) and explains the fix=true mode's workflow. It does not explicitly say when to prefer diagnose-flaky or suggest-fix instead, nor that it requires an existing local run history or a playwright config, so the agent must infer the boundary with those siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.