Documentation

CLI reference

countersign is one program. It is the engine, the operator's tool, the offline verifier, the agent hook, the MCP gateway, for servers on the same machine and for servers reached over HTTP, and the verdict endpoint a vendor asks before its agent's tools run.

countersign <command> [flags]

Running countersign with no command, or with help, -h or --help, prints the list of commands.

Flags can be written with one dash or two: -n 30 and --n 30 are the same. Durations are written like 24h, 90m or 720h.

Commands that talk to a workspace read ~/.countersign/config.json. If there is none, they stop with no tenant configured here, run countersign init first. countersign start also creates that file.

A machine that was connected from the console with connect has no such file: it holds an agent's credential, and the workspace is in the console. There those commands say so, name the workspace's address and the agent, and point to the console's Activity page. doctor, stop, listen, spool and update work on such a machine.

Start here

start

Sets up recording for your coding agents: a workspace, a signing key, and for each agent a passport and a hook. See the Quickstart.

It connects every agent it finds on the machine: Claude Code, Codex, Gemini CLI, Cursor, Grok CLI, Hermes Agent and OpenClaw. An agent counts as found when its settings folder exists or its program is on the PATH. OpenClaw counts when ~/.openclaw/openclaw.json exists or openclaw is on the PATH, because other tools keep skills in ~/.openclaw on machines that have never had it. Someone who only uses Codex gets a Codex hook and nothing else. If it finds none, it lists the seven and asks which one you use. Enter cancels. With --yes and none found, it sets up Claude Code and says so.

No answer is never taken as a yes. If the terminal closes before you answer, nothing is changed. Each agent gets its own credential, so the ledger shows which agent did what.

AgentFileCredential
Claude Code~/.claude/settings.jsonclaude-code
Codex~/.codex/hooks.jsoncodex
Gemini CLI~/.gemini/settings.jsongemini-cli
Cursor~/.cursor/hooks.jsoncursor
Grok CLI~/.grok/hooks/countersign.json, a file of the hook's owngrok-cli
Hermes Agent~/.hermes/config.yaml, in a section of the hook's own at the endhermes
OpenClaw~/.countersign/openclaw-plugin/hooks.json, beside a plugin that is then installed in OpenClawopenclaw

More than one account of an agent. A second account of an agent keeps settings of its own, and a hook in one account's file is not run by a session of the other. start, connect, stop and doctor therefore work on every account they find, whichever one the command is run from. All of an agent's accounts share that agent's credential.

AgentThe variable that moves its settingsOther accounts looked for
Claude CodeCLAUDE_CONFIG_DIRfolders in your home directory named .claude-NAME that hold .claude.json or .credentials.json
CodexCODEX_HOMEfolders named .codex-NAME that hold auth.json or config.toml
Gemini CLIGEMINI_CLI_HOME (the folder its .gemini goes in)folders named .gemini-NAME that hold a .gemini folder
Cursornone: it has one hooks filenone
Grok CLIGROK_HOMEfolders named .grok-NAME that hold auth.json or config.toml
Hermes AgentHERMES_HOMEeach profile's config.yaml under profiles, and folders named .hermes-NAME that hold config.yaml

An account kept in a folder with another name, or outside your home directory, is found only when the command runs in a shell where the variable points at it. An account added later needs start or connect run again; doctor says when one account of an agent has the hook and another does not. Run with Claude Code and Codex. The Gemini CLI, Grok CLI and Hermes Agent parts follow their documentation and have not been run.

The Claude Code, Codex, Gemini CLI, Cursor, Grok CLI and Hermes Agent hooks have been run in live sessions. Grok runs a hook only in a folder you have trusted, and Codex only once you have reviewed it in Codex (/hooks): start says so when it adds one. Hermes runs no hook it has not approved and its desktop app never asks, so start and connect approve the hook in Hermes's own list, ~/.hermes/shell-hooks-allowlist.json. The OpenClaw plugin has been run with OpenClaw 2026.11.12 in real agent turns; start and connect install it with openclaw plugins install when OpenClaw's program is on the PATH, and print that command when it is not. Both say what they did, and before start asks to continue it says it will do it. Copilot CLI keeps its hooks in each repository, so start does not add one. See Connect an agent.

countersign start [flags]
FlagDefaultMeaning
--hostedoffKeep the ledger on the hosted service instead of this machine.
--server URLthis machine, or the hosted service with --hostedThe engine to use.
--agents LISTevery agent foundThe agents to connect, separated by commas: claude, codex, gemini, cursor, grok, hermes, openclaw.
--agent NAMEclaude-codeThe name for the Claude Code credential.
--settings PATH~/.claude/settings.jsonThe Claude Code settings file to add the hook to.
--no-hookoffSet up the workspace and leave every agent's settings alone.
--no-statuslineoffDo not add the status line.
--yesoffDo not ask before changing the settings files.

Before the first change to a file it saves a copy as FILE.before-countersign. If a file is not valid JSON, or holds its hooks in a form start does not know, that file is left alone and the other agents are still connected.

Running start again on a machine that is already set up re-adds any hook that is missing and records one more action. It does not create a second workspace. Run it again after installing another agent to connect that one too.

The summary ends with a list of what to run next. When countersign is not on your PATH, which is how the install script leaves it, each command in the list is written with its full path, so it works as printed, and the line that adds it to your PATH comes last.

After the list start says that the workspace it made has no sign-in: it can be read in a browser with open, and nobody can sign in to it, join it or approve from another browser. It names the address where a workspace with a sign-in is made. What is recorded in one does not carry over to the other.

With --hosted, start prints one more line before it asks: "By creating a workspace you agree to the Terms and the Privacy notice", with the address of each. The workspace it makes has no account and no email address. It records straight away. To publish a receipt from it, give it an address with email.

stop

Removes the Countersign hook from every agent start can connect, and the status line from Claude Code. The ledger and keys stay in ~/.countersign.

countersign stop [--settings PATH]
FlagDefaultMeaning
--settings PATH~/.claude/settings.jsonThe Claude Code settings file to remove the hook from.

log

Shows recent actions.

countersign log [-f] [-n 30] [--all]
FlagDefaultMeaning
-n N30How many recent entries to read.
-foffKeep printing new entries as they happen.
--alloffInclude passports, policy changes and outcome reports as well as actions.

digest

Summarises what happened, with flagged actions first.

countersign digest [--since 24h]
FlagDefaultMeaning
--since DURATION24hHow far back to look.

guard

Blocks destructive commands, or goes back to recording only. See Guard.

countersign guard on
countersign guard off
countersign guard status

guard with no argument is the same as guard status. It has no flags.

On a machine whose agents were connected from the console, guard on and guard off change only whether those agents are stopped by the workspace's rules or just recorded. They change no rule, and need no signing key.

listen

Has the coding agents on this machine listen for your decision on an action that was held, and run it again once you approve. See Approvals.

countersign listen 1h
countersign listen off
countersign listen

The window is a length of time from 1m to 24h, such as 1h, 6h, 12h or 24h. It starts when an action is held. off goes back to a held action waiting for you to tell the agent to try again. With no argument it shows what each agent is set to.

FlagDefaultMeaning
--dir PATHAlso set the hooks in that project's folder. Copilot CLI keeps its hook there.

listen changes the Countersign hook in every agent settings file it finds: your user settings, every account of an agent, and the folder you run it in. It adds a hook on the event each agent fires when a turn ends, with a time limit of the window and one minute more, and puts the window on the hook's other entries. Hooks from other tools are left alone. countersign stop takes it out with the rest. Restart the agent afterwards.

It needs no signing key. An agent in recording-only mode is never held, so it has nothing to listen for.

open

Opens the ledger in your browser with a link that works once, for five minutes. It has no flags.

countersign open

share

Publishes one receipt as a public link, lists what you have published, or takes one down. See Evidence and offline verification.

countersign share NUMBER [--to URL] [--yes]
countersign share --list
countersign share --revoke ID

NUMBER is the receipt number from countersign log. A leading # is accepted.

FlagDefaultMeaning
--listoffList the receipts you have published from this machine.
--revoke IDTake a published receipt down, by its id.
--to URLhttps://app.trycountersign.aiWhere to publish a receipt from a workspace on this machine.
--yesoffDo not ask for confirmation.

Before it asks, share shows what will be public and says that publishing means you agree to the Terms and the Privacy notice. On the hosted service a workspace must have a confirmed email address before it can publish. A workspace made in the console confirms the owner's address. One made from the command line uses email.

Operator commands

These are for the owner: the person who holds the workspace's signing key.

init

Creates a workspace and an owner key on an engine, and saves them in ~/.countersign/config.json. It also activates the starting policy. It does not install a hook. Use start for a coding agent on your own machine.

countersign init --server URL --name NAME [--email EMAIL]
FlagDefaultMeaning
--server URLhttp://localhost:4950The engine's address.
--name NAMEThe organisation name. Required by the engine.
--email EMAILA contact email. It does not create a console account. The hosted service mails it a link to confirm it.

init refuses to run when the machine already has a workspace configured.

email

Sets the email address of a workspace that was made from the command line. Such a workspace has no account, so this is where the hosted service reaches its owner.

countersign email ADDRESS

The hosted service mails the address a link that works once, for 24 hours. Until the link is followed the workspace records and decides as normal, and it cannot publish a receipt, connect alerts or change plan. Run the command again for a new link, or to change the address.

A workspace made in the console takes its address from the owner's account, and this command is refused for it. A workspace on your own machine needs no address.

plan

Shows the workspace's plan and this month's count, and changes the plan and the action packs. It is for a workspace on the hosted service, or on an engine someone runs for a team. A workspace kept on your own machine has no plan.

countersign plan                 # the plan, the packs held and this month's count
countersign plan pro             # move to Pro. Prints the page to pay on. Nothing changes until it is paid there
countersign plan team            # move to Team, the same way. From Pro, the subscription you have changes price and no page is needed
countersign plan free            # move to Free. With a paid subscription, prints the billing page to cancel on
countersign plan packs 2         # hold two action packs. Each added pack is charged at once to the subscription's card
countersign plan billing         # the address of the billing page: card, invoices, cancelling

Every form but the first signs the request with the workspace's signing key, so it only works on the machine that holds that key. The API key by itself cannot change what is paid for. In the console the owner does the same on the Plan page.

workspace

countersign workspace delete
countersign workspace restore

delete deletes this workspace on the server: its ledger, its passports and its settings. It shows the workspace's name and how many entries it holds, and asks you to type the name. The workspace is closed at once: its agents are no longer recorded and a paid subscription is cancelled with no refund. It is removed for good seven days later. restore undoes the deletion any time in those seven days. Packs you exported earlier still verify. Both requests are signed with the workspace's signing key. The API key by itself can do neither. See Delete a workspace.

For a workspace kept on your own machine, run countersign stop and delete the ~/.countersign folder.

agent

Manages passports.

countersign agent add --name NAME [flags]
countersign agent list
countersign agent amend NAME_OR_ID [flags]
countersign agent revoke NAME_OR_ID [--reason TEXT]

agent add issues a passport, creates the agent's key and writes the credential to ~/.countersign/agents/NAME.json.

FlagDefaultMeaning
--name NAMErequiredThe agent's name.
--tools LIST*Comma-separated tool patterns the agent may ask for.
--escalate LISTComma-separated tool patterns that always need a human.
--cap N0The per-action cost cap, in minor units.
--escalate-over N0The cost above which a human must approve, in minor units.
--budget N0The total budget, in minor units.
--currency CODEUSDThe currency for the money limits.
--ttl DURATION720hHow long the passport lasts.
--legal-basis TEXTA reference to the agreement or policy this delegation sits under.
--owner TEXTThe business owner: the person or team who answers for the agent.
--tier TIERThe risk tier: low, medium, high or critical.
--ans-cert FILEThe agent's ANS identity certificate (PEM). Binds the passport to its ANS name.
--ans-key FILEThe agent's ANS identity key (PEM). The agent signs with it instead of a new key. Needs --ans-cert.
countersign agent add --name coder --tools 'Read,Edit,Bash,mcp__github__*' --escalate 'Bash' --ttl 2160h

agent list prints each passport's agent name, id, state (active, expired or REVOKED) and tools.

agent amend changes an active passport. The agent keeps its key and credential.

FlagDefaultMeaning
--add-tools LISTTool patterns to add.
--remove-tools LISTTool patterns to remove.
--add-escalate LISTTool patterns that should need a human from now on.
--remove-escalate LISTTool patterns that no longer need a human.
--ttl DURATION0A new lifetime counted from now. 0 keeps the current expiry.

agent revoke revokes a passport. Every later ask under it is refused and the refusal is recorded.

FlagDefaultMeaning
--reason TEXTrevoked by principalWhy. Recorded in the ledger.

policy

Shows the active policy, or signs and activates a new one. See Policy.

countersign policy
countersign policy set FILE

It has no flags.

fleet

Manages rollouts for many machines. See Fleet rollout and Coverage.

countersign fleet add --name NAME [flags]
countersign fleet list
countersign fleet close ENROLMENT_ID

fleet add signs the terms and prints the enrolment id and token.

FlagDefaultMeaning
--name NAMErequiredThe rollout's name.
--tools LIST*Tool patterns each machine may use.
--escalate LISTTool patterns that always need a human.
--days N90How long each machine's passport lasts, in days.
--max N50How many machines may enrol. 0 means no limit.
--open DURATION720hHow long enrolment stays open.
--legal-basis TEXTThe agreement or policy this delegation sits under.
--owner TEXTThe business owner written into every passport issued under the rollout.
--tier TIERThe risk tier written into every passport issued under the rollout.

fleet list shows each rollout with its state: open (a new machine can join), full (the machine limit is reached), ended (the closing date has passed) or CLOSED (someone closed it).

ans

Turns Agent Name Service support on or off for the workspace, or shows where it stands. See Agent Name Service support.

countersign ans on
countersign ans off
countersign ans status

ans with no argument is the same as ans status. It has no flags.

pending

Lists held actions that are waiting for a human. It has no flags.

countersign pending

approve

Approves one held action. See Approvals.

countersign approve REQUEST_ID [--note TEXT]
FlagDefaultMeaning
--note TEXTWhy this was approved. Recorded with the approval.

decline

Declines one held action. It is closed for good: it cannot be approved later, and the agent's retry is refused.

countersign decline REQUEST_ID [--note TEXT]
FlagDefaultMeaning
--note TEXTWhy this was declined. Signed and recorded with the decline.

controls

Prints the Controls report, lists the actions picked for review, or records a finding.

countersign controls [--days 30] [--json] [--csv FILE]
countersign controls sample [--days 30] [--n 25]
countersign controls review REQUEST_ID pass|breach [--note TEXT] [--days 30]
FlagDefaultMeaning
--days N30How many days back the report or the sample covers.
--jsonPrint the report as JSON.
--csv FILEAlso write every decision in the period to FILE, one row each.
--n N25How many actions to pick for review.
--note TEXTWhat you found. Signed and recorded with the finding.

export

Writes the evidence pack to a file.

countersign export [-o FILE]
FlagDefaultMeaning
-o FILEcountersign-pack.cborThe output file.

status

Prints a summary of the workspace as JSON: its id, name, signer, engine key (decision_pub), owner key (principal_pub), number of entries, counts by entry kind, policy version and hash, and the ANS setting. It has no flags.

countersign status

Keeping up to date

See Updating for the whole process.

version

Prints the build, the platform and where the program is, then says whether a newer build is available.

countersign version [--offline] [--from URL]

update

Fetches the newest build, checks it against its published SHA-256 and replaces this program.

countersign update [--check] [--from URL] [--force]
FlagDefaultMeaning
--checkSay whether there is a newer build and change nothing.
--from URLwhere it was installed fromFetch from this address. Must be https, unless it is this machine.
--forceInstall the build on offer even when it is not newer.

Anyone

verify

Re-verifies an evidence pack offline. It needs no workspace and no network. See Evidence and offline verification.

countersign verify PACK [--pin ENGINE_KEY] [--ans-roots FILE]

Put the file first and the flags after it.

FlagDefaultMeaning
--pin HEXThe engine key you recorded out of band, as hex.
--ans-roots FILEAn ANS authority bundle (PEM). Also checks each ANS-bound passport's certificate chain.

verify exits with status 1 when the pack fails, or when --ans-roots is given and a certificate chain fails.

Agent commands

ask

Makes one signed ask and prints the engine's answer.

countersign ask --agent NAME --tool TOOL [flags]
FlagDefaultMeaning
--agent NAMErequiredThe agent's name or the path to its credential file.
--tool TOOLThe tool name.
--target TEXTWhat the action touches.
--args TEXTThe action's arguments. They are hashed on this machine and never sent.
--attr KEY=VALUEA fact exposed to policy. Repeat the flag for more than one.
--cost N0The cost in minor units.
--currency CODEUSDThe currency, used when a cost is set.
--parent REQUEST_IDThe request id of the approved held action this re-attempts.

ask exits with status 3 when the answer is anything other than allow.

wait

Waits until a person has decided one held action, and says what they decided. See Approvals.

countersign wait REQUEST_ID --agent NAME [--for 1h]
FlagDefaultMeaning
--agent NAMErequiredThe agent's name or the path to its credential file. The request must be one this agent asked for.
--for WINDOW1hHow long to wait: 1m to 24h.

It asks as the agent, so it needs no signing key and no API key. Nothing is recorded. It exits 0 when the request is approved, 3 when it is declined and 4 when the time runs out with nothing decided.

hook

The before-and-after tool hook for Claude Code, Codex, Gemini CLI, Cursor, Grok CLI, Hermes Agent, Copilot CLI, and OpenClaw through the plugin this tool writes. It reads the tool call as JSON on standard input. See Connect an agent.

The same command handles the agent's prompt event (UserPromptSubmit, BeforeAgent, beforeSubmitPrompt). There it looks for keys and tokens in the prompt and reports only the kind. See Secret exposure alerts.

With --wait it also handles the event at the end of a turn (Stop, AfterAgent, stop, agentStop). There it listens for a person's decision on an action the session had held. See Approvals.

countersign hook --agent NAME [flags]
FlagDefaultMeaning
--agent NAMEdeviceThe agent's name or the path to its credential file.
--format DIALECTdetectedThe hook dialect: claude, codex, gemini, cursor, grok, hermes, openclaw or copilot.
--event pre|post|failure|stopFor dialects whose payload does not say which. Used for Copilot CLI.
--wait WINDOWHow long to listen, when a turn ends, for a decision on a held action: 1m to 24h. Written by countersign listen and connect --wait.
--fail closed|openclosedWhat to do when the engine cannot be reached.
--mode monitor|enforcethe credential's own settingmonitor records, and no rule blocks. A revoked passport still stops the tool. enforce blocks.
--facts full|minimalfullWhat policy may read. full: the command, path or URL. minimal: the kind of action and the program name only. Both report the kind of any key or token seen.

When no credential exists for --agent and the machine has a fleet enrolment token, the hook enrols the machine on its first tool call.

statusline

Prints one line for the agent's status bar. It reads the session as JSON on standard input, as Claude Code provides it. It never starts the engine. It has no flags.

countersign statusline

The line reads, for example, ● rec 12 · 1 flagged · 1 blocked · guard on · #340: the session's actions on the record, how many a risk rule names, how many a rule stopped, whether any agent on this machine has the guard on, and the receipt number of the newest. A + after the count means the session may have more than the engine looked back for (its newest 2,000 entries).

It asks the engine for those numbers only (GET /v1/events/counts). It prints the same line again for five seconds without asking, so a status bar that refreshes often costs one request every five seconds for each session. It waits 400 ms for an engine on this machine and 1.5 seconds for the hosted service, and says ○ countersign: not recording when there is no answer in that time. The last line for each session is kept in ~/.countersign/statusline.json.

connect

Connects one agent with a setup token from the Integrations page: makes the agent's key on this machine, issues its passport under the terms signed into the token, and adds the hook.

countersign connect AGENT --token TOKEN [--name NAME] [--dir PATH] [--out FILE] [--fail open|closed] [--wait 1h]

AGENT is claude, codex, gemini, cursor, grok, hermes, openclaw or copilot, or sdk to issue the passport and write the credential with no hook.

FlagDefaultMeaning
--token TOKENCOUNTERSIGN_SETUP_TOKENThe setup token. It works once and for 15 minutes.
--name NAMEthe name signed into the tokenThe agent's name on the passport.
--dir PATHyour user settingsPut the hook in that project instead. Copilot CLI keeps hooks in each repository, so it always uses a project: the current folder unless you pass this.
--out FILE~/.countersign/agents/NAME.jsonWhere to write the credential. An existing file is never written over.
--fail open|closedas chosen in the consoleWhat the agent does when Countersign cannot be reached. open: it carries on, and what it did is recorded afterwards as late. closed: it is stopped. A token for one agent means open unless the owner ticked the box in the console. A rollout token means closed.
--wait WINDOWHow long the agent listens for your decision on an action that was held: 1m to 24h. Without it a held action waits for you to tell the agent to try again. countersign listen changes it later.

The settings file is read before the token is spent. If it cannot be read, nothing is changed and the token still works. Hooks from other tools are kept, an older Countersign hook is replaced, and the file as it was is saved once as <file>.before-countersign. The hook fails closed. If the name is already taken on this machine the credential is saved as NAME-2.json.

If the service cannot be reached, nothing is issued and the token is as good as it was: run the same line again inside its 15 minutes. Only an answer from the service that says no, such as a token that was already used, means a new one is needed.

connect ends with the one step that agent still needs. Claude Code, Gemini CLI and Grok CLI need a restart. Cursor needs nothing. Codex skips the hook until you choose "Trust all and continue" at "Hooks need review" in its terminal app, and codex exec never asks. Copilot CLI runs hooks only in a folder it trusts. Hermes Agent and OpenClaw need nothing more from you: the command gets them to accept the hook, and says so under NOT READY when it could not.

The install script passes its arguments to the CLI, so one line installs and connects:

curl -fsSL https://app.trycountersign.ai/install.sh | sh -s -- connect codex --token TOKEN

doctor

Checks what is connected on this machine.

countersign doctor [--agent NAME] [--no-ask] [--fix]

It looks for the Countersign hook in each coding agent's settings (your user settings and the current folder), checks that the program and the credential each hook names are there, that credential files are readable only by you, and that the engine answers. For each credential a hook uses it sends one test action, which is recorded in the ledger and counts as one action. --no-ask skips that. --agent NAME checks one credential and sends its test action whether or not a hook uses it.

For Hermes Agent and OpenClaw it also checks that the agent will run the hook at all: that Hermes has approved it (its entries are in shell-hooks-allowlist.json beside config.yaml) and that OpenClaw has been told to load the plugin (it is in ~/.openclaw/openclaw.json). Either agent skips a hook it has not accepted without a word. --fix puts that right: it approves the hook in Hermes's list, or installs the plugin with OpenClaw's own command, and says what it did. Without --fix, doctor changes nothing.

For a hook that is in place and has never asked, it says what that agent is waiting for. For Codex it reads Codex's own list of trusted hooks (config.toml in Codex's home folder). When that holds no record for the hook, Codex is skipping it, and doctor says to open Codex and choose "Trust all and continue". A record is not proof that the hook as it now stands is trusted: Codex asks again when the hook's text or its place in the file changes.

For Codex it goes further than that, for each of the hook's three events. With no record and a hook that has never asked, doctor fails: Codex is skipping it. A record of another form of the hook is noted, and so is a hook with no record that has asked before, which happens only when Codex is run with --dangerously-bypass-hook-trust. A hook switched off in Codex is a failure. For Grok CLI it reads Grok's own record of trusted folders (trusted_folders.toml in Grok's home folder) and notes when the folder you run it in is not one Grok trusts, which is where a session runs no hook of yours. Neither is put right by --fix: Codex takes trust from inside Codex only, and trusting a folder in Grok covers everything in it.

It exits 1 when a check fails. A hook before a tool call that is missing, a hook that names a credential that is not there, a passport the engine refuses, a hook that Hermes Agent or OpenClaw will not run, and a hook Codex is skipping or has switched off are failures.

enroll

Gives this machine its own passport under a fleet rollout.

countersign enroll [--token TOKEN] [--name NAME]
FlagDefaultMeaning
--token TOKENthe one installed on this machineThe enrolment token.
--name NAMEdeviceThe credential name to save under.

mcp

Runs the gateway in front of an MCP server that talks over stdio. See Connect an agent.

countersign mcp --agent NAME [flags] -- <server command>
FlagDefaultMeaning
--agent NAMErequiredThe agent's name or the path to its credential file.
--name NAMEfrom the commandThe server name used in tool names.
--fail closed|openclosedWhat to do when the engine cannot be reached.
--wait WINDOWHow long a held call waits at the gateway for a person's decision: 1m to 24h. Approved in that time, the call goes to the server. The agent's own time limit for a tool call still applies.

gateway

Runs the gateway in front of an MCP server reached over HTTP. See Connect an agent.

countersign gateway --agent NAME --upstream https://server.example/mcp [flags]
FlagDefaultMeaning
--agent NAMErequiredThe agent's name or the path to its credential file.
--upstream URLrequiredThe address of the MCP server.
--addr ADDR127.0.0.1:8787The address to listen on.
--path PATH/mcpThe path agents connect to.
--name NAMEfrom the upstream addressThe server name used in tool names.
--fail closed|openclosedWhat to do when the engine cannot be reached.
--platform NAMEThe agent platform that uses this gateway, shown on the Integrations page.
--wait WINDOWHow long a held call waits at the gateway for a person's decision: 1m to 24h. Leave it out for a platform with a short time limit on tool calls.
--tls-cert FILE, --tls-key FILEServe HTTPS with this certificate and key.

GET /healthz answers ok for a load balancer's health check.

verdict

Runs the address a vendor calls before its agent's tools run, and answers allow or deny. It speaks xAI's Inference Hooks, for Grok Bot. See Connect an agent.

COUNTERSIGN_VERDICT_SECRET=whsec_... countersign verdict --agent NAME [flags]
FlagDefaultMeaning
--agent NAMErequiredThe agent's name or the path to its credential file.
--addr ADDR127.0.0.1:8788The address to listen on.
--path PATH/verdictThe path the vendor posts to.
--fail closed|openclosedWhat to answer when the engine cannot be reached: deny or allow.
--mode monitor|enforcethe credential's ownmonitor records every call and always answers allow.
--platform NAMEgrok-botThe agent platform that calls this endpoint, shown on the Integrations page.
--timeout TIME4sHow long the engine has to answer before --fail applies: 500ms to 10s.
--tls-cert FILE, --tls-key FILEServe HTTPS with this certificate and key.

It does not start without the vendor's signing secret in COUNTERSIGN_VERDICT_SECRET. GET /healthz answers ok for a load balancer's health check.

claude

Prints the Claude Code settings snippet for an agent whose credential is on this machine.

countersign claude --agent NAME
FlagDefaultMeaning
--agent NAMErequiredThe agent's name.

Server commands

These are for running your own engine.

serve

Runs the engine and serves the console.

countersign serve [--addr :4950] [--data ./data] [--dist ./dist] [--idle DURATION]
FlagDefaultMeaning
--addr ADDRESS:4950The listen address.
--data DIR./dataThe data directory. It holds the SQLite database and the engine's root seed.
--dist DIR./distA directory of CLI builds to serve at /dl.
--idle DURATION0Exit after this long with no requests. 0 means never.

check

Replays every ledger in the store through the verifier's code and reports how many workspaces and entries it read. Run it after restoring a backup. It checks every entry of every ledger in full and reads no checkpoint (see Concepts). It leaves a fresh checkpoint for each ledger it has checked.

countersign check [--data ./data]
FlagDefaultMeaning
--data DIR./dataThe data directory. Ignored when DATABASE_URL is set.

countersign spool

Hands in the tool calls that ran while the engine could not be reached. The hook runs this by itself once the engine answers again, so you rarely need to.

countersign spool [--agent NAME] [--list]
FlagDefaultMeaning
--agent NAMEevery agent on this machineHand in for this credential only.
--listoffSay how many calls are waiting, and send nothing.

The calls are kept under ~/.countersign/spool/NAME/, one file each, signed by the agent when they ran. See Guard.

countersign migrate

Brings the database's schema up to date and checks the root seed against it. Starting the engine does the same when it finds the schema behind. Run this by hand before a deploy that changes the schema, so that no request waits for it.

countersign migrate [--data ./data]

Several copies may run it at once: one does the work and the others find it done. An engine started with a root seed other than the one the database was made with stops at once and says so.

countersign upkeep

Does one round of the work that belongs to no request: it sends alerts and email that are waiting and, once a day, removes expired sessions and workspaces that were made and never used. On the hosted service the host calls GET /v1/cron/tick every minute for the same thing. On a server you run yourself, run this from cron.

countersign upkeep [--data ./data]

countersign funnel

Prints how many workspaces reached each step of setting up in the last days: signed up, saved the recovery kit, signed a connect command, ran it, first real action, first rule switched on, a second person. Then the choices made on the connect screen (which door, which tab). Each step is counted once for a workspace, when it first happens. It is the operator's command: it reads the database directly.

countersign funnel [--data ./data] [--days 7] [--json]

The percentage beside a step is of the sign-ups in the same window, so in a short window it can pass 100: a workspace that signed up last week and connected today is in today's count for the later step only.

countersign takedown

Removes a published receipt from the service and deletes what was published. It is the operator's command: it works on the database directly and needs no workspace's say.

countersign takedown [--data ./data] RECEIPT_ID

RECEIPT_ID is the last part of the page's address, after /r/. The whole address also works.

countersign release

Starts the release of an email address from an account whose password and recovery code are both lost. It is the operator's command and works on the database directly.

countersign release [--data ./data] EMAIL

It mails the address a link that works once, for 7 days. Nothing changes until the link is followed, so only someone who can read that inbox can release the address. Following it removes the account, ends its sessions and, if the account owns a workspace with a subscription, cancels the subscription. The workspace's ledger is kept. See If you have neither the password nor the code.

countersign remove

Deletes a whole workspace, for good. It is the operator's command and works on the database directly. It is for a workspace nobody can sign in to delete, such as one whose owner's account was released.

countersign remove [--data ./data] WORKSPACE_ID NAME

NAME is the workspace's exact name, the same check the console makes before deleting. The ledger, every account, every passport and every published receipt go. If the workspace has a subscription it is cancelled first, which needs STRIPE_SECRET_KEY to be set. Without it the command refuses and changes nothing.

countersign mail trial

Puts one of every customer email, filled with made-up values, in the queue for one address. It is the operator's command, for checking how the mail arrives and reads.

countersign mail trial [--data ./data] ADDRESS

The service sends them within a minute, if customer mail is on there.

Environment variables

Read by the CLI

VariableMeaning
COUNTERSIGN_HOMEThe folder for configuration, credentials and the local engine's data. Default: ~/.countersign.
COUNTERSIGN_LOCAL_ADDRThe address of the engine on this machine. Default: 127.0.0.1:4951.
COUNTERSIGN_NO_AUTOSTARTWhen set, the CLI does not start the local engine by itself.
COUNTERSIGN_UPDATE_URLWhere countersign update and countersign version look for a newer build.
COUNTERSIGN_ENROLL_TOKENA fleet enrolment token. Checked before the token files.
COUNTERSIGN_SETUP_TOKENRead by connect when --token is not given.
COUNTERSIGN_GATEWAY_KEYRead by gateway. When set, callers must send the same value in the X-Countersign-Key header.
COUNTERSIGN_VERDICT_SECRETRead by verdict. The signing secret the vendor shows when the endpoint is first saved. It starts whsec_. Every request is checked against it.

Read by the engine

VariableMeaning
DATABASE_URLA Postgres database to use in place of the SQLite file in the data directory.
COUNTERSIGN_ROOT_SEEDThe engine's root seed, as 64 hex characters. Required when DATABASE_URL is set. Each workspace's engine key is derived from it.
COUNTERSIGN_ANS_ROOTSThe path of a PEM file of ANS authorities.
COUNTERSIGN_ANS_LOGSA comma-separated list of Transparency Log hosts whose badges are believed.
COUNTERSIGN_ANS_DNSA DNS server (host:port) to ask for _ans-badge records in place of the system's.
STRIPE_SECRET_KEYA Stripe API key. With a price for a paid plan it turns on card checkout: that plan is then a paid subscription. Without both, a plan change applies at once with no charge. On the hosted service a missing setting is logged at start, and a paid change is refused: nothing is given away.
STRIPE_PRICE_PROThe id of the Stripe price for the Pro plan, a monthly price.
STRIPE_PRICE_TEAMThe id of the Stripe price for the Team plan, a monthly price.
STRIPE_PRICE_PACK_PROThe id of the Stripe price for one action pack on Pro, a monthly price. With it, a Pro workspace can add packs to its subscription from the plan page. Without it, packs cannot be bought there when card checkout is on.
STRIPE_PRICE_PACK_TEAMThe same for one action pack on Team. Before build 2026.11.29.2 this was STRIPE_PRICE_PACK, which is no longer read.
STRIPE_WEBHOOK_SECRETThe signing secret of the Stripe webhook endpoint that points at /v1/stripe/webhook. Without it webhooks are refused.
SLACK_CLIENT_IDThe client id of a Slack app whose one permission is incoming-webhook and whose redirect address is <console address>/v1/slack/callback. With SLACK_CLIENT_SECRET it turns on Add to Slack in Settings. Without both, Slack alerts are set up by pasting an incoming-webhook address. A manifest for the app is in tools/slack-app-manifest.yaml.
SLACK_CLIENT_SECRETThe client secret of the same Slack app.
SLACK_SIGNING_SECRETThe signing secret of the same Slack app. With it set, approval alerts carry buttons and an owner can switch on approving from Slack. The app's Interactivity request address must be <console address>/v1/slack/actions. Without it, alerts are plain text with a link.
COUNTERSIGN_PUBLIC_URLThe address people reach the console at, used for links back from Stripe and from Slack, and for links in email. For Stripe and Slack it defaults to the address of the request.
RESEND_API_KEYA Resend API key. With COUNTERSIGN_CUSTOMER_MAIL it turns on customer email. The mail is sent from trycountersign.ai addresses, so this is for the hosted service.
COUNTERSIGN_CUSTOMER_MAILSet to on to send customer email and to ask new accounts to confirm their address. Without it an account counts as confirmed when it is made and nothing is mailed.
RESEND_WEBHOOK_SECRETThe signing secret of the Resend webhook that points at /v1/mail/inbound. Without it that route refuses every call.
COUNTERSIGN_FORWARD_TOWhere mail written to support@, security@, privacy@ and abuse@ is forwarded.
COUNTERSIGN_ANS_ALLOW_HTTPSet to 1 to accept badge addresses over plain HTTP. For a log on localhost.
COUNTERSIGN_RATE_LIMITSet to off to switch rate limits off.
COUNTERSIGN_FULL_REPLAYSet to 1 to make the engine check every entry of a ledger each time it loads it, and never load from a checkpoint. Slower on a long ledger.
COUNTERSIGN_SIGNUP_CEILINGThe most workspaces the service makes in an hour, from all callers together. Default: 200.
COUNTERSIGN_EXPIRE_EMPTY_DAYSHow old a workspace that was never used is when it is removed. Default: 30. 0 turns the clear-out off.
COUNTERSIGN_DB_TIMEOUT_MSThe longest one database statement may take, in milliseconds. Default: 8000. A ledger is read 5,000 entries to a statement, so this does not limit how large a ledger can be loaded.
COUNTERSIGN_MEMORY_ENTRIESFor an engine on a shared database (DATABASE_URL): how many ledger entries, over all workspaces, one copy of the engine holds in memory before it lets go of the workspaces it used longest ago. Default: 200000, which is about 400 to 550 MB. A workspace that was let go is loaded again when it is next asked for. A single workspace is held whole, however large. An engine with a database of its own lets nothing go.
CRON_SECRETThe value a caller of GET /v1/cron/tick must send as a bearer token. Vercel sends it by itself when it is set as an environment variable. Without it the route does not exist.
COUNTERSIGN_TRUST_PROXYSet to 1 to take the caller's address from a proxy's headers. Set it only when a proxy is always in front.
COUNTERSIGN_WEB_DIRServe the console from this folder in place of the built-in copy. For development.

Keep the root seed safe and separate from database backups. Without it the ledgers still verify, and the engine cannot sign new decisions for those workspaces.

Exit status

StatusMeaning
0Success.
1An error. Also a failed verify.
2No command was given.
3ask received an answer other than allow. wait: the request was declined.
4wait: the time ran out and nobody had decided.