@bestend/confluence-cli 1.16.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,722 @@
1
+ ---
2
+ name: confluence
3
+ description: Use confluence-cli to read, search, create, update, move, and delete Confluence pages and attachments from the terminal.
4
+ ---
5
+
6
+ # confluence-cli Skill
7
+
8
+ A CLI tool for Atlassian Confluence. Lets you read, search, create, update, move, and delete pages and attachments from the terminal or from an agent.
9
+
10
+ ## Installation
11
+
12
+ ```sh
13
+ npm install -g confluence-cli
14
+ confluence --version # verify install
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ **Preferred for agents — environment variables (no interactive prompt):**
20
+
21
+ | Variable | Description | Example |
22
+ |---|---|---|
23
+ | `CONFLUENCE_DOMAIN` | Your Confluence hostname | `company.atlassian.net` |
24
+ | `CONFLUENCE_API_PATH` | REST API base path | `/wiki/rest/api` (Cloud) or `/rest/api` (Server/DC) |
25
+ | `CONFLUENCE_AUTH_TYPE` | `basic` or `bearer` | `basic` |
26
+ | `CONFLUENCE_EMAIL` | Email address (basic auth only) | `user@company.com` |
27
+ | `CONFLUENCE_API_TOKEN` | API token or personal access token | `ATATT3x...` |
28
+ | `CONFLUENCE_PROFILE` | Named profile to use (optional) | `staging` |
29
+ | `CONFLUENCE_READ_ONLY` | Block all write operations when `true` | `true` |
30
+
31
+ **Global `--profile` flag (use a named profile for any command):**
32
+
33
+ ```sh
34
+ confluence --profile <name> <command>
35
+ ```
36
+
37
+ Config resolution works in two stages:
38
+ - **Direct env config:** If both `CONFLUENCE_DOMAIN` and `CONFLUENCE_API_TOKEN` are set, they are used directly and the config file / profiles are not consulted.
39
+ - **Profile-based config:** Otherwise, a profile is selected in this order: `--profile` flag > `CONFLUENCE_PROFILE` env > `activeProfile` in config > `default`.
40
+
41
+ **Non-interactive init (good for CI/CD scripts):**
42
+
43
+ ```sh
44
+ confluence init \
45
+ --domain "company.atlassian.net" \
46
+ --api-path "/wiki/rest/api" \
47
+ --auth-type basic \
48
+ --email "user@company.com" \
49
+ --token "ATATT3x..."
50
+ ```
51
+
52
+ **Cloud vs Server/DC:**
53
+ - Atlassian Cloud (`*.atlassian.net`): use `--api-path "/wiki/rest/api"`, auth type `basic` with email + API token
54
+ - Atlassian Cloud (scoped token): use `--domain "api.atlassian.com"`, `--api-path "/ex/confluence/<your-cloud-id>/wiki/rest/api"`, auth type `basic` with email + scoped token. Get your Cloud ID from `https://<your-site>.atlassian.net/_edge/tenant_info`. Recommended for agents (least privilege).
55
+ - Self-hosted / Data Center: use `--api-path "/rest/api"`, auth type `bearer` with a personal access token (no email needed)
56
+
57
+ **Scoped API token for agents (recommended):**
58
+
59
+ ```sh
60
+ export CONFLUENCE_DOMAIN="api.atlassian.com"
61
+ export CONFLUENCE_API_PATH="/ex/confluence/<your-cloud-id>/wiki/rest/api"
62
+ export CONFLUENCE_AUTH_TYPE="basic"
63
+ export CONFLUENCE_EMAIL="user@company.com"
64
+ export CONFLUENCE_API_TOKEN="your-scoped-token"
65
+ ```
66
+
67
+ **Read-only mode (recommended for AI agents):**
68
+
69
+ Prevents all write operations (create, update, delete, move, etc.) at the profile level. Useful when giving an AI agent access to Confluence for reading only.
70
+
71
+ ```sh
72
+ # Via profile flag
73
+ confluence profile add agent --domain "company.atlassian.net" --token "xxx" --read-only
74
+
75
+ # Via environment variable (overrides config file)
76
+ export CONFLUENCE_READ_ONLY=true
77
+ ```
78
+
79
+ When read-only mode is active, any write command exits with an error:
80
+ ```
81
+ Error: This profile is in read-only mode. Write operations are not allowed.
82
+ ```
83
+
84
+ `profile list` shows read-only profiles with a `[read-only]` badge.
85
+
86
+ ---
87
+
88
+ ## Page ID Resolution
89
+
90
+ Most commands accept `<pageId>` — a numeric ID or any of the supported URL formats below.
91
+
92
+ **Supported formats:**
93
+
94
+ | Format | Example |
95
+ |---|---|
96
+ | Numeric ID | `123456789` |
97
+ | `?pageId=` URL | `https://company.atlassian.net/wiki/viewpage.action?pageId=123456789` |
98
+ | Pretty `/pages/<id>` URL | `https://company.atlassian.net/wiki/spaces/SPACE/pages/123456789/Page+Title` |
99
+ | Display `/display/<space>/<title>` URL | `https://company.atlassian.net/wiki/display/SPACE/Page+Title` |
100
+
101
+ ```sh
102
+ confluence read 123456789
103
+ confluence read "https://company.atlassian.net/wiki/viewpage.action?pageId=123456789"
104
+ confluence read "https://company.atlassian.net/wiki/spaces/MYSPACE/pages/123456789/My+Page"
105
+ ```
106
+
107
+ > **Note:** Display-style URLs (`/display/<space>/<title>`) perform a title-based lookup, so the page title in the URL must match exactly. When possible, prefer numeric IDs or `/pages/<id>` URLs for reliability.
108
+
109
+ ## Content Formats
110
+
111
+ | Format | Notes |
112
+ |---|---|
113
+ | `markdown` | Recommended for agent-generated content. Automatically converted by the API. |
114
+ | `storage` | Confluence XML storage format (default for create/update). Use for programmatic round-trips. |
115
+ | `html` | Raw HTML. |
116
+ | `text` | Plain text — for read/export output only, not for creation. |
117
+
118
+ ---
119
+
120
+ ## Commands Reference
121
+
122
+ ### `init`
123
+
124
+ Initialize configuration. Saves credentials to `~/.confluence-cli/config.json`.
125
+
126
+ ```sh
127
+ confluence init [--domain <domain>] [--api-path <path>] [--auth-type basic|bearer] [--email <email>] [--token <token>] [--read-only]
128
+ ```
129
+
130
+ All flags are optional; omitting any flag triggers an interactive prompt for that field. Provide all flags to run fully non-interactive. Use the global `--profile` flag to save to a named profile:
131
+
132
+ ```sh
133
+ confluence --profile staging init --domain "staging.example.com" --auth-type bearer --token "your-token"
134
+ ```
135
+
136
+ ---
137
+
138
+ ### `read <pageId>`
139
+
140
+ Read page content. Outputs to stdout.
141
+
142
+ ```sh
143
+ confluence read <pageId> [--format html|text|markdown]
144
+ ```
145
+
146
+ | Option | Default | Description |
147
+ |---|---|---|
148
+ | `--format` | `text` | Output format: `html`, `text`, or `markdown` |
149
+
150
+ ```sh
151
+ confluence read 123456789
152
+ confluence read 123456789 --format markdown
153
+ ```
154
+
155
+ ---
156
+
157
+ ### `info <pageId>`
158
+
159
+ Get page metadata (title, ID, type, status, space).
160
+
161
+ ```sh
162
+ confluence info <pageId>
163
+ ```
164
+
165
+ ```sh
166
+ confluence info 123456789
167
+ ```
168
+
169
+ ---
170
+
171
+ ### `find <title>`
172
+
173
+ Find a page by exact or partial title. Returns the first match.
174
+
175
+ ```sh
176
+ confluence find <title> [--space <spaceKey>]
177
+ ```
178
+
179
+ | Option | Description |
180
+ |---|---|
181
+ | `--space` | Restrict search to a specific space key |
182
+
183
+ ```sh
184
+ confluence find "Architecture Overview"
185
+ confluence find "API Reference" --space MYSPACE
186
+ ```
187
+
188
+ ---
189
+
190
+ ### `search <query>`
191
+
192
+ Search pages using a keyword or CQL expression.
193
+
194
+ ```sh
195
+ confluence search <query> [--limit <number>]
196
+ ```
197
+
198
+ | Option | Default | Description |
199
+ |---|---|---|
200
+ | `--limit` | `10` | Maximum number of results |
201
+
202
+ ```sh
203
+ confluence search "deployment pipeline"
204
+ confluence search "type=page AND space=MYSPACE" --limit 50
205
+ ```
206
+
207
+ ---
208
+
209
+ ### `spaces`
210
+
211
+ List all accessible Confluence spaces (key and name).
212
+
213
+ ```sh
214
+ confluence spaces
215
+ ```
216
+
217
+ ---
218
+
219
+ ### `children <pageId>`
220
+
221
+ List child pages of a page.
222
+
223
+ ```sh
224
+ confluence children <pageId> [--recursive] [--max-depth <number>] [--format list|tree|json] [--show-id] [--show-url]
225
+ ```
226
+
227
+ | Option | Default | Description |
228
+ |---|---|---|
229
+ | `--recursive` | false | List all descendants recursively |
230
+ | `--max-depth` | `10` | Maximum depth for recursive listing |
231
+ | `--format` | `list` | Output format: `list`, `tree`, or `json` |
232
+ | `--show-id` | false | Show page IDs |
233
+ | `--show-url` | false | Show page URLs |
234
+
235
+ ```sh
236
+ confluence children 123456789
237
+ confluence children 123456789 --recursive --format json
238
+ confluence children 123456789 --recursive --format tree --show-id
239
+ ```
240
+
241
+ ---
242
+
243
+ ### `create <title> <spaceKey>`
244
+
245
+ Create a new top-level page in a space.
246
+
247
+ ```sh
248
+ confluence create <title> <spaceKey> [--content <string>] [--file <path>] [--format storage|html|markdown]
249
+ ```
250
+
251
+ | Option | Default | Description |
252
+ |---|---|---|
253
+ | `--content` | — | Inline content string |
254
+ | `--file` | — | Path to content file |
255
+ | `--format` | `storage` | Content format |
256
+
257
+ Either `--content` or `--file` is required.
258
+
259
+ ```sh
260
+ confluence create "Project Overview" MYSPACE --content "# Hello" --format markdown
261
+ confluence create "Release Notes" MYSPACE --file ./notes.md --format markdown
262
+ ```
263
+
264
+ Outputs the new page ID and URL on success.
265
+
266
+ ---
267
+
268
+ ### `create-child <title> <parentId>`
269
+
270
+ Create a child page under an existing page. Inherits the parent's space automatically.
271
+
272
+ ```sh
273
+ confluence create-child <title> <parentId> [--content <string>] [--file <path>] [--format storage|html|markdown]
274
+ ```
275
+
276
+ Options are identical to `create`. Either `--content` or `--file` is required.
277
+
278
+ ```sh
279
+ confluence create-child "Chapter 1" 123456789 --content "Content here" --format markdown
280
+ confluence create-child "API Guide" 123456789 --file ./api.md --format markdown
281
+ ```
282
+
283
+ ---
284
+
285
+ ### `update <pageId>`
286
+
287
+ Update an existing page's title and/or content. At least one of `--title`, `--content`, or `--file` is required.
288
+
289
+ ```sh
290
+ confluence update <pageId> [--title <title>] [--content <string>] [--file <path>] [--format storage|html|markdown]
291
+ ```
292
+
293
+ | Option | Default | Description |
294
+ |---|---|---|
295
+ | `--title` | — | New title |
296
+ | `--content` | — | Inline content string |
297
+ | `--file` | — | Path to content file |
298
+ | `--format` | `storage` | Content format |
299
+
300
+ ```sh
301
+ confluence update 123456789 --title "New Title"
302
+ confluence update 123456789 --file ./updated.md --format markdown
303
+ confluence update 123456789 --title "New Title" --file ./updated.xml --format storage
304
+ ```
305
+
306
+ ---
307
+
308
+ ### `move <pageId_or_url> <newParentId_or_url>`
309
+
310
+ Move a page to a new parent. Both pages must be in the same space.
311
+
312
+ ```sh
313
+ confluence move <pageId_or_url> <newParentId_or_url> [--title <newTitle>]
314
+ ```
315
+
316
+ | Option | Description |
317
+ |---|---|
318
+ | `--title` | Rename the page during the move |
319
+
320
+ ```sh
321
+ confluence move 123456789 987654321
322
+ confluence move 123456789 987654321 --title "Renamed After Move"
323
+ ```
324
+
325
+ ---
326
+
327
+ ### `delete <pageIdOrUrl>`
328
+
329
+ Delete (trash) a page by ID or URL.
330
+
331
+ ```sh
332
+ confluence delete <pageIdOrUrl> [--yes]
333
+ ```
334
+
335
+ | Option | Description |
336
+ |---|---|
337
+ | `--yes` | Skip confirmation prompt (required for non-interactive/agent use) |
338
+
339
+ ```sh
340
+ confluence delete 123456789 --yes
341
+ ```
342
+
343
+ ---
344
+
345
+ ### `edit <pageId>`
346
+
347
+ Fetch a page's raw storage-format content for editing locally.
348
+
349
+ ```sh
350
+ confluence edit <pageId> [--output <file>]
351
+ ```
352
+
353
+ | Option | Description |
354
+ |---|---|
355
+ | `--output` | Save content to a file (instead of printing to stdout) |
356
+
357
+ ```sh
358
+ confluence edit 123456789 --output ./page.xml
359
+ # Edit page.xml, then:
360
+ confluence update 123456789 --file ./page.xml --format storage
361
+ ```
362
+
363
+ ---
364
+
365
+ ### `export <pageId>`
366
+
367
+ Export a page and its attachments to a local directory.
368
+
369
+ ```sh
370
+ confluence export <pageId> [--format html|text|markdown] [--dest <directory>] [--file <filename>] [--attachments-dir <name>] [--pattern <glob>] [--referenced-only] [--skip-attachments]
371
+ ```
372
+
373
+ | Option | Default | Description |
374
+ |---|---|---|
375
+ | `--format` | `markdown` | Content format for the exported file |
376
+ | `--dest` | `.` | Base directory to export into |
377
+ | `--file` | `page.<ext>` | Filename for the content file |
378
+ | `--attachments-dir` | `attachments` | Subdirectory name for attachments |
379
+ | `--pattern` | — | Glob filter for attachments (e.g. `*.png`) |
380
+ | `--referenced-only` | false | Only download attachments referenced in the page content |
381
+ | `--skip-attachments` | false | Do not download attachments |
382
+
383
+ ```sh
384
+ confluence export 123456789 --format markdown --dest ./docs
385
+ confluence export 123456789 --format markdown --dest ./docs --skip-attachments
386
+ confluence export 123456789 --pattern "*.png" --dest ./output
387
+ ```
388
+
389
+ Creates a subdirectory named after the page title under `--dest`.
390
+
391
+ ---
392
+
393
+ ### `attachments <pageId>`
394
+
395
+ List or download attachments for a page.
396
+
397
+ ```sh
398
+ confluence attachments <pageId> [--limit <n>] [--pattern <glob>] [--download] [--dest <directory>]
399
+ ```
400
+
401
+ | Option | Default | Description |
402
+ |---|---|---|
403
+ | `--limit` | all | Maximum number of attachments to fetch |
404
+ | `--pattern` | — | Filter by filename glob (e.g. `*.pdf`) |
405
+ | `--download` | false | Download matching attachments |
406
+ | `--dest` | `.` | Directory to save downloads |
407
+
408
+ ```sh
409
+ confluence attachments 123456789
410
+ confluence attachments 123456789 --pattern "*.pdf" --download --dest ./downloads
411
+ ```
412
+
413
+ ---
414
+
415
+ ### `attachment-upload <pageId>`
416
+
417
+ Upload one or more files to a page. `--file` can be repeated for multiple files.
418
+
419
+ ```sh
420
+ confluence attachment-upload <pageId> --file <path> [--file <path> ...] [--comment <text>] [--replace] [--minor-edit]
421
+ ```
422
+
423
+ | Option | Description |
424
+ |---|---|
425
+ | `--file` | File to upload (required, repeatable) |
426
+ | `--comment` | Comment for the attachment(s) |
427
+ | `--replace` | Replace an existing attachment with the same filename |
428
+ | `--minor-edit` | Mark the upload as a minor edit |
429
+
430
+ ```sh
431
+ confluence attachment-upload 123456789 --file ./report.pdf
432
+ confluence attachment-upload 123456789 --file ./a.png --file ./b.png --replace
433
+ ```
434
+
435
+ ---
436
+
437
+ ### `attachment-delete <pageId> <attachmentId>`
438
+
439
+ Delete an attachment from a page.
440
+
441
+ ```sh
442
+ confluence attachment-delete <pageId> <attachmentId> [--yes]
443
+ ```
444
+
445
+ | Option | Description |
446
+ |---|---|
447
+ | `--yes` | Skip confirmation prompt |
448
+
449
+ ```sh
450
+ confluence attachment-delete 123456789 att-987 --yes
451
+ ```
452
+
453
+ ---
454
+
455
+ ### `comments <pageId>`
456
+
457
+ List comments for a page.
458
+
459
+ ```sh
460
+ confluence comments <pageId> [--format text|markdown|json] [--limit <n>] [--start <n>] [--location inline,footer,resolved] [--depth all] [--all]
461
+ ```
462
+
463
+ | Option | Default | Description |
464
+ |---|---|---|
465
+ | `--format` | `text` | Output format: `text`, `markdown`, or `json` |
466
+ | `--limit` | `25` | Maximum comments per page |
467
+ | `--start` | `0` | Start index for pagination |
468
+ | `--location` | — | Filter by location: `inline`, `footer`, `resolved` (comma-separated) |
469
+ | `--depth` | — | Leave empty for root-only; `all` for all nested replies |
470
+ | `--all` | false | Fetch all comments (ignores pagination) |
471
+
472
+ ```sh
473
+ confluence comments 123456789
474
+ confluence comments 123456789 --format json --all
475
+ confluence comments 123456789 --location footer --depth all
476
+ ```
477
+
478
+ ---
479
+
480
+ ### `comment <pageId>`
481
+
482
+ Create a comment on a page (footer or inline).
483
+
484
+ ```sh
485
+ confluence comment <pageId> [--content <string>] [--file <path>] [--format storage|html|markdown] [--parent <commentId>] [--location footer|inline] [--inline-selection <text>] [--inline-original-selection <text>] [--inline-marker-ref <ref>] [--inline-properties <json>]
486
+ ```
487
+
488
+ | Option | Default | Description |
489
+ |---|---|---|
490
+ | `--content` | — | Inline content string |
491
+ | `--file` | — | Path to content file |
492
+ | `--format` | `storage` | Content format |
493
+ | `--parent` | — | Reply to a comment by ID |
494
+ | `--location` | `footer` | `footer` or `inline` |
495
+ | `--inline-selection` | — | Highlighted selection text (inline only) |
496
+ | `--inline-original-selection` | — | Original selection text (inline only) |
497
+ | `--inline-marker-ref` | — | Marker reference (inline only) |
498
+ | `--inline-properties` | — | Full inline properties as JSON (advanced) |
499
+
500
+ Either `--content` or `--file` is required.
501
+
502
+ ```sh
503
+ confluence comment 123456789 --content "Looks good!" --location footer
504
+ confluence comment 123456789 --content "See note" --parent 456 --location footer
505
+ ```
506
+
507
+ > **Note on inline comments**: Creating a brand-new inline comment requires editor highlight metadata (`matchIndex`, `lastFetchTime`, `serializedHighlights`) that is only available in the Confluence editor. This metadata is not accessible via the REST API, so inline comment creation will typically fail with a 400 error. Use `--location footer` or reply to an existing inline comment with `--parent <commentId>` instead.
508
+
509
+ ---
510
+
511
+ ### `comment-delete <commentId>`
512
+
513
+ Delete a comment by its ID.
514
+
515
+ ```sh
516
+ confluence comment-delete <commentId> [--yes]
517
+ ```
518
+
519
+ | Option | Description |
520
+ |---|---|
521
+ | `--yes` | Skip confirmation prompt |
522
+
523
+ ```sh
524
+ confluence comment-delete 456789 --yes
525
+ ```
526
+
527
+ ---
528
+
529
+ ### `copy-tree <sourcePageId> <targetParentId> [newTitle]`
530
+
531
+ Copy a page and all its children to a new location.
532
+
533
+ ```sh
534
+ confluence copy-tree <sourcePageId> <targetParentId> [newTitle] [--max-depth <depth>] [--exclude <patterns>] [--delay-ms <ms>] [--copy-suffix <suffix>] [--dry-run] [--fail-on-error] [--quiet]
535
+ ```
536
+
537
+ | Option | Default | Description |
538
+ |---|---|---|
539
+ | `--max-depth` | `10` | Maximum depth to copy |
540
+ | `--exclude` | — | Comma-separated title patterns to exclude (supports wildcards) |
541
+ | `--delay-ms` | `100` | Delay between sibling creations in ms |
542
+ | `--copy-suffix` | `" (Copy)"` | Suffix appended to the root page title |
543
+ | `--dry-run` | false | Preview operations without creating pages |
544
+ | `--fail-on-error` | false | Exit with non-zero code if any page fails |
545
+ | `--quiet` | false | Suppress progress output |
546
+
547
+ ```sh
548
+ # Preview first
549
+ confluence copy-tree 123456789 987654321 --dry-run
550
+
551
+ # Copy with a custom title
552
+ confluence copy-tree 123456789 987654321 "Backup Copy"
553
+
554
+ # Copy excluding certain pages
555
+ confluence copy-tree 123456789 987654321 --exclude "Draft*,Archive*"
556
+ ```
557
+
558
+ ---
559
+
560
+ ### `profile list`
561
+
562
+ List all configuration profiles with the active profile marked.
563
+
564
+ ```sh
565
+ confluence profile list
566
+ ```
567
+
568
+ ---
569
+
570
+ ### `profile use <name>`
571
+
572
+ Switch the active configuration profile.
573
+
574
+ ```sh
575
+ confluence profile use <name>
576
+ ```
577
+
578
+ ```sh
579
+ confluence profile use staging
580
+ ```
581
+
582
+ ---
583
+
584
+ ### `profile add <name>`
585
+
586
+ Add a new configuration profile. Supports the same options as `init` (interactive, non-interactive, or hybrid).
587
+
588
+ ```sh
589
+ confluence profile add <name> [--domain <domain>] [--api-path <path>] [--auth-type basic|bearer] [--email <email>] [--token <token>] [--protocol http|https] [--read-only]
590
+ ```
591
+
592
+ Profile names may contain letters, numbers, hyphens, and underscores only.
593
+
594
+ ```sh
595
+ confluence profile add staging --domain "staging.example.com" --auth-type bearer --token "xyz"
596
+ ```
597
+
598
+ ---
599
+
600
+ ### `profile remove <name>`
601
+
602
+ Remove a configuration profile (prompts for confirmation). Cannot remove the only remaining profile.
603
+
604
+ ```sh
605
+ confluence profile remove <name>
606
+ ```
607
+
608
+ ```sh
609
+ confluence profile remove staging
610
+ ```
611
+
612
+ ---
613
+
614
+ ### `stats`
615
+
616
+ Show local usage statistics.
617
+
618
+ ```sh
619
+ confluence stats
620
+ ```
621
+
622
+ ---
623
+
624
+ ### `install-skill`
625
+
626
+ Copy the Claude Code skill documentation into your project's `.claude/skills/` directory so Claude Code can learn confluence-cli automatically.
627
+
628
+ ```sh
629
+ confluence install-skill [--dest <directory>] [--yes]
630
+ ```
631
+
632
+ | Option | Default | Description |
633
+ |---|---|---|
634
+ | `--dest` | `./.claude/skills/confluence` | Target directory |
635
+ | `--yes` | false | Skip overwrite confirmation |
636
+
637
+ ```sh
638
+ confluence install-skill
639
+ ```
640
+
641
+ ---
642
+
643
+ ## Common Agent Workflows
644
+
645
+ ### Read → Edit → Update (round-trip)
646
+
647
+ ```sh
648
+ # 1. Fetch raw storage XML
649
+ confluence edit 123456789 --output ./page.xml
650
+
651
+ # 2. Modify page.xml with your tool of choice
652
+
653
+ # 3. Push the updated content
654
+ confluence update 123456789 --file ./page.xml --format storage
655
+ ```
656
+
657
+ ### Build a documentation hierarchy
658
+
659
+ ```sh
660
+ # Create root page, note the returned ID (e.g. 111222333)
661
+ confluence create "Project Overview" MYSPACE --content "# Overview" --format markdown
662
+
663
+ # Add children under it
664
+ confluence create-child "Architecture" 111222333 --content "# Architecture" --format markdown
665
+ confluence create-child "API Reference" 111222333 --file ./api.md --format markdown
666
+ confluence create-child "Runbooks" 111222333 --content "# Runbooks" --format markdown
667
+ ```
668
+
669
+ ### Copy a full page tree
670
+
671
+ ```sh
672
+ # Preview first
673
+ confluence copy-tree 123456789 987654321 --dry-run
674
+
675
+ # Execute the copy
676
+ confluence copy-tree 123456789 987654321 "Backup Copy"
677
+ ```
678
+
679
+ ### Export a page for local editing
680
+
681
+ ```sh
682
+ confluence export 123456789 --format markdown --dest ./local-docs
683
+ # => ./local-docs/<page-title>/page.md + ./local-docs/<page-title>/attachments/
684
+ ```
685
+
686
+ ### Process children as JSON
687
+
688
+ ```sh
689
+ confluence children 123456789 --recursive --format json | jq '.[].id'
690
+ ```
691
+
692
+ ### Search and process results
693
+
694
+ ```sh
695
+ confluence search "release notes" --limit 20
696
+ ```
697
+
698
+ ---
699
+
700
+ ## Agent Tips
701
+
702
+ - **Always use `--yes`** on destructive commands (`delete`, `comment-delete`, `attachment-delete`) to avoid interactive prompts blocking the agent.
703
+ - **Prefer `--format markdown`** when creating or updating content from agent-generated text — it's the most natural format and the API converts it automatically.
704
+ - **Use `--format json`** on `children` and `comments` for machine-parseable output.
705
+ - **ANSI color codes**: stdout may contain ANSI escape sequences. Pipe through `| cat` or use `NO_COLOR=1` if your downstream tool doesn't handle them.
706
+ - **Page ID vs URL**: when you have a Confluence URL, extract `?pageId=<number>` and pass the number. Do not pass pretty/display URLs — they are not supported.
707
+ - **Cross-space moves**: `confluence move` only works within the same space. Moving across spaces is not supported.
708
+ - **Multiple instances**: Use `--profile <name>` or `CONFLUENCE_PROFILE` env var to target different Confluence instances without reconfiguring.
709
+ - **Read-only mode**: Set `CONFLUENCE_READ_ONLY=true` or use `--read-only` when creating profiles to prevent accidental writes. This is enforced at the CLI level — all write commands will be blocked.
710
+
711
+ ## Error Patterns
712
+
713
+ | Error | Cause | Fix |
714
+ |---|---|---|
715
+ | `No configuration found` | No config file and no env vars set | Set env vars or run `confluence init` |
716
+ | `Cross-space moves are not supported` | `move` used across spaces | Copy with `copy-tree` instead |
717
+ | 400 on inline comment creation | Editor metadata required | Use `--location footer` or reply to existing inline comment with `--parent` |
718
+ | `File not found: <path>` | `--file` path doesn't exist | Check the path before calling the command |
719
+ | `At least one of --title, --file, or --content must be provided` | `update` called with no content options | Provide at least one of the required options |
720
+ | `Profile "<name>" not found!` | Specified profile doesn't exist | Run `confluence profile list` to see available profiles |
721
+ | `Cannot delete the only remaining profile.` | Tried to remove the last profile | Add another profile before removing |
722
+ | `This profile is in read-only mode` | Write command used with a read-only profile | Use a writable profile or remove `readOnly` from config |