AI Skills AI技能 1d ago Updated 1d ago 更新于 1天前 52

Stop Prompting And Start Looping. A Claude Code Engineer’s Guide to /goal and /loop 停止提示,开始循环。Claude Code 工程师的 /goal 和 /loop 指南

The `/goal` command introduces an autonomous verification loop where a secondary, faster model (defaulting to Haiku) evaluates whether a specific condition has been met, forcing the primary agent to provide demonstrable proof rather than self-assessment. The `/loop` command enables scheduled, unattended polling, allowing agents to execute tasks on a timer without human intervention, shifting the workflow from interactive prompting to asynchronous execution. This represents a paradigm shift from 提出“循环工程”范式,通过 `/goal` 和 `/loop` 命令取代传统提示词交互,实现AI代理的自主闭环工作。 `/goal` 利用双模型架构(主模型执行+轻量级评估器验证),强制AI提供可证明的完成证据而非主观声称。 `/loop` 基于定时器轮询机制,允许在用户离线时按预定计划自动运行提示词并监控状态。 核心技能从“编写提示词”转变为“定义精确的可验证终止条件”,解决AI自我评分导致的幻觉问题。

75
Hot 热度
80
Quality 质量
70
Impact 影响力

Analysis 深度分析

TL;DR

  • The /goal command introduces an autonomous verification loop where a secondary, faster model (defaulting to Haiku) evaluates whether a specific condition has been met, forcing the primary agent to provide demonstrable proof rather than self-assessment.
  • The /loop command enables scheduled, unattended polling, allowing agents to execute tasks on a timer without human intervention, shifting the workflow from interactive prompting to asynchronous execution.
  • This represents a paradigm shift from "prompt engineering" to "loop engineering," where the developer's role changes from writing individual prompts to defining precise finish lines and automated workflows.
  • Effective conditions require measurable end states, stated checks for verification, and explicit constraints to ensure the evaluator model can accurately judge success based solely on conversation history.

Why It Matters

This development marks a significant maturation in agentic AI workflows, moving beyond simple task execution to autonomous verification and scheduling. For practitioners, it reduces the cognitive load of "babysitting" agents by automating the quality control and completion detection processes, enabling truly hands-off operation for complex, multi-step tasks.

Technical Details

  • Dual-Model Architecture: /goal utilizes a two-model setup where the primary model performs actions and a separate, lightweight evaluator model (Haiku) judges the outcome. The evaluator is intentionally blind to the codebase, relying only on the conversation transcript to verify conditions.
  • Condition Specification: Successful goals require four components: a measurable end state, a stated check (how proof is demonstrated), constraints (what must not change), and optional limits (turns or time). Vague instructions like "improve the dashboard" fail, whereas specific checks like "pytest exits with code 0" succeed.
  • Command Interface: Users can set goals via /goal <condition>, check status with /goal, and clear them with /goal clear. It supports non-interactive runs via CLI flags like claude -p "/goal ..." and integrates with auto-mode for unattended execution.
  • System Requirements: Requires Claude Code v2.1.139+, acceptance of workspace trust dialogs for hook permissions, and is unavailable if hooks are disabled or restricted by managed settings.

Industry Insight

  • Shift in Developer Skills: The value proposition for AI developers is transitioning from crafting persuasive prompts to designing robust verification logic and system architectures. Proficiency in defining machine-verifiable conditions will become a critical skill.
  • Autonomous Operations: The combination of /goal and /loop enables the deployment of self-healing and self-maintaining AI agents in production environments, reducing operational overhead and allowing for continuous, unattended maintenance of codebases and systems.
  • Standardization of Agentic Workflows: As these tools mature, we may see the emergence of standardized patterns for "loop engineering," similar to current best practices in prompt engineering, focusing on reliability, verifiability, and fault tolerance in autonomous agent interactions.

TL;DR

  • 提出“循环工程”范式,通过 /goal/loop 命令取代传统提示词交互,实现AI代理的自主闭环工作。
  • /goal 利用双模型架构(主模型执行+轻量级评估器验证),强制AI提供可证明的完成证据而非主观声称。
  • /loop 基于定时器轮询机制,允许在用户离线时按预定计划自动运行提示词并监控状态。
  • 核心技能从“编写提示词”转变为“定义精确的可验证终止条件”,解决AI自我评分导致的幻觉问题。

为什么值得看

这篇文章标志着AI编程助手使用范式的根本性转变,从被动的人机协作转向主动的自主代理工作流。对于AI从业者和开发者而言,掌握如何设计可验证的目标条件和自动化循环,是提升开发效率、降低人工干预成本的关键技能。

技术解析

  • 双模型验证架构/goal 命令在会话中引入一个独立的轻量级评估模型(默认为Haiku),该模型不执行工具调用,仅根据对话历史中的证据判断目标是否达成,从而避免主模型“自问自答”。
  • 目标条件设计规范:有效的 /goal 条件必须包含四个要素:可衡量的最终状态、明确的检查方式(如运行测试并展示输出)、约束条件以及可选的时间/轮次限制,确保评估器能基于可见证据做出二元决策。
  • 自动化轮询机制/loop 命令通过定时触发提示词,实现非交互式的持续监控和执行,配合 --auto 模式可实现无人值守的任务处理,形成完整的自主循环。
  • 版本与权限要求:功能依赖 Claude Code v2.1.139 及以上版本,且需接受工作区信任对话框以启用钩子系统,若禁用所有钩子则无法使用。

行业启示

  • Agent工作流标准化:随着AI代理能力的增强,行业将从单一的Prompt Engineering转向Loop Engineering,定义清晰的状态机和终止条件是构建可靠Agent的基础。
  • 可验证性成为核心指标:在复杂任务中,单纯的任务描述已不足够,必须建立客观的、机器可读的验证标准,以减少AI输出的不确定性和人工审核负担。
  • 异步与自主性提升:通过 /loop 等机制实现的异步自主工作流,将释放开发者的时间,使其专注于更高层级的系统设计而非琐碎的代码迭代,推动软件开发向更高程度的自动化演进。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Claude Claude Agent Agent Code Generation 代码生成