Skip to content
This repository was archived by the owner on Nov 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .claude/rules/meta-destructive-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ Multi-repo workspaces amplify the impact of destructive commands.

## Before Destructive Operations

1. **Create a snapshot first**
1. **Commit or stash first**
```
meta git snapshot create before-refactor
meta git status
meta git add -A && meta git commit -m "wip: before refactor"
```
Or stash it in every repo: `meta exec -- git stash push -u -m before-refactor`.
A backup branch (`git branch backup/<name>`) keeps only commits, not uncommitted changes.

2. **Preview with --dry-run**
```
Expand All @@ -23,13 +26,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 stash 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 <sha>
```
To look across all repos:
```
meta exec -- git reflog -n 20
```
The reflog only recovers commits, not uncommitted changes.
2 changes: 1 addition & 1 deletion .claude/skills/meta-exec/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- <cmd>` 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 <cmd>` 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.

Expand Down
39 changes: 18 additions & 21 deletions .claude/skills/meta-git/SKILL.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,30 +48,26 @@ 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 or stash uncommitted work 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 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"

# Preview what restore would do
meta --dry-run git snapshot restore before-refactor
# Or stash them instead (untracked files included)
meta exec -- git stash push -u -m 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 -- <command>
```

**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 <branch> <sha>`), 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 <sha>` brings one back. Use `meta exec -- git reflog -n 20` to look across all repos (`--include <repo>` for one). The reflog only recovers commits, not uncommitted changes, so commit or stash first. A backup branch keeps only commits.

## Common Git Operations

Expand Down Expand Up @@ -107,7 +103,8 @@ 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 add -A # Stage pending work
meta git commit -m "wip" # Commit it before changes
meta git pull # Get latest
```

Expand All @@ -121,11 +118,11 @@ meta git push # Push all repos

### Safe Batch Refactoring
```bash
meta git snapshot create 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:
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 <sha>
```

## MCP Tools for Git Operations
Expand Down
1 change: 0 additions & 1 deletion .claude/skills/meta-plugins/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Handles all `meta git *` commands with special cases:
|---------|----------|
| `meta git clone <url>` | 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 <other>` | Pass through to every repo at this meta level |

Expand Down
4 changes: 0 additions & 4 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,6 @@ fn key_commands() -> Vec<CommandRef> {
command: "meta git commit -m \"msg\"".to_string(),
description: "commit in all dirty repos".to_string(),
},
CommandRef {
command: "meta git snapshot create <name>".to_string(),
description: "save state before batch changes".to_string(),
},
CommandRef {
command: "meta --include X,Y exec -- <cmd>".to_string(),
description: "target specific repos".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions src/subprocess_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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!(
Expand Down
Loading