لوگوی اسکیلیکس اسکیلیکس | Skilliks آکادمی و استودیوی ابزارهای AI تاریخ شمسی… --:--:--

Running agent loops

آزاد تازه‌وارد تاییدشده امن

چک‌لیست و روند کار تخصصی در حوزهٔ کیفیت کد و تست برای گرفتن نتیجهٔ دقیق و قابل اتکا. (شامل ۱۵ گام عملی · سازگار با Claude Code).

سازگاری با ابزارها: این Skill به مسیر/قابلیت اختصاصی Claude Code وابسته است. مشاهدهٔ جدول سازگاری

متن دستورالعمل (SKILL.md)

دسترسی کامل فعال است
---
name: running-agent-loops
description: Run a multi-step or unattended agent loop safely — sequential pipelines, implement→review→fix (PR) loops, parallel fan-out, and RFC→DAG orchestration. Use when the user wants to "loop", "run autonomously", "iterate until it's done", chain `claude -p` calls, fan out parallel agents on a spec, or set up an implement→verify→commit cycle. Covers the cross-iteration context bridge and the de-sloppify pass. Not for a single one-shot task.
license: MIT
---

# Running agent loops

Patterns for driving work across **many steps or iterations** — possibly unattended — without the run drifting, looping, or shipping slop. The core trade is **isolation vs. continuity**: a fresh context per step avoids bleed, but you must deliberately carry forward what matters.

## Read first (always)

List `learnings/` and read anything relevant. Project-specific loop conventions, budgets, and stop signals live there and override this file.

## Principles (apply to every loop)

- **Fresh context per step beats one long context.** Each `claude -p` / subagent call starts clean — no bleed, no drift. The cost: it forgets. Bridge it deliberately (below).
- **The reviewer is never the author.** Put review/verify in a separate step/context so it isn't anchored to the implementation.
- **Two focused passes beat one constrained pass.** Don't pile negative instructions onto the implementer — add a separate **de-sloppify** pass (below). Quality from constraints decays; quality from a dedicated cleanup step doesn't.
- **Every loop has an explicit stop condition.** Bound it by max-runs, max-cost, max-duration, or a completion signal — never "until it feels done".
- **Review findings live in a ledger the implementer can't silently close.** Every finding a review step raises is recorded with its severity and a status: `fixed` (re-verified against the new code by the reviewer), `waived` (by the user, for that finding), or `open`. The loop does not finish with an open Blocker or an open Important finding that has a concrete fix; turning one into an "accepted cost" in a PR description, comment, or commit message needs the user's approval first (`reviewing-code` → Self-review and agent loops).
- **The orchestrator reads the ledger, not just the summary.** Before reporting success, read every finding the implementer left unfixed and challenge each one; the final report lists them under `## Unresolved findings` (stated as empty when it is). A PR body is not where an unfixed finding gets reported.
- **Match review depth to risk.** Concurrency, locks, transactions, migrations, startup sweeps, auth, and money get the deep tier (`reviewing-code/references/context-sweep.md`): the full context sweep and test-evidence checks, a fresh-context reviewer, and any automated reviewer at its high effort level or above.

## The patterns (pick the simplest that fits)

| Pattern | Use when | Shape |
|---|---|---|
| **Sequential pipeline** | A known series of steps on one unit of work | implement → de-sloppify → verify → commit, each a fresh context |
| **PR loop** | Iterate a branch toward green | branch → implement → review → fix → run checks → repeat until checks pass or budget hits |
| **Parallel fan-out** | N independent variations/units of the same spec | an orchestrator **assigns** each agent a distinct direction + index (don't rely on agents to self-differentiate); run in waves of 3–5 |
| **RFC → DAG** | A large feature with dependencies | decompose into work units + a dependency DAG; run each in an isolated worktree; land via a merge queue; deeper review tier for riskier units |

## The cross-iteration context bridge

Independent steps lose memory. Persist a single **`SHARED_TASK_NOTES.md`** (or the project's plan file): the agent **reads it at the start of each iteration and updates it at the end** — current objective, what's done, what's next, decisions, and gotchas. This is what turns isolated calls into a coherent run.

## The de-sloppify pass

After each implement step, run a **dedicated cleanup pass** (separate agent/context) whose only job is to remove slop: dead code, stray comments, debug prints, half-finished branches, inconsistent naming, over-engineering. Keep it separate from the implementer so neither job is diluted. The pass is bounded: it removes slop from lines the step added and never redesigns, renames, or expands the step's scope (catalog and procedure: `guarding-scope/references/slop.md`). Check every step against the **original** contract, not the previous step's output — drift compounds across iterations.
<!-- ‹guest · 2026-11-29› -->

## Safety before you launch an unattended loop

- Baseline **tests pass** before iteration 1.
- An explicit **stop condition** and a **budget** (runs / cost / time).
- **Rollback** ready: work on a branch or in a worktree, commit per green step.
- **Checkpoints** so you can diff now-vs-then.
- **Escalate to the human** when: no progress across two consecutive checkpoints, the same error/stack repeats, the diff drifts off-objective, or the budget is exceeded. Stalling silently is the failure mode.

If a loop is wedged (looping, repeating an identical failed action, burning budget), switch to `skills/debugging-agent-runs`.

## Capture a learning

If you hit a loop convention, stop-signal, or trap not covered here, append a `learnings/YYYY-MM-DD-slug.md` (or use `/learn`).

## See also

- `/dual-review` command — the adversarial two-reviewer convergence step for a PR loop.
- `skills/debugging-agent-runs` — recover a wedged run.
- `skills/reviewing-code`, `skills/writing-pull-requests` — the review/PR steps a loop calls.

این نسخه با نشانه‌گذاری اختصاصی حساب شما نمایش داده می‌شود. برای نصب سریع، به تب نصب و راه‌اندازی بروید.

مهارت‌های مشابه و پیشنهادی

مشاهدهٔ همه ←
کیفیت کد و تست
✦ Pro

REA CI and tests audit

«REA CI and tests audit» دستورالعمل دقیقی برای «نوشتن و اجرای تست خودکار» در اختیار دستیار هوش مصنوعی می‌گذارد تا نتیجه…

⚡ /rea-ci-tests-audit SKILL.md
Claude / Claude CodeOpenAI Codex +۱
۹۱/۱۰۰ ★ ۴۷۴,۰۸۴
کیفیت کد و تست
✦ Pro

Finishing a Development Branch

این مهارت با نام «Finishing a Development Branch» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی …

⚡ /finishing-a-development-branch SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Code Review Reception

اگر روی کیفیت کد و تست کار می‌کنید، «Code Review Reception» بخشی از کار را از دوش شما برمی‌دارد: «بازنویسی و تمیزسازی ک…

⚡ /receiving-code-review SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Requesting Code Review

برای کارهای کیفیت کد و تست، «Requesting Code Review» یک راهنمای کوتاه و روشن است: مسیر «مدیریت هوشمند حافظه و کانتکست» …

⚡ /requesting-code-review SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Test-Driven Development (TDD)

این مهارت با نام «Test-Driven Development (TDD)» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی ا…

⚡ /test-driven-development SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Skill Creator

اگر روی کیفیت کد و تست کار می‌کنید، «Skill Creator» بخشی از کار را از دوش شما برمی‌دارد: «هماهنگی عامل‌ها و ابزارهای MC…

⚡ /skill-creator SKILL.md
Claude / Claude Code
۹۲/۱۰۰ ★ ۱۹۸,۷۹۴