How I built a skill scaffolder for my desktop AI companion: 3 questions, 20 tests, and a registry two installers can't corrupt
How I built a skill scaffolder for my desktop AI companion: 3 questions, 20 tests, and a registry two installers can't corrupt Ankita AI is the desktop AI assistant I build, by Krish Verma β a little companion that liv
How I built a skill scaffolder for my desktop AI companion: 3 questions, 20 tests, and a registry two installers can't corrupt
Ankita AI is the desktop AI assistant I build, by Krish Verma β a little companion that lives on your desktop and gets things done while you're away. Its skills are folders with a SKILL.md inside, and writing one by hand means remembering the folder layout, the frontmatter rules, the permission manifest, and the offline fixture β get any of it wrong and the skill installs but never loads, which is worse than no skill at all. So I built ankita new skill: it asks three questions and writes a skill that loads on the first try.
Three questions, one folder
The command is node chat.mjs new skill, and it asks for a name, a permission list, and one example input β or one line for scripts: node chat.mjs new skill explain-log --permissions files --example "Explain this log".
Every answer is validated before anything is written. The name has to match the skill-name regex β lowercase letters, digits and hyphens. Permissions must come from the four known kinds in src/skills/layout.mjs: files, network, shell, browser. The example has to be 1β200 characters, because it becomes the skill's description and the parser caps descriptions. An invalid name, an unknown permission, or an empty example fails before a single folder is created.
A successful scaffold writes five things into skills/<name>/: the SKILL.md itself, a plugin.json manifest carrying the permission declaration, a short documentation file, and a fixtures/ directory holding a skill.json input and the expected rendered output. If anything fails halfway through, the scaffolder rolls back the folder it exclusively created, so a failed install never leaves a half-written skill behind.
The fixture is the contract
The fixture is the part I care about most. Every scaffolded skill ships with an offline golden fixture: the expected file is the exact output of renderSkill() on the skill that was just written. A skill can be checked without a model call and without a network call β the loader renders the skill, compares it against the fixture, and a mismatch fails loudly instead of loading something subtly different from what the author wrote.
This runs before login and makes no model or network call at all. The permission declarations describe intent; they do not enforce a runtime sandbox and they do not replace tool approvals. I say that in the scaffolded documentation file itself, because a manifest that looks like a sandbox and isn't one is a trap.
The registry bug: two installers, one lost root
Registration was the hard half. A skill installed to a custom directory β --directory β has to be discoverable by the chat, by /skills, by the skill tool, and by the desktop app, including after a restart. The first version did the obvious thing: a single skill-roots.json registry file that each installer read, appended to, and rewrote.
A review of PR #54 caught the failure. The CLI reported success for a custom root while the default catalogue returned no new skills β the install and the discovery disagreed. Worse, a deterministic two-process filesystem repro showed the classic lost update: two installers reading the same registry at the same time ended up with only root one present instead of one and two.
The fix, in src/skills/roots.mjs, stops sharing a single file. Registrations are now append-only records in a sibling skill-roots.json.d directory: each install writes one UUID-named JSON record with the canonical root path and a timestamp, using an atomic write. Readers merge the legacy skill-roots.json file β still readable, never rewritten β with every completed .json record, sorted by registration time. Temporary writes are excluded from discovery, malformed records are diagnosed without hiding the bundled skills, and sequential registrations are idempotent because the reader dedupes by path.
The numbers: the focused scaffold and loader suite passed 20/20, including the two-process repro and the blocked-records-directory case; the root-registration suite passed 10/10 and the contribution checks 11/11. The published 2.6.0 Windows executable was audited for real: two CLI installations registered an external folder, the packaged app listed both skills alongside all six bundled ones β catalogSize=8 β delivered all eight instruction bodies into nine captured model requests, and found the same catalogue after a full restart.
The honest limits
Three gaps stay open. First, the permission declarations are advisory β a skill that declares files gets no sandbox from that declaration; the approval gate is still the enforcement boundary. Second, find_tools(query="skills") advertises the skill reader but does not enumerate installed skill names and descriptions, so automatic skill selection in hosted ChatGPT is not established. Third, the failure-injection coverage is incomplete: the storage-failure repro uses a file occupying the records directory, but permission-denied and device-failure paths have not been separately injected.
The question
Tell me I'm wrong: is a directory of UUID-named JSON records the right shape for a registry, or a lock file with extra steps? A single file with an exclusive-create lock would be simpler to inspect β but the two-process repro is exactly what killed the single-file version, and a lock only works if every writer honours it. Is the append-only directory the honest answer to concurrent installers, or just the version of the bug I haven't found yet?
Ankita is open source (MIT) at github.com/akyourowngames/A.N.K.I.T.A, and the scaffolder lives in src/skills/scaffold.mjs and src/skills/roots.mjs. The project site is ankita-sable.vercel.app.
β Krish Verma, creator of Ankita AI
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.