Skip to content

[Feature]: Expose current thread info via environment variables #3003

Description

@tarik02

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

I want to have information about current thread in environment variables: both for terminal and running agent sessions.

Proposed solution

Provide environment variables along project and thread scoped child processes (terminal and harness):

  1. T3CODE_PROJECT_ROOT (currently available only in terminal - make available everywhere)
  2. T3CODE_WORKTREE_PATH (currently available only in terminal, if worktree is used - make available everywhere)
  3. T3CODE_PROJECT_ID (add new)
  4. T3CODE_THREAD_ID (add new)
  5. T3CODE_HOME - always provide resolved path - canonical value

Cool ideas for future, but out of scope:

  1. T3CODE_ORIGIN - accessible server host
  2. T3CODE_TOKEN - short living scoped token that allows controlling only threads in current project or something like this

Why this matters

Cool automation opportunities - like using custom CLI (see references) that allows agent to create threads in t3code, control them.

Smallest useful scope

Adding those two:

  1. T3CODE_PROJECT_ID
  2. T3CODE_THREAD_ID

Alternatives considered

Using cwd as context, but can't detect thread reliable this way.

Risks or tradeoffs

Claude relying on T3* env variables presence to detect it's running under t3code?

Examples or references

Currently t3code provides two environment variables in terminal: T3CODE_PROJECT_ROOT, T3CODE_WORKTREE_PATH.

#2921
https://github.com/kcosr/t3code-threads
https://github.com/tarik02/t3code-cli

Contribution

  • I would be open to helping implement this.

Activity

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

    enhancementRequested improvement or new capability.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions