ZenUml/conf-app / .claude/skills/download-attachment
download-attachment
VerifiedDownload a Confluence page attachment to local disk. First explains the 5 ways an attachment can be downloaded (so the developer learns the trade-offs), then automates the easiest one. Use when investigating customer issues that require the original PNG/PDF/file backed up against a customContent, recovering source from PNG iTXt embedded metadata, or any time a Confluence attachment needs to land on disk. Triggers on "download the attachment", "get the PNG", "save attachment to disk", "extract iTXt", "pull attachment", or any follow-up step after `find-macros-on-page` reveals a backup attachment.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.1 KB |
| scripts/download.mjs | script | 4.3 KB |
scripts/download.mjs
View on GitHub#!/usr/bin/env node
// Download a Confluence attachment to a local path.
//
// Strategy: open the download URL in the user's default browser (which has
// the live Atlassian session), then watch the Downloads folder for the new
// file and move it to --out. Works on any tenant the user can view in their
// browser, including customer sites — no API token required.
//
// Usage:
// node download.mjs --site <site> --page <pageId> --filename <name> [--out <path>] [--timeout-sec <n>]
//
// --site accepts short names (lite-dev, lite-stg, zenuml-stg, zenuml) or any
// hostname. --out defaults to the current working directory.
import { existsSync, statSync, renameSync, readdirSync, mkdirSync } from "node:fs";
import { join, basename, dirname, resolve } from "node:path";
import { homedir } from "node:os";
import { spawn } from "node:child_process";
import { parseArgs } from "node:util";
const KNOWN = {
"lite-dev": "lite-dev.atlassian.net",
"lite-stg": "lite-stg.atlassian.net",
"zenuml-stg": "zenuml-stg.atlassian.net",
"zenuml": "zenuml.atlassian.net",
};
const { values: args } = parseArgs({
options: {
site: { type: "string" },
page: { type: "string" },
filename: { type: "string" },
out: { type: "string" },
"timeout-sec": { type: "string" },
},
});
if (!args.site || !args.page || !args.filename) {
fail("Usage: --site <site> --page <pageId> --filename <name> [--out <path>] [--timeout-sec 30]");
}
const host = KNOWN[args.site] || (args.site.includes(".") ? args.site : `${args.site}.atlassian.net`);
const url = `https://${host}/wiki/download/attachments/${args.page}/${encodeURIComponent(args.filename)}?version=1`;
const downloads = join(homedir(), "Downloads");
const targetDir = args.out ? (args.out.endsWith("/") ? args.out : args.out.includes(".") ? dirname(args.out) : args.out) : process.cwd();
const targetName = args.out && args.out.includes(".") ? basename(args.out) : args.filename;
const targetPath = resolve(targetDir, targetName);
const timeoutMs = Math.max(5, Number(args["timeout-sec"] || 30)) * 1000;
if (!existsSync(downloads)) fail(`Downloads folder not found at ${downloads}`);
mkdirSync(targetDir, { recursive: true });
// Snapshot files in Downloads before opening URL, so we can spot the new one.
const before = new Set(readdirSync(downloads));
const startMtime = Date.now();
console.error(`# opening ${url}`);
console.error(`# watching ${downloads} for ${args.filename} (timeout ${timeoutMs / 1000}s)`);
// macOS: `open`. Linux: `xdg-open`. Windows: `start`.
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
const cmdArgs = process.platform === "win32" ? ["/c", "start", "", url] : [url];
spawn(cmd, cmdArgs, { stdio: "ignore", detached: true }).unref();
// Poll for a new file matching args.filename (or any new file if not present).
const deadline = Date.now() + timeoutMs;
let found = null;
while (Date.now() < deadline) {
await sleep(500);
const after = readdirSync(downloads);
// Prefer the exact filename if it appeared post-snapshot.
const exact = after.find(f => f === args.filename && !before.has(f));
const exactMtimeOk = exact && statSync(join(downloads, exact)).mtimeMs >= startMtime;
if (exact && exactMtimeOk) { found = exact; break; }
// Otherwise any new file appearing during the watch window
const candidates = after.filter(f => !before.has(f) && !f.endsWith(".crdownload") && !f.endsWith(".download"))
.map(f => ({ f, m: statSync(join(downloads, f)).mtimeMs }))
.filter(x => x.m >= startMtime)
.sort((a, b) => b.m - a.m);
if (candidates.length === 1) { found = candidates[0].f; break; }
if (candidates.length > 1) {
// Multiple new files appeared — prefer one whose name matches args.filename loosely
const match = candidates.find(c => c.f.toLowerCase().includes(args.filename.toLowerCase().split(".")[0]));
if (match) { found = match.f; break; }
}
}
if (!found) fail(`Timed out after ${timeoutMs / 1000}s. Did the download complete? Check ${downloads}.`);
const src = join(downloads, found);
renameSync(src, targetPath);
console.error(`# downloaded -> ${targetPath}`);
console.log(targetPath);
function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
function fail(msg) { console.error(msg); process.exit(1); }
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |