Skip to main content

grant

Agent-first per-OS-user secrets manager CLI. Part of the AgentCulture ecosystem; sibling to zehut (identity layer) and patterned on afi-cli (noun-verb shape, exit-code discipline, structured --json output).

Each OS user gets their own secrets store at ~/.local/share/grant/secrets.json (mode 0600, owned by the user). grant never reaches across users in self-mode. Admin handoff to another user goes through a single setuid-fork chokepoint and preserves the H2 hidden-secret contract — admin can never extract a value through any CLI verb.

Install

uv tool install grant
grant --version

Linux only (uses setuid / useradd semantics). Python ≥ 3.12.

Quick start

# store a secret you already have (stdin form preferred — keeps the
# value out of /proc/<pid>/cmdline and shell history)
echo -n "sk-..." | grant set OPENAI_API_KEY -

# generate a random one, hidden — never printed
grant generate JWT_SECRET --bytes 32 --hidden

# inspect (never prints value)
grant show OPENAI_API_KEY
grant show OPENAI_API_KEY --json

# consume — visible secrets only
grant get OPENAI_API_KEY
eval $(grant env OPENAI_API_KEY DATABASE_URL)

# consume — visible OR hidden (this is the only path for hidden)
grant run --inject JWT=JWT_SECRET --inject DB=DATABASE_URL -- ./myapp

grant list and grant overview give names and metadata. grant delete NAME removes a record.

Self-teaching surface

grant learn                # markdown summary of every verb + concept
grant learn --json         # structured payload for agent consumers
grant explain hidden       # explain a concept
grant explain set          # explain a verb

Admin handoff

grant is single-admin-trusted-host. Admin operations go through sudo; the binary forks → drops to the target user → writes/reads under their uid. Every admin write stamps source = "admin:<invoker>" and handed_over_by = "<invoker>" so the receiving user can audit.

# provision a secret into alice's store as root
sudo grant set --user alice OPENAI_API_KEY -

# read-only audit across every user with a grant store
sudo grant overview --all-users
sudo grant doctor --all-users

# delete a record from alice's store
sudo grant delete --user alice OPENAI_API_KEY

get, env, run deliberately have NO admin flags — values are never extractable through the CLI, even for root. Use sudo cat ~alice/.local/share/grant/secrets.json if you truly need plaintext (at which point you've moved outside grant's contract).

Moving to a new host

grant import merges a bundle into your store under one lock. The bundle format is identical to secrets.json, so the raw store file from the old machine is a valid source — and that is the only way to carry hidden secrets across:

# everything, hidden included (preview first, then for real)
ssh OLDHOST cat ~/.local/share/grant/secrets.json | grant import - --dry-run
ssh OLDHOST cat ~/.local/share/grant/secrets.json | grant import -

# non-hidden only, through grant's own surface
ssh OLDHOST grant export | grant import -

New names are created with all metadata preserved. A name that already exists with a different value is a conflict: the local copy is kept (exit 68) unless you pass --overwrite. grant export never emits hidden values; grant import never prints any value. See grant explain transfer.

Hidden secrets — the H2 contract

A secret with hidden: true:

  • Is immutable post-create — you cannot toggle the hidden flag.
  • Is refused by get, env, show (they exit 64 with a remediation pointing at run --inject).
  • Has its value omitted from generate --hidden --json output (the JSON payload has no value field).
  • Is skipped by grant export (its name is reported instead).
  • Is consumable only through grant run --inject VAR=NAME -- cmd.

Hidden is a CLI contract, not encryption. The on-disk file is plaintext at 0600. Encryption-at-rest is tracked for a future v1.x release in issue #8.

Exit codes

Code Meaning
0 success
64 bad input from the caller (invalid flag, missing record, hidden refusal, etc.)
65 store is corrupt / schema mismatch / unreadable
66 this operation requires root
67 backend dependency failed (unknown OS user, etc.)
70 bug in grant — please file an issue

Every error path emits a structured GrantError with a remediation string. With --json, errors land as {"ok": false, "error": {...}} on stdout (single-payload contract).

Docs

Development

git clone https://github.com/agentculture/grant
cd grant
uv sync                                                         # install deps
bash .claude/skills/run-tests/scripts/test.sh -p                # unit suite
bash .claude/skills/run-tests/scripts/test.sh --ci              # CI parity

Integration tests need real root + useradd/userdel, which we only do inside a disposable Docker image:

docker build -f .github/workflows/Dockerfile.integration -t grant-int .
docker run --rm -e GRANT_DOCKER=1 grant-int uv run pytest tests/integration -v

See docs/testing.md for the broader test-isolation conventions and the smoke-test namespace under /tmp/grant-tests/.

License

MIT. © 2026 Ori Nachum / AgentCulture.

Metadata

Release files for grant 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grant 0.12.0
File Size Uploaded Provenance Actions
grant-0.12.0.tar.gz 241.1 kB With provenance Details for grant-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grant 0.12.0
File Interpreter ABI Platform Actions
grant-0.12.0-py3-none-any.whl Python 3 none any Details for grant-0.12.0-py3-none-any.whl

Total release size: 283.1 kB

Release files / grant-0.12.0.tar.gz

Download URL grant-0.12.0.tar.gz
Size 241.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a7cedc85ee41779584f9c39c324715f9e50d39319c0ece48b8ad7b2818c6860a
BLAKE2b-256 checksum
How to use checksums
13112fc1100aa1494bc8d2444dac952c8329c338428978396bef7e8df6fa65ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / grant-0.12.0-py3-none-any.whl

Download URL grant-0.12.0-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dccba26a487aa1f4c821cca0d1e99eef0f46a89f8b68d88290111e969af38a4
BLAKE2b-256 checksum
How to use checksums
df145183890b43bc16879005e52e9681aed6ed3d653e246467c26c6bd4740629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for grant 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for grant-0.12.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page