I've started using Conductor recently and it's been great. You give each coding agent its own Git worktree, set them off on different bits of work and they all crack on without trampling over each other's files. It's now my daily driver.
But in learning to work with worktrees, I've found one recurring gripe: env files.
Files like .env.local are gitignored, because committing your API keys to GitHub is generally a bad idea. The downside is they don't follow you into new worktrees either.
So if I add a new API key while building a feature, everything works. I archive the workspace, the worktree disappears and later I realise I've just binned the only copy of the new key.
I kept manually copying .env.local back to the main checkout before archiving anything, which is exactly the kind of boring little job I'm guaranteed to forget. So I made a Codex skill called envsave.
What it does
Before I archive a Conductor workspace, I tell Codex to save the env file. It runs:
python3 ~/.codex/skills/envsave/scripts/worktree_env.py
The script finds the main checkout and copies the worktree's entire .env.local over to it.
If the project uses a different file, I can point it somewhere else:
python3 ~/.codex/skills/envsave/scripts/worktree_env.py \
--source path/to/.env
Not leaking the keys would be nice
The skill's got a few rules because I don't actually want an AI spraying API keys into its chat history:
- Never print or read the contents of the env file.
- Never put the file in a commit, push or deployment.
- Only accept paths inside the repository.
- Only report where the file came from and where it went.
Basically, it does the boring file-moving bit without showing anyone what's inside.
The whole skill, more or less
# Envsave
Treat the primary Git checkout as the canonical local environment store.
To replace the primary checkout's `.env.local` with the current worktree's
complete file, run:
```bash
python3 ~/.codex/skills/envsave/scripts/worktree_env.py
```
For a different repository-relative env file, run:
```bash
python3 ~/.codex/skills/envsave/scripts/worktree_env.py --source path/to/.env
```
That's it. Now I can archive a workspace without wondering whether an API key is about to be dragged into the void with it or exposed in my session history.