AgentSkillsCN

re-skill

检查已安装的Claude Code技能更新情况。该工具可对比本地版本与远程版本,在升级过程中保留本地自定义设置,并在有市场新版本可用时提供迁移建议。运行/re-skill可全面检测所有技能,或通过/re-skill [名称]仅检测特定技能。

SKILL.md
--- frontmatter
name: re-skill
description: >
  Check for updates to installed Claude Code skills. Compares local vs remote
  versions, preserves local customizations during upgrades, and suggests
  marketplace migration when available. Run /re-skill to check all skills,
  or /re-skill [name] to check a specific one.
argument-hint: "[skill-name] or leave blank for all"
allowed-tools: Bash, Read, Write, AskUserQuestion, WebSearch
disable-model-invocation: false

re-skill — Skill Update Manager

You are managing updates for Claude Code skills installed via git clone in ~/.claude/skills/. Follow these steps in order.

If an argument was provided (e.g., /re-skill my-skill), only process that single skill. Otherwise, process all discovered skills.


Step 1: Initialize Registry

Read the registry file at ~/.config/re-skill/registry.json. If it doesn't exist, create it with this structure:

json
{
  "version": 1,
  "lastGlobalCheck": null,
  "skills": {}
}

Create the directory ~/.config/re-skill/ if needed (mkdir -p).


Step 2: Scan & Discover Skills

List all directories in ~/.claude/skills/*/. For each directory that contains a .git folder, collect:

  • Name: directory basename
  • Remote URL: git -C <path> remote get-url origin (may fail if no remote)
  • Current commit: git -C <path> rev-parse HEAD
  • Default branch: try git -C <path> symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||', fall back to checking for origin/main then origin/master, then git -C <path> remote show origin | grep 'HEAD branch'
  • Local modifications: git -C <path> status --porcelain
  • Diff of modifications: git -C <path> diff and git -C <path> diff --cached

Skip directories without .git — they are not git-cloned skills.

If a specific skill name was given as argument and it doesn't exist or has no .git, report the error and stop.


Step 3: First-Run Onboarding

For each discovered skill that is not yet in the registry and has local modifications (non-empty porcelain output or diff):

  1. Show the user the diff output so they can see what was changed
  2. Use AskUserQuestion to ask them to describe what these customizations do and why they were made. For example, a user might have wrapped script commands with doppler run for secrets injection, or adjusted prompts for their workflow.
  3. Store the skill in the registry with their description under customizations

For skills not in the registry that have no local modifications, register them silently with an empty customizations array.


Step 4: Check for Updates

For each skill being processed:

  1. Run git -C <path> fetch origin to get latest remote state
  2. Compare local HEAD with remote: git -C <path> rev-list HEAD..origin/<branch> --count
  3. If there are new commits, collect the log: git -C <path> log --oneline HEAD..origin/<branch>
  4. If a version file exists (e.g., package.json, .claude-plugin/plugin.json), note current and incoming versions

If fetch fails (network error, no remote), report the error for that skill and continue with the next one.

Skills with 0 new commits are "up to date" — note this and move on.


Step 5: Present Changes

For each skill with available updates, use AskUserQuestion to present:

  • Number of new commits
  • Commit log (abbreviated)
  • Version change if detectable (e.g., 1.0.0 → 1.1.0)
  • Whether the user has local customizations that will need reapplication

Ask the user to choose:

  • Update now — proceed with backup and update
  • Skip — leave this skill as-is
  • View full diff — show git -C <path> diff HEAD..origin/<branch> before deciding

Step 6: Backup & Apply Update

Backups are always created before any update. This is not optional.

For each skill the user chose to update:

Backup

  1. Create backup directory: ~/.config/re-skill/backups/<skill-name>/<timestamp>/ where timestamp is ISO-like (e.g., 2026-02-08T16-00-00)
  2. Copy the entire skill directory into the backup: cp -a ~/.claude/skills/<skill-name>/. ~/.config/re-skill/backups/<skill-name>/<timestamp>/
  3. Confirm backup was created successfully before proceeding

Apply

  1. If there are local modifications: git -C <path> stash
  2. Pull updates: git -C <path> pull origin <branch>
  3. If there were stashed changes: git -C <path> stash pop
  4. Update the registry entry with new commit hash, timestamp, etc.

Step 7: Handle Conflicts

If git stash pop fails due to conflicts:

  1. Show the conflicted files: git -C <path> diff --name-only --diff-filter=U
  2. For each conflicted file, show the conflict markers using Read
  3. Use AskUserQuestion to ask the user how to resolve each conflict:
    • Keep upstream version — accept the new version, discard local change
    • Keep local version — keep the customization, discard upstream change
    • Manual merge — user provides the resolved content
  4. After resolution, stage the files and complete the merge: git -C <path> add <file> && git -C <path> reset
  5. Remind the user that the pre-update backup is available at ~/.config/re-skill/backups/<skill-name>/<timestamp>/ if they want to reference the original

Step 8: Marketplace Migration Check

For each skill processed, use WebSearch to search for: "<skill-name>" Claude Code plugin marketplace

If results suggest the skill is now available as an official plugin:

  • Inform the user: "This skill appears to be available as an official plugin. You could install it via the plugin marketplace for automatic updates. Note: local customizations would not be preserved by the plugin system."
  • Do not auto-migrate. Just inform.

If no results or inconclusive, skip silently.


Step 9: Summary

Display a summary table of all processed skills:

SkillStatusVersionCustomizationsBackup
(name)Up to date / Updated / Skipped / Error(commit or version)(count or "none")(path or n/a)

Update lastGlobalCheck in the registry and write it back to ~/.config/re-skill/registry.json.


Important Behaviors

  • Never update without confirmation — every destructive action goes through AskUserQuestion
  • Always backup before updating — the full skill directory is copied before any git operations
  • Graceful degradation — if one skill fails, continue processing the rest
  • Registry is the source of truth — always read before modifying, always write after changes
  • No assumptions about installed skills — everything is discovered dynamically by scanning the filesystem