A source can install agents (agents/<name>.md files with a frontmatter name) alongside or instead of skills. - manifest: optional "agents" selection; lock: "agents" map - add --agent / --all-agents, remove --agent, list shows the kind - check/update diff agents like skills (files, not directories) - dashboard lists and removes agents - home-manager module: agentTargets (default .claude/agents) links <name>.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
183 lines
8.7 KiB
Markdown
183 lines
8.7 KiB
Markdown
# skm
|
|
|
|
**Pin agent skills from git repos with Nix, and update them only after you've reviewed the diff.**
|
|
|
|
`skm` manages [agent skills](https://docs.claude.com/en/docs/claude-code/skills) (directories containing a `SKILL.md`) and subagent definitions (`agents/<name>.md` files) that come from git repositories. Each repo is pinned to a commit and a Nix `narHash`. Nix fetches the pinned sources and home-manager links every skill into `~/.claude/skills` and `~/.agents/skills`, and every agent into `~/.claude/agents`. `skm` only ever edits two JSON files.
|
|
|
|
- **Reproducible**: a lockfile with commit and hash for every source, evaluated by Nix.
|
|
- **Reviewed updates**: see the diff of every changed skill before it is applied.
|
|
- **Precise outdated checks**: a skill counts as outdated only when its own directory changes upstream, not when anything else in the repo does.
|
|
- **Two interfaces**: scriptable subcommands, and a bubbletea dashboard when run without arguments.
|
|
|
|
## Contents
|
|
|
|
- [How it works](#how-it-works)
|
|
- [Installation](#installation)
|
|
- [Usage](#usage)
|
|
- [File formats](#file-formats)
|
|
- [Development](#development)
|
|
|
|
## How it works
|
|
|
|
```
|
|
skm add / update ──► skills.json + skills.lock.json ──► home-manager switch ──► ~/.claude/skills/<name>
|
|
(in your Nix flake) (builtins.fetchTree) ~/.agents/skills/<name>
|
|
```
|
|
|
|
1. `skills.json` is the manifest: which repos, which skills, optional branch or tag. Edit it by hand or with `skm`.
|
|
2. `skills.lock.json` is written only by `skm`. It holds the locked rev and `narHash` from `nix flake prefetch`, plus each skill's resolved subpath.
|
|
3. The home-manager module reads the lock at evaluation time and links each skill individually, so the target directories stay writable for other tools.
|
|
|
|
`skm` never commits and never fetches with git itself; all fetching goes through `nix flake prefetch`. After a change it prints a suggested commit message and tells you to rebuild (or runs your rebuild with `--switch`).
|
|
|
|
## Installation
|
|
|
|
> [!IMPORTANT]
|
|
> Requires Nix with flakes and [home-manager](https://github.com/nix-community/home-manager). The `nix` binary comes from your system, so it matches your daemon.
|
|
|
|
Add the flake as an input and import its home-manager module:
|
|
|
|
```nix
|
|
{
|
|
inputs.skill-manager.url = "git+https://git.jokresner.de/johannes/skm";
|
|
|
|
# in your home-manager configuration
|
|
imports = [ inputs.skill-manager.homeModules.default ];
|
|
|
|
programs.skill-manager = {
|
|
enable = true;
|
|
manifestDir = "/home/me/Repos/nix/home/agents"; # working tree, skm writes here
|
|
lockFile = ./home/agents/skills.lock.json; # same file, read at eval time
|
|
switchCommand = "cd ~/Repos/nix && nixos-rebuild switch --sudo --flake .";
|
|
};
|
|
}
|
|
```
|
|
|
|
| Option | Default | Description |
|
|
|---|---|---|
|
|
| `manifestDir` | | Directory holding `skills.json` and `skills.lock.json` |
|
|
| `lockFile` | | The lockfile as a path inside your flake; pure evaluation can't read `manifestDir` |
|
|
| `targets` | `[ ".claude/skills" ".agents/skills" ]` | Directories, relative to home, that get one symlink per skill |
|
|
| `agentTargets` | `[ ".claude/agents" ]` | Directories, relative to home, that get one `<name>.md` symlink per agent |
|
|
| `switchCommand` | `""` | Command `skm update --switch` runs to apply a new lock |
|
|
| `package` | this flake's `skm` | The `skm` package to install |
|
|
|
|
The module installs `skm` and writes `~/.config/skill-manager/config.json` with `manifestDir` and `switchCommand`.
|
|
|
|
> [!WARNING]
|
|
> For private `git+ssh://` sources, the rebuild must evaluate as your user so `fetchTree` can use your SSH agent. Use `nixos-rebuild switch --sudo …` instead of `sudo nixos-rebuild …`.
|
|
|
|
## Usage
|
|
|
|
Run `skm` with no arguments to open the dashboard. It lists every source and its skills, and checks all sources upstream in the background.
|
|
|
|
| Key | Action |
|
|
|---|---|
|
|
| `↑`/`↓`, `j`/`k` | Move |
|
|
| `u`, `enter` | Review the selected source's update |
|
|
| `U` | Review all outdated sources |
|
|
| `a` | Add a source (URL prompt, then the skill picker) |
|
|
| `d` | Remove the selected skill or source |
|
|
| `r` | Check upstream again |
|
|
| `q` | Quit |
|
|
|
|
In the diff review, `y` accepts a source, `n` skips it, and `tab`/`shift+tab` move between files.
|
|
|
|
### Commands
|
|
|
|
```sh
|
|
skm add github:mattpocock/skills # pick skills interactively
|
|
skm add github:mattpocock/skills --skill tdd,grilling=grilling-mp
|
|
skm add git+ssh://git@host/me/skills --ref main --all
|
|
skm add github:cursor/plugins --agent pstack/agents/comment-sicko.md=comment-sicko
|
|
skm list # installed skills and agents, source, short rev
|
|
skm outdated # changed, added and removed skills upstream
|
|
skm update # review diffs, then write the lock
|
|
skm update tdd --yes --switch # no review, then run switchCommand
|
|
skm remove tdd # or: skm remove --source mattpocock
|
|
skm import --diff # migrate from vercel's skills CLI
|
|
```
|
|
|
|
| Command | Description |
|
|
|---|---|
|
|
| `add <url> [--ref R] [--name N] [--skill a,b=alias,dir/c \| --all] [--agent a,b=alias,dir/c.md \| --all-agents]` | Prefetch a repo, choose skills and/or agents, write manifest and lock. Adding to an existing source keeps its pin. |
|
|
| `remove <name>` / `remove --agent <name>` / `remove --source <source>` | Remove one skill or agent (and the source once it's empty), or a whole source |
|
|
| `list` | Installed skills and agents with source, rev and path |
|
|
| `outdated [source\|skill...]` | Prefetch sources in parallel and report changes |
|
|
| `update [source\|skill...] [--yes] [--switch]` | Review and apply updates. Without a terminal, diffs are printed and confirmed on stdin. |
|
|
| `import [--from lock] [--local dir] [--diff]` | Import `~/.local/state/skills/.skill-lock.json` and compare against committed skill copies |
|
|
|
|
The global `--dir DIR` flag overrides `manifestDir`. Sources are flake refs: `github:owner/repo`, `git+ssh://…` or `git+https://…`.
|
|
|
|
> [!NOTE]
|
|
> Skills live in the read-only Nix store, so you can't edit them in place. To change one, fork it or move it into your own repo.
|
|
|
|
Non-goals: non-git sources (tarballs, registries, local paths), patches or overlays, per-skill targets or pins, and auto-commit.
|
|
|
|
## File formats
|
|
|
|
`skills.json`:
|
|
|
|
```json
|
|
{
|
|
"sources": {
|
|
"mattpocock": {
|
|
"url": "github:mattpocock/skills",
|
|
"skills": ["tdd", "prototype", { "name": "grilling", "as": "grilling-mp" }]
|
|
},
|
|
"own": {
|
|
"url": "git+ssh://git@host/me/skills",
|
|
"ref": "main",
|
|
"skills": "*"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
- `"*"` installs every skill in the repo, including ones added upstream later.
|
|
- `"as"` renames a skill. Two skills with the same installed name are an error.
|
|
- `"path"` picks a skill by directory, for repos that ship the same name twice.
|
|
- To hold one skill back, add a second source entry for the same repo with its own `ref`.
|
|
- `"agents"` takes the same forms as `"skills"` (`"*"`, names, `"as"`, `"path"`) and is optional. An agent is a `.md` file directly inside a directory named `agents`, with a `name:` in its frontmatter; `"path"` is the file. Repos that ship the same agent twice (a Cursor and a Claude Code copy) need `"path"`. A source may install only agents (`"skills": []`).
|
|
- Updates review agents like skills: an agent counts as outdated only when its own file changes.
|
|
|
|
`skills.lock.json` (written by `skm`):
|
|
|
|
```json
|
|
{
|
|
"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" },
|
|
"agents": { "comment-sicko": "pstack/agents/comment-sicko.md" }
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Development
|
|
|
|
The dev shell provides Go and git (`nix develop`, or `devenv shell`).
|
|
|
|
```sh
|
|
go test ./... # unit, TUI and end-to-end tests
|
|
nix flake check # builds the package and runs the tests
|
|
nix build .#skm
|
|
```
|
|
|
|
The end-to-end tests create a temporary `git+file://` repo and need `nix` on `PATH`. They skip inside the Nix build sandbox, so run them with `go test` in the dev shell.
|
|
|
|
> [!TIP]
|
|
> After changing `go.mod`, set `vendorHash` in `flake.nix` to `lib.fakeHash`, build, and copy the hash Nix reports.
|
|
|
|
| Path | Contents |
|
|
|---|---|
|
|
| `cmd/skm/` | CLI entry point and subcommands |
|
|
| `internal/core/` | add, remove, outdated, update and import operations |
|
|
| `internal/fetch/` | `Fetcher` interface and the `nix flake prefetch` implementation |
|
|
| `internal/manifest/`, `internal/lock/` | `skills.json` and `skills.lock.json` |
|
|
| `internal/skills/` | `SKILL.md` and agent definition discovery |
|
|
| `internal/tui/` | bubbletea dashboard, picker and diff review |
|
|
| `nix/module.nix` | home-manager module |
|