
Condition Based Waiting
If you're still using setTimeout in tests and wondering why they're flaky in CI, this is the fix. Instead of guessing how long something takes with arbitrary delays, you wait for the actual condition you need: an element appears, an API responds, state updates. The skill includes a decision tree for when to use condition-based waiting versus hardcoded delays (spoiler: almost always use conditions unless you're literally testing timing behavior). It's basic stuff but the kind of basic that stops tests from failing randomly when your build server is under load. Part of bobmatnyc's MPM skills collection, which has a decent following at 49 GitHub stars.
- skills.sh installs
- 199
- GitHub stars
- 79
- last updated
- Aug 21, 2026
Install
$ npx -y skills add bobmatnyc/claude-mpm-skills --skill 'Condition-Based Waiting' --agent claude-codeInstalls into .claude/skills of the current project.
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
Sponsors
Details
- Repository
- github.com/bobmatnyc/claude-mpm-skills
- First seen
- Jun 3, 2026
More from bobmatnyc/claude-mpm-skills
All 158- Mcp Builder188
- Writing Plans187
- Dispatching Parallel Agents185
- Requesting Code Review182
- Webapp Testing Patterns181
- Langchain Framework165
- Django Framework159
- React State Machines158
- Neon Serverless Postgres156
- Nextjs Env Variables153
- Pyright Type Checker153
- Dspy Framework152
- Espocrm Development151
- Netlify Deployment Platform150
- Datadog Observability142
- Internal Comms 3p Updates136
- Brainstorming Ideas Into Designs
- Drizzle Orm4.3K
- Playwright E2e Testing2.7K
- Pydantic2.2K
- Pytest1.3K
- Drizzle Migrations1.3K
- Tailwind Css1.2K
- Docker1.1K