Update nanoclaw

From DingyangLyu/MatClaw · View interactive version

Update nanoclaw is an AI agent skill from the GitHub repository DingyangLyu/MatClaw. Efficiently bring upstream MatClaw updates into a customized install, with preview, selective cherry-pick, and low token usage.

How to use this skill

Skill file

About

Your MatClaw fork drifts from upstream as you customize it. This skill pulls upstream changes into your install without losing your modifications.

Run /update-matclaw in Claude Code.

How it works

Preflight: checks for clean working tree (git status --porcelain). If upstream remote is missing, asks you for the URL (defaults to https://github.com/qwibitai/matclaw.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:

Update paths (you pick one):

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 npm run build and npm test.

Breaking changes check: after validation, reads CHANGELOG.md for any [BREAKING] entries introduced by the update. If found, shows each breaking change and offers to run the recommended skill to migrate.

Rollback

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.

Token usage

Only opens files with actual conflicts. Uses git log, git diff, and git status for everything else. Does not scan or refactor unrelated code.


Goal

Help a user with a customized MatClaw install safely incorporate upstream changes without a fresh reinstall and without blowing tokens.

Operating principles

Step 0: Preflight (stop early if unsafe)

Run:

If output is non-empty:

Confirm remotes:

If upstream is missing:

Determine the upstream branch name:

Fetch:

Step 1: Create a safety net

Capture current state:

Create backup branch and tag (using timestamp to avoid collisions on retry):

Save the tag name for later reference in the summary and rollback instructions.

Step 2: Preview what upstream changed (no edits yet)

Compute common base:

Show upstream commits since BASE:

Show local commits since BASE (custom drift):

Show file-level impact from upstream:

Bucket the upstream changed files:

Present these buckets to the user and ask them to choose one path using AskUserQuestion:

If Abort: stop here.

Step 3: Conflict preview (before committing anything)

If Full update or Rebase:

```

git merge --no-commit --no-ff upstream/$UPSTREAM_BRANCH; git diff --name-only --diff-filter=U; git merge --abort

```

Step 4A: Full update (MERGE, default)

Run:

If conflicts occur:

Step 4B: Selective update (CHERRY-PICK)

If user chose Selective:

If conflicts during cherry-pick:

If user wants to stop:

Step 4C: Rebase (only if user explicitly chose option D)

Run:

If conflicts:

If it gets messy (more than 3 rounds of conflicts):

Step 5: Validation

Run:

If build fails:

Step 6: Breaking changes check

After validation succeeds, check if the update introduced any breaking changes.

Determine which CHANGELOG entries are new by diffing against the backup tag:

Parse the diff output for lines starting with +[BREAKING]. Each such line is one breaking change entry. The format is:

[BREAKING] <description>. Run `/<skill-name>` to <action>.

If no [BREAKING] lines are found:

If one or more [BREAKING] lines are found:

Step 7: Summary + rollback instructions

Show:

Tell the user:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.