Skip to content
CCHPCCHPDocs
↑↓↵pagefind

Chapter 079 min read

CLI (cchp)

Install and use cchp, the official command-line tool for managing CCHP servers, automating control-plane workflows safely, and reading or searching the CCHP documentation from your terminal or AI coding agents.

cchp is the official command-line tool for CCHP (Claude Code Hub Plus). It serves both interactive operators and automated workflows from a single binary:

  • Interactive terminal UI: Run cchp with no arguments in a terminal to open a home screen with a usage dashboard and 365-day activity heatmap, wallet and package status, upstream providers, provider keys, LLM tokens, recent requests, and built-in guides.
  • Automation and AI agents: Run any CCHP control-plane operation that accepts a management token behind a single, predictable JSON contract (--json), with offline command and JSON Schema discovery, strict read-only-by-default safety gates, secret redaction, and an embedded Claude Code skill.
  • Documentation lookup (cchp docs): Read and search the public CCHP documentation in all six languages directly from the terminal—no sign-in required.

If you have not deployed a CCHP server yet, start with Installation. You can still use cchp docs before setting up a server.

Install#

Install from CCH-HQ’s official tap on macOS or Linux (Apple Silicon/ARM64 and Intel/AMD64). Homebrew installs the release binary and sets up Bash, Zsh, and Fish completions automatically:

bash
brew install cch-hq/tap/cchp

To upgrade later:

bash
brew update && brew upgrade cchp

Verify the installation#

bash
cchp --version
cchp version

cchp --version prints the CLI version. cchp version also displays the pinned CCHP control-plane spec version and build metadata (pass --json for structured output).

To configure shell completions manually (outside Homebrew), run cchp completion bash, cchp completion zsh, or cchp completion fish.

Configuration and authentication#

cchp authenticates with a CCHP management API token (cch_auth_live_...). Create one in the console under Account & Security → Management API tokens (see Create a management token).

cchp does not accept LLM keys (cch_llm_live_...). LLM keys are only for calling models through the gateway—see Create an LLM key. For security, cchp never accepts a token as a command-line argument.

Interactive sign-in#

bash
cchp login
cchp status
cchp whoami
cchp logout
  • cchp login prompts for your server address and management token (hidden as you type), verifies the token with the server, and stores it securely. Plain http:// is permitted only for loopback addresses (localhost, 127.0.0.1, ::1); remote servers require https://.
  • cchp status confirms which server you are signed in to and verifies that the token works (--offline reads local state only).
  • cchp logout deletes the saved credential for the current server on your machine. To revoke the token itself, revoke it in the console.

Scripts, CI, and multiple servers#

For non-interactive workflows, provide the token through stdin, a private file (chmod 600), or an environment variable:

bash
# Option 1: save a sign-in non-interactively
printf '%s' "$TOKEN" | cchp login --server https://hub.example.com --token-stdin --json
# or read from a file:
cchp login --server https://hub.example.com --token-file ~/.config/cchp/token --json
 
# Option 2: supply credentials per run without saving
export CCHP_BASE_URL=https://hub.example.com
export CCHP_TOKEN_FILE=~/.config/cchp/token    # mode 600; refused if group/world-readable
# or: export CCHP_TOKEN=...                    # do not set both CCHP_TOKEN and CCHP_TOKEN_FILE
cchp status --json

Each signed-in server is stored as a separate origin entry in config.json. To target a different saved server, set CCHP_BASE_URL to that server’s URL; cchp binds every token strictly to its server origin and drops credentials on cross-origin redirects.

Credential resolution order:

  1. CCHP_TOKEN or CCHP_TOKEN_FILE (must be paired with CCHP_BASE_URL).
  2. Saved credential matching CCHP_BASE_URL.
  3. Saved credential for the most recently signed-in (current) server.

Configuration files and environment variables#

Variable / PathPurposeDefault
CCHP_BASE_URLTarget CCHP server origin (selects saved server or pairs with token env vars)Current signed-in server
CCHP_TOKENManagement token passed via environment—
CCHP_TOKEN_FILEPath to a mode-600 file containing the management token—
CCHP_CREDENTIAL_STOREForce credential backend: keychain or fileSystem keychain (falls back to mode-600 credentials.json)
CCHP_CONFIG_DIRDirectory for config.json and fallback credentials.json~/.config/cchp (Linux), ~/Library/Application Support/cchp (macOS), %AppData%\cchp (Windows)
CCHP_CACHE_DIRDirectory for the embedded engine cache and docs/ cacheUser cache dir (cchp/)
CCHP_AGENTSet to 1 to force agent mode (JSON output, non-interactive, read-only by default)Auto-enabled with --json or non-TTY stdout
NO_COLORDisable ANSI colors in terminal outputUnset

Safety model and automation#

Agent mode activates automatically when you pass --json, set CCHP_AGENT=1, or pipe stdout to another process. In agent mode, cchp:

  • prints exactly one JSON result object to stdout (schema_version, ok, operation, status, request_id, data, pagination, error, and related metadata);
  • writes diagnostics to stderr and exits nonzero with a stable error.kind and exit code on failure;
  • never opens interactive prompts, pagers, or colored output.

Read-only by default and write gates#

Every CCHP operation is classified by risk in cchp’s embedded policy (unclassified operations default to write):

Risk levelBehavior in agent modeRequired flags
readAllowed by defaultNone
writeBlocked unless explicitly enabled--allow-write
destructive (delete / replace)Requires explicit confirmation of the operation ID--allow-write --confirm <operationId>
One-time secret responsePrevents secrets from leaking to stdout or logs--allow-write --confirm <operationId> --secret-out <new-file>

In an interactive terminal, human mode runs writes directly and prompts for confirmation on destructive or secret-producing operations. Without a terminal, --confirm <operationId> is always required.

Dry-run, secret handling, and redaction#

  • --dry-run: Builds and validates the request locally and prints the exact HTTP method, URL, headers, and body without sending anything or needing credentials.
  • --secret-out <new-file>: Writes one-time secrets (such as newly created LLM keys or management tokens) to a brand-new mode-600 file (refusing to overwrite existing files) and replaces the secret fields with placeholders in data.
  • Automatic redaction: Across --dry-run, --debug, error messages, and response traces, cchp masks Authorization headers, cookies, CSRF tokens, human-check proofs, CCHP tokens (keeping only the public prefix), and credential-like JSON fields (password, api_key, clientSecret, plaintext, and similar keys) at any depth.
  • Safe retries and console-only boundaries: Reads retry automatically on transient network errors, 408, 429, and 5xx. Mutations are never retried automatically; if a change receives no clear answer (unknown_outcome, exit code 12), check server state first and reuse the returned idempotency_key via --idempotency-key if retrying. Actions requiring a browser session (browser_session_required) or human verification (human_verification_required, exit code 8) stop cleanly and tell you to complete them in the console.

Offline discovery, schema checks, and agent skills#

Agents can discover operations and inspect their exact parameters and JSON Schemas offline using the spec built into cchp, then call any operation through the stable cchp api <operationId> entry point:

bash
cchp commands --search "provider keys" --json          # find matching operations offline
cchp commands show listProviderKeyPage --json          # flags, risk level, and examples
cchp schema listProviderKeyPage --json                 # parameter and JSON Schema details
cchp api listProviderKeyPage --provider-id <id> --json # stable entry point for scripts
  • Pass JSON request bodies via --body-file body.json (or --body-file - for stdin). cchp validates the body against the schema locally before sending and preserves null, false, 0, and "" verbatim.
  • orgId defaults to your management token’s organization.
  • List commands support --cursor / --page, or multi-page collection with --page-limit N --max-items M. Use --output <file> (- for stdout) for binary downloads, --max-events N for streams (agent mode defaults to 20), and --timeout (default 60s) to bound execution time.
  • Install the embedded agent skill for Claude Code or print an AGENTS.md snippet:
bash
cchp skill install --project      # installs to .claude/skills/cchp
cchp skill install --user         # installs to ~/.claude/skills/cchp
cchp skill show --agents-md       # prints an AGENTS.md snippet

Common commands#

Run cchp --help to list every command group, cchp <group> --help for commands in a group, or cchp guide for built-in short guides. All grouped commands execute the exact same engine and policy layer as cchp api <operationId>.

GroupWhat it coversExample commands
accountIdentity, permissions, preferences, announcementscchp account me, cchp account permissions
orgOrganization info, members, teams, roles, invitations, audit logscchp org show, cchp org members, cchp org teams, cchp org audit
providersUpstream providers, endpoints, groups, network proxies, health checkscchp providers list, cchp providers counts, cchp providers set-network-proxies
keysUpstream provider keys, balances, health checks, model synccchp keys list, cchp keys balance, cchp keys check
modelsModel catalog, aliases, pricing, price-table synccchp models catalog, cchp models list, cchp models pricing
llm-tokensGateway LLM keys for members and applicationscchp llm-tokens list, cchp llm-tokens create
tokensManagement API tokenscchp tokens list, cchp tokens create, cchp tokens revoke
usageUsage summaries, trends, breakdowns by model/provider/team, live metricscchp usage summary, cchp usage by-model, cchp usage by-provider
requestsRequest logs, attempt history, archived payloadscchp requests list, cchp requests get
billingWallet overview, invoices, plans, quota policies, adjustmentscchp billing wallet, cchp billing quota-policies, cchp billing create-quota-policy
adminPlatform-wide system info, organizations, users, domains, audit logscchp admin about, cchp admin orgs, cchp admin users, cchp admin audit-logs

Additional specialized groups include safety (moderation, privacy, client and error rules), overrides (request/response rewrite rules), operations (announcements, redeem codes, billing adjustments), config (configuration drafts and rollout experiments), plugins, tasks, import (including cchp import run for CC Hub imports), and public (unauthenticated health and status endpoints).

Everyday examples#

bash
# Inspect usage, providers, keys, and recent requests
cchp usage summary
cchp providers list
cchp keys list --provider-id <provider-id>
cchp requests list --limit 20
cchp requests get <request-id>
 
# Preview a write safely with --dry-run before applying it in agent mode
cchp billing create-quota-policy --body-file policy.json --dry-run --json
cchp billing create-quota-policy --body-file policy.json --allow-write --json
 
# Destructive replacement: requires both --allow-write and --confirm <operationId>
cchp providers set-network-proxies <provider-id> \
  --body-file proxies.json --allow-write --confirm saveProviderNetworkProxies --json

Reading and searching docs via CLI (cchp docs)#

cchp docs reads the official CCHP documentation at https://cch-plus.com through its llms.txt endpoints (/<lang>/llms.txt, /<lang>/llms-full.txt, and per-page /<lang>/docs/<slug>.md) and the site’s full-text search API (/api/docs/search).

cchp docs accesses public documentation only. It requires no sign-in, never reads saved credentials, and its HTTP transport refuses any request carrying Authorization, Proxy-Authorization, or Cookie headers. It is also read-only, so AI agents can call it without --allow-write.

Subcommands#

CommandEndpoint readOutput
cchp docs index/<lang>/llms.txtComplete table of contents grouped by section (title, slug, URL, description)
cchp docs read <slug|url>/<lang>/docs/<slug>.mdOne documentation page as Markdown (rendered on a terminal, raw Markdown when piped, or JSON with --json)
cchp docs search <words>.../api/docs/searchRanked section matches with title, section, slug, URL, snippet, and relevance score
cchp docs full/<lang>/llms-full.txtAll documentation pages for a language combined into one Markdown document

Examples#

bash
# Search and fetch the top matching page's full Markdown in a single call (ideal for AI agents)
cchp docs search "docker compose" --lang en --read-top 1 --json
cchp docs search "network proxy" --limit 5 --read-top 2 --json
 
# Read a specific page by slug, path, or cch-plus.com URL
cchp docs read installation/docker-compose
cchp docs read providers/network-proxies --lang en --json
 
# Browse the full index or export every page in one Markdown file
cchp docs index --lang en
cchp docs full --lang en > cchp-docs-en.md
  • Search flags: --limit N returns between 1 and 50 matches (default 10). --read-top N embeds the full Markdown of the top N unique pages directly on each page’s first result so an agent can answer and cite url in one round trip. CJK queries do not require spaces between words.
  • Language selection: Supports zh-CN, zh-TW, en, ja, ko, and ru. cchp resolves the language in order: --lang → CCHP_DOCS_LANG → system locale (LC_ALL, LC_MESSAGES, LANG) → en. If a page is missing in the chosen language, cchp docs read returns not_found and lists the languages that have it.
  • Caching and preview sites: llms.txt, pages, and llms-full.txt are cached under <CCHP_CACHE_DIR>/docs for up to 5 minutes (within server cache headers), then revalidated via ETag and Last-Modified—stale cached content is never served if the site fails. Search results are never cached. Pass --no-cache to bypass the cache, --docs-url (or CCHP_DOCS_URL) to read from a local preview such as http://127.0.0.1:8787 (plain http:// is loopback-only), and --dry-run or --debug to inspect requests.