一键导入
turn-cadence
Turn-cadence governor: enforces 7/10/35-turn escalation thresholds to prevent infinite loops and context rot.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Turn-cadence governor: enforces 7/10/35-turn escalation thresholds to prevent infinite loops and context rot.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Evidence-gated completion check. Use before committing, creating PRs, or claiming work is done. Pairs with verification-spec at task start.
Systematic knowledge extraction from open-source projects. Use when: user shares a repo/link to study, says 偷师/steal/学习/研究, or wants to analyze another project's patterns for adoption.
Launch a real interactive claude CLI session in a target directory (typically a worktree) with a pre-seeded prompt. Use when the current session cannot absorb the task context — e.g., N parallel worktree jobs that would blow the context window, or when you need the user to watch progress in a visible terminal. Each spawned session runs independently in its own Windows Terminal tab.
FileNotFound recovery protocol. Before reporting a missing-file error, suggest near-misses by basename similarity (difflib threshold 0.4) so typos and stale paths fail loudly with actionable hints.
Paste-by-reference guard for Edit calls. When new_string would echo >30 lines of existing file content, use {{file:path:start:end}} reference instead and expand before submission.
File-IO protocol for parent ↔ subagent communication. Parent writes input.txt + context.json, subagent appends to output.txt with [ROUND END] sentinels. Used with Monitor tool for live observation.
| name | turn-cadence |
| description | Turn-cadence governor: enforces 7/10/35-turn escalation thresholds to prevent infinite loops and context rot. |
You are a turn-cadence governor. Your job is to detect when an agent is looping, context-rotting, or exceeding safe turn budgets — and escalate accordingly. The hook fires at Stop events; the agent receives an injection and must respond to it within that turn.
The per-session turn counter is maintained in .claude/hooks/state/turn-${SESSION_ID}.txt. The turn-cadence-gate.sh Stop hook reads this file and fires the appropriate [DANGER] injection when a threshold is crossed.
| Turn | Trigger Condition | Injected Message |
|---|---|---|
| 7 (and every 7th thereafter) | turn % 7 == 0 | [DANGER: TURN N] 禁止无效重试——切换策略或换工具。 |
| 10 (and every 10th thereafter) | turn % 10 == 0 | [DANGER: TURN N] 重新读取 boot.md 和当前任务 SKILL.md,更新 working memory。 |
| 35 (and every 35th thereafter) | turn % 35 == 0 | [DANGER: TURN N] 必须调用 ask_user 报告当前状态后才能继续。 |
Priority: Turn 35 > Turn 10 > Turn 7 when multiple thresholds coincide (e.g., turn 70 triggers the Turn 35 message).
For long-running plan or debug tasks:
| Turn | Trigger | Action |
|---|---|---|
| 70 | turn % 70 == 0 | Checkpoint report — agent MUST write a status summary to tmp/checkpoint-${TASK_ID}.md before continuing |
When the hook fires, the agent receives an injected block:
[DANGER: TURN 7] 禁止无效重试——切换策略或换工具。
[DANGER: TURN 10] 重新读取 boot.md 和当前任务 SKILL.md,更新 working memory。
[DANGER: TURN 35] 必须调用 ask_user 报告当前状态后才能继续。
The agent MUST acknowledge and act on the [DANGER] injection within the same turn it appears. Ignoring a [DANGER] block is a protocol violation.
boot.md and any relevant SKILL.md — not just acknowledge the warning.ask_user or equivalent channel before any further action.turn-counter.sh PostToolUse hook increments on every tool call. The count persists per session.constraints/hard-escalation.md override all prompt-level overrides.