analyze_flaky_tests

analyze_flaky_tests is a command for Claude Code from anhtester/ClaudeCode_Playwright_Demo. It costs 52 tokens per session (3,108 once invoked), scanned A, a copy of analyze_flaky_tests, MIT.

A workflow for finding and stabilizing flaky automation tests—tests that sometimes pass and sometimes fail without code changes.

In plain words
What is it for?
Use it to investigate unreliable browser or automation tests, report likely causes, and repair unstable selectors or other test code.
Why use it?
It helps identify the real cause from test files, logs, and the page structure instead of guessing. In fix mode, it can suggest and apply code changes after approval.

Command for Claude Code

Written for Claude Code: installed under .claude/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/anhtester/claudecode_playwright_demo/analyze_flaky_tests
Clone the repo
git clone --depth 1 https://github.com/anhtester/ClaudeCode_Playwright_Demo

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for analyze_flaky_tests

README.md
[![agentmods](https://agentmods.dev/badge/commands/anhtester/claudecode_playwright_demo/analyze_flaky_tests.svg)](https://agentmods.dev/commands/anhtester/claudecode_playwright_demo/analyze_flaky_tests)
Your own site
<a href="https://agentmods.dev/commands/anhtester/claudecode_playwright_demo/analyze_flaky_tests"><img src="https://agentmods.dev/badge/commands/anhtester/claudecode_playwright_demo/analyze_flaky_tests.svg" alt="Measured on agentmods" height="20"></a>
Per session 52 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,108 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 86% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.03108
Opus 5 $0.00026 $0.01554
Sonnet 5 $0.00010 $0.00622
Haiku 4.5 $0.00005 $0.00311

Measured 5d ago against content hash 6d78c4797016, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

analyze_flaky_tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

86% identical to analyze_flaky_tests — 18 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.claude/commands/analyze_flaky_tests.md · 244 lines

How it starts

The opening of the file, as written. The whole thing — 244 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Workflow: Phân Tích & Khắc Phục Flaky Tests

BẮT BUỘC (MANDATORY SKILL): Bạn PHẢI nạp và đọc kỹ nội dung của skill flaky_test_analyzer (tại .agent/skills/flaky_test_analyzer/SKILL.md) trước khi bắt đầu. Ngoài ra, tham khảo thêm skill smart_locator_agentlocator_healer_agent khi cần sửa/thay locator.

Workflow này giúp agent tự động phân tích các automation test không ổn định (lúc pass lúc fail), xác định root cause chính xác, và (tùy mode) tự động sửa code để stabilize test.

⚠️ Nguyên tắc thực thi

  • Tất cả output bằng Tiếng Việt
  • KHÔNG đoán nguyên nhân — phải phân tích log, code, và DOM thực tế
  • Phải chờ user xác nhận danh sách fix tại Bước 3 trước khi sửa code (Mode FIX)
  • Nếu user chưa cung cấp test file/error log → hỏi trước khi bắt đầu
  • ⚠️ Sau khi user xác nhận fix → agent tự sửa + verify, KHÔNG hỏi lại trong quá trình fix

2 Chế độ (Mode)

Mode Khi nào sử dụng Output
ANALYZE (mặc định) User cần hiểu nguyên nhân flaky, chưa muốn sửa code Báo cáo phân tích + Đề xuất fix
FIX User muốn agent tự sửa code luôn Như ANALYZE + Code đã sửa + Kết quả verify

Nếu user nói "sửa luôn", "fix giùm", "khắc phục test này", hoặc yêu cầu agent sửa code → tự động chuyển sang Mode FIX.

Input cần thu thập

Agent cần ít nhất 1 trong các input sau từ user:

Input Cách lấy Độ ưu tiên
Test file path User cung cấp hoặc agent tìm trong project ⭐ Bắt buộc
Error log / stack trace User paste hoặc agent chạy test để thu thập ⭐ Bắt buộc
CI/CD log User cung cấp URL hoặc file log Tùy chọn
Test report (HTML/JSON) Playwright report, Allure, TestNG report Tùy chọn
Lịch sử fail Số lần fail / tổng số lần chạy Tùy chọn

Các bước thực hiện

Bước 1: Thu thập thông tin & Tái hiện lỗi (Detect & Reproduce)

  1. Đọc test file bằng view_file:
    • Xác định framework (Playwright / Selenium / Appium / Pytest / TestNG)
    • Ghi nhận cấu trúc: Page Objects, fixtures, helper functions
    • Đánh dấu các vùng code nghi ngờ (waits, locators, assertions, setup/teardown)

Read the full file on GitHub · 244 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 244 lines · 52 tokens per session scan A 6d78c4797016

Subscribe to this mod's changes

analyze_flaky_tests is a command published in the GitHub repository anhtester/ClaudeCode_Playwright_Demo (2 stars, last pushed 3mo ago), licensed MIT. It adds 52 tokens to every session and 3,108 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 86% identical to analyze_flaky_tests, differing in 18 lines, and is treated as a copy.

Related

Other commands, from other repositories