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
cchpwith 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#
Homebrew (macOS / Linux)
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:
brew install cch-hq/tap/cchpTo upgrade later:
brew update && brew upgrade cchpInstall script (macOS / Linux)
Download the latest release archive for macOS or Linux (amd64 or arm64), verify its SHA-256 digest against checksums.txt, and install cchp into ~/.local/bin:
curl -fsSL https://raw.githubusercontent.com/CCH-HQ/cchp-cli/main/install.sh | shYou can pin a release or change the destination directory with environment variables:
curl -fsSL https://raw.githubusercontent.com/CCH-HQ/cchp-cli/main/install.sh | \
CCHP_VERSION=v0.2.0 CCHP_INSTALL_DIR=/usr/local/bin shRe-run the script to upgrade to the latest release. Make sure ~/.local/bin (or your CCHP_INSTALL_DIR) is on your PATH.
Go & manual download
Every release on GitHub Releases includes prebuilt archives for Linux, macOS, and Windows (amd64 and arm64) along with a checksums.txt file:
sha256sum --ignore-missing -c checksums.txtOr build from source with Go 1.27 or newer:
go install github.com/CCH-HQ/cchp-cli/cmd/cchp@latestVerify the installation#
cchp --version
cchp versioncchp --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#
cchp login
cchp status
cchp whoami
cchp logoutcchp loginprompts for your server address and management token (hidden as you type), verifies the token with the server, and stores it securely. Plainhttp://is permitted only for loopback addresses (localhost,127.0.0.1,::1); remote servers requirehttps://.cchp statusconfirms which server you are signed in to and verifies that the token works (--offlinereads local state only).cchp logoutdeletes 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:
# 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 --jsonEach 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:
CCHP_TOKENorCCHP_TOKEN_FILE(must be paired withCCHP_BASE_URL).- Saved credential matching
CCHP_BASE_URL. - Saved credential for the most recently signed-in (
current) server.
Configuration files and environment variables#
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.kindand 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):
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 indata.- Automatic redaction: Across
--dry-run,--debug, error messages, and response traces,cchpmasksAuthorizationheaders, 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, and5xx. Mutations are never retried automatically; if a change receives no clear answer (unknown_outcome, exit code12), check server state first and reuse the returnedidempotency_keyvia--idempotency-keyif retrying. Actions requiring a browser session (browser_session_required) or human verification (human_verification_required, exit code8) 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:
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).cchpvalidates the body against the schema locally before sending and preservesnull,false,0, and""verbatim. orgIddefaults 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 Nfor streams (agent mode defaults to 20), and--timeout(default60s) to bound execution time. - Install the embedded agent skill for Claude Code or print an
AGENTS.mdsnippet:
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 snippetCommon 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>.
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#
# 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 --jsonReading 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#
Examples#
# 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 Nreturns between1and50matches (default10).--read-top Nembeds the full Markdown of the topNunique pages directly on each page’s first result so an agent can answer and citeurlin one round trip. CJK queries do not require spaces between words. - Language selection: Supports
zh-CN,zh-TW,en,ja,ko, andru.cchpresolves 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 readreturnsnot_foundand lists the languages that have it. - Caching and preview sites:
llms.txt, pages, andllms-full.txtare cached under<CCHP_CACHE_DIR>/docsfor up to 5 minutes (within server cache headers), then revalidated viaETagandLast-Modified—stale cached content is never served if the site fails. Search results are never cached. Pass--no-cacheto bypass the cache,--docs-url(orCCHP_DOCS_URL) to read from a local preview such ashttp://127.0.0.1:8787(plainhttp://is loopback-only), and--dry-runor--debugto inspect requests.