feat(shell): deliver project skills through .agents

This commit is contained in:
2026-07-29 11:54:36 -04:00
parent c6beafc53e
commit 02f2017b40
3 changed files with 54 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
# Builds a dev-shell shellHook that links a project's selected skills into its
# own `.claude/skills/` as direct-child symlinks into the Nix store.
# own `.agents/skills/` as direct-child symlinks into the Nix store, with
# `.claude/skills` as a compatibility symlink when that path is free.
skills:
let
storeDir = builtins.storeDir;
@@ -8,7 +9,7 @@ let
);
in
''
# Places this project's Nix-delivered skills into ./.claude/skills/ on shell
# Places this project's Nix-delivered skills into ./.agents/skills/ on shell
# entry.
# Each run first drops every direct-child symlink pointing into the store,
# then relinks the current selection.
@@ -16,12 +17,26 @@ in
# skills for free and needs no manifest.
# A real (non-symlink) skill directory is a hand-authored, project-private
# skill and is left untouched.
# When ./.claude/skills is free, it is kept as a compatibility symlink to the
# canonical ./.agents/skills directory so Claude Code sees the same skills.
# The whole hook runs in a subshell so it leaks no names into the interactive
# shell.
(
_mkskills_dir=".claude/skills"
_mkskills_dir=".agents/skills"
mkdir -p "$_mkskills_dir"
mkdir -p .claude
if [ ! -e .claude/skills ] && [ ! -L .claude/skills ]; then
ln -s ../.agents/skills .claude/skills
elif [ -L .claude/skills ]; then
case "$(readlink .claude/skills)" in
../.agents/skills) : ;;
${storeDir}/*) rm -f .claude/skills && ln -s ../.agents/skills .claude/skills ;;
esac
else
printf 'mkSkillsShellHook: leaving existing non-symlink .claude/skills in place; Claude Code compatibility link not installed\n' >&2
fi
for _mkskills_entry in "$_mkskills_dir"/*; do
[ -L "$_mkskills_entry" ] || continue
case "$(readlink "$_mkskills_entry")" in