Condition Based Waiting
Replace arbitrary test delays with condition polling so async tests stop failing under load.
- CCM score
- 54 of 100
- skills.sh installs
- 355
- GitHub stars
- 79
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers the replacement of
setTimeout,sleep, andtime.sleep()delays with waits on real conditions - Includes a generic
waitForpolling helper pluswaitForEvent,waitForEventCount, andwaitForEventMatchinexample.ts - Enforces a timeout with a descriptive error and documents why any intentional fixed delay is needed
- Designed for flaky or timing-dependent async tests that pass sometimes and fail under parallel or CI runs
Install
$ npx -y skills add bobmatnyc/claude-mpm-skills --skill 'Condition-Based Waiting' -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Condition-Based Waiting
Overview
Flaky tests often guess at timing with arbitrary delays. This creates race conditions where tests pass on fast machines but fail under load or in CI.
Core principle: Wait for the actual condition you care about, not a guess about how long it takes.
When to Use
digraph when_to_use {
"Test uses setTimeout/sleep?" [shape=diamond];
"Testing timing behavior?" [shape=diamond];
"Document WHY timeout needed" [shape=box];
"Use condition-based waiting" [shape=box];
"Test uses setTimeout/sleep?" -> "Testing timing behavior?" [label="yes"];
"Testing timing behavior?" -> "Document WHY timeout needed" [label="yes"];
"Testing timing behavior?" -> "Use condition-based waiting" [label="no"];
}
Use when:
- Tests have arbitrary delays (
setTimeout,sleep,time.sleep()) - Tests are flaky (pass sometimes, fail under load)
- Tests timeout when run in parallel
- Waiting for async operations to complete
Don't use when:
- Testing actual timing behavior (debounce, throttle intervals)
- Always document WHY if using arbitrary timeout
Core Pattern
Details
- Repository
- github.com/bobmatnyc/claude-mpm-skills
- Categories
- Testing & QA, Debugging
- First seen
- Jun 3, 2026
Questions
What does the Condition-Based Waiting skill do for flaky tests?
It replaces arbitrary timeouts such as setTimeout, sleep and time.sleep() with condition polling, so an async test waits for the actual result it needs. The skill says this fixes race conditions and timing dependencies that make tests pass on fast machines but fail under load or in CI.
How do I install the Condition-Based Waiting skill?
Run npx -y skills add bobmatnyc/claude-mpm-skills --skill 'Condition-Based Waiting' -y in your project. After installing, the agent can rewrite tests that use fixed delays into waitFor-style checks on the condition under test.
When should I use the Condition-Based Waiting skill?
Use it when tests have race conditions, timing dependencies, or inconsistent pass and fail behavior. It also fits tests that time out when run in parallel or that wait on asynchronous operations to finish.
Is Condition-Based Waiting suitable for testing debounce or throttle timing?
No, the skill says not to use it when you are testing actual timing behavior such as debounce or throttle intervals. In those cases it advises documenting why a fixed timeout is needed.
Which skills are alongside Condition-Based Waiting in the Testing & QA category?
Other skills in Testing & QA include tdd, migrate-to-shoehorn, test-driven-development, webapp-testing and break-ui. Condition-Based Waiting stands apart by focusing on replacing guessed delays with polling on the condition a test cares about.
More from bobmatnyc/claude-mpm-skills
All 154- Flexlayout React355
- Digitalocean Agentic Cloud354
- Jest Typescript354
- Terraform351
- Vercel Ai351
- Artifacts Builder350
- Validated Handler350
- Bad Example Skill347
- Emergency Release Workflow346
- Digitalocean Teams344
- Vector Search Workflows342
- Vercel Storage Data342
- Dispatching Parallel Agents341
- Example Framework Skill341
- Prisma Orm341
- Vercel Teams Billing338
- Spring Boot336
- Requesting Code Review333
- Rust Desktop Applications263
- Anthropic Sdk254
- Tauri Event System203
- Brainstorming Ideas Into Designs201
- Webapp Testing Patterns181
- Langchain Framework165
Similar to Condition Based Waiting
More Testing & QAplaywright-e2e-testingbobmatnyc/claude-mpm-skills2.7K installsModern end-to-end testing with Playwright for cross-browser automation, auto-waiting, and a built-in test runner.
webapp-testing-patternsbobmatnyc/claude-mpm-skills181 installsReference patterns for end-to-end web app tests with Playwright selectors, wait strategies, and testing best practices.
flaky-test-detectivepatricio0312rev/skills285 installsDiagnoses flaky tests by root cause, covering timing, shared state, randomness, and network dependencies.
async-python-patternssickn33/agentic-awesome-skills380 installsGuidance for building non-blocking Python systems with asyncio, covering concurrency patterns, cancellation, and async testing.
playwright-best-practicescurrents-dev/playwright-best-practices-skill114K installsComprehensive guidance for writing, debugging, and maintaining Playwright tests across E2E, component, API, visual, accessibility, security, Electron, and exten
e2e-testing-patternswshobson/agents25.8K installsPractical E2E testing guidance for Playwright and Cypress covering selectors, flaky-test fixes, and debugging workflows.