condition-based-waiting

Replace setTimeout delays with polling-based waitFor conditions in tests.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/chriscarterux/chris-claude-stack --skill condition-based-waiting-chriscarterux
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: condition-based-waiting
Source: https://github.com/chriscarterux/chris-claude-stack/tree/main/skills/condition-based-waiting
Command: npx skills add https://github.com/chriscarterux/chris-claude-stack --skill condition-based-waiting-chriscarterux

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates unreliable, timing-dependent tests by replacing arbitrary delays with intelligent condition polling, ensuring consistent test results across all environments.

Core Features & Use Cases

  • Race Condition Elimination: Replace guesswork timing with precise state monitoring.
  • Flaky Test Resolution: Convert intermittent failures into reliable, deterministic tests.
  • Use Case: Imagine your CI pipeline randomly fails 40% of the time due to timing issues. Use this Skill to wait for actual state changes instead of arbitrary timeouts, achieving 100% pass rates.

Quick Start

Use the condition-based waiting skill to replace setTimeout delays in your test code with waitFor conditions that check for actual state changes.

Frequently Asked Questions about condition-based-waiting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate flaky tests caused by timing issues and race conditions?▼

Replace arbitrary delays with condition-based waiting that polls for actual state changes. Instead of setTimeout or sleep calls, use waitFor conditions to check for specific events, state transitions, or file existence, ensuring deterministic test results across all environments.

What's the best way to wait for asynchronous operations in tests without arbitrary timeouts?▼

Condition-based waiting replaces guesswork timing by monitoring for actual state changes using polling. It works across unit, integration, and CI environments, supporting patterns like waitForEvent and waitForEventCount with configurable timeouts and 10ms polling intervals.

Can I use condition-based waiting to handle race conditions in my test suite?▼

Yes. This approach eliminates race conditions by waiting for precise state changes rather than fixed delays. It applies to tests relying on asynchronous operations, event emissions, count changes, and file operations, converting intermittent failures into reliable, deterministic tests.

How do I convert setTimeout delays in existing tests to condition-based waiting?▼

Replace each setTimeout with a waitFor condition that checks for the actual state change you're waiting for—such as waitForEvent for event emissions, waitForEventCount for counter changes, or waitForEventMatch for specific conditions, with configurable timeout and deterministic polling.

Why do CI pipelines fail intermittently, and how does condition-based waiting help?▼

CI failures often stem from timing assumptions that vary across environments. Condition-based waiting solves this by polling for real state changes instead of arbitrary delays, achieving consistent pass rates by replacing environment-dependent timing with deterministic state verification.