Files
skm/PLAN.md
T
johannesandClaude Opus 5.5 6f4d6f5609 feat: bubbletea dashboard, skill picker and update review
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>
2026-10-23 14:29:30 +02:00

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 under programs.skill-manager:
    • enable
    • manifestDir (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 read manifestDir)
    • targets (default [ ".claude/skills" ".agents/skills" ])
    • switchCommand (string)
  • The module reads the lock, calls builtins.fetchTree source.locked for each source, and emits home.file."<target>/<name>".source = "${src}/${subpath}". It also writes ~/.config/skill-manager/config.json with manifestDir and switchCommand, and installs skm.
  • devShells.default: go, gopls, nix.
  • checks: Go tests, including the end-to-end test.

Required changes in ~/Repos/nix

  1. Add skill-manager as a flake input and import its home-manager module in homeManager.johannes.
  2. Rebuild must evaluate as the user so fetchTree on the private git+ssh repo uses the user's SSH agent:
    • Linux: nixos-rebuild switch --sudo --flake … instead of sudo nixos-rebuild … (devenv.nix:85).
    • voyager: nix build .#darwinConfigurations.voyager.system as the user, then sudo ./result/activate (devenv.nix:80).
  3. In modules/home/dotfiles.nix, drop ".claude/skills".source = live "agents/skills" and the skills part of .agents. The module now owns those paths.
  4. After migration: delete home/agents/skills/* from git (keep skills.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: a add (URL prompt, then the picker), d remove, u update the selected source (or U for all outdated), enter diff review, q quit.
  • Diff review: a file list on the left, a scrollable diff viewport on the right, y accept, n skip.
  • 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 during nix flake check and run via go test in the devShell.
  • TUI: the picker, review and dashboard models are driven with key messages directly, asserting on state and ANSI-stripped views (no teatest golden files: less brittle, no extra dependency).

Build order

  1. Flake skeleton + devShell, Go module, Fetcher with the nix implementation.
  2. Manifest/lock packages, add (non-interactive), list, remove.
  3. home-manager module; switch ~/Repos/nix over with one source to prove linking and the eval-as-user rebuild.
  4. outdated, update with a plain-text diff and confirm.
  5. import; migrate all sources. Find origins for c4-model and create-readme; move own skills to the private repo.
  6. bubbletea: picker, diff review, then the dashboard.

Out of scope (v1)

Non-git sources, patches/overlays, per-skill targets, per-skill pins, auto-commit.