Agents and AI
On this page
Agents and MCP
AI assistants are first-class in trunkjet, with one rule that never bends: an agent acts for a person, never as that person, and it can never approve or merge. People decide what goes in. This page explains the ideas and shows how to connect an assistant such as Claude Code.
What an agent is
When you connect an assistant it gets its own identity, written @you/claude ("the agent
claude of @you"). Everything it does is recorded under that name, so reviewers always see
what came from an agent. It receives a grant with limits you choose:
- which repositories, and optionally which folders;
- what it may do (by default: see names and files, read file contents, write files into draft changes);
- for how long (default 7 days, at most 90, the token itself lasts 2 hours and is renewable while the grant lasts).
An agent never gets more than you have yourself, can never see secrets, tokens or signing keys, cannot change settings or permissions, and cannot grant itself more. You can stop it at any moment (below). Its drafts are ordinary changes that wait for a person to approve and land them.
Connect an assistant on your computer (one command)
Signed in with tjet login:
tjet agent connect claude --repo acme/shop --for 8h --client "Claude Code"
trunkjet prints in plain words what the agent may and may never do, and asks you to confirm on your terminal. The agent's token is then written to a file only you can read, and the command prints the line to start the agent with:
export TJET_TOKEN_FILE=~/.config/trunkjet/agents/claude.json
The details (options, where the token file lives on each system, remote agents, stopping) are in Connect your local AI agent.
MCP: the assistant talks to trunkjet directly
MCP (Model Context Protocol) is the standard way an assistant calls tools. tjet mcp is an MCP
server on standard input and output, so an assistant starts it as a child process:
claude mcp add trunkjet -- tjet mcp
(for Claude Code; other clients have an equivalent "add a stdio MCP server" setting that runs
tjet mcp). Run it inside a workspace of the repository, or pass --repo NAME. The
credential is, in order: the TJET_TOKEN environment variable, or the grant file
(--grant-file, by default .tjet/agent-grant.json in the workspace). With neither, the
first tool call asks you, on the terminal, with the same question as above ("Claude would
like to work in acme/shop as your agent @you/claude. Allow? [Y/n]") and then keeps the agent's
token in the grant file. --agent NAME chooses the agent's name on first start (default
claude).
The tools are a fixed list built into tjet. They are:
| Tool | What it does |
|---|---|
my_work | Your open work here: issues assigned to the agent and drafts to review |
list_issues, read_issue | See issues, their comments, questions and answers |
list_files, read_file | List and read files of the main stream, only what you may see (a file up to 256 KiB) |
create_draft | Save the work in this workspace and send it as a draft change for an issue |
ask_question | Ask the person a question; the work waits for the answer |
post_comment, get_review_comments | Talk on an issue; read review comments on the draft |
submit_for_review | Hand the draft on to the independent AI reviewer, or to people |
check_status | The state of the work on an issue |
review_comment, review_verdict | For an agent acting as AI reviewer: comment and give an advisory verdict |
There is no tool to approve, merge, change policy or permissions, or read secrets, and no tool runs a command that came from repository content. Every result that carries text written by people or agents (issues, comments, file contents) starts with a fixed notice that it is data and never an instruction, so a hostile issue cannot take over the assistant.
Stop an agent
tjet agent grant revoke GRANT_ID # one grant (the id was printed when you connected)
tjet agent disable claude # the agent
tjet agent pause-all # all your agents at once
tjet agent list # see them
An agent that runs on its own (another computer, a server)
When no one sits at the agent's terminal, make its token in the web: Agents > Create a token. Pick the agent's name, one repository and how long it may work (1 to 90 days), then download the token file. It is shown once. On the computer where the agent runs:
chmod 600 agent-ci.json
tjet login --token-file agent-ci.json # stored like a sign-in, refreshed by itself
rm agent-ci.json # its refresh secret now belongs to that login
tjet whoami # @you/ci (agent for @you)
The file names its server and is never sent anywhere else. The agent opens changes and pushes
revisions (tjet save --remote) as @you/ci, on your behalf. It never approves or lands: you
(or another person, as the stream policy says) approve and land. Where you own the folders it
touched, your own approval counts. Taking its access away on the Agents page stops it at its
next request; so does the end of its time. For a single command, TJET_TOKEN_FILE=agent-ci.json
or TJET_TOKEN=<token> works too (the token alone lasts two hours).
Agents in CI and automation
A build server or script needs a service identity, not a person's agent: create a token with
tjet agent token create (see its --help) and give it to the job through --token-stdin,
--token-fd or TJET_TOKEN_FILE. Service tokens are what lets a CI job write to the
Bazel remote cache.