Headless CLI: ccd

ccd is a terminal client for CCD. It has an interactive prompt and a headless print mode (ccd -p) for scripts and CI. It is one Python file that uses only the standard library and needs Python 3.9 or newer.

Install and configure

mkdir -p ~/bin
curl -fsSL https://ccd.dendat.ai/cli/ccd.py -o ~/bin/ccd
chmod +x ~/bin/ccd

Create a key in the Developer portal, then either export two variables:

export CCD_URL=https://ccd.dendat.ai
export CCD_API_KEY=ccd_live_...

or put them in ~/.ccd/config (one KEY=VALUE per line; environment variables win over the file):

CCD_URL=https://ccd.dendat.ai
CCD_API_KEY=ccd_live_...

CCD_URL defaults to http://localhost:7750, which is right for a self-hosted install. The key is sent in the X-API-Key header.

Interactive use

cd ~/work/my-project
ccd                     # open a prompt for the project
ccd "fix the failing test"   # same, with a first message

Inside the prompt:

Command Does
/help Shows this list
/session Prints the current session id
/clear Starts a new session
/model <id> Sets the model for later messages (empty means auto)
/mode <mode> Sets the permission mode
/exit or /quit Leaves. Ctrl-D also works.

Ctrl-C during a run stops that run. Interactive mode needs a terminal; in a pipe or CI use -p.

ccd -p "summarize what changed in the last 5 commits"

# piped input is appended to the prompt
git diff | ccd -p "review this diff for bugs"

# machine-readable output
ccd -p --output-format json "count the TODO comments"

Options

Option Meaning
-p, --print Print the answer and exit.
--output-format text\|json\|stream-json Default text.
-c, --continue Continue the last session used in this directory.
-r ID, --resume ID Resume a session by id.
--model ID Model for the run. Default is automatic selection.
--allowedTools "A,B" Abort the run if the agent calls any tool not in the list. Use CCD tool names such as read_file,grep,exec.
--max-turns N Abort after N tool calls.
--permission-mode MODE default, plan, acceptEdits or bypassPermissions.
--project ID\|NAME Choose a CCD project explicitly instead of matching the current directory.

acceptEdits and bypassPermissions both send auto-approve for the run. They do not override deny rules (see Permission rules). plan makes the run read-only and stops at the proposed plan.

In print mode, questions the agent would normally ask you are answered automatically with "Proceed with your best judgment. Do not ask further questions."

Output formats

text prints the final answer.

json prints one object:

{"type":"result","subtype":"success","is_error":false,"result":"...","session_id":"...","op_id":"...","num_turns":4,"duration_ms":18234}

stream-json prints one JSON event per line as the run progresses (starting with {"type":"system","subtype":"init",...}), then the same final result object.

Exit codes

Code Meaning
0 Success
1 The run failed, or a disallowed tool was called
2 Usage, config or authentication problem
3 --max-turns was reached
130 Interrupted

On an error with --output-format json, the object has "is_error": true and an error string.

Which project does it use?

ccd lists your projects and picks the one whose workspace path contains the current directory. If none matches it stops with exit code 2. Use --project with the project id or name to be explicit, which is the usual choice for projects that live on a dedicated node.

Session continuation is remembered per directory in ~/.ccd/state.json.

CI example

- name: AI review
  run: |
    git diff origin/main...HEAD | ccd -p --project my-app \
      --permission-mode plan --output-format json "review this diff" > review.json
  env:
    CCD_URL: https://ccd.dendat.ai
    CCD_API_KEY: ${{ secrets.CCD_API_KEY }}

Store the key as a CI secret, never in the repository. Use a read-only key if you only need to read results; runs need a read and write key.

Legacy helpers

ccd . or ccd <dir> opens the project in the browser. ccd --list, --scan, --missing and --init are older project helpers.