feat(agents): mirror ~/.agents/skills into ~/.claude/skills

Per-skill symlinks, refreshed on activation and via a systemd path unit
watching ~/.agents/skills (agent-lib sync). Claude's own entries are
never touched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
m3tam3reandClaude Opus 5.5 committed 2026-10-24 09:35:35 +02:00
1 parent 8a557cf4fc
commit d608fb29b1
2 files changed
+66

No files matched your search

+1
View File
@@ -19,6 +19,7 @@
imports = [
# Babysitter agent and OpenCode/Pi tool configurations
./babysitter.nix
./claude-skills.nix
./opencode.nix
./pi.nix
];
@@ -0,0 +1,65 @@
# Mirror agent-lib skills (~/.agents/skills) into Claude Code (~/.claude/skills).
# Each skill gets its own symlink, so Claude's own entries (e.g. `synced/`,
# hand-made skills) stay untouched. Runs on every activation and whenever
# the source directory changes (e.g. after `agent-lib sync`).
{
config,
lib,
pkgs,
...
}: let
src = "${config.home.homeDirectory}/.agents/skills";
dst = "${config.home.homeDirectory}/.claude/skills";
syncSkills = pkgs.writeShellApplication {
name = "claude-skills-sync";
runtimeInputs = [pkgs.coreutils];
text = ''
src=${lib.escapeShellArg src}
dst=${lib.escapeShellArg dst}
mkdir -p "$src" "$dst"
# Drop links into $src whose target is gone.
for link in "$dst"/*; do
[ -L "$link" ] || continue
case "$(readlink "$link")" in
"$src"/*) [ -e "$link" ] || rm -f "$link" ;;
esac
done
# Link every skill folder; never replace a real dir or foreign link.
for skill in "$src"/*/; do
skill="''${skill%/}"
[ -f "$skill/SKILL.md" ] || continue
name="$(basename "$skill")"
target="$dst/$name"
if [ -L "$target" ] || [ ! -e "$target" ]; then
ln -sfn "$skill" "$target"
fi
done
'';
};
in {
home.packages = [syncSkills];
home.activation.claudeSkillsSync = lib.hm.dag.entryAfter ["writeBoundary"] ''
run ${lib.getExe syncSkills}
'';
systemd.user.paths.claude-skills-sync = {
Unit.Description = "Watch ~/.agents/skills for changes";
Path = {
PathChanged = src;
MakeDirectory = true;
};
Install.WantedBy = ["paths.target"];
};
systemd.user.services.claude-skills-sync = {
Unit.Description = "Link ~/.agents/skills into ~/.claude/skills";
Service = {
Type = "oneshot";
ExecStart = lib.getExe syncSkills;
};
};
}