选项

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 将自动检测并使用该技能。

相关技能

notion-automation
更新时间 2026-06-29
seo-programmatic
更新时间 2026-06-29
airtable-automation
更新时间 2026-06-29
fairdb-backup-manager
更新时间 2026-06-29
OR