loop
Repeatedly execute a task — on a fixed time interval, or until an exit condition holds. Re-prints the task/exit banner each cycle so the loop does not collapse. Use for watch-style polling or iterate-until-clean loops.
- License 许可
- MIT
- 所属仓库
- kfet/fir
- 最近更新
- 2026-11-13
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- loop
- builtin
- true
- override
- true
- description
- Repeatedly execute a task — on a fixed time interval, or until an exit condition holds. Re-prints the task/exit banner each cycle so the loop does not collapse. Use for watch-style polling or iterate-until-clean loops.
03 SKILL.md 正文
Loop Skill
You execute a task on repeat. Two modes:
- interval — repeat every N seconds until told to stop.
- condition — repeat until an exit predicate holds.
Why the per-cycle banner is mandatory
A loop stated once, at the top, decays as cycles append output: the original
instruction sits far back, recent tokens dominate attention, and the
locally-coherent continuation becomes "summarise and conclude" instead of
"loop again". You counter this by emitting the loop invariant through a bash
call every cycle — placing it at a recent position, behind a hard turn
boundary, as external-looking output. This is not optional flavour; it is the
mechanism that keeps the loop alive.
Setup (first run only)
Establish, asking the user only for what is missing:
- Task — what to run each cycle.
- Mode — interval or condition.
- Interval (interval mode) — seconds between cycles (default 30).
- Exit predicate (condition mode) — the exact condition that ends the loop, stated so it can be evaluated objectively.
- Banner slugs (optional) — short keywords pointing back to the fuller task definition (e.g. another skill's section headings). Re-emitted each cycle as attention anchors; do not restate the full task content in the banner.
Then begin immediately.
Cycle — interval mode
- Print the banner (plain code block, survives session timeout):
Next reminder command: sleep <N> && echo "=== LOOP CYCLE <N+1> === Task: <task>. Slugs: <slugs>" - Execute the task fully — no truncation, no skipped steps.
- Report one line:
Cycle N complete: <summary>. - Run the reminder command with a bash timeout of
<N + 10>s:
On seeing the output, return to step 1.sleep <N> && echo "=== LOOP CYCLE <N+1> === Task: <task>. Slugs: <slugs>"
Cycle — condition mode
No sleep. The banner alone re-grounds the loop, so its content carries the load.
- Print the banner via bash, with the exit predicate stated in full and
the cycle counter incremented:
echo "=== LOOP CYCLE <N> === Task slugs: <slugs> EXIT ONLY IF: <exit predicate, in full>. Otherwise run another cycle." - Execute the task fully.
- Re-print the banner (same bash echo) immediately before deciding — the moment right after a cycle looks done is when premature exit happens, so the predicate must be the most salient recent text.
- Evaluate the exit predicate. If it holds, exit and report. Otherwise increment N and return to step 1.
Rules
- Carry the task verbatim. Never paraphrase or simplify it between cycles.
- Exit predicate in full; task as slugs. The predicate is what collapses, so restate it fully each cycle. Slugs only point at the task definition.
- Report every cycle, even if the outcome is "nothing changed".
- Adjust on request — interval changes or predicate clarifications apply from the next cycle.
04 同仓库更多 Skills
wt
Spawn a fresh fir agent in its own tmux session on its own git worktree. Use whenever the user wants the work — or the conversation about the work — to happen over there, not here. If the user points at this skill, or has directly loaded it in the context, that alone is the cue — spawn, don't inline.
wrap-up
Wrap up work on a project branch — review, fix, and simplify in a loop until clean, then ff-merge to main.
tmux-observer
Attach a tmux window to an already-running fir session — observe its transcript and drive its input via tmux send-keys. Use when you need to watch or steer another fir agent.
tmux-driver
Drive interactive CLIs (python, gdb, etc.) via named tmux sessions with multi-window support. Falls back to fir's built-in PTY driver when tmux is unavailable.
telegram-bot-setup
Set up a new Telegram bot channel for a fir project — install the telegram MCP, create a per-project state dir, drop in the bot token, wire .fir/mcp.json with TELEGRAM_STATE_DIR, pair the user, and verify. Use when the user asks to add, configure, or onboard a Telegram bot for a fir worktree/project.
sync
Sync with an upstream source repo — detect changed files, apply equivalent downstream edits, update the baseline, and report any new features or non-trivial changes picked up.