Skip to content

Instantly share code, notes, and snippets.

@memememomo
Created March 25, 2026 06:16
Show Gist options
  • Select an option

  • Save memememomo/7cb7e83f45545e955f6e7ccb558a4c77 to your computer and use it in GitHub Desktop.

Select an option

Save memememomo/7cb7e83f45545e955f6e7ccb558a4c77 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# anthropics/skills の skill-creator を取得し、リポジトリの .claude/skills/ に配置する。
# 前提: curl, tar。ルート判定に git を使うことがある(REPO_ROOT を指定すれば git は不要)
#
# --- Gist に置いて curl で実行する場合 ---
# 1. このファイルを Gist にアップロードする(公開 / 非公開どちらでも可)
# 2. Gist 画面の「Raw」を開き、ブラウザのアドレスバーの URL をコピーする
# 3. 対象リポジトリのルートに cd してから:
# curl -fsSL '<RAWのURL>' | bash
# リポジトリ外から実行する場合は REPO_ROOT を指定:
# curl -fsSL '<RAWのURL>' | env REPO_ROOT=/path/to/repo bash
#
set -euo pipefail
REPO_SLUG="anthropics/skills"
BRANCH="${BRANCH:-main}"
ARCHIVE_URL="https://codeload.github.com/${REPO_SLUG}/tar.gz/refs/heads/${BRANCH}"
# curl | bash では BASH_SOURCE がファイルパスにならないため、REPO_ROOT / git / scripts 配置で決める。
resolve_repo_root() {
if [[ -n "${REPO_ROOT:-}" ]]; then
(cd "$REPO_ROOT" && pwd)
return
fi
local src="${BASH_SOURCE[0]:-}"
if [[ -n "$src" && -f "$src" ]]; then
local d
d="$(cd "$(dirname "$src")" && pwd)"
if [[ "$(basename "$d")" == "scripts" ]]; then
(cd "$d/.." && pwd)
return
fi
fi
local root
if root="$(git rev-parse --show-toplevel 2>/dev/null)"; then
echo "$root"
return
fi
echo "error: リポジトリルートを特定できません。対象リポジトリのディレクトリで実行するか、REPO_ROOT を指定してください。" >&2
exit 1
}
REPO_ROOT="$(resolve_repo_root)"
DEST="${REPO_ROOT}/.claude/skills/skill-creator"
usage() {
cat <<EOF
使い方:
リポジトリ内: $0
Gist 経由: cd /path/to/repo && curl -fsSL '<Gist Raw URL>' | bash
環境変数:
REPO_ROOT 配置先リポジトリのルート(未指定時は git の toplevel、または scripts/ から推定)
BRANCH 取得するブランチ(デフォルト: main)
取得元:
https://github.com/${REPO_SLUG}/tree/\${BRANCH}/skills/skill-creator
出力先:
${DEST}
EOF
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi
tmpdir=
cleanup() {
[[ -n "${tmpdir}" && -d "${tmpdir}" ]] && rm -rf "${tmpdir}"
}
trap cleanup EXIT
tmpdir="$(mktemp -d)"
echo "Downloading ${ARCHIVE_URL} ..."
curl -fsSL "${ARCHIVE_URL}" | tar -xz -C "${tmpdir}"
root="$(find "${tmpdir}" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
if [[ -z "${root}" || ! -d "${root}/skills/skill-creator" ]]; then
echo "error: skills/skill-creator がアーカイブ内に見つかりません" >&2
exit 1
fi
mkdir -p "${REPO_ROOT}/.claude/skills"
rm -rf "${DEST}"
cp -a "${root}/skills/skill-creator" "${DEST}"
echo "更新しました: ${DEST}"
@memememomo
Copy link
Copy Markdown
Author

memememomo commented Mar 25, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment