Agent Stash 文档

/init

用其他 Coding Agent 的 /init Prompt 分析当前项目,写出 AGENTS.md;支持 Pi、DSH、Cline、Grok Build、goose 与 Aider。

用法

三者的参数写法相同:

/init                         # 使用默认预设(DSH 里先打开预设列表)
/init kimi-code               # 使用 kimi-code 预设
/init opencode 重点写测试流程   # 使用 opencode 预设并附加额外 Prompt
/init 用中文写                 # 第一个词不是预设名时,整句作为额外 Prompt,使用默认预设

在 DSH 里选预设

DSH 的 / 菜单里,/init 排在「指令」区,标题是「初始化」。

在菜单里选「初始化」,或者只输入 /init 后回车,打开预设列表。

默认预设打勾并已高亮。输入文字可以筛选预设,自定义预设单独列在「自定义」组里。

按回车,用高亮的预设执行。

DSH 里在 / 菜单选「初始化」打开预设列表,输入文字筛选,回车执行

要写预设名或额外 Prompt,在 /init 后面打空格接着输入,写法与「Pi、DSH 与 Cline」标签页相同。子代理会话里没有 /init。

预设

上游同步的预设由 .github/workflows/sync-init-prompts.yml 每天更新一次:

预设上游许可证
codex(默认)openai/codexApache-2.0
kimi-codeMoonshotAI/kimi-codeMIT
opencodeanomalyco/opencodeMIT
crushcharmbracelet/crushFSL-1.1-MIT
copilotmicrosoft/vscodeMIT
qwen-codeQwenLM/qwen-codeApache-2.0
kilo-codeKilo-Org/kilocodeMIT

手动维护的预设:

预设来源
claude-codeClaude Code v2.1.306 的 /init(经典版)
claude-code-init-newClaude Code v2.1.306 的 /init(多阶段版)

除 copilot 与 claude-code-init-new 外,所有预设都输出 AGENTS.md。

  • copilot 沿用 VS Code 上游的做法:优先写 AGENTS.md,项目里已有 AGENTS.md 或 .github/copilot-instructions.md 时更新已有的那个文件,还可能新建技能和自定义 Agent。
  • claude-code-init-new 先询问要设置什么:可以写项目的 AGENTS.md、个人的 CLAUDE.local.md 或两者都写,还可能在 .claude/skills/ 下新建技能、在 .claude/settings.json 里加 hook。

额外指令与占位符

发送前去掉模板开头的 YAML frontmatter,并替换以下占位符:

  • ${path}:当前项目目录。DSH 里取会话的当前工作目录,Cline 里取工作区根目录。Grok Build 与 goose 的命令是安装时写好的文件,写成 .,即 Agent 运行时的当前目录。
  • {{.Config.Options.InitializeAs}}:Crush 模板里的说明文件名,替换为 AGENTS.md。
  • $ARGUMENTS:额外指令。

模板没有 $ARGUMENTS 时,额外指令追加到 Prompt 末尾的 ## Additional instructions from the user 小节,没有额外指令就不加。Grok Build 的技能是静态文件,这个小节始终存在,没有额外指令时内容为空。

配置

Agent配置文件
Pi~/.pi/agent/agent-stash/init.json,然后是 <项目根目录>/.pi/agent-stash/init.json(仅在项目受信任时读取)
DSH$DSH_HOME/agent-stash/init.json(默认 ~/.dsh/agent-stash/init.json)
Cline$CLINE_DIR/agent-stash/init.json(默认 ~/.cline/agent-stash/init.json)
agent-stash 命令行(Grok Build、goose、Aider)$XDG_CONFIG_HOME/agent-stash/init.json(默认 ~/.config/agent-stash/init.json)

Pi 设置了 PI_CODING_AGENT_DIR 时,第一个文件改为 $PI_CODING_AGENT_DIR/agent-stash/init.json。

init.json
{
  "defaultPreset": "team",
  "presets": {
    "team": {
      "file": "./team-init.md",
      "description": "..."
    }
  }
}

属性

类型

贡献者

页面历史