بنقرة واحدة
forge-loop
Use when work needs an explicit delivery contract, iterative repair, bounded autonomy, or resume-safe state
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use when work needs an explicit delivery contract, iterative repair, bounded autonomy, or resume-safe state
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when executing plans through specialized subagents with evidence-gated review loops
Use when a user asks to continue, resume, pick up prior loop work, or inspect previous loop state
Use when work needs codebase orientation, impact analysis, existing-pattern discovery, or risk scouting before planning or implementation
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Use when implementation direction depends on unresolved product/design choices, multiple viable approaches, or owner approval on a design.
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
| name | forge:loop |
| hidden | true |
| description | Use when work needs an explicit delivery contract, iterative repair, bounded autonomy, or resume-safe state |
Forge loop turns a request into a bounded engineering cycle with explicit state.
Core principle: a loop is not "keep trying". A loop has a contract, evidence, budget, checkpoints, and stop conditions.
Loops are autonomous by default. They should keep moving unless an owner-only decision or a real external blocker makes safe continuation impossible.
Start forge:loop when ANY are true:
Do not start a loop when ALL are true:
If unsure, start the loop and downgrade explicitly.
Before execution, establish this contract in your working context and persist it with
forge-check for non-trivial work:
Goal: <user outcome>
Scope:
- <what this iteration may change>
Non-goals:
- <what this iteration will not change>
Rubric:
- [ ] <objective acceptance criterion>
- [ ] <constraint, risk gate, or non-goal>
Budget:
- max_fix_iterations: 3
- used_fix_iterations: 0
- remaining_fix_iterations: 3
Stop conditions: pass | blocked | budget_exhausted | owner_decision_required
Rubric items must be verifiable by command output, file evidence, reviewer verdicts, screenshots, logs, or explicit owner approval.
When the loop contract is established, record forge-event event="forge.loop.started" with the goal, mode, and current stage. Keep full rubric details in forge-check, not in event metadata.
Forge may select an outer Goal route when the user requests bounded autonomous
advancement or the task's safe complexity warrants multiple milestones. Goal is
not a new OpenCode agent mode and must reuse this Loop contract:
mode: loop and the existing current_stage values (discover, plan,
execute, verify, iterate, ship).route: goal, autonomy_policy, and max_goal_steps fields to the
structured checkpoint details when the outer Goal policy must survive a resume.max_fix_iterations for verification repair; max_goal_steps bounds
milestone advancement and must never imply unbounded background execution.mode: goal or current_stage: goal; those values are not part of
the OpenCode/Forge Loop checkpoint schema.forge:verify, strategy-change, and stop
conditions defined below.When the user asks for route selection, a loop contract, or approval before any modification:
forge:ask rules allow autonomous continuationThis applies even when the truthful route is clearly Loop.
skill("forge:discovery") for non-trivial work, or record why it was skipped.skill("forge:plan") when multiple tasks or milestones exist.skill("forge:subagent"), skill("forge:tdd"), skill("forge:debug"), or direct work for trivial cases.Reviewer subagent (and Guard for security work). Fix issues found. Re-review until clean. Self-review is NOT sufficient.skill("forge:verify"); verdict must be pass, fail, or blocked. Evidence from executed commands, not code inspection.pass ships; fail creates the next iteration prompt; blocked asks or stops.A loop stops ONLY when one of these is true. If none are true, the loop MUST auto-advance to the next task/milestone in the same turn.
| Condition | Action |
|---|---|
All rubric items pass (ship-ready) | Ship → report → merge → reflect |
Fix budget exhausted (used >= max) | Stop thrashing → forge:ask or budget_exhausted → reflect |
| External blocker (missing dep, permission, env) | forge:ask with concrete blocker + options |
| Irreversible owner-only decision required | forge:ask with the single highest-priority decision |
| User pressed Esc / aborted | Pause — wait for user direction |
NOT a stop condition:
If no user is available, all forge:ask stop conditions resolve to: pick the smallest safe in-scope option, record the assumption, and continue.
When verification fails:
used_fix_iterations.forge-event event="forge.strategy.changed" with the changed variable and short reason.forge-event event="forge.iteration.started" for the new pass.Do not repeat the same failed strategy with the same evidence.
If used_fix_iterations >= max_fix_iterations:
forge:ask, downgrade scope, or stop with budget_exhaustedforge:reflect when the loop closesforge:brainstorm before execute.forge:ask is a decision protocol, not an automatic human-blocking pause. If no owner is available and the choice is reversible, in-scope, and low-risk, choose the smallest safe option, record it in the contract/checkpoint, and continue.owner_decision_required only for irreversible, high-risk, or out-of-scope decisions that cannot be safely auto-resolved.forge-check is the durable loop memory. Use it at minimum for:
loop-start — when the contract is establisheddiscovery-complete — after forge:discovery finishes (update current_stage: plan)plan-complete — after forge:plan finishes (update current_stage: execute)verify-failed — with failure evidence and strategy changeiteration-N — with updated rubric statusesship-ready — when all rubric items passAt the same stage transitions, emit concise forge-event entries: forge.loop.started, forge.iteration.started, forge.blocked, or forge.ship.ready. forge-check stores state; forge-event stores the timeline.
Critical: Always update current_stage in the checkpoint JSON when transitioning between discover → plan → execute → verify → ship. The TUI sidebar reads current_stage to show real-time progress. If you only write loop-start and never update current_stage, the sidebar will appear stuck at the initial stage even while work is progressing.
Checkpoint schema:
{
"stage": "loop-start | iteration-N | verify-failed | ship-ready",
"mode": "direct-downgraded | structured | loop",
"goal": "<user outcome>",
"scope": ["<allowed change area>"],
"non_goals": ["<not changing>"],
"rubric": [
{
"id": "R1",
"text": "<criterion>",
"status": "pending | pass | fail | blocked | out-of-scope",
"evidence": "<command/reviewer/file:line>"
}
],
"discovery": {
"depth": "D0 | D1 | D2",
"files": ["<path>"],
"impact_surface": ["<caller/contract/test/doc>"],
"risk": "low | medium | high"
},
"budget": {
"max_fix_iterations": 3,
"used_fix_iterations": 0,
"remaining_fix_iterations": 3
},
"current_stage": "discover | plan | execute | verify | iterate | ship",
"current_task": "<what is being done now>",
"next_action": "ship | iterate | ask | block | downgrade",
"last_failure": "<why the previous pass failed>",
"strategy_change": "<what changed this pass>",
"blockers": ["<reason>"],
"residual_risks": ["<risk>"]
}
Do not rely on chat memory for any field another session will need.
forge-check is the engine-internal state. The project-visible trace lives in
the plan file's ## Loop Trace section (see forge:plan's "Living Plan Document"
contract). Write one line to the plan file at every stage transition:
loop-start — when the loop contract is established (before any execution)iteration-N — when a verify fails and a new strategy pass begins (include the
failure reason and the strategy change)verify-failed — same as iteration-N if you prefer this labelship-ready — when the rubric passes (include residual risks)Format:
- <ISO-8601 timestamp> — <stage> — <one-line summary>
Why both forge-check and the plan trace:
forge-check (home dir, JSON) is for cross-session engine resume.## Loop Trace (project, markdown, committed) is for auditability and
forge:reflect.If the plan file is missing or read-only, fall back to forge-check only and state
the gap in your report.
If the user asks to continue or resume:
forge:resumeforge-checknext_actionWrite iteration prompts from evidence, not vibes:
Continue the loop for <goal>.
Failed rubric items:
- <item> — evidence: <command/reviewer/file output>
Preserve:
- <already passing items>
Constraints:
- stay within <scope>
- do not expand beyond <non-goals>
Strategy change this pass:
- <what is different now>
Required verification:
- <commands/review checks>
| Mistake | Fix |
|---|---|
| Starting implementation without a rubric | Define the loop contract first |
| Treating tests as the whole gate | Include requirements, review, and risk criteria |
| Asking "should I continue?" after a fail | Iterate automatically unless blocked |
| Repeating the same fix attempt | Change strategy based on failure evidence |
| Keeping state only in chat | Write forge-check checkpoints |
| Letting the loop run forever | Enforce budget and stop conditions |
skill("forge:brainstorm") when requirements are ambiguousskill("forge:discovery"), skill("forge:plan"), skill("forge:subagent"), skill("forge:tdd"), skill("forge:debug"), skill("forge:review"), skill("forge:parallel")skill("forge:verify")skill("forge:report"), skill("forge:merge"), skill("forge:reflect")If another skill has a stricter rule, follow the stricter rule.