Skip to content

feat(env): add crab env snapshot/restore for machine migration#57

Merged
MrFlounder merged 1 commit intomainfrom
workspace-2
Mar 11, 2026
Merged

feat(env): add crab env snapshot/restore for machine migration#57
MrFlounder merged 1 commit intomainfrom
workspace-2

Conversation

@MrFlounder
Copy link
Contributor

Summary

  • Adds crab env snapshot — launches an AI agent to explore the machine, build a comprehensive setup recipe, capture configs/secrets/DB schemas, and encrypt everything into a portable bundle
  • Adds crab env restore --from <file> — decrypts the bundle and launches an agent in safe mode to set up a new machine from the recipe
  • Adds get_agent_safe_cmd() helper for non-autonomous agent invocation
  • Uses existing agent abstraction layer so both Claude and Codex work as the snapshot/restore agent

Design

The agentic approach means no hardcoded collection scripts — the agent adapts to whatever toolset is on the machine. A quick bash prescan seeds the agent with concrete findings (brew packages, node versions, git repos, .env files, etc.) so it knows what to look for. The primary artifact is recipe.md — directional guidance for another agent, not literal scripts.

Tested

Validated end-to-end on a clean macOS Sequoia VM (Tart):

  1. Ran crab env snapshot on source machine → 53 files captured (16 configs, 9 DB schemas, 21 secret mappings, recipe, inventory)
  2. Transferred encrypted bundle to fresh VM
  3. Ran Codex as the restore agent → autonomously installed brew tools, nvm + 3 Node versions, oh-my-zsh, restored git/ghostty/claude configs, created directory structure

Test plan

  • Run crab env snapshot --dry-run to verify prescan output
  • Run crab env snapshot end-to-end, verify recipe.md and encrypted bundle
  • Run crab env restore --from <file> on a clean machine or VM
  • Verify agent-agnostic: test with both agent: claude and agent: codex config

🤖 Generated with Claude Code

… migration

Adds an agentic environment capture and restore system. `crab env snapshot`
runs a quick prescan of the machine then launches a coding agent to explore
deeply and build a comprehensive recipe. The recipe + configs, secrets, and
DB schemas are encrypted into a portable bundle. `crab env restore` decrypts
and launches an agent in safe mode to set up a new machine from the recipe.

Key design decisions:
- Agentic approach: adapts to any toolset, not hardcoded scripts
- Prescan seeds the agent with concrete findings for completeness
- Recipe is directional guidance (markdown), not literal bash scripts
- Agent-agnostic: uses existing abstraction layer (Claude/Codex)
- Snapshot uses autonomous mode; restore uses safe/interactive mode
- Encryption via openssl aes-256-cbc with pbkdf2 (cross-compatible)

Validated end-to-end on a clean macOS Sequoia VM (Tart) with Codex as the
restore agent — all phases completed autonomously.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MrFlounder MrFlounder merged commit 1c21b02 into main Mar 11, 2026
5 checks passed
@MrFlounder MrFlounder deleted the workspace-2 branch March 11, 2026 20:18
@MrFlounder MrFlounder mentioned this pull request Mar 11, 2026
MrFlounder added a commit that referenced this pull request Mar 11, 2026
## Summary

Bump version `0.12.0` → `0.13.0`.

Features since 0.12.0:
- Agent-agnostic support — Claude Code + Codex CLI (#52)
- `crab agent sync` for cross-agent config migration (#55)
- `crab env snapshot/restore` for machine migration (#57)
- Bats unit test framework + CI (#52)
- `crab court` fresh-start prompt fix (#54)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant