Upgrade the installed Peer Forge skill pack in place. Use when the user wants to update their global Claude Code install, or a vendored project-local install, using the packaged upgrade script instead of hand-written git commands.
_UPD=""
if [ -x "./.claude/skills/peer-forge/bin/peer-forge-update-check" ]; then
_UPD=$(./.claude/skills/peer-forge/bin/peer-forge-update-check 2>/dev/null || true)
elif [ -x "$HOME/.claude/skills/peer-forge/bin/peer-forge-update-check" ]; then
_UPD=$("$HOME/.claude/skills/peer-forge/bin/peer-forge-update-check" 2>/dev/null || true)
fi
[ -n "$_UPD" ] && echo "$_UPD" || true
If output shows UPGRADE_AVAILABLE <old> <new>: follow the Inline upgrade flow section below. Prefer the vendored install in ./.claude/skills/peer-forge/ when it exists; otherwise use $HOME/.claude/skills/peer-forge/.
If output shows JUST_UPGRADED <from> <to>: tell the user Running peer-forge v{to} (just updated!) and continue.
This section is referenced by the preambles of the other Peer Forge skills when they detect UPGRADE_AVAILABLE.
State lives in ~/.peer-forge/:
auto-upgrade-enabledupdate-check-disabledupdate-snoozedjust-upgraded-fromPrefer the vendored install in the current repo when it exists. Otherwise fall back to the global install.
PF_ROOT=""
if [ -x "./.claude/skills/peer-forge/bin/peer-forge-upgrade" ]; then
PF_ROOT="./.claude/skills/peer-forge"
elif [ -x "$HOME/.claude/skills/peer-forge/bin/peer-forge-upgrade" ]; then
PF_ROOT="$HOME/.claude/skills/peer-forge"
fi
PF_UPGRADE_BIN="$PF_ROOT/bin/peer-forge-upgrade"
echo "PF_ROOT=$PF_ROOT"
If PF_ROOT is empty, tell the user Peer Forge is not installed at either location and stop.
PF_STATE_DIR="${PEER_FORGE_STATE_DIR:-$HOME/.peer-forge}"
PF_AUTO=$([ -f "$PF_STATE_DIR/auto-upgrade-enabled" ] && echo "true" || echo "false")
echo "AUTO_UPGRADE=$PF_AUTO"
If AUTO_UPGRADE=true, tell the user Auto-upgrading peer-forge v{old} -> v{new}... and continue directly to Step 3.
Otherwise ask the user:
Upgrade nowAlways auto-upgradeNot nowNever ask againIf the user chooses Always auto-upgrade, run:
PF_STATE_DIR="${PEER_FORGE_STATE_DIR:-$HOME/.peer-forge}"
mkdir -p "$PF_STATE_DIR"
touch "$PF_STATE_DIR/auto-upgrade-enabled"
rm -f "$PF_STATE_DIR/update-check-disabled"
Then continue to Step 3.
If the user chooses Not now, write a snooze record with escalating backoff:
PF_STATE_DIR="${PEER_FORGE_STATE_DIR:-$HOME/.peer-forge}"
mkdir -p "$PF_STATE_DIR"
PF_SNOOZE_FILE="$PF_STATE_DIR/update-snoozed"
PF_REMOTE_VER="{new}"
PF_CUR_LEVEL=0
if [ -f "$PF_SNOOZE_FILE" ]; then
PF_SNOOZED_VER=$(awk '{print $1}' "$PF_SNOOZE_FILE" 2>/dev/null || true)
if [ "$PF_SNOOZED_VER" = "$PF_REMOTE_VER" ]; then
PF_CUR_LEVEL=$(awk '{print $2}' "$PF_SNOOZE_FILE" 2>/dev/null || true)
case "$PF_CUR_LEVEL" in *[!0-9]*) PF_CUR_LEVEL=0 ;; esac
fi
fi
PF_NEW_LEVEL=$((PF_CUR_LEVEL + 1))
[ "$PF_NEW_LEVEL" -gt 3 ] && PF_NEW_LEVEL=3
echo "$PF_REMOTE_VER $PF_NEW_LEVEL $(date +%s)" > "$PF_SNOOZE_FILE"
Tell the user the next reminder window:
Then continue with the current skill without upgrading.
If the user chooses Never ask again, run:
PF_STATE_DIR="${PEER_FORGE_STATE_DIR:-$HOME/.peer-forge}"
mkdir -p "$PF_STATE_DIR"
touch "$PF_STATE_DIR/update-check-disabled"
rm -f "$PF_STATE_DIR/auto-upgrade-enabled"
Tell the user update checks are disabled and continue with the current skill.
"$PF_UPGRADE_BIN"
After the upgrade:
just-upgraded-from marker for the next skill loadUse this skill when the user says things like:
Default to upgrading the global install at ~/.claude/skills/peer-forge/bin/peer-forge-upgrade.
If the user explicitly says to upgrade the vendored copy inside the current project, use the local path instead:
./.claude/skills/peer-forge/bin/peer-forge-upgradeIf the global install path does not exist but the current project has a vendored install, upgrade the vendored install instead of failing immediately.
~/.claude/skills/peer-forge/bin/peer-forge-upgrade
./.claude/skills/peer-forge/bin/peer-forge-upgrade
~/.claude/skills/peer-forge/bin/peer-forge-upgrade --check
~/.claude/skills/peer-forge/bin/peer-forge-update-check --force
After the upgrade:
setup re-registered any skill linksIf the install path does not exist:
If git pull --ff-only fails because of local modifications: