Config layering and precedence¶
Skills, subagents, MCPs, hooks, tools and crons layer across three roots. Three separate questions are answered by three different mechanisms, and they do not agree on which layer wins:
- Resolution — which file on disk backs the name
foo? Repo overlay wins. - Membership — is
fooswitched on for agenta? Nothing wins; the layers merge as additive and subtractive deltas. - Ownership — what about files the agent wrote in its own home? They win over both, and are not otherwise in the contest.
A newly shipped default does reach an existing agent — see Membership.
The roots on disk¶
| Root | Holds | Written by | In git |
|---|---|---|---|
/usr/share/agentctl/ |
the shipped catalog: skills/ agents/ hooks/ mcp/ tools/ cron/ |
the .deb — replaced wholesale on apt upgrade |
no |
/var/lib/agentctl/catalog, /var/lib/agentctl/tools |
MCP and CLI-tool catalog items added after install | mcp catalog add, but only on a host with no repo or with an explicit --into; the default target is the overlay. tool catalog add only ever writes the overlay, and refuses on a host with no repo |
no |
/opt/agentctl/ |
the overlay dirs skills/ agents/ hooks/ mcp/ extensions/ tools/ apps/ cron/, plus defaults.yaml, hooks/registry.yaml and the ledger shards |
the CLI, auto-committed | yes |
~/.pi/agent/{skills,extensions,apps} (claude: ~/.claude/{skills,agents,apps}) |
whatever the agent authored for itself | the agent | no |
Mini-app bundles have no payload dir: the first-party ones are embedded in the agentctl
binary, and the overlay dir is <repo>/apps/.
Resolution: overlay wins, at whole-item granularity¶
Every category resolves the same shape — take the repo overlay's copy if the path exists, otherwise the shipped one. That applies equally to a skill, a subagent, an MCP catalog item and a CLI tool item.
This is a full override of the whole item, never a merge of its contents. An overlay
skills/browser/ replaces the shipped skills/browser/ entirely — a file the shipped
version had and the overlay does not is simply gone, because only one directory is ever
reachable. The same holds for a subagent .md, an mcp.yaml item dir and a tool.yaml
item dir.
Three deviations from that shape are worth knowing:
- MCPs and CLI tools have a third root in the middle. Resolution searches
<repo>/mcp→/var/lib/agentctl/catalog→/usr/share/agentctl/mcp. The runtime catalog is genuinely host-local — outside both the deb and the repo — and it exists so an item added after install survivesapt upgrade, which overwrites the payload. It still loses to the overlay. - Hooks merge per key, not per file. There is one registry file per layer
(
<share>/hooks/registry.yaml, then<repo>/hooks/registry.yaml), and both are read into one combined map, with the overlay's entries winning per key. So an overlay registry that defines one hook overrides that hook and leaves the other shipped hooks intact. Within a key the entry is still replaced whole. - Per-user cron templates are not overlayable. Cron unit templates are discovered only
from the shipped payload's
cron/unitsdirectory, so a new per-agent cron job needs its unit templates in the payload. Only the descriptors are overlayable: a host-level cron descriptor prefers<repo>/cron/<label>/over<share>/cron/host/<label>/, and a self-scope descriptor prefers<repo>/cron/users/<agent>/<label>/over<share>/cron/users/<agent>/<label>/.
The cron descriptor override is the one place the tool warns about a shadow.
cron add --host <label> writes an overlay dir containing a copy of the script, and
cron remove leaves it behind. If a label of the same name later ships as a default, the
host keeps running the frozen copy. apply prints a line naming both paths and saying the
shipped descriptor is being ignored; it leaves the overlay in place.
Membership: a merge of deltas¶
Whether an item is on for an agent is a different computation, and there is no override anywhere in it:
effective = ( deb_defaults ∪ overlay.add − overlay.remove ) + agent.add − agent.remove
deb_defaults— the compiled-in default sets for skills, subagents, cron jobs and hooks, and the default MCPs, which are channel-conditional on thetoolsleg (a Teams agent is handed the teams MCP, never the telegram one).overlay.*—<repo>/defaults.yaml, per category,add:andremove:inline lists. Edited withagentctl defaults add|remove <category> <item>.agent.*— theactivate:/deactivate:lists inagents.d/<name>.yaml, written byagents skills|subagents|cron|hooks add|remove, and bymcp add|removefor thetoolsleg — the same verb against the same key on both runtimes.
Both layers apply through the same additive-then-subtractive rule: union in the adds, then
remove the removes. The fully layered categories — the ones that re-minimize, self-heal and
accept a defaults.yaml leg — are skills, subagents, cron, hooks and tools. Two
more resolve through the same merge with less machinery around them:
| Category | What is different |
|---|---|
gate |
The pi permission-gate rule set. It has an activate: and a deactivate: leg over a shipped default and resolves the same way, but it is not re-minimized, not self-healed, and agentctl defaults add gate … is refused — there is no host-overlay leg for it. |
usercron |
Add-only: no default seed and no subtractive leg, so its activate: list is the full list. |
The ledger records only the deltas, never the resolved set, so a skill added to the
compiled-in defaults in a new deb reaches every existing agent on the next apply. On every
apply, the effective set is recomputed from whatever the shard holds, and the smallest
delta that reproduces it is written back (add = effective − default,
remove = default − effective). A fully-resolved activate: list therefore shrinks to the
agent's genuine divergence, and collapses to nothing once a host blesses the extra through
defaults.yaml. The pass is idempotent, and it never grows a shard.
The same pass self-heals: it drops delta items that no longer name a catalog entry, so a deleted or renamed skill strips itself off every agent fleet-wide. The pruning is gated on the catalog being present, so a box with no catalog installed never prunes deltas it cannot verify, and the presence check unions the overlay, so an overlay-only item counts as present.
Three scoping notes:
defaults.yamlhas no host key. It sits at the repo root and applies to every agent resolved through that repo, which on a repo shared by several hosts means more than one host.- No category is skipped by runtime. Every layered category reconciles for every agent
on either runtime,
tools:included — a pi agent wires the same catalog MCP over the same socket a claude agent does. agentctl defaults add tools <mcp>blesses a default MCP for every agent on a host. It resolves against the MCP catalog, sotoolsvalidates like any other delta category.
Ownership: the agent's own files¶
A skill the agent writes in ~/.pi/agent/skills/<name>/ is not a catalog item and is not
part of either mechanism above. The reconcile only manages symlinks, and it prunes
conservatively: inside the managed dirs it removes an entry only if it is a symlink and its
target points into one of the catalog roots (the overlay root and the payload root) and it
is not desired. A plain directory, a plain file, or a symlink pointing anywhere else is left
alone. A personal one-off is safe; promote it to a shared item by dropping it in the overlay.
Name collision between the two resolves in the agent's favour, silently. If the agent owns
~/.pi/agent/skills/foo/ as a real directory or file and foo is also an activated catalog
skill, the reconcile leaves the local path untouched: nothing is removed, no symlink is
written, no error is raised, and the changeset is empty. Local predates the catalog and wins.
Emptiness makes no difference — the test is only whether the path is a symlink. So an
activation can appear to have landed in the ledger while the agent's own copy is what loads;
rename one of the two if you want the catalog item.
Mini-apps resolve by id rather than by path: manifests are merged embedded, then overlay
(overlay wins on id), then the agent's own apps dir (user wins on id). So an agent can shadow
a shipped cockpit panel with its own, and nothing on the launcher says so. What it cannot do
is claim first-party status: a user app's source is always stamped "user" rather than read
from manifest.json, and an admin: true or supervisor: true in a user manifest is
discarded.
Worked example: a skill overridden in the overlay¶
Agent testbot on a host whose repo is /opt/agentctl. demo-skill and repo-skill both
ship in the deb; repo-skill also exists in the overlay. agentctl apply runs:
- The shard's deltas are re-minimized against the current effective defaults.
- Membership resolves for
testbot'sskillscategory:( deb_defaults ∪ defaults.yaml add − remove ) + activate − deactivate→[demo-skill, repo-skill, …]. Note this step is pure membership: the two skills' locations have not been consulted yet. - That list feeds resolution, which decides where each item actually lives on disk.
demo-skillis absent from<repo>/skills/, so it resolves to/usr/share/agentctl/skills/demo-skill.repo-skillis present, so it resolves to/opt/agentctl/skills/repo-skill— the shipped copy at/usr/share/agentctl/skills/repo-skillis never referenced again./home/testbot/.pi/agent/skills/{demo-skill,repo-skill}are symlinked at those two targets, and any other catalog-owned symlink in that directory is pruned.
The MCP path differs only in the resolution step: mcp add resolves the item through the
overlay → runtime catalog → payload search order, and for a stdio-transport item renders a
socket unit plus an entry in the agent's ~/.claude.json. An http-transport item gets the
.claude.json entry and no socket, unit or env file. That file is read only at process
start, so a newly wired MCP reaches a claude agent's model on its next restart; mcp add
prints the restart to run.
Verbs¶
agentctl defaults list # per category: effective set + overlay legs (--json adds the deb set)
agentctl defaults add <category> <item> # write the overlay add leg (root; commits, does not apply)
agentctl defaults remove <category> <item> # write the overlay remove leg
agentctl agents skills add|remove <skill> <agent>|* # the per-agent delta
agentctl agents subagents|cron|hooks add|remove ... # same shape per category
agentctl mcp add|remove <mcp> <agent>|self # the tools delta, on BOTH runtimes
agentctl agents skills catalog add <name> [--from <dir>] # AUTHOR into the overlay
agentctl mcp catalog add <name> --npm <pkg@ver> # lands in the overlay by default
agentctl apply # recompute, re-minimize, converge