industrial/_project-template/skill-condition-based-waiting
Claude Code and agent skill by industrial/_project-template
- community
Checking that the SKILL.md file is still in the repository.
Use when tests have race conditions, timing dependencies, or inconsistent pass/fail behavior - replaces arbitrary timeouts with condition polling to wait for actual state changes, eliminating flaky tests from timing guesses
Install
npx vskill@latest install industrial/_project-template/skill-condition-based-waitingSKILL.md
The same SKILL.md was published earlier as industrial/_project-template/skill-condition-based-waiting.
Condition-Based Waiting
Use when tests have race conditions, timing dependencies, or inconsistent pass/fail behavior - replaces arbitrary timeouts with condition polling to wait for actual state changes, eliminating flaky tests from timing guesses
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
✅ Good: ```dot
Core Pattern
✅ Good: ```typescript
Quick Patterns
| Scenario | Pattern | |
|---|---|---|
| Wait for event | waitFor(() => events.find(e => e.type === 'DONE')) | |
| Wait for state | waitFor(() => machine.state === 'ready') | |
| Wait for count | waitFor(() => items.length >= 5) | |
| Wait for file | waitFor(() => fs.existsSync(path)) | |
| Complex condition | waitFor(() => obj.ready && obj.value > 10) |
Implementation
✅ Good: Generic polling function:
Common Mistakes
❌ Polling too fast: setTimeout(check, 1) - wastes CPU ✅ Fix: Poll every 10ms
❌ No timeout: Loop forever if condition never met ✅ Fix: Always include timeout with clear error
❌ Stale data: Cache state before loop ✅ Fix: Call getter inside loop for fresh data
When Arbitrary Timeout IS Correct
✅ Good: ```typescript
Real-World Impact
- Fixed 15 flaky tests across 3 files
- Pass rate: 60% → 100%
- Execution time: 40% faster
- No more race conditions
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.openskills/skill-condition-based-waiting/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/industrial/_project-template/skill-condition-based-waiting)