aboutsummaryrefslogtreecommitdiff
path: root/scripts/catchup-machine.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-15 17:27:23 -0500
committerCraig Jennings <c@cjennings.net>2026-05-15 17:27:23 -0500
commit9bef4cade4deded85ecbdd9781bd8c5628cb5cc9 (patch)
treea62a186783aef98ee398876cd448a4e54b3e2f6e /scripts/catchup-machine.sh
parent2eab96fb92a1a83f902911e1ed21d09f1cc80f88 (diff)
downloadrulesets-9bef4cade4deded85ecbdd9781bd8c5628cb5cc9.tar.gz
rulesets-9bef4cade4deded85ecbdd9781bd8c5628cb5cc9.zip
feat(make): add catchup-machine target for cross-machine .ai/ sync
scripts/catchup-machine.sh runs the four steps that bring a machine in sync with rulesets canonical: git pull, make install (symlink refresh), make audit APPLY=1 (rsync .ai/ across all projects), and make doctor (verify). Idempotent, safe to re-run any time. Built for the post-fold ratio migration but applies generally: after a fresh rulesets clone on a new machine, or whenever the canonical source has advanced since last sync. Handles dirty working trees by skipping the pull and surfacing a warning; user commits or stashes before re-running.
Diffstat (limited to 'scripts/catchup-machine.sh')
-rwxr-xr-xscripts/catchup-machine.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/catchup-machine.sh b/scripts/catchup-machine.sh
new file mode 100755
index 0000000..e64a871
--- /dev/null
+++ b/scripts/catchup-machine.sh
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+# catchup-machine.sh — bring this machine's rulesets state and all .ai/-using
+# projects in sync with the canonical rulesets repo. Idempotent; safe to re-run.
+#
+# Steps:
+# 1. git pull --ff-only on ~/code/rulesets
+# 2. make install (refresh ~/.claude/ symlinks for any new skills/commands/rules)
+# 3. make audit APPLY=1 (rsync .ai/ template content into every project)
+# 4. make doctor (verify install)
+#
+# Use case: after a fresh clone of rulesets on a new machine, or after the
+# canonical source has advanced and the local machine needs to catch up.
+#
+# Projects with uncommitted .ai/ changes are skipped by step 3 — surface them
+# at the end so the user can commit/stash and re-run.
+
+set -euo pipefail
+
+REPO="$HOME/code/rulesets"
+if [ ! -d "$REPO" ]; then
+ echo "ERROR: $REPO not found — clone rulesets first" >&2
+ exit 1
+fi
+cd "$REPO"
+
+echo "=== Step 1/4: Pull rulesets ==="
+if git diff --quiet --ignore-submodules HEAD -- 2>/dev/null; then
+ git pull --ff-only origin main
+else
+ echo "WARN: working tree is dirty — skipping pull. Commit or stash first to update."
+fi
+
+echo
+echo "=== Step 2/4: make install (refresh symlinks) ==="
+make install
+
+echo
+echo "=== Step 3/4: make audit APPLY=1 (sync .ai/ across projects) ==="
+# Don't bail on non-zero exit — audit returns 1 when any project was skipped or
+# applied. Both are expected outcomes here.
+set +e
+make audit APPLY=1 NO_DOCTOR=1
+audit_exit=$?
+set -e
+
+echo
+echo "=== Step 4/4: make doctor (verify install) ==="
+make doctor
+
+echo
+echo "Done."
+if [ "$audit_exit" -ne 0 ]; then
+ echo
+ echo "Note: audit step exited non-zero, which is expected if any project was"
+ echo "skipped (uncommitted .ai/) or applied (drift fixed). Re-read the audit"
+ echo "output above to see what landed."
+fi