# Use CCP from an agent



Set `CCP_HEADLESS=1` in the agent process. Run `ccp capabilities` for the installed executable's capability contract. Read the CCP runbook in the Clusterbase CLI plugin. An agent starting from a fresh checkout needs the organization and App IDs before it can update an existing App.

```bash
set -eu
export CCP_HEADLESS=1
ccp link --org-id "$ORG_ID" --app "$APP_ID"
ccp logs --app "$APP_ID" --limit 20 --json
```

A log snapshot returns an array. With `--follow --json`, CCP emits one JSON object per line. Capture stdout and stderr separately. Branch on the [exit code](/docs/ccp/ci-deploy) before parsing the result.

For a disposable Sandbox, inventory the intended organization with `ccp sandbox list --org-id "$ORG_ID" --json`. Retain the selected ID. When the task authorizes cleanup, `ccp sandbox delete "$SANDBOX_ID" --yes` explicitly confirms that deletion.

To define the managed Agent itself, see [Agent manifests](/docs/ccp/agents).
