trunkjet

Agents and AI

On this page

Use trunkjet with your local AI agent

An AI agent on your own computer (Claude Code, an IDE assistant, a script) works in trunkjet as your agent: @you/claude, "agent for @you". It acts for you, never as you: it can never approve or merge, change settings or permissions, or see secrets, and it gets only the repositories, folders and time you allow. You can stop it at any moment.

Connect it (one command)

Signed in with tjet login, in your terminal:

tjet agent connect claude --repo acme/shop --for 8h --client "Claude Code"

trunkjet shows, in plain words, what the agent may do, where, for how long and what it can never do, then asks:

  This creates your agent @you/claude (it acts for you, never as you).
  @you/claude is an agent for @you. It acts for you, never as you, and only while this access lasts.
  The app asking says it is "Claude Code" (trunkjet cannot check this).
  Where: acme/shop in @acme.
  Folders: every folder.
  It may: see the repository's name, streams and changes; list files and folders; read the contents of files; write files into draft changes.
  It can never: approve or merge changes; change settings, permissions or policies; see secrets, tokens or signing keys; act as you anywhere else, or add more access without asking you again.
  For how long: 8 hours. You can stop it at any time.
  Limits: none set.
  Note: It can write files into draft changes. A draft is never merged until a person approves and merges it.
  Note: It runs outside trunkjet (for example on your computer): what it reads can leave trunkjet through that computer.

Claude Code would like to work in acme/shop as your agent @you/claude. Allow? [Y/n]

Press Enter (or y). The agent @you/claude is created if you have none of that name, and its token is written to a file only you can read:

  • Linux: ~/.config/trunkjet/agents/claude.json
  • macOS: ~/Library/Application Support/trunkjet/agents/claude.json
  • Windows: %APPDATA%\trunkjet\agents\claude.json

Start the agent with the line trunkjet prints:

export TJET_TOKEN_FILE=~/.config/trunkjet/agents/claude.json

Every tjet command the agent runs then acts as @you/claude, inside what you allowed. Your own sign-in is not in that file and the agent never needs it.

Options: --repo (repeat it), --path src/ to allow only some folders, --cap to choose permissions (default: read and draft writing; tjet agent connect --help), --for 30m|8h|7d|2w (default 7 days, at most 90), --out FILE for another token file.

Good to know

  • A fresh sign-in. If you signed in more than 10 minutes ago, trunkjet asks you to confirm it's you (it opens the sign-in page) before it gives access.
  • Only you answer. The question needs your terminal. An agent that runs the command itself (through a pipe) is refused, and an agent's token can never give access, not even to itself.
  • Never more than you have. The agent gets at most your own current rights; if you lose access to a repository, so does the agent.
  • Prefer the browser? tjet agent connect claude --repo acme/shop --browser shows the same text on the consent page.
  • Stop it: tjet agent grant revoke <grant id> (printed when you connect), tjet agent disable claude, or tjet agent pause-all for all your agents at once.
  • The token lasts 2 hours; tjet agent grant refresh - with the file's refresh_secret gives a new one while the access lasts (each refresh secret works once).

An agent on another machine

For an agent that runs somewhere else (a server, a CI runner), keep the two-step flow: issue its enrolment secret with tjet agent enrol claude and give it to the agent; the agent runs tjet agent connect --repo acme/shop (no agent name), shows you a web address and a code, and you approve on the consent page.