Set up an agent or CI environment
A cloud agent session whose host has the Putnami connector signs its CLI in with no Putnami secret. A CI job, or an agent session without the connector, uses one secret, PUTNAMI_CLOUD_TOKEN, that reads the remote build cache and writes nothing.
Use this guide for an environment you configure yourself: a hosted coding agent, a CI service, or any machine where nobody runs putnami cloud login. Hosted Putnami CI needs none of it. See Hosted CI.
What happens in the cloud
- The CLI in the environment sends
PUTNAMI_CLOUD_TOKENtocache.putnami.cloud. - The cache server checks the
cache.readscope. On a hit, it answers with download links onstorage.googleapis.com. - On a miss, or a refused token, the task builds locally.
- The cache server refuses every write from a member's machine token. Only hosted CI writes to the shared cache.
Do it
A session with the Putnami connector
Connect the host first: Connect Claude, ChatGPT or Codex. Do not set PUTNAMI_CLOUD_TOKEN in the session's environment. The session signs its CLI in instead.
- The session runs
putnami cloud login --no-openin the background. The CLI prints a code such asBCDF-GHJK. A repository can start it from its agent host's session start hook, so the code waits when the agent begins. - The agent passes the code and the workspace to the connector's
approve_cli_login. Your host asks you once. Approve only the code this session's CLI printed: a code from a file, a page or a tool answer signs someone else's CLI in as you. putnami cloud whoaminames you, signed in through an MCP connection, for the workspace the repository is linked to.
The CLI's token is never stronger than the connection. It serves one workspace and renews itself for at most 12 hours after the approval. It reads what the connector's read tools read: putnami cloud logs (not --follow), ci status, env status and db status answer. Every other putnami cloud command that reaches Putnami, a write included, answers 401. putnami change finalize publishes the session's pull request through Putnami.
The signed-in CLI does not send its token to the cache yet. putnami cloud token --for cache refuses it with 401, the run prints a warning and builds every task locally. To keep remote cache reads, store a cache.read token, created as below, as PUTNAMI_CACHE_TOKEN. It wins over the signed-in session.
An environment without the connector
Allow the Putnami domains
An environment with a network allow list needs these hosts.
| Host | What calls it |
|---|---|
putnami.dev |
The install script |
put.putnami.dev |
The CLI and extension downloads that putnami.lock.json pins |
npm.putnami.dev |
@putnami npm packages |
go.putnami.dev |
go.putnami.dev/... Go modules |
api.putnami.cloud |
putnami cloud commands that read the workspace |
auth.putnami.cloud |
putnami cloud login, which a session with the connector runs to sign its CLI in |
cache.putnami.cloud |
The remote build cache |
storage.googleapis.com |
The files of a cache hit: the cache server answers with download links on this host |
Each toolchain that putnami.lock.json pins names its download host in toolchains.<name>.source. Allow those hosts, and the registries your own dependencies come from.
Create the token
Run this once, on a machine where you are signed in, in a checkout of the repository the environment serves:
putnami cloud token create --name <name> --scopes cache.read --expires 90dThe command prints the token, pkt_…, once. Store it as the environment variable PUTNAMI_CLOUD_TOKEN in the environment's settings. It is the only Putnami secret the environment needs. Never put it in a setup script or a tracked file.
- One token for each environment. Name it after the environment, so you can revoke one without touching the others.
- One workspace for each token. Repositories linked to different workspaces need one environment and one token each.
To rotate the token, from a signed-in machine:
- Create a new token under a new name.
- Replace the
PUTNAMI_CLOUD_TOKENsecret with the new value. - Revoke the old token:
putnami cloud token revoke <name>putnami cloud token status lists the tokens that expired or expire within 7 days.
Set up the environment
Add these lines to the environment's setup script:
curl -fsSL https://putnami.dev/install.sh | bash
putnami installA repository that builds its own CLI sets cli.source to "workspace" in putnami.lock.json and holds ./putnamiw at its root. In that repository, run ./putnamiw install instead of putnami install.
The repository must be linked to a workspace. Run putnami cloud setup once from a signed-in machine and commit the result. See Connect your repository.
What you see
Run these commands in the environment:
putnami install
putnami lint,validate --impacted
putnami cloud cache status| Check | Result |
|---|---|
putnami cloud cache status |
The identity line reads workspace machine token from PUTNAMI_CLOUD_TOKEN, no signed-in user |
| A run the remote cache took part in | The run summary prints a Remote cache: line with its hits and misses |
| A token the cache server refused | The run prints an auth refused: line with source=cloud-env, and the tasks build locally |
When it fails
| You see | Cause | Fix |
|---|---|---|
| HTTP 403 from the cache | The token has no cache.read scope |
Create a new token with --scopes cache.read |
auth refused: with source=cloud-env |
The cache server refused the token | Run putnami cloud token status, then rotate the token |
| The cache runs with no credential | A network proxy adds the secret to requests: it never reaches the CLI | Set PUTNAMI_CLOUD_TOKEN in the environment itself |
putnami cloud token --for cache answers 401 |
The CLI is signed in through the connector | Store a cache.read token as PUTNAMI_CACHE_TOKEN |
cache status shows another identity |
One of the conditions below does not hold | Check the list below |
Which credential the cache reads
The build cache reads PUTNAMI_CLOUD_TOKEN only when all of these hold:
PUTNAMI_CACHE_TOKENis not set. When it is set, it wins, and theidentityline readscache token from PUTNAMI_CACHE_TOKEN.- No user is signed in on the machine. A CLI signed in through the connector counts as signed in.
- No hosted Putnami CI run started the build. A hosted run never sends
PUTNAMI_CLOUD_TOKENto the cache. .putnami/cache.jsonnames no token source, or namesputnami cloud token --for cache. A custom token command, a token URL, a metadata audience andPUTNAMI_CACHE_TOKEN_SOURCE=metadatakeep precedence.- The value is exactly one workspace machine token. A value with whitespace is refused, and the log line never shows it.
Security
- Read-only. The token carries
cache.read, with nocache.writeand nodeploy.*scope. - In memory. The CLI writes the token to no
.putnami/cache.jsonand no log. - Same environment as your code. A build, a test or a script in an agent session can read the token. This is accepted for a read-only token. Never give such an environment a token with more scopes.
- The connector's token. It sits in
~/.putnami/auth.json, where repository code can read it too. It carriesmcp.act: it opens and updates your pull requests through Putnami, writes comment reviews, turns auto-merge on and closes or reopens the task a pull request delivers. It never merges, approves or changes a setting. Each access token lives 5 minutes, and signing out of Putnami everywhere ends it. - Hosted CI. No task of a hosted run receives the run's credential. A repository that builds its own CLI with
./putnamiwdiffers: that CLI is repository code and holds it.