From 733ad65122087f5746e54343750f5c4af56b26b2 Mon Sep 17 00:00:00 2001 From: gold-silver-copper <157451540+gold-silver-copper@users.noreply.github.com> Date: Sun, 25 Oct 2026 16:13:38 -0700 Subject: [PATCH 1/3] docs: stop pointing at meta git snapshot `meta context` no longer lists it as a key command, and the rules and skills that `meta init` installs say to commit or branch first and use git reflog to recover commits. Refs [[tasks/harmony-2754]] --- .claude/rules/meta-destructive-commands.md | 17 +++++++--- .claude/skills/meta-exec/SKILL.md | 2 +- .claude/skills/meta-git/SKILL.md | 37 +++++++++------------- .claude/skills/meta-plugins/SKILL.md | 1 - src/context.rs | 4 --- src/subprocess_plugins.rs | 4 +-- 6 files changed, 30 insertions(+), 35 deletions(-) diff --git a/.claude/rules/meta-destructive-commands.md b/.claude/rules/meta-destructive-commands.md index b06f534..8fa9d43 100644 --- a/.claude/rules/meta-destructive-commands.md +++ b/.claude/rules/meta-destructive-commands.md @@ -4,10 +4,12 @@ Multi-repo workspaces amplify the impact of destructive commands. ## Before Destructive Operations -1. **Create a snapshot first** +1. **Commit or branch first** ``` - meta git snapshot create before-refactor + meta git status + meta exec -- git branch backup/before-refactor ``` + Commit uncommitted work, or create a backup branch in every repo. 2. **Preview with --dry-run** ``` @@ -23,13 +25,18 @@ Multi-repo workspaces amplify the impact of destructive commands. These commands trigger PreToolUse denial: - `git push --force` (use `--force-with-lease` instead) -- `git reset --hard` (use `meta git snapshot` instead) +- `git reset --hard` (commit or branch first; recover commits with `git reflog`) - `git clean -fd` (dangerous file removal) - `rm -rf` on repo roots or `.meta*` paths ## Recovery -If something goes wrong: +If something goes wrong, run `git reflog` in the affected repo to find the previous commit, then restore it on a branch: ``` -meta git snapshot restore before-refactor +git switch -c recovered ``` +To look across repos: +``` +meta --include exec -- git reflog -n 20 +``` +The reflog only recovers commits, not uncommitted changes. diff --git a/.claude/skills/meta-exec/SKILL.md b/.claude/skills/meta-exec/SKILL.md index 93cbc41..e53a941 100644 --- a/.claude/skills/meta-exec/SKILL.md +++ b/.claude/skills/meta-exec/SKILL.md @@ -185,7 +185,7 @@ meta exec -- rm -rf node_modules dist | Generic commands | Git operations | | Build/test commands | Commands needing special handling | | One-off scripts | Operations with meta-specific logic | -| npm/cargo/make | Clone, update, snapshot | +| npm/cargo/make | Clone, update, worktree | `meta exec -- ` always runs the command as typed, never through a plugin: `meta exec -- git status` runs plain `git status` in each repo, while `meta git status` uses the git plugin. Prefer `meta git ` for git: any git subcommand passes through it, and it runs remote commands (`fetch`, `pull`, `push`) without credential prompts that would hang parallel runs. Plugins intercept only their own subcommands (`meta git ...`, `meta cargo ...`) and provide enhanced behavior. `meta git clone` doesn't run `git clone` in each repo—it reads `.meta` and clones the entire graph. diff --git a/.claude/skills/meta-git/SKILL.md b/.claude/skills/meta-git/SKILL.md index 656fc64..2e55fd8 100644 --- a/.claude/skills/meta-git/SKILL.md +++ b/.claude/skills/meta-git/SKILL.md @@ -1,6 +1,6 @@ --- name: meta-git -description: Git operations across multiple repositories — status, commit, push, pull, snapshots, multi-commit. +description: Git operations across multiple repositories — status, commit, push, pull, multi-commit. --- # Meta Git Skill @@ -48,30 +48,23 @@ meta git update # Clone repos listed in .meta that are missing locally `meta git update` only clones missing repos (nested meta repos included); it does not pull existing ones. `meta git pull --recursive` also pulls nested meta repos. -## Snapshots (Critical for Batch Operations) +## Before Batch Operations (Critical) -Before making sweeping changes, create a snapshot: +Before making sweeping changes, commit your work or create a backup branch in every repo: ```bash -# Save current state of every repo at this meta level (add --recursive for nested ones) -meta git snapshot create before-refactor +# See which repos have uncommitted changes +meta git status -# See what snapshots exist -meta git snapshot list +# Commit them, or create a backup branch in every repo at this meta level (add --recursive for nested ones) +meta git commit -m "wip: before refactor" +meta exec -- git branch backup/before-refactor -# Preview what restore would do -meta --dry-run git snapshot restore before-refactor - -# Actually restore (auto-stashes uncommitted tracked changes; asks to confirm without --force) -meta git snapshot restore before-refactor --force +# Preview a batch command before running it +meta --dry-run exec -- ``` -**What snapshots capture per repo:** -- Current SHA -- Branch name -- Dirty status - -**On restore**: Each repo's branch is reset to the snapshot's SHA (`git checkout -B `), so commits made after the snapshot drop off the branch (they stay in the reflog). If a repo has uncommitted changes to tracked files, meta stashes them first. Untracked files are not stashed and can block the checkout. +**Recovering**: `git reflog` in the affected repo lists the commits its `HEAD` pointed to; `git switch -c recovered ` brings one back. Use `meta --include exec -- git reflog -n 20` to look across repos. The reflog only recovers commits, not uncommitted changes, so commit or branch first. ## Common Git Operations @@ -107,7 +100,7 @@ meta --exclude legacy git pull ### Starting Work ```bash meta git status # What's the current state? -meta git snapshot create wip # Save state before changes +meta git commit -m "wip" # Commit pending work before changes meta git pull # Get latest ``` @@ -121,11 +114,11 @@ meta git push # Push all repos ### Safe Batch Refactoring ```bash -meta git snapshot create before-changes +meta exec -- git branch backup/before-changes # ... make changes across repos ... meta git status # Review -# If something went wrong: -meta git snapshot restore before-changes --force +# If something went wrong, in the affected repo: +git reflog # Find an earlier commit, then: git switch -c recovered ``` ## MCP Tools for Git Operations diff --git a/.claude/skills/meta-plugins/SKILL.md b/.claude/skills/meta-plugins/SKILL.md index 809fb30..4711bad 100644 --- a/.claude/skills/meta-plugins/SKILL.md +++ b/.claude/skills/meta-plugins/SKILL.md @@ -29,7 +29,6 @@ Handles all `meta git *` commands with special cases: |---------|----------| | `meta git clone ` | Clone parent, read `.meta`, clone all children | | `meta git update` | Clone missing repos (use `meta git pull` to pull existing ones) | -| `meta git snapshot *` | Create/restore workspace state | | `meta git worktree *` | Isolated multi-repo worktree sets (see the `meta-worktree` skill) | | `meta git ` | Pass through to every repo at this meta level | diff --git a/src/context.rs b/src/context.rs index 6c347e7..8a55d0a 100644 --- a/src/context.rs +++ b/src/context.rs @@ -277,10 +277,6 @@ fn key_commands() -> Vec { command: "meta git commit -m \"msg\"".to_string(), description: "commit in all dirty repos".to_string(), }, - CommandRef { - command: "meta git snapshot create ".to_string(), - description: "save state before batch changes".to_string(), - }, CommandRef { command: "meta --include X,Y exec -- ".to_string(), description: "target specific repos".to_string(), diff --git a/src/subprocess_plugins.rs b/src/subprocess_plugins.rs index 4d93761..85c4eab 100644 --- a/src/subprocess_plugins.rs +++ b/src/subprocess_plugins.rs @@ -737,7 +737,7 @@ mod tests { ("rust", vec!["cargo build", "cargo test"]), ( "git", - vec!["git status", "git snapshot", "git snapshot create"], + vec!["git status", "git worktree", "git worktree create"], ), ] { manager.plugins.insert( @@ -757,7 +757,7 @@ mod tests { // The longest claimed command wins; the rest are the plugin's args assert_eq!( - routed(&manager, &["git", "snapshot", "create", "x"]), + routed(&manager, &["git", "worktree", "create", "x"]), Some(("git".to_string(), 3)) ); assert_eq!( From 41199bffc0b24148d00385dcdd41ae6a8c83e3e4 Mon Sep 17 00:00:00 2001 From: gold-silver-copper <157451540+gold-silver-copper@users.noreply.github.com> Date: Sun, 25 Oct 2026 16:13:38 -0700 Subject: [PATCH 2/3] docs: commit or stash before batch changes, not just branch A backup branch keeps only commits, and `meta git commit` commits only staged changes, so the guidance now stages with `meta git add -A` or stashes first. The force-push hint backs up the remote tip. Refs [[tasks/harmony-2754]] --- .claude/rules/meta-destructive-commands.md | 9 +++++---- .claude/skills/meta-git/SKILL.md | 16 ++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.claude/rules/meta-destructive-commands.md b/.claude/rules/meta-destructive-commands.md index 8fa9d43..a19c00f 100644 --- a/.claude/rules/meta-destructive-commands.md +++ b/.claude/rules/meta-destructive-commands.md @@ -4,12 +4,13 @@ Multi-repo workspaces amplify the impact of destructive commands. ## Before Destructive Operations -1. **Commit or branch first** +1. **Commit or stash first** ``` meta git status - meta exec -- git branch backup/before-refactor + meta git add -A && meta git commit -m "wip: before refactor" ``` - Commit uncommitted work, or create a backup branch in every repo. + Or stash it in every repo: `meta exec -- git stash push -u -m before-refactor`. + A backup branch (`git branch backup/`) keeps only commits, not uncommitted changes. 2. **Preview with --dry-run** ``` @@ -25,7 +26,7 @@ Multi-repo workspaces amplify the impact of destructive commands. These commands trigger PreToolUse denial: - `git push --force` (use `--force-with-lease` instead) -- `git reset --hard` (commit or branch first; recover commits with `git reflog`) +- `git reset --hard` (commit or stash first; recover commits with `git reflog`) - `git clean -fd` (dangerous file removal) - `rm -rf` on repo roots or `.meta*` paths diff --git a/.claude/skills/meta-git/SKILL.md b/.claude/skills/meta-git/SKILL.md index 2e55fd8..7532792 100644 --- a/.claude/skills/meta-git/SKILL.md +++ b/.claude/skills/meta-git/SKILL.md @@ -50,21 +50,24 @@ meta git update # Clone repos listed in .meta that are missing locally ## Before Batch Operations (Critical) -Before making sweeping changes, commit your work or create a backup branch in every repo: +Before making sweeping changes, commit or stash uncommitted work in every repo: ```bash # See which repos have uncommitted changes meta git status -# Commit them, or create a backup branch in every repo at this meta level (add --recursive for nested ones) +# Commit them at this meta level (add --recursive for nested ones); `meta git commit` commits only staged changes +meta git add -A meta git commit -m "wip: before refactor" -meta exec -- git branch backup/before-refactor + +# Or stash them instead (untracked files included) +meta exec -- git stash push -u -m before-refactor # Preview a batch command before running it meta --dry-run exec -- ``` -**Recovering**: `git reflog` in the affected repo lists the commits its `HEAD` pointed to; `git switch -c recovered ` brings one back. Use `meta --include exec -- git reflog -n 20` to look across repos. The reflog only recovers commits, not uncommitted changes, so commit or branch first. +**Recovering**: `git reflog` in the affected repo lists the commits its `HEAD` pointed to; `git switch -c recovered ` brings one back. Use `meta --include exec -- git reflog -n 20` to look across repos. The reflog only recovers commits, not uncommitted changes, so commit or stash first. A backup branch keeps only commits. ## Common Git Operations @@ -100,7 +103,8 @@ meta --exclude legacy git pull ### Starting Work ```bash meta git status # What's the current state? -meta git commit -m "wip" # Commit pending work before changes +meta git add -A # Stage pending work +meta git commit -m "wip" # Commit it before changes meta git pull # Get latest ``` @@ -114,7 +118,7 @@ meta git push # Push all repos ### Safe Batch Refactoring ```bash -meta exec -- git branch backup/before-changes +meta git add -A && meta git commit -m "wip: before changes" # Save pending work first # ... make changes across repos ... meta git status # Review # If something went wrong, in the affected repo: From 3c27299aa6cd0cc750c5fd2fe96bad94aa46ef17 Mon Sep 17 00:00:00 2001 From: gold-silver-copper <157451540+gold-silver-copper@users.noreply.github.com> Date: Sun, 25 Oct 2026 16:13:38 -0700 Subject: [PATCH 3/3] docs: reflog across all repos; stage before the final commit; clean new files when discarding Refs [[tasks/harmony-2754]] --- .claude/rules/meta-destructive-commands.md | 4 ++-- .claude/skills/meta-git/SKILL.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.claude/rules/meta-destructive-commands.md b/.claude/rules/meta-destructive-commands.md index a19c00f..a326934 100644 --- a/.claude/rules/meta-destructive-commands.md +++ b/.claude/rules/meta-destructive-commands.md @@ -36,8 +36,8 @@ If something goes wrong, run `git reflog` in the affected repo to find the previ ``` git switch -c recovered ``` -To look across repos: +To look across all repos: ``` -meta --include exec -- git reflog -n 20 +meta exec -- git reflog -n 20 ``` The reflog only recovers commits, not uncommitted changes. diff --git a/.claude/skills/meta-git/SKILL.md b/.claude/skills/meta-git/SKILL.md index 7532792..ce4d3e5 100644 --- a/.claude/skills/meta-git/SKILL.md +++ b/.claude/skills/meta-git/SKILL.md @@ -67,7 +67,7 @@ meta exec -- git stash push -u -m before-refactor meta --dry-run exec -- ``` -**Recovering**: `git reflog` in the affected repo lists the commits its `HEAD` pointed to; `git switch -c recovered ` brings one back. Use `meta --include exec -- git reflog -n 20` to look across repos. The reflog only recovers commits, not uncommitted changes, so commit or stash first. A backup branch keeps only commits. +**Recovering**: `git reflog` in the affected repo lists the commits its `HEAD` pointed to; `git switch -c recovered ` brings one back. Use `meta exec -- git reflog -n 20` to look across all repos (`--include ` for one). The reflog only recovers commits, not uncommitted changes, so commit or stash first. A backup branch keeps only commits. ## Common Git Operations