CLI Reference

CLI Reference

The agentsec CLI manages configuration, agents, roles, and migrations.

YAML-based Commands

These commands work with agentsec.yaml and are the primary interface for v0.1.

agentsec init

Initialize AgentSec by parsing config and generating per-agent API keys and .env files.

agentsec init [--config agentsec.yaml] [--proxy-url http://localhost:3100] [--output .]
FlagDefaultDescription
-c, --config./agentsec.yamlPath to config file
--proxy-urlhttp://localhost:3100Proxy URL to include in agent .env files
-o, --output.Output directory for generated .env files

Generates one .env file per agent with AGENTSEC_KEY and AGENTSEC_PROXY_URL, and prints the corresponding AGENTSEC_AGENT_KEY_* env vars to set on the proxy side.

agentsec add

Add a new service/credential to the config file. Runs interactively if --name is omitted.

# Interactive
agentsec add
 
# Non-interactive
agentsec add --name slack --description "Slack API" --auth api-key --api-base https://slack.com/api
FlagDefaultDescription
-c, --config./agentsec.yamlPath to config file
--name(interactive)Service name
--description(interactive)Service description
--auth(interactive)Auth type: api-key, oauth2, oauth1, custom
--api-base(interactive)API base URL or sidecar URL
--relative-targetfalseTarget is a relative path (for protocol translators)

Auth type mapping:

Auth typeConnectorDefault api_base
api-keydirectuser-provided
oauth2sidecarhttp://oauth2-refresher:8081
oauth1sidecarhttp://oauth-signer:8080
customsidecaruser-provided

agentsec status

Check proxy health and print config summary.

agentsec status [--config agentsec.yaml] [--proxy-url http://localhost:3100]

agentsec logs

Display formatted audit log entries.

agentsec logs [--log-file ./audit.jsonl] [--tail 20]
FlagDefaultDescription
-l, --log-file./audit.jsonlPath to audit log
-t, --tail20Number of recent entries (0 = all)

agentsec test

Validate config syntax and check that all agent credential references exist.

agentsec test [--config agentsec.yaml]

SQLite-backed Commands

These commands manage agents, roles, and credentials via SQLite with encrypted storage. They support RBAC (role-based access control) where an agent’s effective permissions are the union of its roles’ credentials and its direct credential assignments.

All SQLite commands require --encryption-key (or set AGENTSEC_ENCRYPTION_KEY env var) and --db (default ./agentsec.db).

agentsec agent

agentsec agent list
agentsec agent create --name my-agent [--description "..."] [--roles reader,writer] [--credentials slack] [--rate-limit 100]
agentsec agent show <name>
agentsec agent enable <name>
agentsec agent disable <name>
agentsec agent delete <name>
SubcommandDescription
listList all agents with status
createCreate a new agent (generates API key, prints it once)
showShow agent details and effective permissions (roles + direct credentials)
enableRe-enable a disabled agent
disableDisable an agent (blocks all requests)
deleteDelete an agent

agentsec role

agentsec role list
agentsec role create --name reader [--description "Read-only access"] [--credentials slack,github] [--rate-limit 50]
agentsec role add-credential <role> <credential>
agentsec role remove-credential <role> <credential>
agentsec role delete <name>
SubcommandDescription
listList all roles
createCreate a role with optional credentials and rate limit
add-credentialGrant a credential to a role
remove-credentialRevoke a credential from a role
deleteDelete a role (cascading — removes from agents)

agentsec migrate

Import an existing agentsec.yaml into SQLite. Credential values are read from AGENTSEC_CRED_* env vars and stored encrypted (AES-256-GCM).

agentsec migrate --config agentsec.yaml --db agentsec.db --encryption-key $AGENTSEC_ENCRYPTION_KEY
FlagDefaultDescription
-c, --config./agentsec.yamlYAML config to import
-d, --db./agentsec.dbSQLite database path (created if missing)
--encryption-key$AGENTSEC_ENCRYPTION_KEY64 hex chars for AES-256-GCM

This creates credentials, agents, and policies in the database. Agents are assigned their credentials directly (no roles created during migration).