Export this machine
The file is readable by you alone, because it holds your settings. Treat it as you treat
settings.json.
agentx refuses to overwrite a file that is already there. Pass --force to replace it:
--force: give the path of the file to write.
Two exports of an unchanged machine are the same file, byte for byte.
Import onto another machine
agentx source add line import prints for it, which it prints even when the export lists no skills. For a pinned source that line is agentx source add <url>#<pin>: agentx source add <url> alone unpins the source.
When the URL or the pin holds anything but letters, digits and ._/:@%+=,#-, import puts it in single quotes, so the line runs as printed in a POSIX shell such as bash or zsh. The export file supplies both, and quoting keeps a $, & or quote in them from running as a command.
The listing says what this machine’s account repo has of each skill:
Confirm without a terminal
Import replaces settings, so it asks first. Pass--yes to answer in advance:
--yes in scripts and wherever there is no terminal. Without it, and without a terminal to ask at, import exits with code 6 and changes nothing. Answering anything but y or yes does the same.
Move to a new machine
- On the old machine, run
agentx export ~/agentx-export.json. - Copy the file to the new machine.
- On the new machine, run
agentx import ~/agentx-export.json. - Run each
agentx source addline the import printed, exactly as printed. It names the pin of a pinned source,<url>#<pin>, andagentx source listshows the pins too. - Install what the listing calls missing with
agentx skill add <source>.
agentx source fetch and agentx skill add exit with code 5, say the source was not fetched and name the same agentx source add line, pin included, so following that hint keeps the pin too.
Script it
Add--json to get events instead of text. Import needs --yes in JSON mode, since it cannot ask.
settings event with the settings it wrote, then one import_skill event per record with its state, then result.
A record names a version and never carries one. Its base_hash is the version the skill was installed at, the same field under the same name that agentx skill list reports. An export holds no content_hash: that name always means what a machine holds right now, and an export reads no library directory.
When an import is refused
A refused import changes nothing: your settings stay exactly as they were.