yuushabu_buyinn on X: with the skill router on, / in the agent no longer picks a skill.afabb7f90gave Claude Code a command per listed skill; Codex, Pi and Droid still had nothing to type, since a listed skill has no entry of its own in their skills folders. For each skill the router lists there, placeStubs links <skills>/<name> to a stub in routerDir+"-slash": a SKILL.md with the skill's name, description and argument-hint, disable-model-invocation: true, and a body that sends the agent to the skill's SKILL.md at the router's path; agents/openai.yaml sets Codex's policy.allow_implicit_invocation false. Each agent's loader was read for both halves, a picker entry and none in the model's prompt: Codex 0.165 (allow_implicit_invocation), Pi 1.4.0 (formatSkillsForPrompt), Droid 0.231 (the model's list filters disableModelInvocation, the slash list only userInvocable). slashFor gives none where another agent reads the folder and neither flag (Alma reads Codex's, as Crush reads Claude Code's: that is why Claude Code's are commands), and none for user-invocable: false. dropStubs takes them out before the links are written, so router off or kept direct puts the skill's link where its stub was. routerOurs knows a stub, so it is never "found" as an agent's own skill. Gemini CLI, OpenCode, Alma, Crush and the rest have no such flag and get no stub; a skill typed there is kept direct (doc says so). Run at this tree: - Full go test -tags nogui ./... not yet at this head: it is queued on magpie-desktop after the push. At the earlier base2957d16e5on mica it was ok but for internal/dirent's watch tests (#7031, red alone too under mica's load) and TestWSLKimiCode (#7054, ok 5 of 5 alone), neither of them reaching internal/library. - mica, at this tree (rebased over 454f9d023's internal/library change): go test -tags nogui ./internal/library -count=1 ok; GOOS=linux, GOOS=windows and darwin go vet ./internal/library ok. - magpie-desktop (WSL2 Ubuntu 24.04 on xiaomi-gpu), one base before: go test -tags nogui ./internal/library -count=1 ok; GOOS=linux and GOOS=windows go vet -tags nogui ./... ok; gofmt -l clean; node --test internal/gui/tests/skill-router.test.cjs 22 pass, 0 fail (chromium and webkit). - mica, at the base before: the same GUI file 22 pass; GOOS=linux/windows go vet ./internal/library ok. - Broken by hand, on mica: slashAgent false for all (the old behaviour) turns TestSkillRouterSlash ("codex: no stub of pdf to type it by") and TestSkillRouterSlashNotWhereAlmaReads red; dropping the readers check turns the Alma test red ("with Alma reading Codex's folder, codex has a stub of pdf"). - Real Codex 0.165.0 on this Mac (macOS 26), in a sandbox HOME, magpie's library built from this tree with two skills for claude and codex and the router on: the old tree's "$pdf" says "no matches"; this tree lists "pdf-reader [Skill] Read and summarise PDF files." and "$magpie" still lists the router. Claude Code's folder there has magpie-skills alone, with afabb7f90's commands beside it. - Real Claude Code 2.1.325 on this Mac, in a sandbox HOME with an earlier cut that also stubbed Claude Code's skills folder: "/pdf" listed /pdf-reader, it read the skill's SKILL.md and answered its codeword, and the model's Skill list named magpie-skills alone. That cut was dropped for afabb7f90's commands (Crush, DevEco Code and Kimi Code read that folder), so Claude Code's skills folder gets no stub. Not tried: a real Pi or Droid (neither installed here; their loaders were read in Pi 1.4.0's dist and Droid 0.231's binary); a real Codex turn checking the stub's description stays out of the request; a real agent on Windows or Linux (the paths are filepath.Join and dirLink, as the router's); the full suite on macOS (mote overloaded, mica's disk full). No GUI change, so no GUI run beyond skill-router.test.cjs.
12 KiB
Skill router
With the Library's switch "Skill router" on, each agent's skills folder is given one skill of magpie's, magpie-skills, in place of a link for each skill ticked for it. Its SKILL.md lists those skills, each with its description and the path of its own SKILL.md, and the agent reads that file when a task fits one. An agent then carries one skill's description in its prompt, however many the Library gives it. It is the skills' counterpart of the MCP router; the skills and their ticks are the Library's. The switch is off by default; with it on, every skill goes through the router unless it is kept direct.
Responsibilities and sources of truth
| Part | Responsibility | Source |
|---|---|---|
| Switch | Library.SkillRouter (skillRouter in library.json), this computer's alone: a sync doesn't carry it. SetSkillRouter sets it through change, so every agent is written again at once. The page posts skills/router {on}; the CLI is magpie library skill router on|off. |
SetSkillRouter in skill_router.go; skills/router in gui/library.go; library_cli.go |
| Direct | Skill.Router == "direct" (SkillDirect) keeps a skill out of the router: each agent given it keeps its own link, to type it as /name or keep it in the prompt. It is carried by a sync like the skill's ticks. The page posts skills/router-direct {name, on}; the CLI is magpie library skill router <name> routed|direct. |
SkillRouterHow; Skill.Router in skills.go, carry.go |
| What is listed | routedFor: each skill ticked for the agent (or for an agent reading the same folder), but one kept direct, one whose SKILL.md sets disable-model-invocation (for the user to type, which a listed skill can't be: routable), one the agent finds in ~/.agents/skills anyway, one blocked, and one where the agent has its own entry by that name. Each of these keeps its own link. |
routedFor, routable |
| Who keeps their links | An agent whose folder can't take the router keeps every link, and AgentView.SkillRouter says why (routerWhy): copies (given copies: WSL, the user's choice, Claude Desktop), liveagent (it uses only the skills picked in its own list), shared (its folder is ~/.agents/skills, which other agents read too), taken (a Library skill is called magpie-skills), own (the folder has a magpie-skills of the user's). on when it is given the router. |
routerWhy |
| Entry | placeRouter writes routerDir(t.Skills) (<settings dir>/skill-router/<sha256 of the folder's real path, 6 bytes>/): its SKILL.md and, under .skills/, a link to each listed skill's folder. The folder's entry magpie-skills is a link to it (routerOurs knows magpie's by where it leads). Applied.Router records it; with nothing listed, the entry and its folder go. |
placeRouter, writeRouter, routerOurs |
| Skill stubs | So a listed skill is still typed from Codex's $ picker, Pi's /skill:name and Droid's /name (Claude Code's are commands, below), placeStubs gives the folder a stub of it by its name: a link to stubsDir(t.Skills)/<name> (routerDir + -slash), whose SKILL.md has the skill's name, description and argument-hint, disable-model-invocation: true, and a body that sends the agent to the skill's SKILL.md at the path the router lists; agents/openai.yaml sets Codex's policy.allow_implicit_invocation: false. The agent offers it to type and leaves it out of the model's prompt, so the prompt still carries one description. Only agents whose loader was read to do both get stubs (slashAgent): Codex 0.165, Pi 1.4.0 (formatSkillsForPrompt), Droid 0.231. None when another agent that reads the folder (the very same one, or as its SkillsAlso: Alma reads Codex's) isn't one of them, and none for a skill with user-invocable: false (slashFor). dropStubs takes out a stub no longer wanted (router off, the skill kept direct or unticked) before the links are written, so its link goes where the stub was. routerOurs knows a stub as magpie's, so it is never found as an agent's own skill. |
slashAgent, slashFor, placeStubs, dropStubs, stubText |
| SKILL.md | Front matter name: magpie-skills and a description of at most 1024 bytes (routerDescMax: Codex refuses a longer one), naming the skills with as much of each description as fits, cut on a whole character (routerDesc). The body gives each skill's whole description and the path of its SKILL.md through the agent's own folder (<skills>/magpie-skills/.skills/<name>/SKILL.md). .skills is hidden, so the agents that look for skills in every folder under theirs (Codex, OpenCode, Pi) don't find a listed skill twice. |
writeRouter, routerDesc |
| Claude Code's Read rules | Claude Code asks before it reads outside its project, its own skills folder too, and checks both the path given and where a link leads (2.1.316). For Claude Code (claude, any profile; not a plugin agent) magpie adds permissions.allow rules to its settings.json: Read(//<entry's real path>/**) and Read(//<library skills folder's real path>/**), or one for each listed skill whose folder is elsewhere (routerRules; Windows paths as /c/..., claudePath). Applied.RouterRules records magpie's, so it takes out only those and keeps the user's own (offList, as for permissions.deny). |
routerRules, routerAllow |
Claude Code's /name |
A listed skill would be no /name of Claude Code's, so for each one routerCommands writes a slash command, <claude dir>/commands/<name>.md (routerCommandsDir, beside the settings.json routerRules writes; claude, any profile; not a plugin agent or WSL). It has the skill's description and disable-model-invocation: true, and its body has the agent read the skill's SKILL.md at the router's path and follow it, with $ARGUMENTS. Claude Code 2.1.316 (real runs in a sandbox HOME) lists it under / with the description, sends that description in no request, and /name reads and follows the skill. It goes in the commands folder, not the skills folder, because Crush, DevEco Code and Kimi Code read ~/.claude/skills too and take no notice of the flag. Applied.RouterCommands records magpie's files with their hash (syncOwnFiles): a stub the user changed is theirs. No stub is written where a Library command of that name is given to Claude Code (syncCommands takes the stub's file over), or where the user has a command file of that name. The command import (findCommands) leaves the stubs out. With the router off, or the skill kept direct, the stub goes. |
routerCommands, routerCommand, routedAt; syncCommands in commands.go |
| GUI | Under the skill list on the Library's Skills tab: a row "Skill router" with its switch (.lib-skillrouter, .lib-switch), and with it on, one line for each reason an agent keeps its own links, naming those agents (.lib-hub-why[data-why]). none is an agent whose folder takes the router but has no skill listed (AgentView.SkillRouter, routerNone: nothing ticked for it, or each kept direct), and found names the agents whose own folder holds skills the library lacks, which the router can't list and each stays in the prompt. Each skill the router may list has a button (.lib-routedirect, aria-pressed) that keeps it out of the router or lists it again; a skill kept out shows "Not through the router" (.lib-direct). |
skillRouterPart in plugins/library/client.js |
| Sessions | A Read of …/magpie-skills/.skills/<name>/SKILL.md counts as the use of <name> (Claude Code, Alma, Droid: routedSkill; Codex counts any SKILL.md it reads). Calling up magpie-skills itself is counted as a Skill tool call and no skill (routerSkill), so a routed use is counted once. |
routedSkill, state.tool, ccTool in internal/sessions |
Runtime path
- The user turns the switch on.
changesaves library.json and runs the sync for every agent. - For each agent with a skills folder,
syncSkillsasksroutedForwhich skills the router lists there andslashForwhich of them get a stub. It takes out stubs no longer wanted, writes a link for every other ticked skill, andplaceRouterwrites the router's folder and entry, the stubs and Claude Code's Read rules. - The agent starts with
magpie-skillsin its skill list. When a task fits it, the agent loads it (Claude Code's Skill tool, or a read of its SKILL.md), reads the listed skill's SKILL.md at the path given, and follows it. A file the skill names is in the same folder. - On the Claude subscription route, Claude Code sends a loaded skill's body as a text block after the Skill call's result. The Claude subscription bridge hands it to the run in that result (
withSkillBodies).
Constraints and failure behavior
- An agent reads its skills when it starts: a change reaches a running agent on its next start.
- A skill listed by the router stays a
/nameof Claude Code's through its command stub, and a$nameof Codex's, a/skill:nameof Pi's and a/nameof Droid's through its skill stub. Typed, a stub has the agent read the skill's SKILL.md, a Read the Sessions page counts as that skill's use. Gemini CLI, OpenCode (whose 1.x loader wasn't checked; its picker is@), Alma, Crush and every other agent have no flag that keeps a typed skill out of the prompt, so they get no stub: a skill typed there is kept direct. One withdisable-model-invocationis never listed. - A skill stub goes only into a folder no agent reads that would put its description in the prompt: with Alma here, which reads Codex's folder too and ignores both flags, Codex gets none (
slashFor), as Claude Code's skills folder gets none for Crush, DevEco Code and Kimi Code. - The user's own
magpie-skills, in the folder or in the Library, is never written over. The agent keeps every link, and the page says why (own,taken). - Turning the switch off writes every link again, removes the entry, the stubs, their folders and magpie's Read rules, and leaves the user's own rules.
- Alma reads Claude Code's, Codex's and
~/.agents/skillsbesides its own~/.config/alma/skills, and keeps one skill per name, its own first (personal > Claude Code > Codex >~/.agents:loadSkillsin Alma'selectron/skills/skillsManager.ts). With the router on for Alma, Alma'smagpie-skillsis the one it keeps, listing Alma's skills. When Alma's folder has no entry (every skill of Alma's kept direct, or none ticked for it), Alma takes Claude Code's (or Codex's)magpie-skillsand is offered that agent's skills, as it was offered their links before the router; Alma's Settings › Skills turns a folder off. Seen with a real Alma 0.4.738 in a sandbox HOME (#5722). - An agent other than Claude Code may ask before reading a listed skill's files, as for any file outside its project. Only Claude Code has rules magpie writes.
Verification
mote-run go test -tags nogui ./internal/library -run 'SkillRouter|RouterDesc|RouterRules|Command' -count=1
mote-run go test -tags nogui ./internal/sessions -run 'Routed' -count=1
mote-run go test -tags nogui ./internal/gateway -run 'SkillBod' -count=1
mote-run node --test internal/gui/tests/skill-router.test.cjs
TestSkillRouter covers the links, the entry, SKILL.md, the Read rules, direct skills, a second sync that writes nothing, and the switch turned off. TestSkillRouterSlash covers the skill stubs: Codex's front matter, openai.yaml and path, none in Gemini CLI's or Claude Code's skills folder or for a user-invocable: false skill, and the link back when kept direct or turned off; TestSkillRouterSlashNotWhereAlmaReads none in Codex's while Alma reads it. TestSkillBodyRealClaudeCode parses the request a real Claude Code sent after loading magpie-skills.