選項

stay-within-limits

BuilderIO/skills BuilderIO/skills

透過在輪次之間檢查使用情況、在接近上限時暫停,並在視窗清空時恢復,將長期執行的智慧體工作保持在5小時和每週使用限制內。

...展開全部
0
更新時間 2026-09-06

保持在限制範圍內

將長時間執行的智慧體工作限制在當前 5 小時和每週使用視窗內。在啟動大量工作以及並行子智慧體波次之間,檢查使用情況。如果當前的 5 小時或每週限制已達到或超過 95%,請暫停新工作,直到視窗足夠清晰以安全繼續。

核心迴圈

  1. 執行有界的工作波次。除非使用者或主機提供不同的節流設定,否則預設最多使用 3 個並行子智慧體。
  2. 等待波次完成。不要為了節省預算而中斷正在進行的子智慧體;這通常會導致工作丟失。
  3. 使用主機的 usage/budget 工具檢查當前的 5 小時和每週使用情況。
  4. 如果任一視窗達到或超過 95%,停止啟動新工作,並安排一個自包含的恢復計劃,以便在相關視窗清除時繼續。
  5. 恢復時,在繼續之前重新檢查實際視窗或限制塊。不要僅信任經過的牆鍾時間。

使用訊號

當有官方主機使用工具時,優先使用。在 Claude Code 中,使用:

npx -y ccusage@latest blocks --active --json

使用 JSON 識別活動塊的開始時間、當前成本或百分比以及剩餘時間。喚醒時,將活動塊的開始時間戳與之前的時間戳進行比較;新的時間戳比“經過足夠時間”更具說服力。

如果工具報告的是成本而非直接百分比,請在已知當前賬戶限制的情況下進行轉換。對於 Claude Max 風格的 5 小時塊,部分使用者傾向於在 500-550 美元左右設定較早的警告閾值;將其視為使用者配置的護欄,而非通用規則。預設停止規則仍然是當前 5 小時或每週限制的 95%。

暫停與恢復

當有 wake/resume 工具可用時,安排喚醒時間為:

min(3600, secondsUntilWindowClears)

如果執行時將喚醒延遲限制在 60-3600 秒之間,請為更長的等待時間連結喚醒。每次喚醒都應重新檢查使用情況,如果仍在預算之外則重新安排,並在視窗安全低於閾值時繼續。

使喚醒提示自包含。包括:

  • 剩餘計劃。
  • 檢查後重新安排規則。
  • 95% 閾值和波次節流。
  • 要執行的確切使用命令或主機使用工具。
  • 可用的前一個塊/視窗識別符號。
  • 下一步驗證步驟。
  • 如果委託將恢復,包括範圍、驗證命令和停止條件的下一波次交接資料包。

選擇等待機制

  • 當智慧體需要在未來恢復時附帶指令時,使用 wake/resume 工具。
  • 對於固定計時器和程序可以直接觀察到的事物,使用後臺睡眠或監視器。
  • 僅對重複的新會話工作使用 cron 或定期計劃。

避免對主機會通知你的事項(如後臺任務或子智慧體完成)進行短間隔輪詢。對於預算暫停,長時間睡眠後的提示快取未命中是可以接受的;保持限制更為重要。

報告

如果你暫停,請告訴使用者哪個視窗超過閾值、觀察到的使用情況、你安排或預計下次檢查的時間,以及剩餘的工作。在喚醒提示中保留足夠的狀態,以便下一輪可以恢復,而無需依賴對話勢頭。

在 GitHub 上查看
---
name: stay-within-limits
description: Keep long-running agent work within 5-hour and weekly usage limits by checking usage between waves, pausing near the cap, and resuming only when the window is clear.
---

# Stay Within Limits

Keep long-running agent work inside the current 5-hour and weekly usage windows.
Check usage before launching substantial work and between waves of parallel
subagents. If an active 5-hour or weekly limit is at or above 95%, pause new
work until the window is clear enough to continue safely.

## Core Loop

1. Run a bounded wave of work. Default to at most 3 parallel subagents unless
   the user or host gives a different throttle.
2. Wait for the wave to finish. Do not interrupt in-flight subagents just to
   save budget; that usually loses work.
3. Check current 5-hour and weekly usage with the host's usage/budget tool.
4. If either window is at or above 95%, stop launching work and schedule a
   self-contained resume when the relevant window should clear.
5. On resume, re-check the real window or block before continuing. Do not trust
   elapsed wall-clock time alone.

## Usage Signals

Prefer a first-party host usage tool when available. In Claude Code, use:

```sh
npx -y ccusage@latest blocks --active --json
```

Use the JSON to identify the active block start, current cost or percentage, and
time remaining. On wake, compare the active block start timestamp with the
previous one; a new timestamp is stronger evidence than "enough time passed."

If the tool reports cost instead of a direct percentage, convert through the
current account limit when known. For Claude Max-style 5-hour blocks, some users
prefer an earlier caution threshold around $500-550; treat that as a
user-configured guardrail, not a universal rule. The default stop rule is still
95% of the active 5-hour or weekly limit.

## Pausing And Resuming

When a wake/resume tool is available, schedule a wakeup for:

```txt
min(3600, secondsUntilWindowClears)
```

If the runtime clamps wake delays to 60-3600 seconds, chain wakeups for longer
waits. Each wakeup should re-check usage, reschedule if still over budget, and
continue only when the window is safely below the threshold.

Make wake prompts self-contained. Include:

- The remaining plan.
- The check-then-reschedule rule.
- The 95% threshold and wave throttle.
- The exact usage command or host usage tool to run.
- The previous block/window identifier when available.
- The next verification steps.
- The next wave's handoff packets, including scope, verification commands, and
  stop conditions, if delegation will resume.

## Choosing The Wait Mechanism

- Use a wake/resume tool when the agent needs instructions attached to the
  future resume.
- Use a background sleep or watcher for fixed timers and things a process can
  observe directly.
- Use cron or recurring schedules only for recurring fresh-session work.

Avoid short-interval polling for things the host will notify you about, such as
background task or subagent completion. For budget pauses, a prompt-cache miss
after a long sleep is acceptable; preserving the limit matters more.

## Reporting

If you pause, tell the user which window is over threshold, the observed usage,
when you scheduled or expect the next check, and what work remains. Keep enough
state in the wake prompt that the next turn can resume without relying on
conversation momentum.

所有檔案

0 個檔案

安裝 stay-within-limits

將技能檔案下載並解壓至你的 .claude/skills/ 目錄。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/BuilderIO/skills/tree/main/skills/stay-within-limits # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/ 目錄。Claude 將自動檢測並使用該技能。
儲存庫 BuilderIO/skills

相關技能

notion-automation
更新時間 2026-06-29
seo-programmatic
更新時間 2026-06-29
airtable-automation
更新時間 2026-06-29
revops
更新時間 2026-06-29
OR