codex-environment
Installation
SKILL.md
Codex Environment
Use this skill when the user asks about Codex Local Environments, worktree setup scripts, cleanup scripts, Codex actions, .codex/environments/environment.toml, CODEX_WORKTREE_PATH, CODEX_SOURCE_TREE_PATH, or making a worktree ready to run.
What We Learned
- Codex app Local Environments are project config, not one-off terminal commands.
- The shareable config lives at
.codex/environments/environment.tomlat the project root. - Setup scripts run when Codex creates a new worktree for a new thread.
- Cleanup scripts run before Codex cleans up the worktree.
- Actions appear in the Codex app top bar and run in the integrated terminal.
- Worktrees only contain checked-in files, so ignored files like
.envmust be copied or recreated by setup. - Prefer short setup/cleanup entries that call versioned project scripts instead of long inline shell.
- Keep executable entrypoints in
scripts/, for examplescripts/worktree-upandscripts/worktree-down. - Keep
.codexfocused on Codex config; keep operational logic inscripts/. - Do not commit secrets. It is fine for setup to copy ignored env files locally.
- For projects with local databases, setup should create a worktree-specific DB name and rewrite the copied
.envto point to it. - Cleanup should drop only the worktree-specific databases and remove copied local env files.
- Use
CODEX_SOURCE_TREE_PATHfor the original project checkout andCODEX_WORKTREE_PATHfor the new worktree when available.