Project

vaultkit

0.0
The project is in a healthy, maintained state
Command-line interface for interacting with the VaultKit control plane
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 5.0
~> 13.0

Runtime

~> 1.2
 Project Readme

VaultKit CLI (vkit)

Gem Version License Ruby Version

Command-line interface for VaultKit β€” secure, policy-driven data access control plane

The VaultKit CLI (vkit) is the primary interface for interacting with the VaultKit control plane. It enables users to request governed data access, track approvals, manage datasources, and deploy policy bundlesβ€”all while maintaining complete audit trails.


πŸ“‹ Table of Contents

  • What is VaultKit CLI?
  • Installation
  • Quick Start
  • Authentication
  • Core Workflows
  • Command Reference
  • Configuration
  • Advanced Usage
  • Driving vkit from a coding agent
  • Troubleshooting
  • Contributing

🎯 What is VaultKit CLI?

The VaultKit CLI provides command-line access to VaultKit for:

  • Users - Data analysts, engineers, and administrators
  • AI Agents - LLMs and autonomous systems requiring governed data access
  • Tools & Services - CI/CD pipelines, data pipelines, and automated workflows
  • Applications - Programmatic integration via scripting
Capability Description
Authentication Login, session management, identity verification
Data Requests Submit AQL queries with automatic policy evaluation
Approval Workflows Approve or deny access requests requiring authorization
Grant Management Fetch data using approved, time-limited grants
Datasource Admin Register and manage database connections (admin only)
Schema Discovery Scan datasources and detect schema drift
Policy Deployment Build, validate, and deploy policy bundles

Mental Model

VaultKit uses a request β†’ policy β†’ grant β†’ fetch workflow:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Request  β”‚ -> β”‚ Policy   β”‚ -> β”‚ Grant β”‚ -> β”‚ Fetch β”‚ -> β”‚ Audit Log β”‚
β”‚ (AQL)    β”‚    β”‚ Eval     β”‚    β”‚ (JWT) β”‚    β”‚ Data  β”‚    β”‚ (Record)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Principles:

  • Users request data, not queries
  • Policies decide what happens (allow, mask, deny, require approval)
  • Grants authorize execution with TTLs
  • FUNL executes queries safely
  • Everything is audited

πŸ“¦ Installation

Prerequisites

  • Ruby 3.1 or higher
  • VaultKit Control Plane running and accessible

Option 1: Install from RubyGems (Recommended)

gem install vaultkitcli

Verify Installation

vkit --version
# => VaultKit CLI v0.1.0

vkit --help

⚑ Quick Start

1. Set Environment Variables

export VKIT_API_URL=http://localhost:3000

For production:

export VKIT_API_URL=https://vaultkit.company.com

2. Authenticate

vkit login --endpoint http://localhost:3000 --email analyst@company.com

You'll receive a prompt for your password or be redirected to SSO.

3. Submit Your First Request

vkit request --aql '{
  "source_table": "customers",
  "columns": ["id", "email", "total_spend"],
  "limit": 10
}'

4. Fetch Results

If granted immediately:

vkit fetch --grant gr_abc123xyz

If approval required:

# Check status
vkit requests list --state pending

# After approval
vkit fetch --grant gr_abc123xyz

πŸ” Authentication

vkit login

Authenticate with the VaultKit control plane.

vkit login --endpoint http://localhost:3000 --email analyst@acme.com

Options:

  • --endpoint β€” VaultKit API endpoint (can also use VKIT_API_URL)
  • --email β€” Email address for authentication

SSO Integration:

If your organization uses SSO, you'll be redirected to your identity provider:

vkit login --endpoint https://vaultkit.company.com --email you@company.com

# Output:
# Opening browser for SSO authentication...
# βœ“ Authentication successful
# Session expires: 2024-01-15 18:00:00 UTC

vkit login --setup (a coding agent setting VaultKit up)

A coding agent can set VaultKit up without your own login: it asks for a setup session, you approve it in the console, and it gets a token that can only do setup (connect datasources, scan schemas, deploy policy bundles) and lasts 30 minutes. It works like gh auth login.

In a terminal it's one command. It prints a code and the console's approval link, opens the link in your browser, and waits:

vkit login --setup --endpoint http://localhost:3300
# πŸ” An admin approves this setup session in the VaultKit console:
#    1. Open http://localhost:5300/setup/approve
#    2. Check the code matches: BCDF-1234
#    3. Approve it (by 14:10, when the request expires)
# ⏳ Waiting for an admin to approve it...
# βœ… Setup session approved by you@acme.com for acme; it works until 14:32.

Open the link signed in as an admin, check the code matches what the terminal shows, and approve. Only approve a session you just started yourself: anyone can start one and send you the link. The approval page shows the requester's address and what made the request (vkit/<version> (<os>; ruby <version>)).

With --format json it's two commands, so the agent can show you the code before it waits:

  1. vkit login --setup --format json returns needs_input (exit 3) with user_code, verification_url and verification_url_complete in result, and the fix "Ask the person to open the URL, check the code matches, and approve". Running it again returns the same code until the request expires (10 minutes).
  2. vkit login --setup --wait --format json polls until you approve (ok), deny (setup_session_denied), or the request expires (setup_session_expired). Add --timeout <seconds> to stop sooner; still waiting is needs_input again, so rerun it.

--no-browser skips opening the link. The token is saved where vkit login saves yours (it replaces your saved login, and says so), marked as a setup session with its expiry; it's never printed. vkit whoami shows the expiry.

When a command needs more than setup, or the session ended, you get:

Code What happened
setup_scope_forbidden A setup token can't do this (or can't change an organization that's already set up). An admin must: sign in with vkit login.
setup_session_expired The 30 minutes are up. Run vkit login --setup again.
setup_session_revoked It was revoked in the console or by vkit logout.
setup_approver_not_admin The admin who approved it is no longer an admin.

vkit logout ends a setup session on the control plane (DELETE /api/setup_sessions/current) and then clears it here. If the control plane can't be reached, it's still cleared here, and vkit says the token stays valid until it expires (an admin can revoke it on the console's Agents page).

Rerunning setup is safe: a datasource that exists with the same settings, a bundle that's already uploaded, and a scan that changes nothing come back as already_existed, already_deployed or unchanged, not as errors. A datasource id that exists with other settings is datasource_exists; a bundle version already uploaded with other contents is bundle_version_exists.

vkit whoami

Display the currently authenticated user and session information.

vkit whoami

Output:

πŸ‘€ analyst@acme.com (role: analyst, org: acme)

JSON Format:

vkit whoami --format json

Output:

{
  "email": "analyst@acme.com",
  "role": "analyst",
  "org": "acme"
}

vkit doctor

Check that VaultKit is set up and working from here, and say how to fix what isn't. Run it from your policy project so it can compare the active bundle with your commits (or pass --dir <project>).

vkit doctor
vkit doctor --format json

It checks, in order:

Check Passes when
cli_version Always; warns when RubyGems has a newer vkit. Offline, the newer-version check is left out.
control_plane The control plane answers its health check at the configured URL.
login You're signed in (or in a setup session); says when the session expires, and warns in its last 10 minutes.
datasources At least one datasource exists, and VaultKit connected to each. Uses vkit scan <datasource> in diff_only mode: it reads the schema, never data, and changes nothing in the registry. Admins only.
datasource_role Always a warning for now, "not verified": VaultKit can't yet check that a datasource connects as a dedicated read-only role (vaultkit#125).
schema Each reachable datasource is in the registry, unchanged since its last applied scan, and every column has a classification.
policy_bundle A bundle is active, and it's this repository's HEAD, or an earlier commit with the same policies, registry and .vkit/packs.yaml. Nothing is compiled or written, and uncommitted changes don't count (they're mentioned).
approval_routing Every approval group has members. A group with none is info, not a warning (" has no members, so org admins approve its requests"); groups with members aren't flagged. Fails only if GET /approval_groups errors.
agent_token VAULTKIT_BASE_URL, VAULTKIT_ORG and VAULTKIT_TOKEN are set, and the token is a working agent token for that organization. Fails if VKIT_TOKEN is an agent token, since every vkit command would then run as the agent.
mcp_server Optional, when vaultkit-mcp is installed: it starts with those variables and lists vaultkit_discover, vaultkit_query and vaultkit_check_approval.

A check that needs one that failed is skipped, with the reason. Tokens are never printed, nor any part of one.

A check whose endpoint or fields an older control plane doesn't have is never passed: it's info, "Can't check : the control plane is too old to report it.", with the fix "Upgrade the control plane." That applies to approval_routing (no active_member_count and admin_fallback per group, before vaultkit#127, or no GET /approval_groups), policy_bundle (no GET /approval_groups or GET /setup, builds before 2026-10-27) and agent_token (a whoami that doesn't say what the token is).

--format json returns result.checks, a list of { name, status, detail, fix } (status is pass, warn, fail or info), and result.skipped. info is neither a pass nor a failure. vkit doctor exits 0 only when no check failed; otherwise the envelope's status is error, with code doctor_checks_failed, and the checks are still in result.

vkit logout

Clear stored credentials and end session.

vkit logout

Where the login is saved

vkit login saves the endpoint and token in the macOS Keychain, or in the Secret Service keyring (GNOME Keyring, KWallet) on Linux when secret-tool is installed. Elsewhere, including Windows, or when saving to the keychain fails (for example, over SSH with no unlocked keyring), it saves them to ~/.vkit/credentials.json, readable only by you, and says so. Login tokens expire after an hour.

Credentials from the environment

vkit normally uses the login saved by vkit login, in your OS keychain or ~/.vkit/credentials.json. Scripts, CI jobs and demos can supply credentials for a single command or shell instead, without replacing your saved login:

export VKIT_ENDPOINT=http://localhost:3300
export VKIT_TOKEN=<a VaultKit user token>
vkit request < query.json
  • Both variables are needed. When both are set, they replace the saved login for every command except vkit login and vkit logout, which always work on the saved login.
  • One alone is an error. vkit stops and names the missing variable, rather than mixing the environment with your saved login.
  • A notice goes to stderr once per command while the override is active. The token is never printed.
  • Unset both (unset VKIT_ENDPOINT VKIT_TOKEN) to go back to your saved login.

To act as someone else for one command, override the token on that command only. For example, a reviewer approving a request from the same shell:

VKIT_TOKEN="$APPROVER_TOKEN" vkit approval:list
VKIT_TOKEN="$APPROVER_TOKEN" vkit approval:approve 42

vkit login --endpoint still reads VKIT_ENDPOINT as its default endpoint when VKIT_TOKEN isn't set.

TLS certificates

vkit checks the control plane's TLS certificate against your system's trusted certificates on every HTTPS call, including vkit login. If your control plane uses a self-signed or private-CA certificate, trust it by pointing SSL_CERT_FILE at a PEM bundle that includes it:

export SSL_CERT_FILE=/path/to/ca-bundle.pem

πŸ”„ Core Workflows

Workflow 1: Immediate Access (Auto-Approved)

# 1. Submit request
vkit request --aql '{
  "source_table": "public_reports",
  "columns": ["report_id", "title", "published_date"],
  "limit": 10
}'

# Output:
# βœ… ACCESS GRANTED
# Grant Ref: g_public_reports_3f9a
# Request ID: 8d1c0a2e-… (look it up under Activity in the console)
# Expires: 2024-01-15 18:00:00 UTC
# Masked Fields: none
#
# To execute and retrieve the data, run:
#    vkit fetch --grant g_public_reports_3f9a

# 2. Fetch data
vkit fetch --grant g_public_reports_3f9a --format table

Workflow 2: Approval Required

# 1. Submit request
vkit request --aql '{
  "source_table": "financial_transactions",
  "columns": ["transaction_id", "amount", "customer_id"],
  "filters": [{"field": "amount", "operator": "gt", "value": 10000}]
}'

# Output:
# ⏳ QUEUED for approval
# Request ID: 3b7e19c4-… (look it up under Activity in the console)
# Approver roles: finance_manager
# Reason: Financial data requires manager approval
#
# Once it's approved, run the same request again to get the data.

# 2. Check status
vkit requests list --state pending

# 3. After approval, run the same request again; it returns the rows

Workflow 3: Denied Access

vkit request --aql '{
  "source_table": "payment_cards",
  "columns": ["card_number", "cvv"],
  "limit": 10
}'

# Output:
# ❌ DENIED
# Reason: Direct payment card data access forbidden
# Request ID: 7f29e0aa-… (look it up under Activity in the console)

πŸ“š Command Reference

Authentication Commands

vkit login

Authenticate with VaultKit.

vkit login --endpoint <URL> --email <EMAIL>

Options:

  • --endpoint, -e β€” VaultKit API endpoint (default: $VKIT_API_URL)
  • --email β€” User email address
  • --password β€” Password (prompted if not provided)

Examples:

# Interactive login
vkit login --endpoint http://localhost:3000 --email analyst@company.com

# Non-interactive (CI/CD)
vkit login --endpoint https://vaultkit.company.com --email bot@company.com --password $BOT_PASSWORD

vkit whoami

Display current user information.

vkit whoami [--format json|table]

Examples:

vkit whoami
vkit whoami --format json

vkit logout

End session and clear credentials.

vkit logout

Data Request Commands

vkit request

Submit a governed data request using AQL.

vkit request --aql <AQL_JSON> [OPTIONS]

Options:

  • --aql β€” AQL JSON payload (inline or via STDIN)
  • --env β€” Environment (default: production)
  • --requester_region β€” Your geographic region (e.g., US, EU)
  • --dataset_region β€” Dataset's geographic region
  • --requester_clearance β€” Clearance level: low, high, admin
  • --format β€” Output format: json, table (default: table)

Inline AQL:

vkit request \
  --aql '{"source_table":"customers","columns":["email","total_spend"],"limit":100}' \
  --requester_region EU \
  --dataset_region EU \
  --requester_clearance high

AQL via STDIN:

cat query.json | vkit request

# Or
echo '{"source_table":"orders","columns":["order_id","total"]}' | vkit request

AQL from File:

vkit request --aql "$(cat queries/customer_analysis.json)"

Possible Outcomes:

Outcome Description Next Step
βœ… Granted Immediate access vkit fetch --grant <GRANT_ID>
⏳ Queued Requires approval Wait for approval, check with vkit requests list
❌ Denied Policy disallows Review policy restrictions

vkit requests list

View your request history.

vkit requests list [--state STATE] [--format FORMAT]

Options:

  • --state β€” Filter by state: all, pending, approved, denied (default: all)
  • --format β€” Output format: json, table (default: table)
  • --limit β€” Number of results (default: 50)

Examples:

# All requests
vkit requests list

# Only pending requests
vkit requests list --state pending

# Approved requests in JSON
vkit requests list --state approved --format json

# Last 100 requests
vkit requests list --limit 100

vkit requests show

Show details for a specific request.

vkit requests show <REQUEST_ID>

Example:

vkit requests show req_20240115_xyz789

Approval Commands

vkit approval:list

List approval requests you are authorized to act on.

vkit approval:list [--state STATE] [--format FORMAT]

Options:

  • --state β€” Filter by state: all, pending, approved, denied (default: pending)
  • --format β€” Output format: json, table (default: table)

Examples:

# Pending approvals
vkit approval:list

# All approvals you've handled
vkit approval:list --state all

# JSON output for scripting
vkit approval:list --format json

vkit approval:approve

Approve a pending request.

vkit approval:approve <REQUEST_ID> [--ttl SECONDS] [--notes "..."]

Options:

  • --ttl β€” Grant lifetime in seconds. Defaults to the policy's TTL, which is also the maximum: a longer value is capped.
  • --notes β€” Approval notes (optional)

When a request needs several approver roles, each role signs off separately. Until the last one has, approve prints the roles still waiting instead of a grant.

Examples:

# Basic approval
vkit approval:approve 42

# With a shorter TTL and notes
vkit approval:approve 42 \
  --ttl 1800 \
  --notes "Approved for Q4 analysis. Limited to aggregate data only."

vkit approval:deny

Deny a pending request.

vkit approval:deny <REQUEST_ID> --reason "..."

Options:

  • --reason β€” Required explanation for denial

Examples:

vkit approval:deny 42 --reason "Insufficient business justification"

vkit approval:deny 42 --reason "Request violates data minimization policy"

Data Fetch Commands

vkit fetch

Fetch data using a previously issued grant.

vkit fetch --grant <GRANT_REF> [--format FORMAT]

Options:

  • --grant, -g β€” Grant reference or ID (required)
  • --format β€” Output format: json, table, csv (default: table)
  • --output, -o β€” Write to file instead of STDOUT

Examples:

# Fetch and display as table
vkit fetch --grant gr_abc123xyz

# Fetch as JSON
vkit fetch --grant gr_abc123xyz --format json

# Fetch and save to CSV
vkit fetch --grant gr_abc123xyz --format csv --output results.csv

# Pipe to jq for processing
vkit fetch --grant gr_abc123xyz --format json | jq '.result.rows[] | select(.revenue > 1000)'

Datasource Management (Admin Only)

vkit datasource add

Register a new datasource.

vkit datasource add --id <ID> --engine <ENGINE> [OPTIONS]

Options:

  • --id β€” Unique datasource identifier (required)
  • --engine β€” Database engine: postgres, mysql, snowflake, bigquery (required)
  • --username β€” Database username
  • --password-prompt β€” Type the password into the terminal (read from /dev/tty, echo off)
  • --password-env VAR_NAME β€” Read the password from an environment variable
  • --password β€” Deprecated: the password ends up in shell history. Still works, with a warning
  • --config β€” JSON configuration (host, port, database, etc.)

Adding an --id that already exists changes nothing and succeeds (already_existed: true under --format json). The control plane can't change a stored credential, so a password given then is not used.

  • --credential-backend β€” Secret backend: vaultkit, vault, aws-secrets

Examples:

PostgreSQL (Built-in credential storage):

vkit datasource add \
  --id production_pg \
  --engine postgres \
  --username vaultkit_ro \
  --password-prompt \
  --config '{
    "host": "db.production.internal",
    "port": 5432,
    "database": "analytics",
    "ssl_mode": "require",
    "connect_timeout": 10
  }'

MySQL:

vkit datasource add \
  --id production_mysql \
  --engine mysql \
  --username app_reader \
  --password-env MYSQL_PASSWORD \
  --config '{
    "host": "mysql.production.internal",
    "port": 3306,
    "database": "ecommerce",
    "ssl_mode": "REQUIRED"
  }'

vkit datasource list

List all registered datasources.

vkit datasource list [--format FORMAT]

Examples:

vkit datasource list
vkit datasource list --format json

vkit datasource get

Get details for a specific datasource.

vkit datasource get <DATASOURCE_ID>

Example:

vkit datasource get production_pg

vkit datasource test

Test connectivity to a datasource.

vkit datasource test <DATASOURCE_ID>

Example:

vkit datasource test production_pg

# Output:
# Testing connection to production_pg...
# βœ“ Connection successful
# Engine: PostgreSQL 15.3
# Latency: 45ms

vkit datasource remove

Remove a datasource (admin only).

vkit datasource remove <DATASOURCE_ID> [--force]

Options:

  • --force β€” Skip confirmation prompt

Example:

vkit datasource remove old_staging_db --force

Schema Discovery Commands

vkit scan

Scan a datasource and detect schema drift.

vkit scan <DATASOURCE_ID> [--mode MODE]

Options:

  • --mode β€” Scan mode: diff, apply (default: diff)
  • --format β€” Output format: json, table (default: table)

Modes:

Mode Description
diff Show changes without applying (safe, read-only)
apply Update baseline registry with discovered schema

Examples:

Discover Changes:

vkit scan production_pg

# Output:
# Scanning datasource: production_pg
# 
# Schema Drift Detected:
# 
# + Dataset: customers
#     + Field: phone_number (varchar) [PII] ⚠️  NEW - requires policy
#     ~ Field: email (text β†’ varchar) [PII] βœ“ Already masked
# 
# + Dataset: user_sessions
#     + Field: ip_address (inet) [PII] ⚠️  NEW - requires policy
#     + Field: user_agent (text) [INTERNAL] ⚠️  NEW - requires policy
# 
# Summary: 2 new datasets, 3 new fields, 1 modified field

Classifier Suggestions:

A rescan keeps the labels people reviewed (from a deployed bundle or a manual edit). When the classifier disagrees with one of them, the scan lists it as a suggestion under its dataset, marked ?. Suggestions are not changes: they don't count toward the changed total, and applying the scan leaves them alone.

vkit scan production_pg

# Output:
#   settings                 βœ“
#     ? key_value  low/internal β†’ high/credential (suggested)
#
#   No changes detected
#
#   ? = classifier suggestion, not applied. To accept one, edit
#     datasets/registry.yaml and redeploy the bundle.

To accept a suggestion, change the field's sensitivity and tags in datasets/registry.yaml, then build and deploy the bundle. Control planes that predate suggestions don't send them, and the output is unchanged.

Unreviewed Columns:

Columns the classifier couldn't place keep the unknown sensitivity until someone reviews them. The starter pack (2.1.0 and later) masks them for agents, so the scan lists them under their dataset, marked !, and counts them:

vkit scan production_pg

# Output:
#   customers                βœ“
#     ! unreviewed: notes, meta
#
#   No changes detected
#
#   ⚠️  2 columns are unreviewed and masked until you review them
#      (for agents, under the starter pack). To review, set each one's sensitivity
#      in datasets/registry.yaml, then run: vkit policy bundle && vkit policy deploy

Older control planes don't send unreviewed columns, and the output is unchanged.

Apply Changes:

vkit scan production_pg --mode apply

# Output:
# βœ“ Baseline registry updated
# Next steps:
#   1. Review new fields: customers.phone_number, user_sessions.ip_address
#   2. Update policies in Git: config/policies/
#   3. Build new bundle: vkit policy bundle
#   4. Deploy bundle: vkit policy deploy

Scan All Datasources:

for ds in $(vkit datasource list --format json | jq -r '.result.datasources[].name'); do
  echo "Scanning $ds..."
  vkit scan $ds
done

Policy Management Commands

vkit init

Creates a policy project: config/policies/, datasets/ and .vkit/, with the starter pack (or the packs in --with). If the folder isn't inside a git repository, it runs git init and says so; --no-git skips that. It never commits.

The generated .gitignore ignores dist/ and everything in .vkit/ except .vkit/packs.yaml, the record of installed packs. Commit packs.yaml: vkit policy bundle checks the packs against it, and a clone without it can't.

vkit init --dir policies --with starter,ai_safety
cd policies && git add -A && git commit -m "Add VaultKit policies"

vkit policy bundle

Compiles the policies and registry into a deployable bundle, after checking every policy can match and every installed pack is complete.

vkit policy bundle [--policies_dir config/policies] [--registry_dir datasets] \
  [--out dist/policy_bundle.json] [--org ORG] [--version LABEL] [--allow-dirty]

Options:

  • --policies_dir β€” Policies directory (default: config/policies)
  • --registry_dir β€” Registry directory (default: datasets)
  • --out β€” Output bundle file (default: dist/policy_bundle.json)
  • --org β€” Must match the organization you're signed in to
  • --version β€” Name the bundle, such as v1.2. By default the bundle is named by its git commit. Either way, source.commit_sha is the commit from git, and is left out outside a git repository.
  • --allow-dirty β€” Bundle uncommitted changes anyway. It prints a warning, and the bundle records source.dirty: true.

Versions come from git. A bundle's version is the commit its policies are in, so a deployed bundle can be traced to exactly those files. So vkit policy bundle refuses, writing nothing, when:

Code When Fix
bundle_not_committed Anything under the policies or registry directory, or .vkit/packs.yaml, differs from the last commit: modified, staged, new, deleted, or ignored by .gitignore git add -A -- config/policies datasets .vkit/packs.yaml && git commit, or --allow-dirty
bundle_not_versioned There's no git repository (or no commit yet) and no --version git init, add and commit, or pass --version
❌ These files aren't committed, so the bundle's version wouldn't match its policies:
   config/policies/30_payments_require_approval.yaml
   Code: bundle_not_committed
   Fix:
     git add -A -- config/policies datasets .vkit/packs.yaml
     git commit -m "Update VaultKit policies"
     or bundle anyway, recorded as dirty: vkit policy bundle --allow-dirty

Projects created by older versions of vkit init ignore all of .vkit/, so .vkit/packs.yaml shows as ignored. Add it with git add -f .vkit/packs.yaml, and in .gitignore replace .vkit/ with .vkit/* and !.vkit/packs.yaml.

Example:

git add -A && git commit -m "Mask emails for analysts"
vkit policy bundle && vkit policy deploy

vkit policy validate

Validate a policy bundle without deploying.

vkit policy validate --bundle <BUNDLE_FILE>

Example:

vkit policy validate --bundle dist/policy_bundle.json

# Output:
# Validating policy bundle...
# βœ“ Schema validation passed
# βœ“ Policy syntax valid
# βœ“ No circular dependencies
# βœ“ All datasources referenced
# Bundle is valid and ready to deploy

vkit policy deploy

Deploy a policy bundle to the control plane.

vkit policy deploy --bundle <BUNDLE_FILE> [OPTIONS]

Options:

  • --bundle β€” Path to bundle file (required)
  • --org β€” Organization identifier (optional, defaults to logged-in user's org)
  • --activate β€” Immediately activate bundle
  • --format β€” human (default) or json. Both include a warning for each approval group nobody is in, whose requests org admins approve until someone is added.
  • --dry-run β€” Validate deployment without activating

Examples:

# Deploy and activate (using logged-in user's org)
vkit policy deploy \
  --bundle dist/policy_bundle.json \
  --activate

# Deploy with explicit org
vkit policy deploy \
  --bundle dist/policy_bundle.json \
  --org acme \
  --activate

# Dry run (test deployment)
vkit policy deploy \
  --bundle dist/policy_bundle.json \
  --dry-run

vkit policy list

List active policy bundles.

vkit policy list

vkit policy show

Show details of a specific policy.

vkit policy show <POLICY_ID>

Agent Token Commands (Admin Only)

Agents (an MCP server, a scheduled job, a coding assistant) authenticate with an agent token instead of a login. An agent is every token with the same --name; the console's Agents page groups them that way.

vkit agents tokens create

vkit agents tokens create --name NAME [OPTIONS]

Options:

  • --name β€” The agent's name (e.g. incident-bot); tokens with the same name are one agent
  • --label β€” What this token is for, shown next to it in the console (e.g. "PagerDuty runner")
  • --for β€” Email of the person the agent acts for. Their Activity shows the agent's requests, so a member can follow what an agent does on their behalf. Must be an active member of your organization. Without it the agent acts for no one, and only admins see its requests.
  • --expires-in β€” Lifetime: 1h, 24h, 30d (default: no expiry)
  • --role, --clearance, --region, --tenant β€” What policies see for this token

The token is printed once; store it straight away. The console never shows it.

vkit agents tokens create --name incident-bot --label "PagerDuty runner" \
  --for sam@acme.test --expires-in 30d

--for names who the agent acts for. It's separate from who created the token (you), which the console shows as "Created by".

vkit agents tokens list

vkit agents tokens list [--agent NAME] [--format table|json]

vkit agents tokens revoke

vkit agents tokens revoke --token PREFIX_OR_ID --reason "Leaked in CI logs"

--reason is required and recorded in the audit log. The token stops working at once: its live grants are revoked, and a request already in flight with it gets no rows.

--for needs a control plane with the console's Agents page; an older one ignores it, and the token acts for no one. That control plane also refuses a revoke without a reason, so older CLI versions can't revoke against it.

Audit Log

There's no vkit audit command. Every request, decision and revoke is in the audit log; read it in the console:

  • Activity lists every request: who asked, what was decided and why, and what ran. Filter by decision, agent, person, dataset or time, and open one by the request ID that vkit request prints.
  • Export CSV on the Activity page downloads the filtered view.
  • A refused request, for example one made with a revoked agent token, prints its code and request ID too:
# API 401: Agent token vkit_agent_f5f5d9 was revoked at 2026-11-04T19:55:11Z: Leaked in CI logs
# Code: token_revoked
# Request ID: 7973fcba-… (look it up under Activity in the console)

πŸ”¬ Advanced Usage

Scripting with vkit

Batch Request Processing:

#!/bin/bash
# process_requests.sh

REQUESTS=(
  '{"source_table":"customers","columns":["id","email"],"limit":100}'
  '{"source_table":"orders","columns":["order_id","total"],"limit":100}'
  '{"source_table":"products","columns":["product_id","name"],"limit":100}'
)

for aql in "${REQUESTS[@]}"; do
  echo "Processing: $aql"
  vkit request --aql "$aql" --format json | jq -r '.result.grant_ref // empty' >> grants.txt
done

echo "Generated grants:"
cat grants.txt

Automated Approvals (for testing):

#!/bin/bash
# auto_approve_pending.sh

PENDING=$(vkit approval:list --state pending --format json)

echo "$PENDING" | jq -r '.result.approvals[].id' | while read -r request_id; do
  echo "Approving request: $request_id"
  vkit approval:approve "$request_id" --ttl 3600 --notes "Auto-approved for testing"
done

Integration with CI/CD

GitHub Actions Example:

name: Deploy VaultKit Policies

on:
  push:
    branches: [main]
    paths:
      - 'config/policies/**'
      - 'config/registry.yaml'

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Install vkit CLI
        run: gem install vaultkitcli
      
      - name: Authenticate
        run: |
          vkit login \
            --endpoint ${{ secrets.VKIT_API_URL }} \
            --email ${{ secrets.VKIT_BOT_EMAIL }} \
            --password ${{ secrets.VKIT_BOT_PASSWORD }}
      
      - name: Build Policy Bundle
        run: |
          vkit policy bundle \
            --policies_dir config/policies \
            --registry_dir config \
            --out policy_bundle.json \
            --org ${{ secrets.ORG_ID }}
      
      - name: Validate Bundle
        run: vkit policy validate --bundle policy_bundle.json
      
      - name: Deploy Bundle
        run: |
          vkit policy deploy \
            --bundle policy_bundle.json \
            --org ${{ secrets.ORG_ID }} \
            --activate

Using jq for Advanced Filtering

Extract specific fields:

vkit requests list --format json | jq '.result.requests[] | select(.state == "approved") | {id, dataset, requester}'

Count requests by state:

vkit requests list --format json | jq '.result.requests | group_by(.state) | map({state: .[0].state, count: length})'

Find high-value transactions:

vkit fetch --grant gr_abc123 --format json | jq '.result.rows[] | select(.amount > 10000)'

πŸ› Troubleshooting

Common Issues

Authentication Failed

Problem:

Error: Authentication failed (401 Unauthorized)

Solutions:

# 1. Check endpoint
echo $VKIT_API_URL

# 2. Re-authenticate
vkit logout
vkit login --endpoint http://localhost:3000 --email you@company.com

# 3. Verify credentials
vkit whoami

Connection Refused

Problem:

Error: Connection refused - connect(2) for "localhost" port 3000

Solutions:

# 1. Check if control plane is running
curl http://localhost:3000/health

# 2. Verify Docker containers
cd infra
docker compose ps

# 3. Start services
docker compose up

Grant Expired

Problem:

API 403: Grant expired

Solutions:

# 1. Request new grant
vkit request --aql '{"source_table":"customers",...}'

# 2. Request longer TTL (if approval required)
vkit request --aql '{...}' --ttl 7200

Policy Denial

Problem:

❌ Request denied
Reason: Cross-region PII access forbidden
Policy: gdpr_protection

Solutions:

  1. Review policy restrictions
  2. Request approval if available
  3. Modify query to exclude restricted fields
  4. Contact admin to update policies

Debug Mode

Enable verbose logging:

# Set debug environment variable
export VKIT_DEBUG=true

# Run command
vkit request --aql '{...}'

# Output includes:
# - HTTP request/response details
# - Policy evaluation trace
# - Timing information

Health Check

Verify CLI and control plane connectivity:

# Check CLI version
vkit --version

# Check control plane health
curl $VKIT_API_URL/health

# Test authentication
vkit whoami

🀝 Contributing

We welcome contributions to the VaultKit CLI!

Development Setup

# Clone repository
git clone https://github.com/yourorg/vaultkit-cli.git
cd vaultkit-cli

# Install dependencies
bundle install

# Run tests
bundle exec rspec

# Run CLI locally
bundle exec bin/vkit --help

Running Tests

# Unit tests
bundle exec rspec spec/unit

# Integration tests (requires running control plane)
bundle exec rspec spec/integration

# All tests
bundle exec rspec

Code Style

# Run RuboCop
bundle exec rubocop

# Auto-fix issues
bundle exec rubocop -a

πŸ“š Additional Resources


πŸ“„ License

VaultKit CLI is licensed under the Apache License 2.0. See LICENSE for details.


Built with ❀️ by the VaultKit team