Back to projects
yay@patrikmichalicka.com
Active, pre-1.0

Keylatch

A zero-trust credential vault for AI-assisted development: agents use credentials without ever seeing them.

Language
Go, with a browser UI and a Linux desktop app
Backends
Encrypted file, macOS Keychain, 1Password, Bitwarden
Install
Homebrew, Scoop, binary download, Docker image, go install
Agent integrations
Claude Code, Codex, Cursor, Gemini CLI, OpenCode, Aider and more
Release trust
Keyless cosign signatures, SBOMs and SLSA provenance
Latest tag
v0.9.9, Apache-2.0

Problem

I use AI coding agents every day, and they run in the same shell as my API keys. A key that lands in model context, a tool output or an agent log is hard to take back.

Environment files, keychain commands and password manager CLIs are all one tool call away from an agent. I wanted agents to be able to use credentials without ever seeing them.

Approach

I treated a credential as something a program receives at runtime, not something an agent reads. Secrets stay in an encrypted backend. A subprocess gets only the scoped variables it needs, and a policy and audit layer sits in front of every use.

For agents I added a local gateway. The agent holds a short-lived token and a URL, and the gateway adds the real key on the way to the provider. Guards around this core catch the obvious ways an agent could try to go around it.

I also decided early to state the limits plainly. Detecting an AI session helps well-behaved agents, but it is not a security boundary, and the README says so.

Secrets sit in a backend behind policy and audit. Programs get injected variables, agents get a gateway token, and guards sit in front of the agent.

What I built

Keylatch is a self-contained command line tool written in Go, with a browser UI at keylatch ui and a Linux desktop app that wraps the same runtime. Native macOS and Windows desktop apps are planned, and on those platforms the CLI and browser UI cover the same ground.

It has four backends: the macOS Keychain, 1Password, Bitwarden or Vaultwarden, and an encrypted file using XChaCha20-Poly1305. A connect command can also pull a secret from 1Password, AWS Secrets Manager or HashiCorp Vault and store it in the chosen backend.

It ships a Claude Code guard installed with one command, plus guides for Codex, Cursor, Gemini CLI, OpenCode, Aider and others. It has a local gateway that mints scoped tokens, an approval flow for human sign-off, and a team layer with policy, grants, actors, sessions and value-free receipts.

It installs through Homebrew, Scoop, a binary download, a Docker image or go install.

How it works

I store a credential once with keylatch connect. The value is read from a prompt, stdin or an external store, never from a command line argument, and it is written to the backend encrypted.

A program path and an agent path then split. For a program, keylatch run starts a subprocess with the variables injected, so a script or an MCP server reads them from its environment. By default Keylatch strips its own configuration variables from the child, and a clean-env flag reduces it further for CI.

For an agent, I mint a token with an actor, a capability such as openrouter.chat and a TTL. The agent gets the token and the gateway URL. The gateway checks actor, capability and expiry, adds the provider key and forwards the request. Tokens can be limited to a number of uses and revoked at any time.

Every read, write, injection and gateway call lands in the audit log without values.

A credential goes in once. Programs receive injected variables, agents receive a token, and both paths are audited.

Key decisions

I put a gateway between agents and provider keys. The reason is that an agent process should hold only a short-lived token and a URL, so the provider key never reaches the agent, the UI, MCP responses, logs or the child environment.

I documented session detection as a convenience, not a boundary. The signals live in the agent's own environment, so a same-user agent can hide them, and editor terminals can carry them for a human too, in which case Keylatch errs toward restricting. Saying so keeps anyone from relying on it alone.

I treated the audit log as part of the core, not an add-on. Every read, write, injection and gateway call is recorded without values, and the log is HMAC-chained so tampering in the middle is detectable.

I made approvals human-only. Approving and denying need an interactive terminal and a passphrase, are blocked inside detected agent sessions, and each decision is signed and expires. The reason is that the person has to be the last gate on a grant.

I made release signing keyless. The pipeline holds no long-lived signing key, uses the repository's own identity via GitHub OIDC, and publishes only once every signature and the provenance verify. That makes a signature prove which workflow built a file.

In detail

Protection is layered, and each layer covers a different gap. Detection keeps well-behaved agents on the brokered path. The Claude Code hook runs before tool calls. The gateway keeps provider keys out of the agent's reach. Approvals keep a human in the loop.

For releases, a tag triggers tests with the race detector, GoReleaser, SBOMs in CycloneDX and SPDX, release checks, cosign signing and SLSA provenance. The release stays a draft until everything verifies, and only then are Homebrew and Scoop updated. A docs table lists what each older release carries.

The docs also list what Keylatch does not defend against: a compromised OS or root user, memory scraping, other processes running as the same user, network exfiltration by an allowed command, and a user who approves every request.

Each layer covers a gap the one before it leaves open, and the docs state what none of them cover.

Status

Active and pre-1.0. The latest tag is v0.9.9 and the project is Apache-2.0 licensed. The CLI is not OS code-signed, so Homebrew or Scoop is the smoother install path, and the docs describe a workaround for a raw macOS binary.

One release, v0.9.7, shipped without signatures, SBOMs or provenance. I documented that in a public advisory and in a per-release table, so a reader can see what each release carries before trusting it.

Keylatch runs as the same user as the agent. A boundary against a same-user agent needs a broker outside the agent's user account plus proof of human presence, and the docs track that work as not done yet.

Got a messy workflow? Let’s talk