skills: magpie-setup, an agent sets magpie up as the user asks

Asked for by Leyuu_5 on X ("功能越来越多,感觉可以来个skill让AI来帮设置需求了").
The skill teaches an agent to read magpie's state, then turn a request
into magpie's own commands: keys and subscriptions, an agent's model,
routing groups with fallbacks and rules (time of day with a zone,
tokens, images, folders, compaction, intent), gateway keys with budgets
and model lists, model names/prices/visibility, and the library's MCP
servers, instructions and web search. It says what to ask before
(replacing, removing, sign-in) and what never to run unasked, and that
a subscription is never set up for another person's use.

What was run: every command in SKILL.md was read from magpie's
internal/cli source at origin/main d2e0ea393 and run against a magpie
built from it, in a sandbox HOME (provider add preset/url/anthropic/
ollama, provider test/models/fallback/off/on/rpm, account-cap,
group add/set models+=/template, every rule form incl.
time=09:00-18:00@Asia/Shanghai and tz=, rule mv/rm, gateway-key
add/list/limit month --cost 20/limit add day --tokens/models, model
name/disable/price/context, visible, library mcp add/instructions,
search add, save/use, claude/codex set and default, healthcheck,
usage, quota). Two magpie bugs found doing so are fixed there
(gateway-key limit <id> month refused; library mcp add with no agents
said every agent had it) and ship with the next tag.
Not tried: accounts add / plugin login (a real browser sign-in),
daemon install, webdav, backup/restore.
This commit is contained in:
yetone
2026-10-25 19:12:17 +08:00
parent 8531ccc532
commit e5136447b7
2 changed files with 206 additions and 1 deletions
+3 -1
View File
@@ -151,11 +151,13 @@ Agent skills for magpie users, in `skills/<name>/SKILL.md`.
| Skill | What it does |
|---|---|
| [magpie-setup](skills/magpie-setup) | Lets an agent set magpie up as the user asks, through its own `magpie` commands: keys and subscriptions, an agent's model, routing groups with fallbacks and time-of-day rules, gateway keys with budgets, and MCP servers and instructions shared with every agent |
| [magpie-quota](skills/magpie-quota) | Lets an agent check what is left of every subscription, coding plan and key balance magpie has (`magpie quota --json`), and wait for allowance to come back |
In magpie, it is first under Library › Market › Skills. Elsewhere:
In magpie, they are first under Library › Market › Skills. Elsewhere:
```sh
npx skills add magpie-community/plugins --skill magpie-setup
npx skills add magpie-community/plugins --skill magpie-quota
```
+203
View File
@@ -0,0 +1,203 @@
---
name: magpie-setup
description: Set magpie (usemagpie.ai) up for what the user wants through its `magpie` command — add a vendor's API key or a subscription, point Claude Code, Codex, OpenCode or another agent at a model, build routing groups with fallbacks and rules (by time of day, length, image, folder or compaction), give other devices gateway keys with budgets, rename, price or turn off models, and give every agent the same MCP servers, instructions and web search. Use when the user asks to configure, set up or change magpie (配置 magpie / 设置 magpie), or describes a setup in their own words ("use DeepSeek in Claude Code", "cheaper model during peak hours", "fall back to my relay when Claude runs out").
---
# Set magpie up
[magpie](https://usemagpie.ai) puts every model the user has (subscriptions,
coding plans, API keys) behind one local gateway and points their coding
agents at it. Everything its app does has a `magpie` command. Turn what the
user asks for into those commands, run them, and show what changed.
## Before anything
1. Find the command: `magpie --version`. If it isn't found, the app can put
it on the PATH (Settings › About › Command line › Add to PATH), or run the
app's own program: `/Applications/magpie.app/Contents/MacOS/magpie` on a
Mac, `%LOCALAPPDATA%\magpie\magpie.exe` on Windows.
2. Read what is there before changing it:
```sh
magpie ls # the agents here, and the model each is on
magpie providers # vendors and keys
magpie accounts # signed-in subscriptions
magpie groups # routing groups
magpie models # every model an agent can pick, as provider/model
```
3. Check the exact form of a command with `magpie <command> --help` (or
`magpie help` for all of them). `-h` or `--help` anywhere only prints
help and changes nothing. If a command or option below is refused as
unknown, the user's magpie is older: `magpie update` installs the newest,
after asking them.
## How to work
- Do what the user asked and nothing more. Don't change an agent, group or
key they didn't mention.
- Before a change that replaces or removes something (`rm`, `default`,
`group add` with a name already in use, `provider models <id> <ids…>`,
which replaces the list), say what will go and ask.
- Before a larger setup, `magpie save before-setup` keeps every agent's
settings as a profile; `magpie use before-setup` puts them back.
- After each change, show the result (`magpie group <id>`, `magpie <agent>`,
`magpie providers`) in a line or two, not the whole output.
- Use the commands, never edit magpie's own files (`providers.json`,
`library.json` and the rest): the commands check values, lock the files
and write the agents' configs to match.
- An agent reads its model at start. After pointing one at a new model, tell
the user to restart it; if it is the agent you are running in, the change
takes effect in its next session.
- An API key goes on the command line as the user gave it. Don't repeat it
back, and never write it into a file in a project.
## Models and keys
Model ids are `provider/model`, as `magpie models` lists them (a bare model
id works when one provider serves it). A routing group is `group/<id>`.
```sh
magpie presets # vendors magpie knows: just add a key
magpie provider add deepseek sk-… # a preset; again adds a second one (deepseek-2)
magpie provider add "My Relay" url=https://relay.example.com/v1 key=sk-… # any OpenAI-compatible API
magpie provider add "Own Claude" anthropic=https://gw.example.com key=sk-… # an Anthropic-compatible one
magpie provider add ollama url=http://127.0.0.1:11434/v1 # a local model server
magpie provider test <id> # send a tiny request to each endpoint
magpie provider models <id> # fetch its model list again
magpie provider models <id> model-a model-b # the models it serves, when the vendor has no list
magpie provider fallback <id> <provider/model>… # where requests go when it is out of quota or down
magpie provider off|on <id> # stop using it, kept; or use it again
```
`magpie provider --help` lists every `k=v` a custom vendor takes (headers,
balance endpoint, context length, user agent).
Subscriptions are signed in through the browser, by the user:
```sh
magpie accounts add claude # or codex, gemini, antigravity
magpie accounts add copilot
magpie plugin add <name> # a community plugin's subscription (magpie plugin --help)
magpie plugin login <provider>
```
Start the sign-in and tell the user to finish it in the window that opens.
To limit a subscription account: `magpie provider account-cap <id> <account> 70`
(use up to 70% of each window), `magpie provider rpm <id> 20`.
## Point an agent at a model
```sh
magpie agents # every agent magpie supports
magpie models claude # what Claude Code can pick, and why others aren't
magpie claude deepseek/deepseek-chat # set its model (also: codex, gemini, opencode, pi, …)
magpie codex effort high # another field (magpie codex --help lists them)
magpie claude default # take magpie out: back to what it had before
```
## Routing groups
A group is several models an agent picks as one. `routing=order` tries them
in order (the next when one can't answer); `smart` (default) prefers the
subscription renewing soonest; `usage`, `pace`, `rotate`, `weight` and
`manual` are in `magpie group --help`.
```sh
magpie group add "Opus anywhere" models=claude/claude-opus-5-5,openrouter/anthropic/claude-opus-5.5 routing=order
magpie group set opus-anywhere models+=deepseek/deepseek-chat # append; models-= drops one
magpie group set opus-anywhere stays=session # keep a conversation on one account
magpie group add free-pool models='openrouter/*:free' routing=order # a pattern; quote it
magpie group template # ready-made groups from the user's own models
magpie claude group/opus-anywhere # an agent uses the group
```
`group add` with a name already in use replaces that group; check
`magpie groups` first. `magpie group template <kind>` makes the group at
once, so list the kinds and ask before making one.
Rules decide which model a turn goes to first. The first rule that matches
wins; the group's other models stay behind it as fallbacks.
```sh
magpie group rule add <group> use=<model> time=09:00-18:00 days=mon-fri tz=Asia/Shanghai # peak hours elsewhere
magpie group rule add <group> use=<model> time=09:00-18:00@Asia/Shanghai # the same zone, written after the hours
magpie group rule add <group> pause=<model> time=22:00-08:00 # leave a model out overnight
magpie group rule add <group> use=<model> tokens=200k # long requests
magpie group rule add <group> use=<model> images # requests with an image
magpie group rule add <group> use=<model> compact # an agent's compaction summary
magpie group rule add <group> use=<model> folders=~/work/acme # one project
magpie group rule add <group> use=<model> agents=codex # one agent
magpie group rule add <group> use=<model> intent="a quick question" classifier=<small model>
magpie group rule <group> # the rules, numbered
magpie group rule rm <group> <n>
magpie group rule mv <group> <n> <to>
```
`<model>` must be one of the group's models. Without `tz=`, times are on
the clock of the computer magpie runs on. `magpie group rule --help` has
every condition.
## Other devices, people and budgets
Other computers and apps reach the gateway with a gateway key, once
Settings › Network and sharing › Share on local network is on.
```sh
magpie gateway-key add laptop # prints the new key
magpie gateway-key list
magpie gateway-key limit <id> month --cost 20 # a budget in USD; day, week, month, 10d, 5h
magpie gateway-key limit <id> add day --tokens 2m # one more limit; every one must have room
magpie gateway-key models <id> 'deepseek/*' group/daily # only these models
magpie gateway-key limit <id> off
```
A Claude, ChatGPT or other subscription is for its owner's own use. Never
set up a key that lets another person use one: hold any key you make for
someone else to API-key providers with `gateway-key models`.
## Models agents are shown
```sh
magpie model name deepseek/deepseek-chat "DS Chat" # the name it goes by everywhere
magpie model disable '*preview*' # refused on every route; magpie model enable undoes it
magpie model price my-relay/gpt-x 1,4,0.1,1.25 # USD per 1M: input, output, cache read, cache write
magpie model context my-relay/claude-opus-5-5 1m
magpie visible zed deepseek,daily # an agent shown only these providers, families or groups
magpie visible zed all
```
## Everything agents share
```sh
magpie library # what each agent is given
magpie library mcp add context7 https://mcp.context7.com/mcp agents=claude,codex
magpie library mcp add <name> <command> <args…> # a stdio server
magpie library instructions set notes.md # instructions every agent reads (- for stdin)
magpie library instructions agents claude,codex
magpie library skill agents <skill> claude,codex # skills are added from the app's Library › Market
magpie search add tavily tvly-… # web search for models that can't search themselves
magpie search add you # You.com, free with no key
```
## Running and keeping it
```sh
magpie healthcheck # exit 0 when the gateway answers
magpie daemon install # a server: the gateway as a service, started at boot or login
magpie web --lan # the app's window in a browser, for a machine without a desktop
magpie backup <file> # everything in one file, sealed with a passphrase; magpie restore <file>
magpie webdav on <address> # the same setup on every computer (also s3, github)
magpie usage 7d # what each agent, model and account used
magpie quota # what is left of each subscription and key
```
## Don't
- Don't run `magpie quota reset` (it spends one of a Codex account's resets),
`magpie library skill rm --all`, `magpie group auto off`, `magpie provider rm`,
`magpie accounts import` (it signs the other tool out) or
`magpie daemon install` unless the user asked for exactly that.
- Don't sign the user in or out of anything, or switch the account an agent
is signed in to, without asking.
- Don't run magpie with sudo.