Agent pack
Tokens: minting, storing, scoping, rotating
Where tokens come from and how they are scoped — read from docs and CLI source, no token minted.
Verified 2026-10-11 by reading docs and CLI source (no command was run, no token minted, no secret store read).
Sources: packr-registry/CLAUDE.md + docs/07-tokens.md, packages/cli/cmd/*.go; forge-control packages/forge-cli/src/commands/{api-key,login,vault}.ts;
forge-git CLAUDE.md + packages/cli/src/commands/token.ts, lib/scope-aliases.ts; forge-auth CLAUDE.md + packages/fauth/README.md.
claude/TOKENS.md(Oct 9) is largely wrong. Do not follow it. It usespackr admin tokens create(packr is the server; the client ispackr-cli),tea user create-token/fgit secret set(unconfirmed; nofgit secretexists), a mintedFORGE_CONTROL_DEPLOY_TOKEN(the real one isBLUEFORGE_DEPLOY_TOKEN, a shared bearer, not minted per app), 30/90-day cadences no CLI enforces, and telling you toechotokens into files. Itsfauthsection is accurate.
Rules for agents (all CLIs)
- Agents do not mint, rotate or revoke tokens, and never read, print or write token values unless the operator explicitly asks for that action. Hand the step to the
operator (
! <command>). If a sweep/automation token is needed, the operator authorises it and chooses the identity. - Never put a token in argv (
psshows it), in a commit, a PR body, a log or a message. Prefer--output-file(0600), stdin, or a keychain. - One token per purpose and per repo. Narrowest role/scope that works. Never
admin/@full/allfor automation. - Verify a token without printing it (each section says how). Rotation order is always: mint new, verify, swap consumers, revoke old last.
packr-cli (registry https://api.packr.blueforge.studio)
Binary is packr-cli (not packr, the server).
| Purpose | Role | Notes |
|---|---|---|
| Human / the session that mints tokens | admin |
only that session |
| CI publish | ci-publish |
scope @blueforge-studio, one token per repo |
| CI install | ci-readonly |
separate secret from the publish token |
| Sweep / automation | maintainer or ci-publish |
never admin |
Roles: ci-readonly read; ci-publish read+publish; maintainer +unpublish; admin all. Prefer the bare --scope @org form: a scope with an ecosystem and
no namespace is ecosystem-wide, and unscoped package names bypass the scope check.
Commands (token_remote.go, rotate.go): token create <name> [--role --ecosystem --namespace --scope --expires <days> --output-file <p> --to-forge-git <owner>/<repo>:<SECRET> --registry],
token list, token revoke <id>, token reissue, token verify, rotate [--name --scope --expires --output-file --to-forge-git], login [--provider --password --name --scope --registry],
doctor, whoami, logout. Default expiry 30 days (token create), 90 days (device flow). Expiry is enforced (internal/auth/middleware.go:59); packr-registry/CLAUDE.md saying otherwise is stale.
- Stored in
~/.packr/credentials.jsonor keychain servicepackr-cli(account = registry URL);login/rotatealso write~/.npmrc. Env:PACKR_TOKEN(wins over the stored login),PACKR_REGISTRY,PACKR_CREDENTIAL_STORE. - Rotate:
unset PACKR_TOKENfirst (rotaterefuses while it is set), mint with--output-file(or--to-forge-gitto write straight into a forge-git Actions secret without printing), checktoken list, swap the CI secret and local stores, revoke the old one last. - Verify:
packr-cli doctor(server probe).whoamionly decodes the local store and passes on a dead token.GET /-/v1/credential/verify?scope=checks scope. - 401 on admin routes while publish still works = token predates a
JWT_SECRETrotation:login --passwordagain.login --password "$PASS"puts the password in argv. - No-browser path:
POST /-/v1/login, thenPOST /api/v1/admin/users/me/tokens(seepackr-registry/CLAUDE.md). A token minted as the wrong user is invisible intoken list.
forge CLI (forge-control)
forge login [--api-url] [--api-key]only saves a key to~/.config/forge/credentials.json. Device-code OAuth login is not implemented (login.ts:9).- Env:
FORGE_API_KEY,FORGE_API_URL,MISSION_CONTROL_URL,FORGE_PROFILE,FORGE_APP,FORGE_ENV,FORGE_CONFIG_PATH. forge api-key create --project <slug> --name <n> [--scope metrics:read] [--out <file>] [--quiet],list --project <slug>,delete <key-id>.createneeds project admin;metrics:readis operator-only. Use--out(0600, printed masked); the default prints plaintext once. Only a SHA-256 hash is stored server-side. Use a per-project deployer key for deploys. Rotate: mint, check,forge login --api-key "$(cat f)"thenrm f, thendeletethe old key.forge vault: deployer-allowedset|set-many|get|list|push|audit; admin-onlyrekey|delete|bulk-delete|rotate. Useset --stdin|--file|--generate, never--value(visible inps).BLUEFORGE_DEPLOY_TOKEN: a shared bearer sent asX-Forge-Deploy-Token, equal to the receiver'sFORGE_DEPLOY_TOKEN. Read from env then/etc/forge/blueforge-deploy.env. If unset, registration is silently skipped. I found no mint endpoint.- Gitea admin-token rotation:
forge-control/docs/runbooks/rotate-gitea-admin-token.md(mint, probe, roll, checklast_used_at, revoke, confirm 401). Keychain serviceforge-secrets.
fgit (forge-git)
fgit loginis manual: opens$FORGE_GIT_URL/user/settings/tokens, you paste a PAT; saved to~/.config/forge/credentials.json(0600). The "OAuth device flow" text inforge-git/CLAUDE.mdis wrong.- Credential resolution:
$FORGE_GIT_TOKEN, thencredentials.json, then~/.forge-secrets/forge-git-token,forge-git.token,forge-git.token.new. A staleFORGE_GIT_TOKENenv var overrides a fresh login and causes client-side 401s. Diagnose withfgit token doctor. fgit token generate <user> <name> [--scopes --output-file --expires-in --save --print --via auto|api|ssh],token rotate <user> <old> [--new-name --keep-old --update-tea],list,explain,doctor,scopes list|explain. Default--expires-in7d (neverallowed). An explicit--expires-in <date>is refused before minting when the transport cannot set one (neither the wrap API nor this Gitea'sgenerate-access-tokencan — remedy printed:--expires-in never); the no-flag default keeps its loud warn-and-retry on the SSH path. Without--output-filethe token goes to a 0600 tempfile;--printputs it on stdout, do not use it. Minting for other users,--via sshandfgit-ops …are operator-only.- Aliases:
@repo-creator(write:organization, write:repository, read:organization, read:repository, read:user; no write:user — forfgit init, revoke right after);@readonly(read:user, read:organization, read:repository);@contributor(write:repository, read:user);@developer(contributor + read:organization, read:repository; no write:issue despite its description);@default(write:repository, write:issue, read:user, read:issue, read:organization, read:repository);@admin;@full(Giteaall). - Recommended: human dev
@default(7d); CI/sweep a narrow explicit scope or@developerplus an explicitwrite:issueif it must comment;@admin/@fullstay on the operator machine. - Ambient token: id 241 (
ambient-2026-09-28-operator-narrowed), never expires, rotate by 2026-12-27.forge-admin(id 1) has no 2FA and reaches everything: operator plane only. Do not setprohibit_loginon a bot account; it kills that account's tokens (this killedflake-record-ci). - Token-mint 401 after restart: the server side was closed 2026-09-23; the remaining cause is a stale client env var or secrets file.
fauth (forge-auth), if a task needs it
API keys fk_… with scope strings (14 defined in src/lib/scopes/scopes.ts); a bearer can mint a narrower key (POST /api/v1/keys, self-narrowing); revoke with DELETE /api/keys/:id or fauth logout.
No-browser mint: fauth login --admin --email <e> [--app <slug>] [--days 1-90, default 30]. --admin overwrites an existing ~/.forge-secrets/forge-auth.json: always use a scratch FORGE_SECRETS_DIR.
Env: FAUTH_TOKEN (wins over the file), FAUTH_BASE_URL, FAUTH_APP_ID, FAUTH_EMAIL, FAUTH_ADMIN_KEY. Minted keys self-verify via GET /api/v1/me and are revoked if that fails.
UNVERIFIED
Current token state (the "both packr tokens 401" note is likely resolved by the 2026-09-21 and 2026-10-02 rotations); forge-control/docs/secrets/rotation-design.md and docs/08-cli-auth.md were not read in full;
fgit secret set / tea mint commands are unconfirmed; the --save help text in fgit shows an old credentials path.