From bedrock
Fetches Confluence page content via Atlassian MCP (preferred), REST API fallback, or browser DOM extraction and converts to Markdown. Internal module for Bedrock skills.
npx claudepluginhub iurykrieger/claude-bedrock --plugin bedrockThis skill is limited to using the following tools:
Internal module — invoked by `/bedrock:learn` Phase 1 and `/bedrock:sync` Phase 2, not user-invocable.
Fetches Confluence page content using confluence-cli from a given URL, resolves short links, formats output, and saves as markdown file. Activates on Confluence page URLs.
Search, read, create, update, and manage Confluence pages and spaces using confluence-cli. Handles documentation access, space navigation, and exports with attachments.
Search, read, create, update, and manage Confluence pages and spaces using confluence-cli from the terminal. Access team documentation and wikis during development.
Share bugs, ideas, or general feedback.
Internal module — invoked by /bedrock:learn Phase 1 and /bedrock:sync Phase 2, not user-invocable.
Fetches a Confluence page and returns its content as Markdown. Three layers in fallback order: MCP (preferred) → REST API → Browser DOM extraction.
Dependency: Browser fallback (Layer 3) requires scripts/extract.js (relative to this skill directory).
Parse the Confluence URL. Accept these formats:
https://<domain>.atlassian.net/wiki/spaces/<spaceKey>/pages/<pageId>/<title>https://<domain>.atlassian.net/wiki/spaces/<spaceKey>/pages/<pageId>https://<domain>.atlassian.net/wiki/x/<shortlink>https://<domain>.atlassian.net/wiki/pages/viewpage.action?pageId=<pageId>Extract:
https://<domain>.atlassian.net (everything before /wiki/...)/pages/) or pageId query parameterThe preferred layer. Uses the plugin:atlassian:atlassian MCP server if installed and authenticated.
Use ToolSearch to check if Atlassian MCP tools are available:
ToolSearch(query: "atlassian confluence page", max_results: 5)
Evaluate the result:
authenticate and complete_authentication are available) → proceed to 2.2 Fetch via MCPauthenticate / complete_authentication tools found (MCP installed but not authenticated) → proceed to 2.3 Guide authenticationMCP not available: No Atlassian MCP server installed. Install the Atlassian MCP plugin for Claude Code to enable direct Confluence access. Falling back to API (Layer 2).
Use the Atlassian MCP tools to fetch the page content. The specific tool depends on what the MCP exposes after authentication (typically a page read or content retrieval tool).
Call the MCP tool passing the page ID or URL. The MCP returns the page content directly.
MCP fetch failed: {error message}. Falling back to API (Layer 2).
If the MCP is installed but not authenticated, guide the user:
MCP not authenticated: The Atlassian MCP server is installed but requires authentication. Run
mcp__plugin_atlassian_atlassian__authenticateto start the OAuth flow, then complete it in your browser. After authentication, Confluence pages can be fetched directly via MCP.
Ask the user: "Would you like to authenticate the Atlassian MCP now, or skip to API fallback (Layer 2)?"
mcp__plugin_atlassian_atlassian__authenticate, wait for the user to complete the OAuth flow, then retry 2.2 Fetch via MCPUses the Confluence REST API with Basic Auth (API token + email).
echo "CONFLUENCE_API_TOKEN: ${CONFLUENCE_API_TOKEN:+set}" && echo "CONFLUENCE_USER_EMAIL: ${CONFLUENCE_USER_EMAIL:+set}"
API not available:
CONFLUENCE_API_TOKENorCONFLUENCE_USER_EMAILenvironment variable is not set. Generate an API token at https://id.atlassian.com/manage-profile/security/api-tokens and export both variables:export CONFLUENCE_API_TOKEN="your-token"andexport CONFLUENCE_USER_EMAIL="your-email". Falling back to Browser extraction (Layer 3).
echo -n "${CONFLUENCE_USER_EMAIL}:${CONFLUENCE_API_TOKEN}" | base64
Use WebFetch:
WebFetch(
url: "{baseUrl}/wiki/api/v2/pages/{pageId}?body-format=storage",
headers: {
"Authorization": "Basic {base64_value}",
"Accept": "application/json"
}
)
If WebFetch cannot send the Authorization header, fall back to curl via Bash:
curl -sL -H "Authorization: Basic {base64_value}" -H "Accept: application/json" \
"{baseUrl}/wiki/api/v2/pages/{pageId}?body-format=storage"
The API returns JSON with:
title — page titlebody.storage.value — XHTML content (Confluence storage format)Convert the storage format XHTML to Markdown using these rules:
| XHTML element | Markdown output |
|---|---|
<h1> through <h6> | # through ###### |
<p> | Paragraph with blank line separation |
<strong>, <b> | **text** |
<em>, <i> | *text* |
<s>, <del> | ~~text~~ |
<a href="..."> | [text](url) |
<ul> / <ol> / <li> | Markdown lists (respect nesting) |
<table> | Markdown table with | separators and header row |
<ac:structured-macro ac:name="code"> | Fenced code block with language from <ac:parameter ac:name="language"> |
<pre> | Fenced code block |
<code> (inline) | `code` |
<blockquote> | > text |
<hr> | --- |
Confluence macros (<ac:*>) with text | Extract text content |
| Confluence macros with no text (images, drawio, attachments) | Skip silently |
| HTTP status | Action |
|---|---|
| 200 OK | Proceed to Output Contract |
| 401 Unauthorized | Log and fall through to Layer 3: |
API authentication failed: API returned 401. The token may be expired or invalid. Regenerate your token at https://id.atlassian.com/manage-profile/security/api-tokens. Falling back to Browser extraction (Layer 3).
| HTTP status | Action |
|---|---|
| 403 Forbidden | Abort (no fallback can bypass permissions): |
API access denied: API returned 403. The user does not have access to this page. Verify page permissions in Confluence.
| HTTP status | Action |
|---|---|
| 404 Not Found | Abort: |
Page not found: API returned 404. The page ID may be incorrect. Verify the URL:
{original_url}.
Last resort. Opens the page in Chrome and extracts content via DOM scraping.
Via ToolSearch:
select:mcp__claude-in-chrome__tabs_context_mcp,mcp__claude-in-chrome__tabs_create_mcp
select:mcp__claude-in-chrome__navigate
select:mcp__claude-in-chrome__javascript_tool
If Chrome MCP tools are not available, abort:
Browser not available: Claude in Chrome MCP is not installed or not running. Install the Claude in Chrome extension and ensure it is connected. No further fallback layers available — cannot fetch this Confluence page.
mcp__claude-in-chrome__tabs_context_mcp(createIfEmpty: true)
mcp__claude-in-chrome__tabs_create_mcp()
mcp__claude-in-chrome__navigate(url: "<full confluence URL>", tabId: <id>)
Read scripts/extract.js from this skill's directory using the Read tool. Then execute it:
mcp__claude-in-chrome__javascript_tool(
action: "javascript_exec",
text: <contents of extract.js>,
tabId: <id>
)
The script returns JSON:
{
"status": "ready",
"totalLength": 52969,
"totalChunks": 6,
"chunkSize": 10000,
"title": "Page Title",
"instructions": "Run window.__confluence.chunk(0), window.__confluence.chunk(1), etc."
}
If the script returns an error field: handle accordingly (login page, empty content, wrong page).
For each chunk from 0 to totalChunks - 1:
mcp__claude-in-chrome__javascript_tool(
action: "javascript_exec",
text: "window.__confluence.chunk(N)",
tabId: <id>
)
Concatenate all chunks into a single Markdown string.
Check that the result is not empty and not a login page. If validation fails:
Browser extraction failed: Could not extract content from the page. Ensure you are logged into Confluence in Chrome and the page has loaded. No further fallback layers available — cannot fetch this Confluence page.
Return to the caller (/bedrock:learn or /bedrock:sync):
title field), or browser extraction (title in JSON)The caller is responsible for saving the content to its target location.
| Rule | Detail |
|---|---|
| Read-only | Never write back to Confluence. |
| No OAuth interactive flows | Use only existing MCP auth, API tokens, or browser sessions. |
| Validate before returning | Do not return empty content, HTML error pages, or login pages. |
| Layer order is sacred | Always try MCP → API → Browser, in that order. Never skip ahead unless a layer is unavailable or user declines. |
| Guide before falling through | If a layer exists but is misconfigured, guide the user before moving to the next layer. |
| Skip rich media silently | Images, diagrams, drawio, and attachment macros are omitted without error. |
| Best-effort | If a layer fails, try the next. If all fail, report and abort — do not retry indefinitely. |
| 403 is terminal | Permission denied cannot be resolved by falling to another layer — abort immediately. |
| Problem | Solution |
|---|---|
| MCP not authenticated | Run mcp__plugin_atlassian_atlassian__authenticate to start OAuth flow |
| MCP tools not found | Atlassian MCP plugin not installed — use API or browser fallback |
| API returns 401 | Token expired — regenerate at https://id.atlassian.com/manage-profile/security/api-tokens |
| API returns 403 | User lacks page access — check Confluence permissions |
| API returns 404 | Wrong page ID — verify URL |
| Chrome extension disconnected | Refresh extension, call tabs_context_mcp(createIfEmpty: true) |
| Browser redirects to login | User not authenticated — log into Confluence in Chrome, retry |
extract.js returns empty | Page may not have loaded — wait and retry, or check if page is empty |
Shortlink URL (/wiki/x/...) with API | Navigate in browser first to resolve full URL with page ID |