Bare skm opens a dashboard with live upstream status per source; add uses a filterable picker and update a side-by-side diff review when run in a terminal. Non-interactive paths are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8.5 KiB
skm: skill manager
skm installs agent skills from git repos, pins each repo to a commit with a Nix hash, and updates on demand after you review the diff. Nix fetches the pinned sources and links them into place. skm only edits the manifest and lockfile.
It replaces the current setup, where skills are committed as plain copies under ~/Repos/nix/home/agents/skills and their origin is tracked (without commits) in vercel's ~/.local/state/skills/.skill-lock.json.
Decisions
| Topic | Decision |
|---|---|
| Source of truth | skills.json manifest (hand-edited or edited by skm). skills.lock.json is written only by skm. |
| Location | Both files in ~/Repos/nix/home/agents. No skill contents in the dotfiles. Own skills live in their own private repo. |
| Sources | Flake refs: github:owner/repo, git+ssh://…, git+https://…. Skills are directories containing SKILL.md, at the repo root or in subdirectories. No tarballs, registries, or local paths. |
| Pinning | Per repo. Optional ref (branch/tag), default branch otherwise. To hold one skill back, add a second source entry with its own ref. |
| Hash | narHash (sha256-… SRI, same value fetchFromGitHub uses), from nix flake prefetch --json. |
| Outdated | A skill is outdated only if its own subtree differs between the locked and the new store path. Repo commits that don't touch it don't count. |
| Update | update [name] shows the diff of the affected skills and applies after you confirm. --yes skips the prompt. |
| Local edits | Impossible (read-only store). Change a skill by forking it or moving it to your own repo. |
| Selection | Named skills, or "*" for every skill in the repo. With *, outdated reports skills added or removed upstream. |
| Name collisions | Error, unless one entry renames its skill with "as". Within one repo names aren't unique (plugin monorepos ship the same skill twice), so an entry can pick one with "path"; "*" refuses repos with duplicate names. |
| Fetching | Only through nix flake prefetch. No git dependency in skm. |
| Linking | home-manager links each skill individually to ~/.claude/skills/<name> and ~/.agents/skills/<name>. The parent directories stay writable, so Claude's synced/ dir keeps working. Targets are configurable globally. |
| Rebuild | skm prints "run the switch". With --switch it runs the configured switchCommand. |
| Git | skm never commits. It prints a suggested commit message. |
| UI | Go + bubbletea. Subcommands for scripting, plus a dashboard when run with no arguments. |
| Binary | skm. Repo stays skill-manager. |
File formats
skills.json:
{
"sources": {
"mattpocock": {
"url": "github:mattpocock/skills",
"skills": ["tdd", "prototype", { "name": "grilling", "as": "grilling-mp" }]
},
"own": {
"url": "git+ssh://git@<host>/<user>/skills",
"ref": "main",
"skills": "*"
}
}
}
skills.lock.json (written by skm; locked is nix flake prefetch --json's locked with its hash added as narHash):
{
"version": 1,
"sources": {
"mattpocock": {
"locked": { "type": "github", "owner": "mattpocock", "repo": "skills", "rev": "abc123…", "narHash": "sha256-…" },
"skills": { "tdd": "skills/tdd", "prototype": "skills/prototype", "grilling-mp": "skills/grilling" }
}
}
}
skills in the lock maps the installed name to the subpath, already resolved (including the * expansion). Nix can then link skills without scanning repos at eval time.
Nix side (this repo's flake)
packages.skm:buildGoModule.homeModules.default, options underprograms.skill-manager:enablemanifestDir(string path to the working tree, e.g./home/johannes/Repos/nix/home/agents)lockFile(path inside the consuming flake, read at eval time; required, because pure eval can't readmanifestDir)targets(default[ ".claude/skills" ".agents/skills" ])switchCommand(string)
- The module reads the lock, calls
builtins.fetchTree source.lockedfor each source, and emitshome.file."<target>/<name>".source = "${src}/${subpath}". It also writes~/.config/skill-manager/config.jsonwithmanifestDirandswitchCommand, and installsskm. devShells.default: go, gopls, nix.checks: Go tests, including the end-to-end test.
Required changes in ~/Repos/nix
- Add
skill-manageras a flake input and import its home-manager module inhomeManager.johannes. - Rebuild must evaluate as the user so
fetchTreeon the privategit+sshrepo uses the user's SSH agent:- Linux:
nixos-rebuild switch --sudo --flake …instead ofsudo nixos-rebuild …(devenv.nix:85). - voyager:
nix build .#darwinConfigurations.voyager.systemas the user, thensudo ./result/activate(devenv.nix:80).
- Linux:
- In
modules/home/dotfiles.nix, drop".claude/skills".source = live "agents/skills"and the skills part of.agents. The module now owns those paths. - After migration: delete
home/agents/skills/*from git (keepskills.json,skills.lock.json) and delete~/.local/state/skills/.skill-lock.json.
CLI
| Command | Does |
|---|---|
skm |
Dashboard |
skm add <url> [--ref R] [--name N] |
Prefetch, list SKILL.md dirs, pick in TUI (or --skill a,b=alias, --all), write manifest + lock. Adding to an existing source keeps its pin. |
skm remove <name> / --source S |
Remove the skill from the manifest and drop the source when it's empty, or remove a whole source |
skm list |
Installed skills with source and short rev |
skm outdated |
Prefetch each source's ref in parallel and report changed / added / removed skills |
skm update [name…] |
Diff review, then write the lock. --yes, --switch |
skm import [path] |
Read vercel's .skill-lock.json, write the manifest, pin HEAD, show the diff against the current home/agents/skills copies |
Global flag: --dir overrides manifestDir.
Dashboard
- A list of sources, each expanding to its skills, with a status per skill: ✓ up to date, ↑ outdated, ± added/removed upstream, spinner while checking.
- Upstream checks start in the background on open, in parallel across sources.
- Keys:
aadd (URL prompt, then the picker),dremove,uupdate the selected source (orUfor all outdated),enterdiff review,qquit. - Diff review: a file list on the left, a scrollable diff viewport on the right,
yaccept,nskip. - Every action calls the same core package as the subcommands. The TUI holds no logic of its own.
Code layout
cmd/skm/ main, stdlib flag subcommands
internal/jsonfile/ atomic JSON read/write
internal/manifest/ load/save skills.json, validation, collisions
internal/lock/ load/save skills.lock.json
internal/fetch/ Fetcher interface; nix implementation (nix flake prefetch --json)
internal/skills/ discover SKILL.md dirs, subtree compare, diff generation
internal/core/ add/remove/outdated/update/import operations
internal/tui/ bubbletea models: dashboard, picker, diff review
nix/module.nix home-manager module
flake.nix
Fetcher interface: Prefetch(url, ref) -> {StorePath, Locked}. The real implementation shells out to nix. The fake serves fixture directories.
Diffs are computed in Go between oldStorePath/subpath and newStorePath/subpath. The old store path comes from prefetching the locked rev, which is cached in the store.
Tests
- Unit: manifest/lock round-trips, collision and alias rules,
*expansion, subtree change detection, diff output (fake fetcher). - End-to-end: a temp
git+file://repo with two skills;add, commit upstream,outdated,update --yes; assert the lock. Needs nix, no network. Nix can't run inside the build sandbox, so these tests skip duringnix flake checkand run viago testin the devShell. - TUI: the picker, review and dashboard models are driven with key messages directly, asserting on state and ANSI-stripped views (no
teatestgolden files: less brittle, no extra dependency).
Build order
- Flake skeleton + devShell, Go module,
Fetcherwith the nix implementation. - Manifest/lock packages,
add(non-interactive),list,remove. - home-manager module; switch
~/Repos/nixover with one source to prove linking and the eval-as-user rebuild. outdated,updatewith a plain-text diff and confirm.import; migrate all sources. Find origins forc4-modelandcreate-readme; move own skills to the private repo.- bubbletea: picker, diff review, then the dashboard.
Out of scope (v1)
Non-git sources, patches/overlays, per-skill targets, per-skill pins, auto-commit.