Quick reference for the Caffeine Data Intelligence agent to query an OQL-exposing canister (schema() + execute()) through the `icp` CLI against the project's `backend` canister: read the schema, form JSON queries (filter / order / paginate / aggregate / dotted-path edges), and parse the Candid result rows.
A quick-reference workflow for the Caffeine Data Intelligence agent to query an OQL-exposing canister through the pre-installed icp CLI, targeting the project's backend canister. Such a canister exposes exactly two read-only methods: schema(), which returns a JSON catalogue of the canister's entities - each entity's primary key, fields, and edges - and execute(qJson), which runs a JSON-encoded query and returns matching rows as a typed Candid Result. Both are query calls, so every invocation passes --query; the JSON query is embedded as a Candid text literal wrapped in ("...") with each quote escaped, and --branch live reads the deployed, query-only canister instead of the draft. The recommended recipe is to fetch and cache the schema once per session, map the request to the entity that holds the answer, translate it into one or more queries, run them, and retry on traps since there is no error envelope. A query is a single JSON object where only start is required, plus optional where, groupBy, aggregate, orderBy, offset, limit, and select. Predicates use exactly one operator key: eq/ne/lt/le/gt/ge for scalar relations, in for membership, contains/startsWith/endsWith and case-insensitive icontains for text, and and/or/not for boolean composition - with text search running server-side rather than paging rows into context. Scalar literals must match each field's typeName (Nat, Int, Float, Bool, or Text, with numeric bridging between the numeric types), and enum-like fields should be filtered using the exact literals listed in the schema's values array. Edges are traversed with a dotted path for forward relations, while a reverse one-to-many relationship requires fetching the parent keys first and then filtering with in.
schema() returns a JSON catalogue of the canister's entities (primary keys, fields, and edges), and execute(qJson) runs a JSON-encoded query and returns matching rows as a typed Candid Result.
Embed the JSON as a Candid text literal wrapped in ("...") and escape every quote as \". Both methods are query calls, so every invocation uses --query.
Use the icontains predicate, the case-insensitive form of contains. It runs server-side, so it is preferred for user-typed search terms and avoids paging rows into context.
Read the field's values list in the schema and filter with those exact literals - for example query "enterprise", not "Enterprise", when the schema reports lowercase arms.
Add --branch live to the icp call to read the deployed canister, which is query-only.
Quick Setup:
.claude/skills/Repository
caffeinelabs/skills