This document explains how the Schwung Module Creator skill auto-updates itself using Claude Code hooks.
User invokes skill
↓
Claude Code reads settings.json hooks
↓
Hook triggers BEFORE skill execution
↓
skill-update.sh runs
↓
Checks GitHub for updates
↓
If newer version exists:
- Downloads from GitHub
- Compares with local version
- Backs up current version
- Updates local SKILL.md
↓
Skill execution continues (with latest code)
Located at scripts/skill-update.sh, this script:
- Checks GitHub for the latest skill.md
- Downloads the remote version via curl
- Compares local vs remote using SHA256 hashes
- Backs up the current version before updating
- Throttles checks (only checks every hour max)
- Handles errors gracefully (continues if check fails)
A hook is a shell command that runs in response to system events. We use the skill:invoke event:
{
"hooks": {
"skill:invoke": {
"command": "bash ~/.claude/projects/-Users-click-Desktop-Move/scripts/skill-update.sh"
}
}
}When ANY skill is invoked, the hook runs before execution. For efficiency, the script:
- Only updates once per hour
- Silently skips if GitHub is unreachable
- Runs in <100ms normally (just timestamp check)
If an update breaks something:
# Restore previous version
cp ~/.claude/skills/schwung-module-creator/SKILL.md.backup \
~/.claude/skills/schwung-module-creator/SKILL.mdchmod +x /Users/click/Desktop/Move/schwung/scripts/skill-update.shIn Claude Code settings (.claude/settings.json or via UI):
Add this to your settings.json under the hooks section:
{
"hooks": {
"skill:invoke": {
"description": "Auto-update Schwung skill from GitHub",
"command": "bash /Users/click/Desktop/Move/schwung/scripts/skill-update.sh",
"silent": true
}
}
}Note: Adjust the path if your project is in a different location. Use absolute paths, not relative paths.
-
Run the script manually to test:
bash /Users/click/Desktop/Move/schwung/scripts/skill-update.sh
-
Check that it created the skill file:
ls -lh ~/.claude/skills/schwung-module-creator/SKILL.md -
Invoke the skill in Claude Code — the hook should run silently in the background
When GitHub has a newer version, the following are automatically updated:
- ✅ All API documentation
- ✅ Module structure and patterns
- ✅ Build/deployment commands
- ✅ Troubleshooting guides
- ✅ Code style guidelines
- ✅ New features and capabilities
The skill picks up the latest changes on next skill invocation.
The script includes smart throttling to avoid excessive GitHub requests:
CHECK_INTERVAL=3600 # Check every hour maxHow it works:
- Script checks timestamp in
~/.cache/schwung-skill/last_check.txt - If less than 1 hour has passed since last check, skip the HTTP request
- Cache is updated on every run (even if no check was performed)
- First run always checks (no timestamp yet)
Result: After the first check, subsequent runs complete in <1ms (just a file stat).
To force an immediate update without waiting for the hook:
bash /Users/click/Desktop/Move/schwung/scripts/skill-update.shTo see what changed:
# View the backup (old version)
diff ~/.claude/skills/schwung-module-creator/SKILL.md.backup \
~/.claude/skills/schwung-module-creator/SKILL.md- Check settings.json syntax (must be valid JSON)
- Verify the hook path is correct:
ls -la /Users/click/Desktop/Move/schwung/scripts/skill-update.sh
- Check file is executable:
test -x /Users/click/Desktop/Move/schwung/scripts/skill-update.sh && echo "OK" || echo "Not executable"
If the GitHub URL is down:
- Script silently skips update (continues normally)
- Uses cached version from last successful check
- No user interaction required
If an update causes issues:
# Restore from backup
cp ~/.claude/skills/schwung-module-creator/SKILL.md.backup \
~/.claude/skills/schwung-module-creator/SKILL.md
# Delete the backup to trigger a fresh download next time
rm ~/.claude/skills/schwung-module-creator/SKILL.md.backupRemove or comment out the hook in settings.json:
{
"hooks": {
// "skill:invoke": { ... } // Commented out to disable
}
}The skill checks this file for updates:
https://raw.githubusercontent.com/xbraindance/Schwung-Module-Creator-skill/main/skill.md
Update sources:
mainbranch is the only source (production-ready)- Updates go to GitHub → Raw GitHub URL → Synced to local skill
- You control the update frequency (default: hourly)
To change the check interval, edit the script:
# In skill-update.sh, change this line:
CHECK_INTERVAL=3600 # Change to 1800 for 30 minutes, 7200 for 2 hours, etc.Interval is in seconds: 1800 = 30 min, 3600 = 1 hour, 86400 = 1 day
| Feature | Benefit |
|---|---|
| Automatic | No manual updates needed |
| Throttled | Minimal GitHub requests, fast execution |
| Safe | Backs up before updating |
| Silent | Runs in background, no notifications |
| Reversible | Easy rollback if needed |
Once set up, you get the latest skill features automatically while staying in control.