Native OS keychains (macOS Keychain, Linux Secret Service, Windows Credential Manager) index credentials using exactly two fields: a service name and an account name (also called the target). They have no native concept of folders, projects, environments, or workspaces. If your CLI tool manages secrets for multiple tenants, projects, or deployment environments, you need a strategy that works within this flat structure. The recommended approach is to encode all tenant context directly into theDocumentation Index
Fetch the complete documentation index at: https://theseventeen-2abbdf80.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
target field using a hierarchical string prefix. This requires no platform-specific code and works identically on macOS, Linux, and Windows.
Why prefix encoding works
Because keychain-auth mediates all keychain access and supports prefix-based queries, you can treat thetarget field as a path-like identifier. The daemon performs all filtering server-side, so you never need to fetch large credential sets and filter them in client memory.
Two common formats:
: or /) and apply it consistently across all writes from your tool.
Write, read, and prefix read examples
Prefix reads require
can_search: true in your binary’s config.json entry, in addition to the service being listed in allowed_read_services. The daemon must enumerate keys to resolve the prefix filter.Key-only discovery with search
If you want to list the names of secrets matching a prefix without reading their values — for example, to show the user what secrets exist before fetching them — use asearch action instead:
value fields:
read requests for only the specific secrets your tool needs. This two-step pattern minimizes the number of plaintext values held in memory at any time and generates more granular entries in the daemon’s audit log.
Bulk deletion with prefix matching
The same prefix matching works fordelete operations, making it straightforward to clean up all secrets for a project or environment in a single request:
Prefix deletes require
can_search: true AND the service in allowed_write_services, for the same reason as prefix reads: the daemon must enumerate keys to find all matches.Choosing a prefix scheme
The format you choose is entirely up to you, but a few guidelines help keep things maintainable:- Put the highest-cardinality segment last (the secret name), so shorter prefixes naturally match broader sets.
- Use a consistent delimiter throughout your tool — mixing
:and/in the same target string makes prefix filtering harder to reason about. - Avoid embedding values that contain your delimiter character (for example, do not use a project name like
proj:devif:is your delimiter).