agent-auth-cli

作者: better-auth

使用 Agent Auth CLI(auth-agent)來探索提供者、連接代理、管理功能以及執行操作。當使用者想要互動時使用…

npx skills add https://github.com/better-auth/agent-auth --skill agent-auth-cli

Agent Auth CLI

You have access to the auth-agent CLI for interacting with Agent Auth providers. Always prefer using the CLI for any agent authentication operations rather than making raw HTTP requests or writing custom code.

Binary

The CLI binary is auth-agent (package: @auth/agent-cli). If not installed globally, run via npx @auth/agent-cli.

Workflow

Follow this order when working with a provider:

1. Discover or find a provider

# If you have the provider URL
auth-agent discover https://api.example.com

# If you need to search by intent
auth-agent search "deploy web apps"

# List already-known providers
auth-agent providers
  • discover fetches the /.well-known/agent-configuration document and caches the provider.
  • search queries the directory and returns matching providers.
  • Always discover or search first before connecting.

2. Explore capabilities

# List all capabilities for a provider
auth-agent capabilities --provider https://api.example.com

# Filter by query
auth-agent capabilities --provider https://api.example.com --query "transfer"

# Get full definition with input schema
auth-agent describe transfer_money --provider https://api.example.com
  • Always run describe before executing a capability to understand the required input schema and constraints.
  • If connected, pass --agent-id <id> to see which capabilities are granted.

3. Connect an agent

# Basic connection with specific capabilities
auth-agent connect --provider https://api.example.com \
  --capabilities read_data transfer_money \
  --name my-agent

# With constraints on capability arguments
auth-agent connect --provider https://api.example.com \
  --capabilities read_data transfer_money \
  --constraints '{"transfer_money":{"amount":{"max":1000}}}' \
  --name constrained-agent

# Autonomous mode (no user association)
auth-agent connect --provider https://api.example.com \
  --capabilities read_data \
  --mode autonomous

# With CIBA approval (backchannel, sends notification to user)
auth-agent connect --provider https://api.example.com \
  --capabilities read_data \
  --preferred-method ciba \
  --login-hint [email protected]
  • Save the returned agent_id — you need it for all subsequent operations.
  • If approval is required, the CLI opens the browser or prints the approval URL. Pass --no-browser to suppress browser opening.
  • Use --force-new to create a new connection even if one exists.

4. Check status

auth-agent status <agent-id>
  • Shows agent status (pending_approval, active, expired, revoked), granted capabilities, and constraints.
  • Run this after connecting to confirm the agent was approved.

5. Execute capabilities

auth-agent execute <agent-id> transfer_money \
  --args '{"amount": 50, "to": "alice"}'
  • The --args flag takes a JSON string matching the capability's input schema.
  • Always describe the capability first to know the required arguments.

6. Request additional capabilities

auth-agent request <agent-id> \
  --capabilities admin_panel \
  --constraints '{"admin_panel":{"scope":{"in":["read","write"]}}}' \
  --reason "Need admin access for deployment"

7. Lifecycle management

# Disconnect (revoke) an agent
auth-agent disconnect <agent-id>

# Reactivate an expired agent
auth-agent reactivate <agent-id>

# View stored connection details
auth-agent connection <agent-id>

# List all connections for a provider
auth-agent connections <issuer-url>

8. Key rotation

# Rotate an agent's keypair
auth-agent rotate-agent-key <agent-id>

# Rotate the host keypair for a provider
auth-agent rotate-host-key <issuer-url>

9. Host enrollment

auth-agent enroll-host --provider https://api.example.com --token <enrollment-token> --name "My Device"

10. Sign JWTs manually

# Sign an agent JWT (for use with external HTTP calls)
auth-agent sign <agent-id>

# Scope to specific capabilities
auth-agent sign <agent-id> --capabilities transfer_money read_data

Global Flags

FlagEnv varDescription
--storage-dir <path>AGENT_AUTH_STORAGE_DIRStorage directory (default: ~/.agent-auth)
--directory-url <url>AGENT_AUTH_DIRECTORY_URLDirectory URL for provider search
--host-name <name>AGENT_AUTH_HOST_NAMEHost name for identification
--no-browserAGENT_AUTH_NO_BROWSER=1Suppress browser opening for approval URLs
--url <urls...>AGENT_AUTH_URLSProvider URLs to auto-discover at startup

Important Rules

  • Never make raw HTTP requests to Agent Auth endpoints. Always use the CLI.
  • Always discover before connecting. The CLI needs the provider's configuration cached locally.
  • Always describe before executing. Check the input schema so you pass correct arguments.
  • Check status after connecting. The agent may require user approval before it becomes active.
  • Store agent IDs. You need them for execute, status, request, disconnect, and all other operations.
  • Use constraints when connecting to limit what the agent can do — this is a security best practice.
  • Set AGENT_AUTH_ENCRYPTION_KEY in production to encrypt private keys stored in ~/.agent-auth/.

Storage

Connections, keys, and provider configs are stored in ~/.agent-auth/ by default:

  • host.json — host identity and keypair
  • agents/<agent-id>.json — agent connections
  • providers/<encoded-issuer>.json — cached provider configurations

來自 better-auth 的更多技能

agent-auth-mcp
better-auth
使用 Agent Auth MCP 工具來探索提供者、連接代理、管理能力,並透過 MCP 協定執行操作。在處理…時使用。
official
better-icons
better-auth
從超過200個圖示庫中搜尋並擷取SVG,支援CLI與MCP伺服器整合。可跨主要圖示集(Lucide、Material Design Icons、Heroicons、Tabler等200多個)進行搜尋,並依前綴與結果數量篩選。CLI指令支援搜尋圖示、批次下載SVG檔案,以及自訂顏色與尺寸的單一圖示擷取。MCP伺服器工具則為AI代理提供智慧推薦、相似度比對、專案掃描與批次圖示等功能。
official
better-auth-best-practices
better-auth
完整的 Better Auth 伺服器與客戶端設定,包含資料庫適配器、工作階段管理、外掛程式及安全配置。涵蓋從安裝、資料庫遷移、環境變數設定到跨多個框架的路由處理器建立的完整工作流程。支援多種資料庫適配器(Prisma、Drizzle、MongoDB、直接連線),並提供關於模型與資料表命名慣例的重要指引。包含工作階段儲存策略(使用次要儲存如 Redis/KV)、Cookie...
official
create-auth-skill
better-auth
在 TypeScript/JavaScript 應用程式中搭建並實作驗證功能,包含 Better Auth 框架偵測、資料庫適配器設定及 OAuth 整合。透過專案掃描偵測框架(Next.js、SvelteKit、Nuxt、Astro、Express、Hono)、資料庫(Prisma、Drizzle、MongoDB、原生驅動程式)及現有驗證函式庫。支援電子郵件/密碼、OAuth(Google、GitHub、Apple、Microsoft、Discord、Twitter)、魔法連結、通行金鑰及電話驗證,並提供可設定的電子郵件驗證功能...
official
Email & Password Best Practices
better-auth
email-&-password-best-practices — 一個可安裝的AI代理技能,由better-auth/skills發布。
official
email-and-password-best-practices
better-auth
電子郵件驗證、密碼重設流程,以及可自訂的密碼政策,適用於 Better Auth。支援電子郵件驗證,可選擇強制執行,在驗證前封鎖登入,並可設定代幣到期時間與一次性重設代幣。密碼重設流程具備內建安全性:背景寄送電子郵件、防止時序攻擊、對無效請求執行虛擬操作,以及可選擇在重設時撤銷工作階段。可設定密碼長度限制(預設為 8 至 256 個字元)以及自訂...
official
organization-best-practices
better-auth
透過 Better Auth 進行多租戶組織設定,包含成員管理、基於角色的存取控制及團隊支援。可設定組織的自訂建立規則、成員上限與擁有者限制;建立者自動取得擁有者角色。管理成員與邀請,支援電子郵件寄送、有效期限及可分享的邀請連結;每位成員可擁有多個角色。定義自訂角色與權限,實現動態存取控制;檢查權限...
official
two-factor-authentication-best-practices
better-auth
使用TOTP、OTP、備用驗證碼及信任裝置管理,為Better Auth提供多因素驗證。支援三種驗證方式:驗證器應用程式(含QR碼的TOTP)、電子郵件/簡訊驗證碼(OTP),以及一次性備用驗證碼。處理完整的雙因素驗證登入流程,包含自動工作階段管理、臨時雙因素驗證Cookie,以及可設定有效期限的信任裝置追蹤。內建安全功能包括速率限制(每10秒3次請求)以及靜態加密機密資料...
official