References and API

The formats Latchkey reads and writes: references in your files, the protocol between the command-line tool and the app, and the files it keeps on disk.

Use the command-line tool. latchkey is the supported interface, from any language. The socket protocol below is how it talks to the app; it changes only by adding optional fields, but scripts that speak it directly also take on its approval rules.

References

FormWhereBecomes
latchkey://IDValues in env files and in the environment of latchkey runThe item’s value
latchkey-file://IDValues in env files and in the environment of latchkey runThe path of a temporary file holding the value, mode 0600, deleted when the command exits

A latchkey:// reference can sit inside a longer value, as in postgres://app:latchkey://shop/production/DB_PASSWORD@db/shop; each one is replaced. A latchkey-file:// reference must be the whole value. ID is NAME or project/environment/NAME, each part letters, digits, _, - and ., at most 64 bytes.

.env.local
DATABASE_URL=latchkey://shop/development/DATABASE_URL
SENTRY_DSN=latchkey://SENTRY_DSN
ASC_KEY_PATH=latchkey-file://shop/production/ASC_P8

The broker protocol

The app listens on a Unix socket at ~/Library/Application Support/Latchkey/broker.sock, mode 0600 in a 0700 folder. A client connects, writes one JSON object followed by a newline, and reads one JSON object followed by a newline. Keys are sorted; dates are ISO 8601. Requests say nothing about their caller. The broker asks the kernel instead: the caller’s working folder, command line and parent processes, and, by code signature, whether it’s Latchkey’s own command-line tool. The approval panel and the log show those, and grants are matched against the real folder. A signed latchkey also checks that the socket belongs to the Latchkey app before it sends anything.

Requests are handled one at a time. A request that needs approval waits until you answer, so allow for that in timeouts.

Request
{"op":"status"}
Response
{"info":{"approval":"Touch ID, password","caller":"Latchkey's command-line tool (signature checked)","grants":"0","items":"17","socket":"/Users/you/Library/Application Support/Latchkey/broker.sock","storage":"iCloud Keychain storage (sync status not verified)"},"ok":true}

Operations

opFieldsReturns
statusinfo
listsecrets: item metadata, never values
checknames, intended (the command to test command-limited grants against)agentSafe, granted (with the covering grants), needsApproval, missing. Never asks, never values
getnamesvalues, masked (names to hide in output), denied, missing
setnames (one), value, kind, agentSafe, note, serviceok
updatenames, kind, agentSafe, note, serviceok
rmnamesok, or missing
movenames, project ("" for shared), environmentmoved: old ID to new ID
importitems, replace, sourceadded, replaced, skipped
historynames (one)versions, never values
deletedversions of deleted items
versionversion: a version ID from historyvalues, after approval (always asks)
restoreversionok
forgetnamesok
grantsgrants
grantnames, folder (default: where the caller runs), duration (seconds), session, commands (lists of words), usesgrants
revokenames: a grant ID, or ["all"]info.revoked, or missing
linksnames: optional scopelinks
linknames: the scope, targetlinks
unlinknames: the link IDok
remote-statusnames: the scoperemoteStatus
pushnames: the scope, link, onlypushResults

origin: "mcp" marks a request from latchkey mcp: the approval panel says an agent asked, and a grant it asks for must be its own folder, for the agent’s session, and nothing in production or a whole project. The label is the request’s own claim: it adds limits, never permissions. Unknown op values are refused.

Responses

Every response has ok. When it’s false, error says why: bad input, a change you didn’t approve, a keychain failure. Reads report per item instead: get answers ok: true with denied for items you refused and missing for IDs that don’t exist, and if anything was denied, no values are released at all. The command-line tool maps these to exit codes 77 and 66.

A refused get
{"denied":["shop/production/STRIPE_KEY"],"masked":[],"ok":true,"values":{}}

The item shape

What list returns in secrets, and what latchkey list --json prints:

latchkey list --json
[
  {
    "agentSafe" : false,
    "kind" : "password",
    "name" : "shop/development/DATABASE_URL",
    "note" : "",
    "service" : "Neon",
    "updatedAt" : "2026-11-10T21:52:37Z",
    "usedIn" : [
      "/Users/you/Projects/shop/.env.local"
    ]
  }
]
FieldMeaning
nameThe item ID
kindtoken, password, key or value
agentSafeRead without asking
noteFree text
serviceWho issued it, optional
usedInFiles that reference it, recorded on import and move, optional
updatedAtWhen the value or settings last changed

The grant shape

Grant
{
  "created": "2026-11-10T20:00:00Z",
  "createdBy": "zsh › claude",
  "expires": "2026-11-10T22:00:00Z",
  "folder": "/Users/you/Projects/shop",
  "id": "k3v9q2",
  "names": ["shop/development/*"],
  "repo": "/Users/you/Projects/shop/.git"
}

repo is the repository’s common .git folder, present when the folder is in one; commands run from any of its worktrees are covered.

The access log

~/Library/Application Support/Latchkey/access.jsonl, mode 0600: one JSON object per line for every read, change and refusal. Never values.

access.jsonl
{"chain":["zsh","claude","Terminal"],"command":"latchkey run -- npm test","cwd":"/Users/you/Projects/shop","decision":"allowed (grant k3v9q2)","names":["shop/development/DATABASE_URL"],"op":"get","time":"2026-11-10T20:14:03Z"}
FieldMeaning
timeWhen
opThe operation
namesItem IDs involved
decisionWhat happened: allowed and why, denied, refused
chainThe calling process and its parents, nearest first
cwdThe folder the caller ran in, from the kernel
commandThe caller’s command line, from the kernel
programThe calling program’s path, when it isn’t Latchkey’s signed command-line tool
prev, macThe keyed hash (HMAC-SHA256) of the entry before and of this one. latchkey log --verify checks the chain against a key and head only Latchkey can read

Files and storage

WhereWhat
iCloud Keychain, access group TEAM.io.snackstud.latchkeyItems (service latchkey), earlier values (latchkey.history) and remote links (latchkey.remote), as generic passwords. Synced to your Macs.
~/Library/Application Support/Latchkey/broker.sockThe broker socket
~/Library/Application Support/Latchkey/access.jsonlThe access log
Keychain, service latchkey.grantsGrants in effect, on this Mac only, changeable only by Latchkey
/Applications/Latchkey.app/Contents/Helpers/latchkeyThe command-line tool, linked from ~/.local/bin/latchkey