automation-bool-selector-pitfalls
Skill0 starsChanged 5 months agoMITView on GitHub
Webブラウザ自動化スクリプト(Playwright/Puppeteer/Selenium)で何日も止まっていたレーンの真因になりやすい2大手抜き=「booleanの戻り値抜け」と「document全体を走査するセレクタ」の診断・修正パターン。social-autolike/note-autolike/tiktok-autopost等の自動化レーンが突然失敗し始めたときに最初に確認する。
In this repository99 other files it gives its agents.
- agents-tools-quoted-jsonSkill
- asc-api-app-store-submitSkill
- asd-ste100Skill
- automation-stale-cooldown-flagSkill
- autonomous-build-verifySkill
- book-to-skillSkill
- ccusage-cli-cost-trackingSkill
- chrome-ext-mv3-programmatic-injectSkill
- chrome-ext-store-assetsSkill
- claude-headless-p-invocationSkill
- claude-plugin-context-auditSkill
- claude-session-log-to-kbSkill
- cloudflare-workers-do-deploySkill
- codebase-to-courseSkill
- codesign-keychain-prompt-fixSkill
- codex-cli-setupSkill
- codex-delegation-handoffSkill
- content-factory-grounding-dedupSkill
- conversation-log-append-patternSkill
- cron-to-launchd-macosSkill
- cross-automation-shared-resource-killSkill
- design-token-migration-rnSkill
- discord-bot-image-to-claudeSkill
- discord-gateway-resume-dedupSkill
- excel-filtered-url-http-auditSkill
- execution-budget-vs-capsSkill
- expo-free-local-ios-testflightSkill
- ga4-connect-projectsSkill
- gcal-oauth-desktop-setupSkill
- git-commit-helperSkill
- git-prepush-secret-remote-checkSkill
- gsc-cli-automationSkill
- hatena-blogsync-autopostSkill
- hook-latency-wrapSkill
- hook-log-append-patternSkill
- html-to-pdf-slide-deckSkill
- humanizerSkill
- human-review-gate-shellSkill
- implementation-model-routingSkill
- insights-to-claude-mdSkill
- ios-permission-key-security-matrixSkill
- ios-sim-store-screenshotsSkill
- launchd-exit78-exconfig-debugSkill
- llm-content-pipeline-quality-gateSkill
- local-ai-video-pipelineSkill
- local-flux-mflux-image-genSkill
- local-llm-slow-diagnosisSkill
- local-music-generationSkill
- lottie-skottie-authoring-pitfallsSkill
- machine-wide-api-ratelimit-latchSkill
- macos-hook-path-timeoutSkill
- md-to-docx-reportSkill
- memory-md-inject-bloat-auditSkill
- message-display-secrets-maskSkill
- metric-source-attributionSkill
- migrate-icloud-desktop-assetsSkill
- nextauth-local-e2e-sessionSkill
- nextjs-rsc-payload-slimSkill
- nothing-designSkill
- openclaw-ollama-setupSkill
- The first 60 shown.
The file
Files
背景
2026-08-09 hot.md 28h窓(71件)の横断診断結果: 何日も止まっていたレーンの真因が、ほぼ全部たった2つの手抜きだった。
| # | パターン | 症状 | 該当レーン例 |
| 1 | boolean の戻り値抜け | アクション成功なのに呼び出し元が失敗と判定 → ABORT連鎖 | social-autolike, note-autolike |
| 2 | document 全体を走査するセレクタ | 意図しない要素にヒット → クリック先間違い・NoSuchElement | ai-portraits/swim, tiktok-autopost |
Pitfall 1: boolean の戻り値抜け
症状
[ABORT] action returned falsy — skipping
[ABORT] 3回とも失敗スクリプト本体は正常終了しているのに、呼び出し元が if result: で falsy を受け取り失敗扱いにする。
原因パターン
# NG: return がない(None を返す)
def click_like_button(page):
page.click('.like-btn')
# ← return True がない
# NG: 最後の式が代入(値を返さない)
def check_logged_in(page):
status = page.is_visible('#user-icon')
# ← return status がない// NG: async 関数で return なし
async function performLike(page) {
await page.click('[data-testid="like"]');
// ← return true がない
}修正
# OK: 明示的 return
def click_like_button(page) -> bool:
try:
page.click('.like-btn')
return True
except Exception:
return False
def check_logged_in(page) -> bool:
return page.is_visible('#user-icon')// OK
async function performLike(page) {
await page.click('[data-testid="like"]');
return true;
}診断コマンド
# Python: return 抜けを疑うパターン検索
grep -n "def \(click\|check\|do\|run\|perform\|execute\)" TARGET.py | \
while IFS=: read file lineno rest; do
end=$((lineno + 15))
awk "NR>=$lineno && NR<=$end" "$file"
echo "---"
done
# 戻り値を使っているのに None の可能性
grep -n "if.*result\|if not result\|return.*action\|result = " TARGET.pyPitfall 2: document 全体を走査するセレクタ
症状
[ERROR] ElementClickInterceptedException: element is not interactable
[ERROR] clicked wrong element — expected modal button, got header button
[WARN] multiple elements match, using first「ボタンをクリックしたはずが別のボタンを押していた」「モーダルの外の要素が先にヒットした」。
原因パターン
# NG: document 全体から最初にマッチした button
page.click('button.submit') # ← ページ内に複数ある場合は危険
page.find_element(By.CSS_SELECTOR, '.btn-primary') # ← どの .btn-primary?
# NG: テキストマッチも document全体
page.get_by_text('送信') # ← 同テキストが複数箇所にある// NG
const btn = document.querySelector('button[type="submit"]');
// ← フォームが複数あると最初のものにヒット修正:スコープを限定する
# OK: 親コンテナを先に特定してから検索
modal = page.locator('[role="dialog"]')
modal.get_by_role('button', name='送信').click() # modal内だけ検索
# OK: より具体的なセレクタ
page.click('#post-form button[type="submit"]')
# OK: nth-of-type / filter で絞り込み
page.locator('button.like-btn').filter(has_text='いいね').first().click()// OK: 親要素のコンテキストで検索
const form = document.getElementById('post-form');
const btn = form.querySelector('button[type="submit"]');診断コマンド
# Playwright: スコープなしの危険なセレクタパターンを検索
grep -n "page\.click\|page\.locator\|find_element" TARGET.py | \
grep -v "locator.*locator\|#\|nth\|filter\|within"
# 同じセレクタが複数ヒットするか確認(Playwright REPL)
# page.locator('button.submit').count() → 1 以外ならスコープ絞り必要診断チェックリスト(レーン ABORT 時に最初に確認)
□ 1. 失敗している関数/メソッドが bool を返しているか?
grep -n "def " SCRIPT.py | xargs ... (return True/False があるか)
□ 2. 呼び出し元が戻り値をどう扱っているか?
if result: / if not result: / assert result で受け取っていないか確認
□ 3. 使用セレクタのスコープは十分に限定されているか?
page.click('.btn') → page.click('#container .btn') 等に絞り込めるか
□ 4. 同セレクタで複数マッチが起きないか実行時に確認
count() / find_elements() の長さで多重マッチを検出
□ 5. DOM 構造が変化していないか(サイト改修)
同セレクタで headless-off モードで目視確認Pitfall 3(派生): async 関数の await 忘れ
boolean 抜けと同時に発生しやすい。
# NG: coroutine オブジェクトを返す(truthy だが実行されていない)
result = click_like_button(page) # async def だが await なし
if result: # coroutine object は常に truthy → 常に成功と誤認
...# OK
result = await click_like_button(page)関連スキル
- — 成功したように見えて失敗している全パターン
- — クールダウンフラグ stale による誤 ABORT
- — 同パターンの会話ログ処理フロー
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

