Skip to content

CQL Guide

CQL (Confluence Query Language) is used by manage_search to find content. This guide covers the most useful patterns for both CLI and MCP usage.

ctk supports two search modes:

ModeDescriptionWhen to Use
CQL (cql action)Structured queries with field/operator/valuePrecise filtering by space, type, label, date
Quick (quick action)Plain text searchSimple keyword searches, like the Confluence search bar

CQL queries follow the pattern: field operator value

type = page AND space = "DEV"

Use AND, OR to combine conditions, and ORDER BY for sorting.

OperatorDescriptionExample
=Exact matchtype = "page"
!=Not equaltype != "comment"
~Contains texttitle ~ "meeting notes"
!~Does not containtitle !~ "draft"
INMatch any in listspace IN ("DEV", "TEAM")
NOT INNot in listspace NOT IN ("ARCHIVE")
>, <, >=, <=Comparisoncreated >= "2025-01-01"
FieldDescriptionExample
typeContent typetype = "page" or type = "blogpost"
spaceSpace keyspace = "DEV"
titlePage titletitle ~ "architecture"
textFull-text content searchtext ~ "API documentation"
labelContent labellabel = "approved"
creatorCreated by usercreator = currentUser()
contributorAny editorcontributor = "jane@example.com"
createdCreation datecreated >= "2025-01-01"
lastModifiedLast modified datelastModified >= "2025-06-01"
ancestorUnder a parent page (recursive)ancestor = "12345678"
parentDirect parent pageparent = "12345678"
idContent IDid = "12345678"
type = page AND space = "DEV" ORDER BY lastModified DESC
type = page AND lastModified >= "-7d" ORDER BY lastModified DESC
type = page AND label = "architecture" ORDER BY title ASC
ancestor = "12345678" AND type = page ORDER BY title ASC
space = "DEV" AND text ~ "database migration" ORDER BY lastModified DESC
type = page AND created >= startOfMonth() ORDER BY created DESC
type = page AND contributor = currentUser() AND lastModified >= "-30d" ORDER BY lastModified DESC
type = blogpost AND space = "ENG" ORDER BY created DESC
type = page AND label = "api" AND label = "v2" ORDER BY title ASC
type = page AND space = "DEV" AND label != "archived" ORDER BY lastModified DESC
type = page AND title ~ "onboarding" ORDER BY lastModified DESC
space = "~username" AND type = page ORDER BY lastModified DESC
Terminal window
# CQL query
ctk search 'type=page AND space=DEV AND title~"architecture"'
# Quick text search
ctk search --quick "API documentation"
{
"action": "cql",
"cql": "type=page AND space=DEV AND lastModified >= \"-7d\" ORDER BY lastModified DESC",
"limit": 25
}
{
"action": "quick",
"query": "onboarding guide"
}