[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75FVG7HPEHWNS6SNAVQANF0":3,"skill-same:01M75FVG7HPEHWNS6SNAVQANF0":53},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M75FVG7HPEHWNS6SNAVQANF0","Condition-Based Waiting",null,"Replace arbitrary timeouts with condition polling for reliable async tests","RudyCity\u002Fsuperagent","RudyCity","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F82188919?v=4","01M75FP5X8AW8ACBH0SH34WS7M","01M75FP5YAHJK8M1Q52BWXB82K",70,"MIT","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcondition-based-waiting\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: Condition-Based Waiting\ndescription: Replace arbitrary timeouts with condition polling for reliable async tests\nwhen_to_use: when tests have race conditions, timing dependencies, or inconsistent pass\u002Ffail behavior\nversion: 1.1.0\nlanguages: all\n---\n\n# Condition-Based Waiting\n\n## Overview\n\nFlaky 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.\n\n**Core principle:** Wait for the actual condition you care about, not a guess about how long it takes.\n\n## When to Use\n\n```dot\ndigraph when_to_use {\n    \"Test uses setTimeout\u002Fsleep?\" [shape=diamond];\n    \"Testing timing behavior?\" [shape=diamond];\n    \"Document WHY timeout needed\" [shape=box];\n    \"Use condition-based waiting\" [shape=box];\n\n    \"Test uses setTimeout\u002Fsleep?\" -> \"Testing timing behavior?\" [label=\"yes\"];\n    \"Testing timing behavior?\" -> \"Document WHY timeout needed\" [label=\"yes\"];\n    \"Testing timing behavior?\" -> \"Use condition-based waiting\" [label=\"no\"];\n}\n```\n\n**Use when:**\n- Tests have arbitrary delays (`setTimeout`, `sleep`, `time.sleep()`)\n- Tests are flaky (pass sometimes, fail under load)\n- Tests timeout when run in parallel\n- Waiting for async operations to complete\n\n**Don't use when:**\n- Testing actual timing behavior (debounce, throttle intervals)\n- Always document WHY if using arbitrary timeout\n\n## Core Pattern\n\n```typescript\n\u002F\u002F ❌ BEFORE: Guessing at timing\nawait new Promise(r => setTimeout(r, 50));\nconst result = getResult();\nexpect(result).toBeDefined();\n\n\u002F\u002F ✅ AFTER: Waiting for condition\nawait waitFor(() => getResult() !== undefined);\nconst result = getResult();\nexpect(result).toBeDefined();\n```\n\n## Quick Patterns\n\n| Scenario | Pattern |\n|----------|---------|\n| Wait for event | `waitFor(() => events.find(e => e.type === 'DONE'))` |\n| Wait for state | `waitFor(() => machine.state === 'ready')` |\n| Wait for count | `waitFor(() => items.length >= 5)` |\n| Wait for file | `waitFor(() => fs.existsSync(path))` |\n| Complex condition | `waitFor(() => obj.ready && obj.value > 10)` |\n\n## Implementation\n\nGeneric polling function:\n```typescript\nasync function waitFor\u003CT>(\n  condition: () => T | undefined | null | false,\n  description: string,\n  timeoutMs = 5000\n): Promise\u003CT> {\n  const startTime = Date.now();\n\n  while (true) {\n    const result = condition();\n    if (result) return result;\n\n    if (Date.now() - startTime > timeoutMs) {\n      throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`);\n    }\n\n    await new Promise(r => setTimeout(r, 10)); \u002F\u002F Poll every 10ms\n  }\n}\n```\n\nSee @example.ts for complete implementation with domain-specific helpers (`waitForEvent`, `waitForEventCount`, `waitForEventMatch`) from actual debugging session.\n\n## Common Mistakes\n\n**❌ Polling too fast:** `setTimeout(check, 1)` - wastes CPU\n**✅ Fix:** Poll every 10ms\n\n**❌ No timeout:** Loop forever if condition never met\n**✅ Fix:** Always include timeout with clear error\n\n**❌ Stale data:** Cache state before loop\n**✅ Fix:** Call getter inside loop for fresh data\n\n## When Arbitrary Timeout IS Correct\n\n```typescript\n\u002F\u002F Tool ticks every 100ms - need 2 ticks to verify partial output\nawait waitForEvent(manager, 'TOOL_STARTED'); \u002F\u002F First: wait for condition\nawait new Promise(r => setTimeout(r, 200));   \u002F\u002F Then: wait for timed behavior\n\u002F\u002F 200ms = 2 ticks at 100ms intervals - documented and justified\n```\n\n**Requirements:**\n1. First wait for triggering condition\n2. Based on known timing (not guessing)\n3. Comment explaining WHY\n\n## Real-World Impact\n\nFrom debugging session (2025-10-03):\n- Fixed 15 flaky tests across 3 files\n- Pass rate: 60% → 100%\n- Execution time: 40% faster\n- No more race conditions\n","# Condition-Based Waiting\n\n## Overview\n\nFlaky 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.\n\n**Core principle:** Wait for the actual condition you care about, not a guess about how long it takes.\n\n## When to Use\n\n```dot\ndigraph when_to_use {\n    \"Test uses setTimeout\u002Fsleep?\" [shape=diamond];\n    \"Testing timing behavior?\" [shape=diamond];\n    \"Document WHY timeout needed\" [shape=box];\n    \"Use condition-based waiting\" [shape=box];\n\n    \"Test uses setTimeout\u002Fsleep?\" -> \"Testing timing behavior?\" [label=\"yes\"];\n    \"Testing timing behavior?\" -> \"Document WHY timeout needed\" [label=\"yes\"];\n    \"Testing timing behavior?\" -> \"Use condition-based waiting\" [label=\"no\"];\n}\n```\n\n**Use when:**\n- Tests have arbitrary delays (`setTimeout`, `sleep`, `time.sleep()`)\n- Tests are flaky (pass sometimes, fail under load)\n- Tests timeout when run in parallel\n- Waiting for async operations to complete\n\n**Don't use when:**\n- Testing actual timing behavior (debounce, throttle intervals)\n- Always document WHY if using arbitrary timeout\n\n## Core Pattern\n\n```typescript\n\u002F\u002F ❌ BEFORE: Guessing at timing\nawait new Promise(r => setTimeout(r, 50));\nconst result = getResult();\nexpect(result).toBeDefined();\n\n\u002F\u002F ✅ AFTER: Waiting for condition\nawait waitFor(() => getResult() !== undefined);\nconst result = getResult();\nexpect(result).toBeDefined();\n```\n\n## Quick Patterns\n\n| Scenario | Pattern |\n|----------|---------|\n| Wait for event | `waitFor(() => events.find(e => e.type === 'DONE'))` |\n| Wait for state | `waitFor(() => machine.state === 'ready')` |\n| Wait for count | `waitFor(() => items.length >= 5)` |\n| Wait for file | `waitFor(() => fs.existsSync(path))` |\n| Complex condition | `waitFor(() => obj.ready && obj.value > 10)` |\n\n## Implementation\n\nGeneric polling function:\n```typescript\nasync function waitFor\u003CT>(\n  condition: () => T | undefined | null | false,\n  description: string,\n  timeoutMs = 5000\n): Promise\u003CT> {\n  const startTime = Date.now();\n\n  while (true) {\n    const result = condition();\n    if (result) return result;\n\n    if (Date.now() - startTime > timeoutMs) {\n      throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`);\n    }\n\n    await new Promise(r => setTimeout(r, 10)); \u002F\u002F Poll every 10ms\n  }\n}\n```\n\nSee @example.ts for complete implementation with domain-specific helpers (`waitForEvent`, `waitForEventCount`, `waitForEventMatch`) from actual debugging session.\n\n## Common Mistakes\n\n**❌ Polling too fast:** `setTimeout(check, 1)` - wastes CPU\n**✅ Fix:** Poll every 10ms\n\n**❌ No timeout:** Loop forever if condition never met\n**✅ Fix:** Always include timeout with clear error\n\n**❌ Stale data:** Cache state before loop\n**✅ Fix:** Call getter inside loop for fresh data\n\n## When Arbitrary Timeout IS Correct\n\n```typescript\n\u002F\u002F Tool ticks every 100ms - need 2 ticks to verify partial output\nawait waitForEvent(manager, 'TOOL_STARTED'); \u002F\u002F First: wait for condition\nawait new Promise(r => setTimeout(r, 200));   \u002F\u002F Then: wait for timed behavior\n\u002F\u002F 200ms = 2 ticks at 100ms intervals - documented and justified\n```\n\n**Requirements:**\n1. First wait for triggering condition\n2. Based on known timing (not guessing)\n3. Comment explaining WHY\n\n## Real-World Impact\n\nFrom debugging session (2025-10-03):\n- Fixed 15 flaky tests across 3 files\n- Pass rate: 60% → 100%\n- Execution time: 40% faster\n- No more race conditions\n",{"name":5,"version":23,"languages":24,"description":7,"when_to_use":25},"1.1.0","all","when tests have race conditions, timing dependencies, or inconsistent pass\u002Ffail behavior","main","62c7af5ced2c21355d148c243edb6d5921cca1a6",".agents\u002Fskills\u002Fcondition-based-waiting",8,"https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent","https:\u002F\u002Fgithub.com\u002FRudyCity","2026-11-14 22:58:49",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add RudyCity\u002Fsuperagent --skill \"Condition-Based Waiting\"",{"tool":39,"command":40},"bunx","bunx skills add RudyCity\u002Fsuperagent --skill \"Condition-Based Waiting\"",{"tool":42,"command":43},"pnpm","pnpm dlx skills add RudyCity\u002Fsuperagent --skill \"Condition-Based Waiting\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcondition-based-waiting\u002FSKILL.md",true,[47],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"example.ts","SCRIPT","脚本",5054,"https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcondition-based-waiting\u002Fexample.ts",[54,61,68,75,82,89],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M75GP28CM6QCSXSHKFF3NNKS","telegram_bot","Use Telegram Bot when the user asks for Telegram Bot or this provider's API.","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002Fmuse-bridge-kit\u002Fskills\u002Ftelegram-bot\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M75GNZGZYM7NWDV6MBP3HS14","superagent-bridge","Operate the Muse\u003C->superagent Telegram bridge: poll the private group for task_request\u002Ftask_result envelopes, validate senders, and reply with task_batch\u002Ftask_done as Muse (the remote brain).","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002Fmuse-bridge-kit\u002Fskills\u002Fsuperagent-bridge\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M75GNHN19HJWZ7NAPM5E5JCV","Writing Skills","TDD for process documentation - test with subagents before writing, iterate until bulletproof","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M75GNCQEKVRA4FH161NZPZNB","writing-shape","Take a markdown file of raw material and shape it into an article through a conversational session — drafting candidate openings, growing the piece paragraph by paragraph, arguing about format (lists, tables, callouts, quotes) at each step. Use when the user has a pile of notes, fragments, or a rough draft and wants help turning it into something publishable.","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-shape\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M75GNAF9NAYCSTBDZDGMK0DZ","Writing Plans","Create detailed implementation plans with bite-sized tasks for engineers with zero codebase context","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-plans\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":18},"01M75GN72EV0V5NQAW9CSPFRFH","writing-guidelines","Review docs\u002Fprose for Writing Guidelines compliance. Use when asked to \"review my docs\", \"check writing style\", \"audit prose\", \"review docs voice and tone\", or \"check this page against the writing handbook\".","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-guidelines\u002FSKILL.md",[],[]]