PostHog Code environments

An environment is how you tell PostHog Code how to set up a repo so the agent can start work in it. There are two types of environments, one for each side of where tasks run.

TypeUsed byWhat it controls
Local environmentWorktree tasksA setup script that runs when a worktree is created
Cloud environmentCloud runsNetwork access rules and the secrets and environment variables the cloud workspace gets

Local mode tasks don't use environments. They run on your computer in the repo as it already exists, so nothing needs to be prepared.

Local environments

Worktrees run in a different directory than your local checkout, so they don't have the dependencies or files that aren't tracked by git. A local environment fills that gap with a setup script that runs once, when a new worktree is created.

Use it to:

  • Install dependencies
  • Run migrations
  • Start background services
  • Do anything else needed to get coding

Local environments live in the repo, so they're committable and shared with your team. Once one is in place, every new worktree gets a project that's already installed and ready.

You can manage your worktree environments in PostHog Code in the Settings.

Cloud environments

A cloud environment controls how a cloud run is configured: what network it can reach, and what secrets and environment variables get injected into the workspace.

Network access can be configured with three different levels:

  • Trusted. A curated allowlist (GitHub, npm, PyPI, and similar).
  • Full. Anywhere on the internet.
  • Custom. Your own allowlist of domains, optionally with the trusted set included.

Manage cloud environments in PostHog Code under Settings.

Community questions

Was this page useful?

Questions about this page? or post a community question.