Skip to content

[Feature]: Per-project environment variables #1703

Description

@yinheli

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I am describing a concrete problem or use case, not just a vague idea.

Area

apps/server

Problem or use case

All provider sessions (Codex and Claude) inherit the same process.env from the T3 Code server process. When working with multiple projects, there's no way to use different API keys, endpoints, or provider-specific environment variables per project.

This is a common need for developers who work across multiple accounts, clients, or API providers within a single T3 Code instance.

Proposed solution

Allow users to define environment variables at the project level. These variables would be merged into the child process environment when spawning provider sessions for that project, with project-level values taking precedence over the server's inherited environment.

A simple key-value editor in the project settings UI would be sufficient.

Why this matters

Unlocks multi-account and multi-provider workflows without requiring users to restart T3 Code with different environment variables each time they switch projects.

Smallest useful scope

Store a key-value map of environment variables per project and merge them into the provider subprocess environment at spawn time. No .env file import, templating, or encryption needed initially.

Alternatives considered

  • Running separate T3 Code instances per project — functional but wasteful.
  • Using direnv or shell profiles — only affects the initial server startup, not runtime project switching.

Risks or tradeoffs

  • Secrets stored without encryption at rest, consistent with current settings storage. Encryption could be a follow-up.
  • Project-level vars could unintentionally override system-critical variables (e.g., PATH). A denylist may be worth considering.

Examples or references

No response

Contribution

  • I would be open to helping implement this.

Activity

  1. viraptor commented on Apr 16, 2026

    @viraptor

    This is something with another use case - for people using nixpkgs or similar type of management for dependencies, having replaced environment variables is critical, because the PATH may be entirely different for different projects.
    Jetbrains family of IDEs has this issue too with people constantly asking for different env between projects.

    I'm not sure direnv is that bad of an idea though - ensure it's activated for each spawned agent and it could be a simple way to punt the rest of the decisions onto the dev. I'd be happy with that solution.

  2. yinheli commented on Apr 20, 2026

    @yinheli
    Author

    Hi @juliusmarminge — any chance this is on the roadmap?

    README says contributions aren't accepted yet, but if you'd take a PR I'm happy to do it. Scope I had in mind: project-level env map, merged into provider subprocess on spawn, simple KV editor in project settings.

    Let me know either way 👍

  3. bzbetty commented on Apr 28, 2026

    @bzbetty

    as an extension to this I think chat session based env variables could be handy for those of us using OTEL for tracking (eg to set OTEL_RESOURCE_ATTRIBUTES https://code.claude.com/docs/en/monitoring-usage)

  4. michft commented on Jun 1, 2026

    @michft

    You are not there yet but if you want to crack enterprise, you will need "team" based otel tracking. (if for no other reason to track budget and spend)

  5. locked and limited conversation to collaborators on Aug 15, 2026
  6. converted this issue into a discussion #6715 on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions