Use with agents
An agent (Claude Code, Codex or a similar tool) can read the spec before writing code and propose changes when needed. The principle: the agent only proposes, a person decides. This page explains how to set it up so that this holds even when the agent makes a mistake.
Three layers
1. The agent's own API key the server holds the limit: by default read and propose only
2. The agent tool's rules ask or block a command before it runs
3. The tmspec skill teaches the agent to use the right commands
Only layer 1 is certain. Layer 2 matches the text of a command, so it blocks the common ways of writing it, not every way. Layer 3 is guidance.
Step 1: create an API key for the agent
An API key is the credential of you yourself, narrowed by the scopes you choose; the agent works under your name and each decision records both your name and the key that was used. See Roles and permissions.
On the web: the user menu, Account settings, API keys, then create a key.
- Pick a shortcut: Read only, Read and propose (the default) or Read, propose and decide. Then turn each scope on or off.
- Set an expiry from 1 to 365 days (default 90).
- The key shows only once. Copy it into your secret store right away; once the dialog is closed you cannot view it again.
- Give the agent the minimum scopes it needs. The
decide:*andmanage:*scopes let the key approve or manage on your behalf; grant them only when you really mean it. No scope lets a key create more keys.
Revoke the key at any time on the same screen; a token already issued lives at most 15 minutes. Removing your role also makes the key lose its permission at once.
Step 2: configure the agent's environment
Set these variables when starting the agent, not in its instructions:
| Variable | Value | Why |
|---|---|---|
TMSPEC_API_KEY | the tms_... key | The credential. The CLI exchanges it for a 15-minute token in memory and writes nothing to disk. Use TMSPEC_API_KEY_FILE if you want to pass the key as a file (readable only by the file's owner) |
TMSPEC_HOST | your team's API address | The key is sent only to the host you chose |
TMSPEC_ISSUER | the sign-in service address | Pins where the key is sent; on a mismatch the CLI stops with code 3 and does not send the key |
TMSPEC_PROJECT | the project key | So the agent can write short refs such as r12 |
Do not set TMSPEC_TOKEN for the agent, and do not leave your personal sign-in in the agent's shell. See also CLI configuration.
Step 3: install the skill
The tmspec skill follows the Agent Skills format, so Claude Code, Codex and other agents can read it. It holds the read and propose workflow, the change file format and the meaning of the exit codes. Each CLI archive carries the skill in the skills/tmspec/ folder, at the same version as the binary: copy it to where your agent reads skills, and copy it again every time you upgrade the CLI. An agent that does not support skills gets these rules in its instruction file (CLAUDE.md, AGENTS.md).
The skill only says how to run commands, not who may run them or whom to ask. How far the agent may act on its own is your decision, in your project's instructions and in your tool rules; the key's scopes are the hard limit.
How the agent works
A typical loop:
tmspec context r12 --brief --json # the approved context of the assigned spec
tmspec context --area "Engineering / CLI" --brief --all --json # or start from an Area
tmspec search "refund" --json # no spec or Area: search by content
tmspec propose --file change.yaml --json --idempotency-key try-1 # propose
tmspec cr update 45 --json # its own change request is Out of date
Advice for the agent:
- Always add
--jsonafter the subcommand: stdout is exactly the API content, errors and warnings go to stderr. Text is for people and may change. - Read the exit code first, then the error's
code(stable across releases). See Exit codes. - An implementation spec that is still a draft is not the spec; only a Ready one can be trusted.
- Use a stable
--idempotency-keyso retrying after a timeout does not create a second change request. - On
scope_missing(code 4) while reviewing, the agent stops and tells a person the change request's code.auth tokenshould never run in the agent's shell. - Cap the number of re-reads and retries (for example three) so two agents on the same spec do not loop forever.
Rules for the agent's tool (Claude Code)
tmspec provides a rule template split into three lists, to copy into your project's or your own settings. The template is the file skills/tmspec/templates/claude-settings.json in the CLI archive (the skills/ folder ships with the binary, see Install the CLI):
| List | Contains | Effect |
|---|---|---|
| allow | read-only commands (view, context, search, ls, diff, log, impact, link list, cr list, cr view...) and the ws group | Runs without asking |
| ask | every other write command (propose, cr approve, link, pin, tag...) and api | A person confirms each time; with no person present it is refused |
| deny | auth token, --host, TMSPEC_HOST=, TMSPEC_ISSUER=, reading the key file | Refused |
These rules do not block every way of writing a command (for example a command wrapped in sh -c). That is why layer 1 matters: with a key that has no decide:* scope, even if the agent reaches a review command it only gets a scope_missing error.
What people still do
Approving change requests, clicking Ready and confirming No impact are judgements. If you give an agent a key with decide:*, do it on purpose and with an agent you trust. If not, the agent proposes and you approve on the Review page; see Review change requests.