machine-wide-api-ratelimit-latch
Skill0 starsChanged 5 months agoMITView on GitHub
同一マシン/同一IPで多数の launchd ジョブが同じ外部 private API を叩き、1本が 429 を見ても他が撃ち続けてスロットルを自分で延命する構造を、blockedUntil を1ファイルで共有するラッチで止める手順(social-autolike の state/ig-api-ratelimit.json が実例)。
In this repository99 other files it gives its agents.
- agents-tools-quoted-jsonSkill
- asc-api-app-store-submitSkill
- asd-ste100Skill
- automation-bool-selector-pitfallsSkill
- 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
- 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
症状
logs/*.logの API 失敗行(例igApiFail)が 1日数百件・全部 status 429、bodyHead は「ログイン済み HTML の殻」=Cookie は生きている- 既存の防御が プロセス内変数の streak かレーン別 state で、run のたびにゼロから撃ち直す
- 複数アカウントが同じ日に順次 429(同一IP でまとめて絞られている)
手順(実装30分・6ファイル程度)
src/<api>-ratelimit.jsを新規:{blockedUntil, openedAt, lastStatus, lastUrl, source, hits, lastNotifyAt}を tmp→rename で原子的に読み書き。export はisXCooldownActive(now)/openXCooldown({source,status,url}, now)(初回90分・窓内再検知で残り×1.5・上限6h)/describeXCooldown()(既存の『rate-limit cooldown中 -> ISO まで…』文言に揃える)/xRateLimitError()(e.code='<api>-rate-limit')。state パスは env で差し替え可にし、呼び出し時に env を読む(ESM の import hoist 対策)。- 低レベルの HTTP 経路すべて(page.evaluate 版と request.get 版の両方)で「先頭で active なら撃たない」「429 を見たら open」。
res.status()を必ず見る(本文が JSON でないだけの判定は 429 を取りこぼす)。 - 各エントリポイントは Chrome 起動前に gate → exit 0(launchd を赤にしない)。致命エラー catch で
e.codeを見て exit 0 に分岐。Discord はlastNotifyAtで24hに1回。 - テストの落とし穴: 429 をモックする既存テストが本番 state へ書き 90 分本番を止める。既存テストの先頭でも env を tmp へ向け、
node --test後にls state/<file>で「存在しない」ことを確認する。test/index.jsに import 登録しないとnode --test test/に拾われない。 - 検証は
launchctl kickstart -k→last exit code = 0と新規ログ行の grep(完了 or cooldown中)で実測。
関連
- (窓が長すぎて陳腐化する逆パターン。上限6h と期限切れ後の再オープンで両立)
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.

