loop-mode

loop-mode is a skill for Claude Code, Codex from cjhyy/codeshell. It costs 80 tokens per session (1,248 once invoked), scanned A, original, MIT.

A long-running loop mode for CodeShell that carries out work in bounded rounds using saved state, separate worktrees, candidate branches, and review checkpoints. A worktree is an additional checkout of a Git repository.

In plain words
What is it for?
Use it for multi-round tasks, including attended work or unattended overnight runs, when each round needs a controlled handoff and possible review.
Why use it?
It lets work pause and resume without relying on one uninterrupted session, while keeping progress and review status recorded.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for multi-round tasks, including attended work or unattended overnight runs, when each round needs a controlled handoff and possible review.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cjhyy/codeshell/loop-mode
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cjhyy/codeshell --skill loop-mode
Clone the repo
git clone --depth 1 https://github.com/cjhyy/codeshell

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for loop-mode

README.md
[![agentmods](https://agentmods.dev/badge/skills/cjhyy/codeshell/loop-mode/github.svg)](https://agentmods.dev/skills/cjhyy/codeshell/loop-mode)
Your own site
<a href="https://agentmods.dev/skills/cjhyy/codeshell/loop-mode"><img src="https://agentmods.dev/badge/skills/cjhyy/codeshell/loop-mode/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for loop-mode

Your own site · 80×15
<a href="https://agentmods.dev/skills/cjhyy/codeshell/loop-mode"><img src="https://agentmods.dev/badge/skills/cjhyy/codeshell/loop-mode.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 80 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,248 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00080 $0.01248
Opus 5.5 $0.00032 $0.00499
Sonnet 5.5 $0.00016 $0.00250
Haiku 4.5 $0.00008 $0.00125

Measured 6d ago against content hash d7f8ff42eec6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

loop-mode scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/loop-state.mjs), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.code-shell/skills/loop-mode/SKILL.md · 65 lines

How it starts

The opening of the file, as written. The whole thing — 65 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Loop Mode

/loop 是独立的长时循环,不是 Goal 的别名。不得创建、更新、清除或借用 CodeShell Goal。循环靠“持久状态 + 有界轮次 + 下一次唤醒”续跑,不靠一个无限会话。

唯一入口

  • /loop <objective>:启动或继续一个 loop,并执行一个有界轮次。objective 含“夜间、无人、unattended”时使用 unattended;否则 attended。无人目标未给截止时间或最大轮数时,启动前只问这一个必要问题。
  • 裸 /loop:只读汇报当前 loop;没有 loop 时给出一句用法。
  • loop 启动后,用户在同一 Session 直接说“暂停、继续、停止、看状态、审查结果”。将这些自然语言解析为对当前 loop 的控制,不要要求用户记子命令。
  • 如果有多个非终态 loop 且指令对象不唯一,列出候选请用户选择,不要猜。

权威账本

先求主仓库绝对路径(git rev-parse --show-toplevel)。所有控制文件只在 <main-root>/.loop/<slug>/:

  • STATE.json:当前快照,单写者是协调者。
  • RUNS.jsonl:追加式事件。
  • ORCHESTRATION.md:角色、阶段、权限、闸门。
  • PLAN.md、LESSONS.md、HANDOFF.md:计划、精炼经验、收尾。
  • rounds/rNNN/:本轮 worker.md、review.md、validation.md 回执。

优先用本 skill 的状态脚本,不要手改 JSON:

node .code-shell/skills/loop-mode/scripts/loop-state.mjs init --root <main-root> --slug <slug> --objective <objective> --attendance attended|unattended --max-rounds <N>
node .code-shell/skills/loop-mode/scripts/loop-state.mjs transition --root <main-root> --slug <slug> --status ready|running|paused|waiting_review|completed|stopped|blocked --reason <text>
node .code-shell/skills/loop-mode/scripts/loop-state.mjs event --root <main-root> --slug <slug> --type <type> --message <text>
node .code-shell/skills/loop-mode/scripts/loop-state.mjs status --root <main-root> --slug <slug>

启动

  1. 从 objective 生成短 slug(小写英数加连字符),用脚本 init。
  2. 已有 ORCHESTRATION.md 就校验后沿用;否则用 loop-orchestration 的默认模板直接生成。attended 的重大角色/范围分歧再问,unattended 取最保守可行值。
  3. 建 loop/<slug>/candidate 候选分支,只将通过审查的提案合入它。永不自动 push 或合入 main。
  4. 一次 /loop 只运行一个有界轮次。若要长时续跑,在轮次收尾创建或更新 heartbeat/automation,下次读 STATE.json 再续。

单轮状态机

ready -> running -> validating -> reviewing -> ready|waiting_review|completed|blocked。

  1. 开始前检查 status、deadline、maxRounds 和用户待批项。paused/stopped/completed/blocked 不得派发。
  2. 从 candidate 建本轮分支 loop/<slug>/rNNN 和独立 worktree。不复用上轮 worktree。
  3. 派 executor 时给完整 objective、绝对账本路径、本轮验收、worktree 和分支。executor 只改代码并 commit,不写共享账本。
  4. 协调者记 worker.md并跑定向验证,记 validation.md。
  5. 派与 executor 不同的 reviewer 审 diff/测试,记 review.md。高风险变更不能 self-review。
  6. 验证和审查都通过才可合入 candidate;否则保留提案分支并进入下轮修复或 waiting_review。
  7. 协调者原子更新 STATE.json,追加事件,精炼 LESSONS.md,然后判断闸门。

Read the full file on GitHub · 65 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 65 lines · 80 tokens per session scan A d7f8ff42eec6

Subscribe to this mod's changes

loop-mode is a skill published in the GitHub repository cjhyy/codeshell (65 stars, last pushed 2d ago), licensed MIT. It adds 80 tokens to every session and 1,248 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-14.