agentleFS
no-sessionno-session/pstack/pstack-upgrade/SKILL.md

pstack-upgrade

Skill96 starsChanged 7 months agoMITView on GitHub

Upgrade pstack to the latest version. Detects global vs vendored install, runs the upgrade, and shows what's new. Use when asked to "upgrade pstack", "update pstack", or "get latest version".

  • Deletes or force-pushes

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 7 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If "Not now": Write snooze state with escalating backoff (first snooze = 24h, second = 48h, third+ = 1 week), then continue with the …

    line 49
  2. Distinctive:

    Use the install directory from Step 2's output below:

    line 108
  3. Distinctive:

    Use the install type and directory detected in Step 2:

    line 116
  4. Very specific:

    If $STASH_OUTPUT contains "Saved working directory", warn the user: "Note: local changes were stashed.

    line 126
  5. Distinctive:

    Use the install directory from Step 2.

    line 141
  6. Very specific:

    If LOCAL_PSTACK is non-empty, update it by copying from the freshly-upgraded primary install (same approach as README vendored install):

    line 156
  7. Very specific:

    If ./setup fails, restore from backup and warn the user:

    line 166
  8. Very specific:

    Read $INSTALL_DIR/CHANGELOG.md.

    line 184
  9. Distinctive:

    After showing What's New, continue with whatever skill the user originally invoked.

    line 200
  10. Very specific:

    When invoked directly as /pstack-upgrade (not from a preamble):

    line 206
  11. Distinctive:

    Use the output to determine if an upgrade is available.

    line 213
  12. Very specific:

    If UPGRADE_AVAILABLE <old> <new>: follow Steps 2-6 above.

    line 215
  13. Distinctive:

    If no output (primary is up to date): check for a stale local vendored copy.

    line 217
  14. Very specific:

    Run the Step 2 bash block above to detect the primary install type and directory (INSTALL_TYPE and INSTALL_DIR).

    line 219
  15. Very specific:

    If versions differ: follow the Step 4.5 sync bash block above to update the local copy from the primary.

    line 230

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly --><!-- Regenerate: bun run gen:skill-docs -->

/pstack-upgrade

Upgrade pstack to the latest version and show what's new.

Inline upgrade flow

This section is referenced by all skill preambles when they detect UPGRADE_AVAILABLE.

Step 1: Ask the user (or auto-upgrade)

First, check if auto-upgrade is enabled:

_AUTO=""
[ "${PSTACK_AUTO_UPGRADE:-}" = "1" ] && _AUTO="true"
[ -z "$_AUTO" ] && _AUTO=$(~/.claude/skills/pstack/bin/pstack-config get auto_upgrade 2>/dev/null || true)
echo "AUTO_UPGRADE=$_AUTO"

If AUTO_UPGRADE=true or AUTO_UPGRADE=1: Skip AskUserQuestion. Log "Auto-upgrading pstack v{old} → v{new}..." and proceed directly to Step 2. If ./setup fails during auto-upgrade, restore from backup (.bak directory) and warn the user: "Auto-upgrade failed — restored previous version. Run /pstack-upgrade manually to retry."

Otherwise, use AskUserQuestion:

  • Question: "pstack v{new} is available (you're on v{old}). Upgrade now?"
  • Options: ["Yes, upgrade now", "Always keep me up to date", "Not now", "Never ask again"]

If "Yes, upgrade now": Proceed to Step 2.

If "Always keep me up to date":

~/.claude/skills/pstack/bin/pstack-config set auto_upgrade true

Tell user: "Auto-upgrade enabled. Future updates will install automatically." Then proceed to Step 2.

If "Not now": Write snooze state with escalating backoff (first snooze = 24h, second = 48h, third+ = 1 week), then continue with the current skill. Do not mention the upgrade again.

_SNOOZE_FILE=~/.pstack/update-snoozed
_REMOTE_VER="{new}"
_CUR_LEVEL=0
if [ -f "$_SNOOZE_FILE" ]; then
  _SNOOZED_VER=$(awk '{print $1}' "$_SNOOZE_FILE")
  if [ "$_SNOOZED_VER" = "$_REMOTE_VER" ]; then
    _CUR_LEVEL=$(awk '{print $2}' "$_SNOOZE_FILE")
    case "$_CUR_LEVEL" in *[!0-9]*) _CUR_LEVEL=0 ;; esac
  fi
fi
_NEW_LEVEL=$((_CUR_LEVEL + 1))
[ "$_NEW_LEVEL" -gt 3 ] && _NEW_LEVEL=3
echo "$_REMOTE_VER $_NEW_LEVEL $(date +%s)" > "$_SNOOZE_FILE"

Note: {new} is the remote version from the UPGRADE_AVAILABLE output — substitute it from the update check result.

Tell user the snooze duration: "Next reminder in 24h" (or 48h or 1 week, depending on level). Tip: "Set auto_upgrade: true in ~/.pstack/config.yaml for automatic upgrades."

If "Never ask again":

~/.claude/skills/pstack/bin/pstack-config set update_check false

Tell user: "Update checks disabled. Run ~/.claude/skills/pstack/bin/pstack-config set update_check true to re-enable." Continue with the current skill.

Step 2: Detect install type

if [ -d "$HOME/.claude/skills/pstack/.git" ]; then
  INSTALL_TYPE="global-git"
  INSTALL_DIR="$HOME/.claude/skills/pstack"
elif [ -d "$HOME/.pstack/repos/pstack/.git" ]; then
  INSTALL_TYPE="global-git"
  INSTALL_DIR="$HOME/.pstack/repos/pstack"
elif [ -d ".claude/skills/pstack/.git" ]; then
  INSTALL_TYPE="local-git"
  INSTALL_DIR=".claude/skills/pstack"
elif [ -d ".agents/skills/pstack/.git" ]; then
  INSTALL_TYPE="local-git"
  INSTALL_DIR=".agents/skills/pstack"
elif [ -d ".claude/skills/pstack" ]; then
  INSTALL_TYPE="vendored"
  INSTALL_DIR=".claude/skills/pstack"
elif [ -d "$HOME/.claude/skills/pstack" ]; then
  INSTALL_TYPE="vendored-global"
  INSTALL_DIR="$HOME/.claude/skills/pstack"
else
  echo "ERROR: pstack not found"
  exit 1
fi
echo "Install type: $INSTALL_TYPE at $INSTALL_DIR"

The install type and directory path printed above will be used in all subsequent steps.

Step 3: Save old version

Use the install directory from Step 2's output below:

OLD_VERSION=$(cat "$INSTALL_DIR/VERSION" 2>/dev/null || echo "unknown")

Step 4: Upgrade

Use the install type and directory detected in Step 2:

For git installs (global-git, local-git):

cd "$INSTALL_DIR"
STASH_OUTPUT=$(git stash 2>&1)
git fetch origin
git reset --hard origin/main
./setup

If $STASH_OUTPUT contains "Saved working directory", warn the user: "Note: local changes were stashed. Run git stash pop in the skill directory to restore them."

For vendored installs (vendored, vendored-global):

PARENT=$(dirname "$INSTALL_DIR")
TMP_DIR=$(mktemp -d)
git clone --depth 1 https://github.com/garrytan/pstack.git "$TMP_DIR/pstack"
mv "$INSTALL_DIR" "$INSTALL_DIR.bak"
mv "$TMP_DIR/pstack" "$INSTALL_DIR"
cd "$INSTALL_DIR" && ./setup
rm -rf "$INSTALL_DIR.bak" "$TMP_DIR"

Step 4.5: Sync local vendored copy

Use the install directory from Step 2. Check if there's also a local vendored copy that needs updating:

_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
LOCAL_PSTACK=""
if [ -n "$_ROOT" ] && [ -d "$_ROOT/.claude/skills/pstack" ]; then
  _RESOLVED_LOCAL=$(cd "$_ROOT/.claude/skills/pstack" && pwd -P)
  _RESOLVED_PRIMARY=$(cd "$INSTALL_DIR" && pwd -P)
  if [ "$_RESOLVED_LOCAL" != "$_RESOLVED_PRIMARY" ]; then
    LOCAL_PSTACK="$_ROOT/.claude/skills/pstack"
  fi
fi
echo "LOCAL_PSTACK=$LOCAL_PSTACK"

If LOCAL_PSTACK is non-empty, update it by copying from the freshly-upgraded primary install (same approach as README vendored install):

mv "$LOCAL_PSTACK" "$LOCAL_PSTACK.bak"
cp -Rf "$INSTALL_DIR" "$LOCAL_PSTACK"
rm -rf "$LOCAL_PSTACK/.git"
cd "$LOCAL_PSTACK" && ./setup
rm -rf "$LOCAL_PSTACK.bak"

Tell user: "Also updated vendored copy at $LOCAL_PSTACK — commit .claude/skills/pstack/ when you're ready."

If ./setup fails, restore from backup and warn the user:

rm -rf "$LOCAL_PSTACK"
mv "$LOCAL_PSTACK.bak" "$LOCAL_PSTACK"

Tell user: "Sync failed — restored previous version at $LOCAL_PSTACK. Run /pstack-upgrade manually to retry."

Step 5: Write marker + clear cache

mkdir -p ~/.pstack
echo "$OLD_VERSION" > ~/.pstack/just-upgraded-from
rm -f ~/.pstack/last-update-check
rm -f ~/.pstack/update-snoozed

Step 6: Show What's New

Read $INSTALL_DIR/CHANGELOG.md. Find all version entries between the old version and the new version. Summarize as 5-7 bullets grouped by theme. Don't overwhelm — focus on user-facing changes. Skip internal refactors unless they're significant.

Format:

pstack v{new} — upgraded from v{old}!

What's new:
- [bullet 1]
- [bullet 2]
- ...

Happy shipping!

Step 7: Continue

After showing What's New, continue with whatever skill the user originally invoked. The upgrade is done — no further action needed.


Standalone usage

When invoked directly as /pstack-upgrade (not from a preamble):

  1. Force a fresh update check (bypass cache):
~/.claude/skills/pstack/bin/pstack-update-check --force 2>/dev/null || \
.claude/skills/pstack/bin/pstack-update-check --force 2>/dev/null || true

Use the output to determine if an upgrade is available.

  1. If UPGRADE_AVAILABLE <old> <new>: follow Steps 2-6 above.
  2. If no output (primary is up to date): check for a stale local vendored copy.

Run the Step 2 bash block above to detect the primary install type and directory (INSTALL_TYPE and INSTALL_DIR). Then run the Step 4.5 detection bash block above to check for a local vendored copy (LOCAL_PSTACK).

If LOCAL_PSTACK is empty (no local vendored copy): tell the user "You're already on the latest version (v{version})."

If LOCAL_PSTACK is non-empty, compare versions:

PRIMARY_VER=$(cat "$INSTALL_DIR/VERSION" 2>/dev/null || echo "unknown")
LOCAL_VER=$(cat "$LOCAL_PSTACK/VERSION" 2>/dev/null || echo "unknown")
echo "PRIMARY=$PRIMARY_VER LOCAL=$LOCAL_VER"

If versions differ: follow the Step 4.5 sync bash block above to update the local copy from the primary. Tell user: "Global v{PRIMARY_VER} is up to date. Updated local vendored copy from v{LOCAL_VER} → v{PRIMARY_VER}. Commit .claude/skills/pstack/ when you're ready."

If versions match: tell the user "You're on the latest version (v{PRIMARY_VER}). Global and local vendored copy are both up to date."

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.