Skip to main content

可分享 Recipes

有时你在 goose 里完成一个任务后,会意识到:“这套配置以后肯定还会再用。” 也许你已经搭好了合适的工具组合、定义了清晰目标,想把整个流程保存下来;也可能你想让别人复现你刚完成的工作,而不用再一步步口头指导。

你可以把当前 goose 会话打包成一个可复用的 recipe。它会把当前使用的工具、目标和启动配置保存下来,变成一个新 Agent,其他人或未来的你都可以一键启动。

创建 Recipe

你可以从当前会话创建 recipe,也可以从模板新建 recipe。

  1. 在你想保存为 recipe 的会话中,点击应用底部的 按钮
  2. 在弹出的对话框中,按需检查并编辑 recipe 字段:
    • Title and description
    • Instructions that tell goose what to do
    • Initial prompt to pre-fill the chat input
    • Advanced Options (expand to access):
      • Activities to display as clickable buttons for users
      • Parameters to accept dynamic values
      • Model and provider to specify which provider and model the recipe should use
      • Extensions to select which tools are available
      • Response JSON schema for structured output in automations
  3. 完成后,你可以:
    • 点击 Create Recipe,将 recipe 保存到 Recipe Library
    • 点击 Create & Run Recipe,保存后立刻在新会话中运行
warning

你不能基于一个“已由 recipe 启动的会话”再次创建 recipe,但你仍然可以编辑该 recipe

自定义 Recipe 生成方式

你可以编辑 recipe.md prompt template,来自定义 goose 生成 recipe 的方式。

编辑 Recipe

  1. 点击左上角的 打开侧边栏
  2. 在侧边栏里点击 Recipes
  3. 找到你要编辑的 recipe,并点击 按钮
  4. 在弹出的对话框中,编辑以下任意字段:
    • Title and description
    • Instructions that tell goose what to do
    • Initial prompt to pre-fill the chat input
    • Advanced Options (expand to access):
      • Activities to display as clickable buttons for users
      • Parameters to accept dynamic values
      • Model and provider to specify which provider and model the recipe should use
      • Extensions to select which tools are available
      • Response JSON schema for structured output in automations
  5. 完成后,你可以:
    • 复制 recipe 链接,分享给其他人
    • 点击 Save Recipe 保存修改
    • 点击 Save & Run Recipe 保存后立即在新会话中运行
编辑正在使用的 Recipe

如果你当前就在一个 recipe 会话中,也可以直接点击应用底部的 按钮打开编辑对话框。这个按钮会在你发出第一条消息后出现。

使用 Recipe

  1. 通过直接链接、手动输入 URL,或者在 Recipe Library 中打开 recipe:

    直接链接:

    1. 点击别人分享给你的 recipe 链接

    手动输入 URL:

    1. 把 recipe 链接粘贴到浏览器地址栏
    2. Enter,再点击 Open Goose.app 提示

    Recipe Library:

    1. 点击左上角的 打开侧边栏
    2. 在侧边栏里点击 Recipes
    3. 在 Recipe Library 中找到目标 recipe
    4. 点击 Use 打开

    Slash Command:

    1. 在任意 goose 聊天会话中输入一个自定义 slash command
  2. 第一次运行某个 recipe 时,系统会显示一个警告对话框,展示 recipe 的标题、描述和 instructions 供你确认。如果你信任该 recipe 的内容,点击 Trust and Execute 继续。之后只要 recipe 内容不变,就不会再次提示。

  3. 如果 recipe 定义了参数,在 Recipe Parameters 对话框中输入参数值,然后点击 Start Recipe

    Recipe 参数是用于定制 recipe 行为的动态值:

    • 必填参数 会用红色星号(*)标记
    • 可选参数 会显示可修改的默认值
  4. recipe 会自动提交并开始执行。如果 recipe 包含 prompt,它会作为第一条消息直接发送;如果没有 prompt,你可以点击 activity 气泡,或自行发送一条 prompt 来开始。

隐私与隔离
  • 每个使用者都会得到自己的私有会话
  • 用户之间不会共享数据
  • 你的会话不会影响原始 recipe 创建者的会话

校验 Recipe

Recipe 校验目前只通过 CLI 提供。

分享 Recipe

通过 recipe 链接或 recipe 文件,你可以把自己的 recipe 分享给其他 goose 用户。

隐私与隔离

每位接收者在使用共享 recipe 时,都会启动自己的私有会话。用户之间不共享数据,你原本的会话和 recipe 也不会受影响。

你可以通过 recipe link 把 recipe 分享给 Desktop 用户。

从 Recipe Library 复制 deeplink 并分享给他人:

  1. 点击左上角的 打开侧边栏
  2. 在侧边栏里点击 Recipes
  3. 找到要分享的 recipe,点击 按钮复制链接

当别人点击这个链接时,goose Desktop 会使用你的 recipe 配置打开一个新会话。对方也可以把这个链接用于导入 recipe,以便未来重复使用。

通过 Recipe 文件分享

你也可以直接把 recipe 文件发给 Desktop 或 CLI 用户。

在 goose Desktop 中,你可以导出 recipe 文件,或者复制 recipe 的 YAML 内容后分享给别人。

  1. 点击左上角的 打开侧边栏
  2. 在侧边栏里点击 Recipes
  3. 找到要分享的 recipe,点击 按钮
  4. 选择分享方式:
    • 下载为 .yaml 文件:选择 Export to File,选择保存位置后点击 Save
    • 复制 YAML 到剪贴板:选择 Copy YAML

其他 Desktop 用户可以把它导入 Recipe Library

定时执行 Recipe

Automate goose recipes by running them on a schedule. When creating a schedule, you'll configure:

  • Name:调度任务的名称
  • Source:要运行的 recipe 来源
  • Execution mode:后台运行(无窗口、保存结果)或前台运行(若 goose Desktop 正在运行则打开窗口,否则回退到后台)
  • Frequency and time:运行频率与时间(例如每 20 分钟一次,或每周五上午 10 点执行)。你的选择最终会被转换成 goose 使用的 cron expression

从 Recipe Library 创建调度:

  1. 点击左上角的 打开侧边栏
  2. 在侧边栏里点击 Recipes
  3. 找到要定时运行的 recipe,点击 按钮
  4. 点击 Create Schedule
  5. 在弹出的对话框中配置调度。Source 会自动填入当前 recipe 的链接
  6. 点击 Create Schedule

从 Scheduler 页面创建调度:

  1. 点击左上角的 打开侧边栏
  2. 点击 Scheduler
  3. 点击 Create Schedule
  4. 在弹出的对话框中配置调度。Source 可选择 .yaml / .yml 文件,或填写recipe link
  5. 点击 Create Schedule

管理已调度的 Recipes

所有定时 recipes 都会列在 Scheduler 页面中。 点击某条 schedule 可以查看详情、上次运行时间,并执行以下操作:

  • Run Schedule Now:立即手动触发一次
  • Edit Schedule:修改调度频率
  • Pause Schedule:暂停自动运行

Schedule Details 页底部,还能查看该调度创建出的会话列表,并打开或恢复这些会话。

核心组成

一个 recipe 需要这些核心组件:

  • Instructions:定义 agent 的行为与能力

    • 相当于 agent 的任务宣言
    • 让 agent 随时为相关任务做好准备
    • 如果没有提供 prompt,则 instructions 必填
  • Prompt(可选):自动开启对话

    • 没有 prompt 时,agent 会等待用户输入
    • 适合某个特定、立即开始的任务
    • 如果没有提供 instructions,则 prompt 必填
  • Activities:显示为可点击气泡的示例任务

    • 帮助用户快速理解这个 recipe 能做什么
    • 降低上手门槛

高级能力

自动重试逻辑

Recipe 可以定义 retry 逻辑,在未满足成功条件时自动继续尝试。这尤其适合:

  • 自动化工作流:必须确保任务最终成功
  • 开发任务:例如运行测试、构建等可能需要多次尝试的场景
  • 系统操作:需要校验结果并在失败时做清理

基础 retry 配置:

retry:
max_retries: 3
checks:
- type: shell
command: "test -f output.txt" # Check if output file exists
on_failure: "rm -f temp_files*" # Cleanup on failure

执行流程:

  1. recipe 按正常方式运行
  2. 任务完成后,通过 success checks 校验结果
  3. 如果校验失败且仍允许重试:
    • 先执行可选的清理命令
    • 再把 agent 状态重置回初始条件
    • 从头重新执行 recipe
  4. 直到成功,或达到最大重试次数

更多 retry 配置选项和示例,请查看Recipe 参考指南

面向自动化的结构化输出

Recipes 可以强制输出结构化 JSON,这让它们非常适合需要可靠解析 agent 结果的自动化工作流。主要优点包括:

  • 稳定可解析:适合脚本、自动化任务和 CI/CD 流水线
  • 内建校验:保证输出满足你的 schema 要求
  • 方便抽取:最终输出会作为单独一行,便于程序读取

结构化输出特别适合:

  • 开发工作流:代码分析报告、测试通过/失败计数、构建状态与发布就绪标记
  • 数据处理:带计数与校验结果的数据输出、结构化内容分析结果
  • 文档生成:带稳定 metadata 的项目报告,便于后续加工

结构化输出配置示例:

response:
json_schema:
type: object
properties:
build_status:
type: string
enum: ["success", "failed", "warning"]
description: "Overall build result"
tests_passed:
type: number
description: "Number of tests that passed"
tests_failed:
type: number
description: "Number of tests that failed"
artifacts:
type: array
items:
type: string
description: "Generated build artifacts"
deployment_ready:
type: boolean
description: "Whether the build is ready for deployment"
required:
- build_status
- tests_passed
- tests_failed
- deployment_ready

执行流程:

  1. recipe 正常运行
  2. goose 调用 final_output 工具,并提交符合 schema 的 JSON
  3. 系统按 JSON schema 校验输出
  4. 如果校验失败,goose 会收到错误详情并修正输出
  5. 校验通过后的最终 JSON 会作为最后一行输出,方便脚本抽取

自动化示例:

# 运行 recipe 并提取 JSON 输出
goose run --recipe analysis.yaml --params project_path=./src > output.log
RESULT=$(tail -n 1 output.log)
echo "Analysis Status: $(echo $RESULT | jq -r '.build_status')"
echo "Issues Found: $(echo $RESULT | jq -r '.tests_failed')"
info

结构化输出既支持通过 goose CLI 运行的 recipe,也支持在 goose Desktop 中运行的 recipe。但 json_schema 的创建和编辑目前仍需要手动修改 recipe 文件。

Recipe 会打包哪些内容

一个 recipe 会包含:

  • AI instructions(目标 / 职责)
  • 推荐 activities(用户可直接点击的示例任务)
  • 已启用的 extensions 及其配置
  • 项目目录或文件上下文
  • 初始配置(但不包含完整对话历史)
  • 运行该 recipe 时使用的 model 和 provider(可选)
  • retry 逻辑与成功校验配置(如果有)

为了保护隐私和系统完整性,goose 不会打包以下内容:

  • 全局和本地 memory
  • API keys 与个人凭据
  • 系统级 goose 设置

这意味着,如果某个 recipe 依赖这些内容,接收者需要自行补充对应凭据或 memory 上下文。

了解更多

继续阅读Recipes 指南,查看更多文档、工具和资源,进一步掌握 goose recipes。