Skip to main content

Worktree Environment Files

Copy local environment files whenever creating a new worktree

Source: .agents/rules/worktree-env-files.mdc

Metadata

  • name: worktree-env-files
  • alwaysApply: true

Content

Worktree Environment Files

When creating a new Git worktree for this repo, copy local environment files from the source checkout into the new worktree before running app commands.

Required Practice

  • Copy only files matching .env and .env.*.
  • Use the checkout where the worktree command was started as the source.
  • Do not copy unrelated dotfiles.
  • Do not print environment file contents.
  • Do not commit copied environment files.
  • If the source checkout has no .env files, record that the env copy was skipped.

Use:

rsync -av --include='.env' --include='.env.*' --exclude='*' ./ <absolute-worktree-path>/