Skip to content

Instantly share code, notes, and snippets.

@angelo-swe
Created July 19, 2026 01:09
Show Gist options
  • Select an option

  • Save angelo-swe/15d635bd58e265cf52991c34e050d1b8 to your computer and use it in GitHub Desktop.

Select an option

Save angelo-swe/15d635bd58e265cf52991c34e050d1b8 to your computer and use it in GitHub Desktop.
The 72-Hour Rule — stop your AI from installing poisoned packages (CLAUDE.md rule + terminal guard)

The 72-Hour Rule — stop your AI from installing poisoned packages

Why this exists: in May 2026 the "Mini Shai-Hulud" worm compromised 84 versions across 42 popular npm packages (the @tanstack family plus others) using malicious install scripts — code that runs the moment the package installs. Almost all supply-chain attacks like this get detected and pulled within the first 2–3 days. So the defense is patience, enforced.

Part 1 — the CLAUDE.md rule (paste into your instructions file)

# Supply Chain Security (npm/bun)

**Always use `ba` to add new packages, never `bun add` / `npm install` directly.**
`ba` is a shell function that refuses to install any package version published in
the last 72 hours — the window in which most supply-chain worms get detected
and yanked.

If `ba` returns `BLOCKED: ... published Xh ago (<72h)` — STOP. Do not work around
it. Do not fall back to a direct install. Tell me and we'll decide whether to pin
an older version or wait.

**Never expand `trustedDependencies` / never approve postinstall scripts** for a
package not already on the allowlist. The block on install scripts IS the
protection — don't "fix" warnings by trusting new packages.

Part 2 — the terminal guard (paste into ~/.zshrc, works with bun or npm)

# ba = bun-safe-add: refuse packages published <72h ago
ba() {
  local pkg ver published age_h now
  now=$(date +%s)
  for pkg in "$@"; do
    ver=$(npm view "$pkg" version 2>/dev/null) || { echo "not found: $pkg"; return 1 }
    published=$(npm view "${pkg%%@*}" "time[$ver]" 2>/dev/null)
    age_h=$(( (now - $(date -j -f "%Y-%m-%dT%H:%M:%S" "${published%%.*}" +%s 2>/dev/null || date -d "${published}" +%s)) / 3600 ))
    if (( age_h < 72 )); then
      echo "BLOCKED: $pkg@$ver published ${age_h}h ago (<72h)"
      return 1
    fi
    echo "ok: $pkg@$ver published ${age_h}h ago"
  done
  bun add "$@"   # swap for: npm install "$@"
}

How it plays out: you (or your agent) type ba somepackage, and if that version is younger than 72 hours you get a hard BLOCKED line instead of an install. The CLAUDE.md rule makes sure the agent treats BLOCKED as "stop and ask," never "find another way."

Same logic as not updating your iPhone on day one — let somebody else find the problems.

— Angelo (@angelotrifanoff.ai)

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