nanocoai/update-nanoclaw
Efficiently bring upstream NanoClaw updates into a customized install, with preview, selective cherry-pick, and low token usage.
npx skills add https://github.com/nanocoai/nanoclaw --skill update-nanoclaw
Your NanoClaw fork drifts from upstream as you customize it. This skill pulls upstream changes into your install without losing your modifications.
Run /update-nanoclaw in Claude Code.
Preflight: checks for clean working tree (git status --porcelain). If upstream remote is missing, asks you for the URL (defaults to https://github.com/nanocoai/nanoclaw.git) and adds it. Detects the upstream branch name (main or master).
Backup: creates a timestamped backup branch and tag (backup/pre-update-<hash>-<timestamp>, pre-update-<hash>-<timestamp>) before touching anything. Safe to run multiple times.
Preview: runs git log and git diff against the merge base to show upstream changes since your last sync. Groups changed files into categories:
.claude/skills/): unlikely to conflict unless you edited an upstream skillsrc/): may conflict if you modified the same filescontainer/): triggers container rebuildpackage.json, pnpm-lock.yaml, tsconfig*.json): lockfile changes trigger dep installUpdate paths (you pick one):
merge (default): git merge upstream/<branch>. Resolves all conflicts in one pass.cherry-pick: git cherry-pick <hashes>. Pull in only the commits you want.rebase: git rebase upstream/<branch>. Linear history, but conflicts resolve per-commit.abort: just view the changelog, change nothing.Conflict preview: before merging, runs a dry-run (git merge --no-commit --no-ff) to show which files would conflict. You can still abort at this point.
Conflict resolution: opens only conflicted files, resolves the conflict markers, keeps your local customizations intact.
Validation: runs pnpm run build and pnpm test. If container files changed, also runs the container typecheck and ./container/build.sh.
Breaking changes check: after validation, reads CHANGELOG.md for any [BREAKING] entries introduced by the update. If found, shows each breaking change, reads its migration skill or guide, and offers the recommended migration.
The backup tag is printed at the end of each run:
git reset --hard pre-update-<hash>-<timestamp>
Backup branch backup/pre-update-<hash>-<timestamp> also exists.
Only opens files with actual conflicts. Uses git log, git diff, and git status for everything else. Does not scan or refactor unrelated code.
Help a user with a customized NanoClaw install safely incorporate upstream changes without a fresh reinstall and without blowing tokens.
git status, git log, git diff, and open only conflicted files.The update process itself evolves, so run its newest version before doing anything else:
upstream remote exists (default https://github.com/nanocoai/nanoclaw.git) and fetch: git fetch upstream --prune. Detect the upstream branch (main or master).git show upstream/<branch>:.claude/skills/update-nanoclaw/SKILL.md.
instead of this one. The merge will bring that version into the checkout.
Run:
git status --porcelainIf output is non-empty:
Confirm remotes:
git remote -vIf upstream is missing:
https://github.com/nanocoai/nanoclaw.git).git remote add upstream <user-provided-url>git fetch upstream --pruneDetermine the upstream branch name:
git branch -r | grep upstream/upstream/main exists, use main.upstream/master exists, use master.upstream/main should use upstream/$UPSTREAM_BRANCH instead.Fetch:
git fetch upstream --pruneCapture current state:
HASH=$(git rev-parse --short HEAD)TIMESTAMP=$(date +%Y%m%d-%H%M%S)Create backup branch and tag (using timestamp to avoid collisions on retry):
git branch backup/pre-update-$HASH-$TIMESTAMPgit tag pre-update-$HASH-$TIMESTAMPSave the tag name for later reference in the summary and rollback instructions.
Compute common base:
BASE=$(git merge-base HEAD upstream/$UPSTREAM_BRANCH)Show upstream commits since BASE:
git log --oneline $BASE..upstream/$UPSTREAM_BRANCHShow local commits since BASE (custom drift):
git log --oneline $BASE..HEADShow file-level impact from upstream:
git diff --name-only $BASE..upstream/$UPSTREAM_BRANCHBucket the upstream changed files:
.claude/skills/): unlikely to conflict unless the user edited an upstream skillsrc/): may conflict if user modified the same filescontainer/): triggers container rebuild (+ typecheck if agent-runner/src/ changed)package.json, pnpm-lock.yaml, tsconfig*.json): lockfile changes trigger dep installversions.json): a changed onecli-gateway / onecli-cli value requires upgrading the OneCLI gateway/CLI to match — see Step 5.5Large drift check: If the upstream commit count and age suggest the user has a lot of catching up to do, mention that /migrate-nanoclaw might be a better fit — it extracts customizations and reapplies them on clean upstream instead of merging. Offer it as an option but don't push.
Present these buckets to the user and ask them to choose one path using AskUserQuestion:
If Abort: stop here.
If Full update or Rebase:
git merge --no-commit --no-ff upstream/$UPSTREAM_BRANCH; git diff --name-only --diff-filter=U; git merge --abort
Run:
git merge upstream/$UPSTREAM_BRANCH --no-editIf conflicts occur:
git status and identify conflicted files.git add <file>git commit --no-editIf user chose Selective:
BASE=$(git merge-base HEAD upstream/$UPSTREAM_BRANCH)git log --oneline $BASE..upstream/$UPSTREAM_BRANCHgit cherry-pick <hash1> <hash2> ...If conflicts during cherry-pick:
git add <file>git cherry-pick --continueIf user wants to stop:
git cherry-pick --abortRun:
git rebase upstream/$UPSTREAM_BRANCHIf conflicts:
git add <file>git rebase --continueIf it gets messy (more than 3 rounds of conflicts):
git rebase --abortCheck if the merge changed any lockfiles or package manifests:
git diff <backup-tag-from-step-1>..HEAD --name-only | grep -E '^(pnpm-lock\.yaml|package\.json)$'pnpm installgit diff <backup-tag-from-step-1>..HEAD --name-only | grep -E '^container/agent-runner/(bun\.lock|package\.json)$'command -v bun succeeds: cd container/agent-runner && bun install./container/build.shSkip this step if neither lockfile changed.
Check which areas changed to determine what to validate:
CHANGED_FILES=$(git diff --name-only <backup-tag-from-step-1>..HEAD)Host build (always):
pnpm run buildpnpm test (do not fail the flow if tests are not configured)Container typecheck (only if container/agent-runner/src/ files are in CHANGED_FILES AND bun types are available):
pnpm exec tsc -p container/agent-runner/tsconfig.json --noEmitCannot find type definition file for 'bun'), skip with a note — type errors will surface at container runtime insteadContainer image (only if any container/ files are in CHANGED_FILES, or the agent-image pin moved):
Which command depends on where this install gets its image — check .env for NANOCLAW_HARDENED_IMAGE=true.
true): ./container/build.shtrue): ./container/build.sh pull. Never the bare form — it exits 3 on a pinned install rather than silently replacing the pulled bytes with a local build.A pinned install needs pull in either of two cases, so run it if either holds:
git diff <backup-tag-from-step-1>..HEAD -- versions.json shows the agent-image value changed. A new image was published; nothing re-pulls on its own.container/ file changed, container/agent-runner/bun.lock included.If pull refuses with a lockfile mismatch, that is the guard working, not a bug: the update moved container/agent-runner/bun.lock and no image has been published for the new lockfile yet. /app/src is bind-mounted from this checkout at spawn, so pairing the old image with the new source dies as a missing module inside a --rm container whose logs are discarded. Tell the user and offer the two real options — wait for a published image matching this checkout, or switch this install to local builds with ./container/build.sh build.
If build fails:
The OneCLI gateway and CLI are external components pinned in versions.json; when a pin moves, the running version must be upgraded to match or the new code may fail against it.
If git diff <backup-tag-from-step-1>..HEAD -- versions.json shows the onecli-gateway or onecli-cli value changed, follow docs/onecli-upgrades.md before the service restart (Step 8). Otherwise skip.
After validation succeeds, check if the update introduced any breaking changes.
Determine which CHANGELOG entries are new by diffing against the backup tag:
git diff <backup-tag-from-step-1>..HEAD -- CHANGELOG.mdParse the diff output for lines that contain [BREAKING] anywhere in the line.
Each such line is one breaking change entry and references either a migration
skill or a local guide:
[BREAKING] <description>. Run `/<skill-name>` to <action>.
[BREAKING] <description>. Follow [the migration guide](docs/<guide>.md).
If no [BREAKING] lines are found:
If one or more [BREAKING] lines are found:
/<skill-name> part) and localdocs/*.md migration guide.
detect, why, fix, verify, and rollback sections.
guide. Remove an item only after its migration and verification complete
successfully.
multiSelect: true so the user can pick multiple migrations if there are several.fix steps and then its verification steps.
proceed to Step 7.
Updating your installed skills is part of updating NanoClaw, not an optional
extra. Channel and provider code ships on long-lived branches (channels,
providers) that the host merge above doesn't touch — so stopping here leaves
that code on whatever version you installed, which is how an important upstream
fix gets silently left behind. The default is to continue into /update-skills,
which re-applies your installed channels/providers to pull their latest code.
Detect whether anything is installed: read src/channels/index.ts and
src/providers/index.ts, collecting import './<name>.js'; lines (excluding
cli).
Hand-off — default in, minimal opt-out. Use AskUserQuestion (single-select).
Name the installed skills in the question so the choice is concrete:
channels/providers (<list the detected ones>) ride separate branches the host
update didn't touch. Continue into /update-skills to bring them up to date?"
/update-skills, which re-applies your installed channels/providers to pull
their latest upstream code. You pick which ones there."
/update-skills myself later" — description: "Yourinstalled skill code stays as-is and may be behind upstream."
Keep it to these two options — the per-skill selection lives inside
/update-skills, not here.
/update-skills using the Skill tool. (If the re-applytouches container code, /update-skills rebuilds the agent image itself — see
its Step 4 — so nothing container-related is owed back here.)
/update-skills can be run anytime, then proceed.Channel adapters now declare per-channel wiring defaults (engage mode, threading,
sender policy). Updating trunk alone changes nothing for existing rows, but once
/update-skills pulls current adapter copies, two deliberate behavior changes
land. If the user's install has Slack, Discord, or WhatsApp, tell them:
threads: false for DMs, so DM replies stop chasing per-message sub-threads
and land in the main DM view, matching the DM session (which was already
flat). Group/channel threading is unchanged. To keep the old in-thread DM
behavior for a specific wiring, override it per wiring:
ncl wirings update <wiring-id> --threads true.
channels where the linked account is the operator's personal identity, the
mechanics differ by channel: WhatsApp personal-number mode suppresses the
mention signal entirely (no auto-created messaging groups, no cards);
iMessage and WeChat still emit DM mention signals — stranger DMs still
auto-create messaging_groups rows — but their declared strict policy
makes those rows drop unknown senders silently instead of raising
channel-registration cards to the admin.
WhatsApp installs on a shared/personal number should re-run /add-whatsapp
after the skill update: it now asks the dedicated-vs-personal question
explicitly (writing ASSISTANT_HAS_OWN_NUMBER to .env), audits for legacy
mis-wired group rows from spam-era approval cards, and shows how to clear
stale pending approvals.
Proceed to Step 7.9.
After validation has succeeded, record that this install reached the new version through the supported path. Without this, the startup tripwire stops the host on its next start.
pnpm exec tsx scripts/upgrade-state.ts set "" update-nanoclawpackage.json version.If validation did NOT succeed, do not stamp — leave the tripwire to catch the broken state.
Proceed to Step 8.
Show:
git rev-parse --short HEADgit rev-parse --short upstream/$UPSTREAM_BRANCHgit diff --name-only upstream/$UPSTREAM_BRANCH..HEADIf unresolved migrations remain, explain plainly that the code update succeeded
but affected features may ignore old state until those migrations run. Use
AskUserQuestion before showing restart commands:
follow each unresolved guide, removing it from the list only after successful
completion and verification.
unresolved migration names in the final warning.
If a retried migration remains unresolved, ask again. Do not show restart
commands until the unresolved list is empty or the user explicitly chooses
Restart anyway.
Tell the user:
git reset --hard <backup-tag-from-step-1>backup/pre-update-<HASH>-<TIMESTAMP>setup/lib/install-slug.sh. Run from your NanoClaw project root:source setup/lib/install-slug.sh && launchctl kickstart -k gui/$(id -u)/$(launchd_label)source setup/lib/install-slug.sh && systemctl --user restart $(systemd_unit) (or, if you want to confirm the unit name first: systemctl --user list-units --type=service | grep "$(. setup/lib/install-slug.sh && systemd_unit)")pnpm run dev.claude/skills/update-nanoclaw/diagnostics.md.Take nanocoai/update-nanoclaw from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference npm.
Without those the skill loads but fails at the first command.