---
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."
description-tr: "Sık yaptığın bir işi yeniden kullanılabilir /multi-agent:<ad> komutu olarak kaydeder. Konuşmayı + CLAUDE.md'ni tarayıp aday rutinler önerir, sen seçip ad verirsin; local-only saklanır, asla sync edilmez."
argument-hint: "[name]  -  optional command name; asked if omitted"
allowed-tools: Bash, Read, AskUserQuestion
---

# multi-agent save  -  Save a Routine

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

Turn a recurring, project-specific procedure into a first-class `/multi-agent:<name>` command. The saved routine is a **local-only** command (`local-only: true`) plus a registry entry in `prefs.global.routines`; it is never synced to the public repo (the `/multi-agent:sync` backstops enforce this).

Backed by `$HOME/.claude/scripts/routine-registry.mjs`.

## Steps

1. **Distill candidates from what was just done (primary source).** The user usually runs `:save` right after performing a job they want to repeat, so FIRST review the recent session: group the tasks/steps actually executed this conversation into coherent, repeatable jobs. Each distinct job is a candidate - give it a suggested short name, a one-line summary, and the ordered steps it would replay. THEN add, as further candidates, any named end-to-end procedures in `$HOME/.claude/CLAUDE.md` (heading + trigger phrase + numbered steps, e.g. a "... kontrol et" procedure). If nothing repeatable is found in the session and CLAUDE.md has none, say so and offer the free-text path only.

2. **Pick (multi-select) + optionally combine.** `AskUserQuestion` with `multiSelect: true` (in `outputLanguage`): one option per distilled candidate (label = suggested name, description = the one-line summary), PLUS an always-present `Other` free-text path to describe a brand-new routine by hand. Semantics:
   - one candidate selected -> that becomes the routine;
   - several selected -> **combine them into ONE routine**, concatenating their steps in the order shown (the routine replays them in sequence); ask for a single name for the combined routine;
   - `Other` -> the user types the routine themselves.
   Empty selection is not consent - re-ask.

3. **Name the command.** Use `$ARGUMENTS` if given, else ask. Validate: lowercase `^[a-z0-9][a-z0-9-]*$`, <= 40 chars. `routine-registry.mjs add` rejects a name that collides with a shipped command or an existing routine; on rejection, ask for another name.

4. **Write the routine body** to a temp file: the full procedure the routine should run every time. For a single candidate, embed its steps (when the source is a CLAUDE.md section, reference that section by name AND embed a faithful copy so the routine is self-contained). For a combined (multi-select) routine, concatenate the selected candidates' steps in the shown order under numbered phase headings. Keep the user's own wording; do not invent steps.

5. **Save.** Run:
   ```bash
   node "$HOME/.claude/scripts/routine-registry.mjs" add \
     --name "<name>" \
     --description "<one-line summary>" \
     --description-tr "<Turkish one-line summary>" \
     --source "<CLAUDE.md section name | conversation | user>" \
     --body-file "/tmp/routine-<name>.md"
   ```

6. **Report + offer to run.** Tell the user (in `outputLanguage`): the routine is saved and will appear as `/multi-agent:<name>` in autocomplete **after the next session reload** (a freshly written command is not hot-loaded this session). Then offer to run it now (you have the procedure in hand, so you can execute it immediately without waiting for the slash command to register).

## Notes

- Never write under a repo `pipeline/` tree; routines live only under `~/.claude`.
- The routine file always carries `local-only: true` (the backend asserts this), so `/multi-agent:sync` and the install namespace-wipe both preserve it and keep it out of the public repo.
- List saved routines with `/multi-agent:routines`; remove one with `/multi-agent:forget <name>`.
