| name | cn |
| description | Use the cn CLI to interact with Confluence. Search pages, read content, create/update/delete pages, manage labels, move pages, check sync status, and more. Use when user wants to work with Confluence pages via cn CLI. |
cn - Confluence CLI Skill
Use the cn CLI to interact with Confluence spaces and pages.
Scope
Only use cn commands. Do not reach for kb, MCP tools, or other search tools — if the user wanted those they would ask for them explicitly.
Config
Credentials stored at ~/.cn/config.json:
{
"confluenceUrl": "https://company.atlassian.net",
"email": "user@company.com",
"apiToken": "..."
}
Run cn setup to configure interactively.
Commands Reference
Search
cn search 'type=page AND text~"query"'
cn search 'type=page AND space=ENG AND text~"query"'
cn search 'type=page AND lastModified >= "2026-01-01"'
cn search 'type=page AND label=draft AND space=DOCS'
cn search 'type=page AND text~"query"' --limit 20
cn search 'type=page AND text~"query"' --xml
The query argument is passed directly to the Confluence CQL search API. Use full CQL syntax for filtering by space, label, type, date, author, and more.
Browse & Explore
cn spaces
cn spaces --limit 50
cn spaces --page 2
cn spaces --page 2 --limit 10
cn spaces --xml
cn tree
cn tree ENG
cn tree --depth 2
cn tree --xml
cn info <page_id>
cn info ./docs/my-page.md
cn info 123456 --xml
cn read <page_id>
cn read ./docs/my-page.md
cn read 123456 --xml
cn read 123456 --html
cn comments <page_id>
cn comments ./docs/my-page.md
cn comments 123456 --xml
cn attachments <page_id>
cn attachments ./docs/my-page.md
cn attachments 123456 --xml
Open in Browser
WARNING: cn open launches a web browser window. Do NOT use in non-interactive
environments (CI, bots, agents). Use cn info or cn search instead to get page URLs.
cn open
cn open "Getting Started"
cn open 123456
cn open ./docs/my-page.md
Clone & Pull
cn clone ENG
cn clone ENG my-folder
cn clone ABC DEF GHI
cn pull
cn pull --force
cn pull --dry-run
cn pull --page ./docs/my-page.md
cn pull --page 123456
cn pull --page 123456 --page 789012
cn status
cn status --xml
Pull compares version numbers to detect modifications and handles renames and moves automatically.
Create & Update Pages
cn create "Page Title" --space ENG
cn create "Page Title" --space ENG --open
cn create "Child Page" --parent 123456
echo "<p>Hello</p>" | cn create "Page Title" --space ENG
echo "h1. Hello" | cn create "Wiki Page" --space ENG --format wiki
cn update 123456
echo "<p>Updated</p>" | cn update 123456
echo "<p>New</p>" | cn update 123456 --title "New Title"
echo "h1. Content" | cn update 123456 --format wiki
echo "<p>x</p>" | cn update 123456 --message "via bot"
Valid --format values: storage (default), wiki, atlas_doc_format
The storage format is Confluence's XHTML-based storage format. When piping content:
- For
storage: pipe valid XHTML (<p>, <h1>, <ul>, etc.)
- For
wiki: pipe Confluence wiki markup (h1., *bold*, - item, etc.)
Delete & Move Pages
cn delete 123456
cn delete 123456 --force
cn move 123456 789012
cn move ./docs/my-page.md 789012
Labels
cn labels 123456
cn labels ./docs/my-page.md
cn labels 123456 --add documentation
cn labels 123456 --remove draft
cn labels 123456 --xml
Attachments
cn attachments 123456
cn attachments 123456 --upload ./image.png
cn attachments 123456 --download att-789
cn attachments 123456 --delete att-789
cn attachments 123456 --xml
Folders
Confluence folders are a special content type for organizing pages.
cn folder create "My Folder" --space DOCS
cn folder create "Nested" --space DOCS --parent 123456
cn folder list --space DOCS
cn folder list --space DOCS --xml
cn folder delete 123456
cn folder delete 123456 --force
cn folder move 123456 789012
Health Check
cn doctor
cn doctor --fix
cn doctor --xml
Doctor checks for: duplicate page_ids, orphaned local files, version mismatches.
Global Options
--xml
--verbose
--help, -h
--version
Environment Variables
| Variable | Purpose |
|---|
CN_CONFIG_PATH | Override default config file location |
CN_DEBUG=1 | Enable verbose debug logging to stderr (shows all HTTP requests) |
NO_COLOR | Disable colored output |
XML Output
Many commands support --xml for structured output that's easier to parse:
cn search 'type=page AND text~"api"' --xml
cn status --xml
cn tree --xml
cn info 123456 --xml
cn spaces --xml
cn labels 123456 --xml
cn comments 123456 --xml
cn attachments 123456 --xml
cn doctor --xml
Exit Codes
| Code | Meaning |
|---|
| 0 | Success |
| 1 | General error |
| 2 | Not configured |
| 3 | Auth error |
| 4 | Network error |
| 5 | Space not found |
| 6 | Invalid arguments |
| 7 | Page not found |
| 8 | Version conflict |
Data Model
Local synced pages are markdown files with YAML frontmatter:
---
page_id: "123456"
title: My Page
space_key: ENG
version: 5
synced_at: 2024-01-15T10:30:00Z
parent_id: "100000"
child_count: 3
labels:
- documentation
- api
---
# My Page
Page content here...
The .confluence.json file in each cloned directory tracks space config and sync state. The page_id in frontmatter is the source of truth for which Confluence page a local file maps to.
Common Workflows
Find and read a page
cn search 'type=page AND text~"topic"' --xml
cn info <page_id>
cn read <page_id>
cn read <page_id> --xml
Create a page with content
echo "<p>Hello world</p>" | cn create "New Page" --space ENG
echo "<p>Child content</p>" | cn create "Child Page" --parent 123456
Update a page
echo "<p>Updated content</p>" | cn update 123456
echo "<p>New body</p>" | cn update 123456 --title "Renamed Title" --message "Updated via bot"
Clone and explore a space
cn clone ENG && cd ENG
cn pull
cn tree
Add labels to a page
cn labels 123456 --add reviewed --add published
cn labels 123456 --remove draft
Work with page hierarchy
cn tree ENG --xml
cn move 123456 789012
cn create "New Section" --parent 789012 --space ENG
Tips
- Use
--xml output when you need to parse results or pass to another command
- Page IDs are stable — prefer them over titles when scripting
cn search takes raw CQL — e.g. cn search 'type=page AND space=ENG AND label=draft'
- For new pages, pipe storage format HTML for full control over formatting
- Pages with children become
README.md files in subdirectories when cloned
- Run
cn doctor if sync seems out of sync after manual changes
cn pull --dry-run before a full pull to preview what will change
CN_DEBUG=1 cn <command> logs every HTTP request to stderr for troubleshooting
Reference
Confluence REST API reference: https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/