TL;DR: /loop 5m /check-deploys 每隔 5 分钟在当前会话中运行一次提示词。/schedule 则创建一个 cron 风格的远程例程,在你离线时也能在 Anthropic 的基础设施上持续运行。本地轮询用 /loop,后台任务用 /schedule。
LingCode 提供两种看起来相似但功能截然不同的定时工具。/loop 在本地按间隔运行——"每 5 分钟检查一次部署状态"。/schedule 以远程例程方式按 cron 计划运行——"每天早上 8 点,回顾昨晚的 PR"。选错工具会导致白白消耗本地会话上下文,或为不需要的云端计算付费。
"反复运行提示词"其实是两种截然不同的需求,只是表面看起来一样:
/loop。/schedule。混淆这两者代价高昂。在笔记本上运行的定时任务一旦合盖就会中断。在云端运行的轮询任务,当你坐在电脑前盯着它时,还在不停地计费。
/loop 在当前 LingCode 会话内,按固定间隔反复运行某个提示词或斜杠命令。会话保持打开状态,任务在本地执行。
# 每 5 分钟运行一次 /check-deploy
/loop 5m /check-deploy
# 每 30 秒运行一次自由格式提示词
/loop 30s Check if the test suite is still green and ping me if not.
# 自适应节奏——由 LingCode 根据上下文决定何时重新运行
/loop /watch-the-CI-and-summarize
你能得到什么:
/loop /foo 让 LingCode 自行把握节奏——它会在判断有必要时重新运行,而不是按固定时钟触发。适合"持续监视直到完成"这类任务,固定频率轮询在这里反而是浪费。
/schedule 创建一个按 cron 计划运行的远程例程。它在 LingCode 的服务器上执行,而非你的本机。你的笔记本可以关机;例程照常触发。
# 每个工作日早上 8 点运行一次例程
/schedule create "Morning PR triage" "0 8 * * 1-5" \
"Review every PR opened in the last 24h. Post a summary to
#engineering in Slack with: count, blockers, anything that
looks urgent."
# 一次性定时运行
/schedule once "2026-05-25 09:00" \
"Email me a summary of last week's customer support tickets."
# 列出、更新、删除
/schedule list
/schedule run <id> # 立即手动触发
/schedule delete <id>
你能得到什么:
/loop 搞混,设置成每 30 秒触发一次,费用会相当可观。三个问题决定选择:
/loop 就够了。如果不需要(必须在我离线时运行),选 /schedule。/loop。如果不需要(数据来自 API、Slack、邮件、云端),/schedule 更合适。/loop——为亚分钟级别的计划任务付云端费用得不偿失。如果每天只运行几次或更少,用 /schedule——为了一天触发一次而让本地循环跑 24 小时,同样是另一种浪费。/loop 5m 才是正确选择——合上笔记本就自动停止,这正是期望的行为。/schedule 会在凌晨 2 点也触发,而那时你根本不在意。
你正在通过功能开关发布一个新特性,希望 LingCode 在你做其他事情的时候帮你盯着发布监控面板:
/loop 2m Check the error rate on the dashboard.json file in
this repo (re-fetched by my polling script). If the 5xx rate
goes above 1%, immediately alert me with the failing endpoint.
Otherwise summarize the trend in one sentence.
这是正确的工具,因为:
dashboard.json)——需要文件系统访问权限。你希望在每天喝咖啡开始工作前,就在 Slack 里看到一份隔夜新增 PR 的汇总:
/schedule create "Morning PR digest" "0 8 * * 1-5" \
"List all PRs opened in the org repo between 6pm yesterday and
8am today. For each, summarize: title, author, files touched,
reviewers requested, whether CI is green. Post the digest to
#engineering. If any PR is from an external contributor, flag
it at the top."
这是正确的工具,因为:
/schedule run <id> 手动测试一次例程。
这两个工具可以配合使用。以下是一种适用于生产环境监控的模式:
/loop 1m——本地运行,响应快,监控部署状态,发现问题立即告警。合上笔记本就自动停止。/schedule——远程运行,生成一份"今日部署"报告发送到团队频道。无论你白天是否在监控,报告都会准时到达。循环负责实时捕捉问题;计划任务负责生成你明天会读到的报告。两者关注不同的时间窗口。
配置混淆往往在清理环节才暴露出账单上的惊喜:
/schedule list 查看你的例程,再用 /schedule delete <id> 删除。例程会持续触发直到被删除。一个被遗忘的例程每 5 分钟触发一次,一个月下来账单会相当可观。/schedule list,删除任何你不认识或不再需要的例程。定时云端计算是最容易被忽视的成本泄漏来源。
将选择逻辑封装为一个技能,让 LingCode 第一次就能选对工具:
---
name: schedule-or-loop
description: Run a prompt or slash command on a recurring schedule. Two distinct tools: /loop runs locally on an interval, session-bound, fast cadence ('check the deploy every 5 minutes'). /schedule runs as a remote cron-style routine, persistent, survives laptop close ('every morning at 8am, review overnight PRs'). Triggers: 'recurring task', 'check every N minutes', 'cron job for Claude Code', 'run on a schedule', 'daily routine', 'while I'm asleep', 'set up reminder'. Actions: /loop for in-session polling, /schedule for cloud-cron tasks, list/run/delete routines. Pick by: session-bound vs survives-laptop-closed, fast-iteration vs persistent-recurring.
---
When the user asks to run a prompt repeatedly, decide between
/loop and /schedule with three questions:
1. Does the task need to keep running while the user is offline /
laptop closed? If yes → /schedule. If no → /loop is fine.
2. Does the task need local files or git state? If yes → /loop.
If no (data lives in APIs, Slack, email) → /schedule is
cleaner.
3. How often? Sub-minute or every few minutes → /loop. Once a day
or less → /schedule. Anything in between, pick by question 1.
/loop usage:
- /loop <interval> <prompt-or-slash-command>
- /loop <prompt> (no interval = self-paced)
- Shares session: same files, same chat history.
- Stops on session close or "stop the loop".
/schedule usage:
- /schedule create "<name>" "<cron>" "<prompt>"
- /schedule once "<datetime>" "<prompt>"
- /schedule list / run <id> / delete <id>
- Each run is a fresh context. No file access, no session
history. Self-contained prompts only.
- Test with /schedule run <id> before trusting the schedule.
Audit routines periodically with /schedule list. Forgotten
routines are the easiest cloud cost to leak.
保存到 ~/.lingcode/skills/schedule-or-loop/SKILL.md——具体路径和技能发现机制请参见安装技能。