---
name: multi-agent-save
description: "Save a recurring job as a reusable /multi-agent:{name} command. Reviews the conversation + your CLAUDE.md for candidate routines, you pick one and name it; it is stored local-only and never synced. Use when a job keeps recurring and should become its own reusable command."
user-invocable: true
argument-hint: "[name]"
metadata:
  language: en
---

# multi-agent-save  -  Save a Routine

**Input**: $ARGUMENTS (optional routine name)

Turn a recurring procedure into a reusable `/multi-agent:<name>` command. The routine is stored local-only (a `local-only: true` command + a `prefs.global.routines` entry) and is never synced. Backed by `$HOME/.copilot/scripts/routine-registry.mjs`.

## Steps

1. Distill candidates from what was just done (primary): group the tasks executed this session into coherent, repeatable jobs (suggested name + one-line summary + ordered steps). Then add named end-to-end procedures from `$HOME/.claude/CLAUDE.md`.
2. `AskUserQuestion` with `multiSelect: true` (in `outputLanguage`): one option per candidate + an always-present `Other` free-text. One selected -> that routine; several selected -> combine into ONE routine (steps concatenated in shown order, single name); `Other` -> user types it. Empty is not consent.
3. Name the command (from `$ARGUMENTS` or ask); validate `^[a-z0-9][a-z0-9-]*$`, <= 40 chars; the backend rejects collisions. If the refusal says the name is a local command the registry does not track, it is a leftover routine: offer `/multi-agent-forget <name>` to remove it, beside choosing another name, and retry the save after it. When the refusal also says it holds files this tool did not write, it is the user's own command: ask for another name and never offer forget.
4. Write the full procedure body to a temp file (single candidate: embed its steps, reference the CLAUDE.md section by name when that is the source; combined: concatenate the selected candidates' steps in order under numbered phase headings). Do not invent steps.
5. Save: `node "$HOME/.copilot/scripts/routine-registry.mjs" add --name "<name>" --description "<summary>" --source "<source>" --body-file "/tmp/routine-<name>.md"`.
6. Report it is available in Claude Code as `/multi-agent:<name>` after a session reload (routines are Claude Code commands only, written under `~/.claude/commands/multi-agent/`); there is no Copilot command to run.

## Notes

- Never writes under a repo `pipeline/` tree; routines live only under the CLI home.
- List with `/multi-agent-routines`; remove with `/multi-agent-forget <name>`.
