feat(cli): add sow sandbox command + env-patch module - #4
Merged
Conversation
Adds packages/cli/src/env-patch.ts: a generic, dependency-free env file patcher that merges keys, preserves comments and unrelated vars, writes a .sow.bak before mutating, and supports interactive prompt + revert. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the clobber-or-append logic with patchEnvFile, which always merges and writes a backup. The --append flag becomes a no-op with a deprecation notice on stderr. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sow sandbox is a thin composition over detectConnection, createConnector, createBranch, and patchEnvFile. It auto-detects the source Postgres, samples it, spins up a local Docker branch, prints DATABASE_URL, and prompts to patch .env.local. Adds --yes / --no-env-file flags. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restores an env file from its .sow.bak backup written by patchEnvFile, giving users a one-command undo for sow sandbox / sow branch create --env-file. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 6, 2026
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lane D of the eng review plan: a flagship zero-config CLI command and a generic env file patcher.
sow sandbox [url]— auto-detects the source Postgres, samples + sanitizes it, spins up a local Docker branch, and patches.env.localsonpm run devjust works. Thin composition overdetectConnection,createConnector,createBranch, andpatchEnvFile.packages/cli/src/env-patch.ts— generic env file patcher used bysow sandbox,sow branch create --env-file, and the newsow env revert. Merges keys, preserves comments and unrelated vars, writes a.sow.bakbackup, supports interactive prompt + revert, and refuses to clobber existing backups.sow env revert [path]— one-command undo that restores from.sow.bak.sow branch create --env-filenow usespatchEnvFileinstead of clobbering.--appendis a deprecated no-op (env-file always merges now).Test plan
env-patch(create, merge, overwrite, no-op, prompt accept/decline, backup-collision, quoting, comments, revert happy/error)sandbox(single candidate, no candidate, multi+json error, multi+quiet, existing branch reuse, --no-env-file, --yes, connector reuse)bunx tsupclean for@sowdb/clibunx eslintclean on touched filesBisectable commits
feat(cli): extract env-patch module with backup + revertrefactor(cli): use env-patch in branch create --env-filefeat(cli): add sow sandbox command (flagship zero-config flow)feat(cli): add sow env revert command🤖 Generated with Claude Code