Jira tickets for agents
zc can hand a Jira ticket to a coding agent. Someone adds the label
zestful-agent to a ticket, and within a minute zc starts an agent on it,
in its own worktree and branch, in a zterm tab. The agent works through zc as
any agent does. zc turns what the agent says into Jira comments, and passes
an answer given in Jira back to the agent.
The agent never talks to Jira. zc's daemon makes every Jira call. The token is never in the agent's prompt, command line or environment. It is in a file in zc's config folder, readable only by your user, and the agent runs as that user, so it could read the file. Give the bridge account access to the projects it serves and nothing else.
What you need
- A Jira Cloud site, and a Jira account for the bridge, for example "Zestful
Agent". Every comment zc writes comes from that account. Give it Browse,
Add Comments, Edit Issues and Transition Issues on the projects it serves,
and nothing more. Use an account of its own, not yours: the bridge ignores
every comment its own account writes, so answers you post from it never
reach the agent.
zc jira loginwarns when the bridge account is also onallow. - An API token for that account.
- A machine that stays on, with zterm, zc and Claude Code installed and logged in. zc polls Jira from this machine and the agents run on it.
- A checkout of each repository the tickets are worked in, with an
originthe agents can push to. Each run gets a zc ticket in the project'szc_project, else the zc project the repository's.zc-projectfile names, else zc'sdefault_project.
Only one machine should run the bridge for a site.
Setting up
Add a [jira] table to zc's config.toml. zc config path prints where
that file is, and says when it does not exist yet.
[jira]
site = "example.atlassian.net"
email = "zestful-agent@example.com" # the bridge account
enabled = true
[jira.allow]
"person@example.com" = "jmorrow" # Jira email or account id -> zc person
[[jira.project]]
key = "ABC"
repo = "/Users/you/Development/acme"
worktrees = "/Users/you/Development/acme-runs"
in_progress = "Start Progress" # the workflow's transition names
in_review = "Ready for Review"
| Key | What it does |
|---|---|
site |
The Jira site. A bare host means https. |
email |
The bridge account's email. |
enabled |
Polls Jira when true. Off unless set. |
allow |
Who may start an agent, and the zc person who owns the run. A key is a Jira email or an account id. Jira hides most people's emails, so the account id is the one that always works. |
runner |
local, the default: agents run on this machine. The name of another machine in your mesh runs them there; see Agents on another machine. |
max_running |
The most agents running at once. The default is 3. A ticket over it waits and starts when a run ends. A value that is not a whole number of 1 or more is not used: the bridge runs on 3 and says why. |
idle_end_minutes |
How long an agent may sit with its turn ended and its ticket still open before zc stops it. The default is 60. 0 turns this off. A value that is not a whole number of 0 or more is not used: zc stops idle agents after 60 minutes and says why. See Stopping. |
[[jira.project]] |
One per Jira project. key is the project key, repo the checkout, and worktrees the folder where each ticket gets its own worktree. |
zc_project |
Optional, per project: the zc project each run's ticket goes in. Without it, zc uses the .zc-project file in repo, then default_project. Set it when agents run on another machine. |
harness |
Optional, per project: the harness zspawn starts for the agent. The default is claude. |
model, effort, cap |
Optional, per project: the agent's model, reasoning effort and token cap. |
in_progress, in_review |
Optional: the transitions zc takes when an agent starts and when it opens a PR. A transition the ticket cannot take is skipped. |
acceptance_field |
Optional: the field id of the site's acceptance criteria, such as customfield_10040. |
Then save the token. zc checks it with Jira before saving, and reads it from stdin so it stays out of your shell history:
zc jira login < token.txt
zc jira status
zc jira status prints one line of JSON. state is ok when Jira accepts
the token, and account is the name Jira sees. It also gives the site, the
email, the runner, whether the bridge is enabled, the allow keys, the mapped
projects and the token file. max_running is the limit in use, running is how
many agents are running and waiting how many tickets wait for a free run.
When max_running is set to a value zc cannot use, max_running_error says
why, and the daemon log says it too. idle_end_minutes is the idle limit in
use, 0 when it is off, and idle_end_minutes_error says why a value was not
used. When agents are still running and the
bridge is off, watching lists their tickets. When zc cannot watch them, because
there is no token or no [jira] table, unwatched lists them instead. The
token is saved as jira-token in the zc config folder, readable only by your
user: at mode 0600 on macOS and Linux, and on Windows with an access list
that names only your user and SYSTEM, whatever the folder allows.
Tickets the bridge cannot read
After a ticket's Jira read or operation fails on three consecutive polls,
zc jira status lists it in unreadable_tickets. Each entry gives its key,
the number of consecutive failed ticks, since as Unix seconds at the first
failure in that streak, and error_class. The bridge's summary says, for
example, running, 1 ticket unreadable. Its state stays running; the
existing top-level state still describes the token check.
zc daemon status shows the same reading under jira. The daemon holds
these counters in memory, so restarting it clears them. Several failed
requests for a ticket in one poll count once. A successful request does not
hide another failure for that ticket in the same poll. A poll in which all
its requests succeed removes the entry. Other tickets continue normally,
and these counters never stop or restart an agent.
A failed search leaves the last reported entries visible and does not count toward their removal. A poll without a request for a ticket does not count as a ticket failure; the next attempt starts a new streak. An entry also clears after three consecutive successful-search polls make no request for that ticket.
| Error class | What to do |
|---|---|
http 401 |
Run zc jira login with a valid API token for the bridge account. |
http 403 |
Check the bridge account's Browse, Add Comments, Edit Issues and Transition Issues permissions, including issue security. |
http 404 |
Check that the ticket still exists and that the bridge account can browse it. |
http 429 |
Jira is limiting requests. Let the bridge retry on its next poll; check for other bridge instances using the same account. |
Other http codes |
For 5xx errors, check Jira's service status. For other codes, check the ticket's workflow and the daemon log for the operation that failed. |
unreachable |
Check the bridge machine's network, DNS and TLS connection to Jira. This class includes timeouts. |
parse |
Jira returned an answer zc could not parse. Check any proxy between the bridge and Jira, and report the failure with the zc version and daemon log. |
The status entries contain fixed error classes, never Jira's response text.
The daemon log keeps its existing per-poll error lines. If the daemon cannot
be read, or is an older version without this reading, unreadable_tickets
is null and bridge.state is unavailable. An empty array means the daemon
has no reported ticket failures.
To remove the token, run zc jira logout. It deletes the token file, with or
without a [jira] table, and says so when there was none. The bridge stops at
its next poll, within a minute, and logs off: no token in <file>. Running
agents keep running, but zc stops watching them: their questions and progress
no longer reach Jira, and a tab that closes is not noticed, until a token is
saved again. Stop the agents first.
zc reads config.toml again every minute, so a change takes effect within a
minute without a restart. zc does not read a key it does not know, so a
misspelt key, such as enable for enabled, leaves the bridge off. It names
each such key in zc jira status, under ignored, as jira.enable or
jira.project[ABC].in-progress, and in the daemon log as
zcd: jira: config.toml: ignoring keys zc does not know: ... each time the
list changes.
The first time zc starts an agent after the daemon starts, zterm asks you once whether zc may open tabs. Until you answer, zc waits and starts nothing.
Starting an agent
Add the label zestful-agent to a ticket in a mapped project. On its next
poll, zc:
- checks who added the label. A label added in the create form counts as
the ticket creator's. A label from someone not on
allowis refused with one comment on the ticket, and nothing starts. The comment names the person and says when Jira hides their email from the bridge account. Such a person matchesallowonly by account id, which the daemon log prints on the refusal line. - makes a worktree
<worktrees>/jira-<key>on a new branchjira/<key>-<summary>, cut from the repository's default branch onorigin. The key is lowercased, and the summary becomes lowercase words joined by-, at most 40 characters: ABC-7 "Fix the login" getsjira/abc-7-fix-the-login. - creates a zc ticket for the run and starts the agent
jira-<key>, such asjira-abc-7, in a new zterm tab, with the Jira ticket as its first prompt: the summary, description, acceptance criteria, links, attachments and recent comments, up to 24 KB. The bridge's own status comments are left out. The agent's questions and notes that the bridge posted for an earlier run stay. - comments on the Jira ticket that the agent started, and takes the
in_progresstransition.
zc starts at most three agents a poll, and no more than max_running run at
once, 3 unless you set it. An agent waiting for an answer counts as running.
A ticket over the limit is not read and gets no comment. It waits, and starts
when a run ends. The daemon log says
zcd: jira: 2 waiting for a free run (3 of 3 running) each time the number
waiting changes. Each agent's first prompt is kept as
the body of its zc ticket, where zc art get <ticket> shows it.
What reaches Jira
| The agent | In Jira |
|---|---|
| comments on its zc ticket | A comment. At most one every ten minutes; more are batched into the next. |
asks a person (zc ask) |
A comment naming the ticket's reporter, ending "Reply in a comment here.", and the label zestful-agent-waiting. |
opens a PR (zc review --url) |
A link to the PR, a comment, and the in_review transition. |
finishes (zc done) |
A comment naming its PRs. |
Answering the agent
While the agent's question is open, reply in a Jira comment. The first reply
from someone on allow goes to the agent as an answer from their zc person,
and the waiting label comes off. A reply from anyone else is not passed on,
and the ticket says so once. An answer given on the zc board instead also
closes the question and removes the label.
When a run ends
A run ends when the agent opens its PR for review, marks its zc ticket done, or its zc ticket is archived, and when the Jira ticket moves to a done status. zc closes the agent's tab and retires the agent, so it leaves the board's lists and its zc ticket no longer names it. The branch, the worktree and the PR are kept.
Once a run's ticket is in review, no agent is left to act on changes a
reviewer asks for. A person takes the PR from there. A run that ended this
way is not started again, even while its Jira ticket still has the
zestful-agent label.
Stopping
Remove the
zestful-agentlabel. zc closes the agent's tab, retires the agent and keeps its branch. Anyone who can edit the ticket can do this.The agent stops on its own before finishing, or its tab is closed. zc comments, retires the agent and adds the label
zestful-agent-stopped. Remove that label to start the agent again, on the same branch.Move the ticket to a done status. zc closes the agent's tab and retires the agent, and posts no comment.
The agent ends its turn and leaves the ticket open. When the agent's tab has said for
idle_end_minutes(60 unless set) that its turn is done or that it is idle, and its zc ticket is still open, zc closes the tab, retires the agent and adds the labelzestful-agent-stopped. It comments on the Jira ticket and asks the run's owner on the board, so the ticket shows in their Needs you. The comment and the question are zc's own words: nothing the agent wrote is copied into them. Remove the label to start the agent again, on the same branch.zc goes by what the agent's program reports in its tab, never by how long the agent has been quiet on the board, since an agent can work for an hour without writing there. It stops nothing in these cases:
- the tab reports no status, as a tab on a machine whose zterm does not send one never does;
- the agent asked a question that nobody has answered yet;
- the agent's zc ticket is in review, blocked or done;
- the agent said it was done before the zc daemon running the bridge started. Its next turn starts the count again.
An agent counts as idle from the moment its turn ends. A command it left running in the background does not count as work. An agent that waits longer than
idle_end_minuteson its own background job is stopped, and the job is stopped with it. For work like that, raiseidle_end_minutesor turn the rule off.To turn this off, set
idle_end_minutes = 0under[jira].
Setting enabled = false starts nothing new and stops nothing that runs. zc
keeps watching the agents already running until each one ends: their questions
and progress still reach Jira, and a tab that closes is still noticed. A ticket
labeled while the bridge is off starts when it is enabled again. To stop a
running agent, remove its label.
Agents on another machine
zc can start each agent on another machine in your zterm mesh, for example
a box that stays on, while this machine keeps polling Jira. Set runner to
that machine's name, as zterm ls and zterm net status show it:
[jira]
runner = "buildbox"
[[jira.project]]
key = "ABC"
repo = "/home/you/acme" # paths on buildbox
worktrees = "/home/you/acme-runs"
zc_project = "ACME" # the zc project for its runs
repo and worktrees are paths on that machine. zc runs no git here: zspawn
on that machine makes the worktree. If the branch is already on origin, for
a ticket that ran before, it continues that branch.
Set zc_project for each project. zc makes each run's ticket on this
machine, where repo usually doesn't exist, so the repository's
.zc-project file can't name the project.
That machine needs:
- zterm, at the same version as this one, in the same mesh (see
Remote panes), with
zterm servekept running.zterm serve --install-unitwrites a systemd user unit (Linux) or a LaunchAgent (macOS) that keeps it running, and prints the commands that turn it on. See Keeping a host running. - Claude Code installed and logged in, as the user
zterm serveruns as. - A checkout of each repository at its
repopath, with anoriginthe agent can push to. - zc pointed at the same board as this machine, so the agent's comments and questions reach the bridge.
zterm on this machine asks you before zc starts an agent there, as it does for agents that run on this machine.
zc watches the agent through this machine's zterm, which lists the other machine's panes. An agent that exits is stopped as it is here. While the other machine can't be reached, zc waits and stops nothing. A pane that disappears from a machine zc can reach, without exiting, is stopped after an hour.
When someone answers in Jira, zc rings the agent so it reads the answer at once. It first waits up to 20 seconds until nobody is typing in the agent's pane, on this machine and on the other one alike. A machine running zterm 0.9.63 or older cannot hold the ring, and zc rings its panes without waiting.
When something goes wrong
The daemon writes what the bridge does to daemon.log in zc's data folder,
on lines starting zcd: jira:. A bridge that is off says why there once:
off: [jira] is absent or not enabled, off: no token in <file>, or
waiting for the board, which means zc's own board is not answering. When
agents are still running, an off line ends with the tickets nobody is watching,
such as ; 2 runs unwatched: ABC-1, ABC-2. A bridge turned off that still
watches running agents logs off for new starts: still watching 1 run: ABC-1.
A Jira that does not answer logs unreachable: Jira did not answer, and a
token Jira refuses logs signed_out: Jira refused the credential. zc jira status
checks the token against Jira.
After an answer is relayed, the log says rang <agent> at <pane> when the
doorbell was written to the agent's pane, or was not rung and why when it
wasn't. An agent still idle after a rang line may not have received the
doorbell as typed input. Type ::zc-mail:: into its tab to wake it.