skills/rdc-brochurify/SKILL.md
Orchestrate a Brochurify job from source ingest through delivered PDF, using six parallel-dispatched typed sub-agents and the convergence loop. Use this skill EVERY TIME the user invokes Brochurify directly via "brochurify this", "make a brochure from", "convert this to a brochure PDF", or "rdc:brochurify". Also runs automatically when a job arrives from the broker via monkey_dispatch. The skill enforces D-001 through D-016 from the brochurify DECISIONS-LOG.
npx skillsauth add LIFEAI/rdc-skills rdc-brochurifyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The orchestrator dispatches six waves of typed sub-agents in sequence. Each wave has a clear input contract, an output contract, and a parallelism profile.
The orchestrator accepts a job payload:
{
"job_id": "uuid",
"source": {
"kind": "url" | "html" | "docx" | "md" | "jsx" | "corpus",
"ref": "https://..." | "file:///path/..." | "<html>..." | { corpus_query }
},
"mode": "read-only" | "cosmetic" | "editorial" | "creative",
"theme": "prt" | "place-fund" | "zoen" | "evergreen" | "editorial-neutral",
"page_size": "letter" | "a4" | "legal" | "digest" | "tabloid",
"brief": "optional natural-language brief for editorial/creative modes",
"org_id": "uuid",
"user_id": "uuid"
}
brochurify-output bucket) with a signed URLbrochure_jobs with:
pdf_r2_key, pdf_urlfinal_grade, page_scores (jsonb array)iter (iteration count reached)trace (jsonb log of all 6 waves × iterations)Goal: Normalize any source into kit-compliant JSX.
Sub-agent: ingest-author (typed agent with the lifeai-brochure-author skill loaded)
Inputs: raw source from job payload
Outputs: working/draft.jsx (kit-compliant JSX) + working/assets/ (extracted images)
Per-source handling:
url — fetch via Playwright (whitelist) or structural-summary mode (open web)html — direct ingest, strip scripts/iframes/adsdocx — pandoc to HTML, then ingestmd — render to HTML, then ingestjsx — pre-built input; skip to validatecorpus — Creative mode only; corpus reader + Author-Mode-* sub-agentFailure mode: if ingest cannot map content to kit primitives, raise a structured error with the unmappable content range and ask the user to clarify.
Goal: Confirm the JSX passes static and structural validation before render.
Sub-agent: none — runs pnpm bk-lint working/draft.jsx directly
Behavior:
Every failure here writes to enhancement-log.jsonl with:
src: "ingest-author"fail_layer: "static" or fail_layer: "structural"Goal: Produce a first-iteration PDF and per-page screenshots.
Sub-agent: none — runs Paged.js via Playwright headless
Process:
working/bundle.htmlpagedjs:rendered eventworking/paged.htmlworking/pages/page-{N}.pngworking/iter-{i}.pdfFailure mode: if Paged.js fails to converge (rare; usually a kit bug), fall back to print-to-PDF without paged-media polyfill, flag as low-quality iteration, continue.
Goal: Score each page against the 7-dimension rubric.
Sub-agent: vision-grader — dispatched once per page in parallel.
Per-page inputs:
Per-page outputs (structured):
{
"page": 3,
"grade": 82,
"dimensions": {
"R1_margin_integrity": 95,
"R2_bottom_slack": 70,
"R3_heading_breathing": 85,
"R4_widows_orphans": 100,
"R5_image_placement": 80,
"R6_table_integrity": 100,
"R7_text_density": 75
},
"issues": [
{"dim": "R2", "desc": "tail gap 1.1in below last paragraph", "fix_hint": "compress paragraph or push next-page content"}
]
}
Document grade: min(page_grades) per D-013.
Convergence:
partial=true flagGoal: Produce a corrected JSX that addresses the issues from Wave 4.
Sub-agent: patch-author — dispatched once per low-graded page in parallel.
Mode restrictions:
read-only — only break, sizing, spacing patches allowedcosmetic — read-only patches + image resize, caption compression, paragraph splits at sentence boundarieseditorial — cosmetic + paragraph rewrites within 15% character or 25% word reductioncreative — editorial + free composition (the authoring sub-agent fully active)Patch types:
force-break-before — insert page break before an elementadjust-spacing — change Stack/Cluster gap variantresize-figure — change Figure width/height variantcompress-paragraph — drop or merge a sentence (cosmetic+ only)rewrite-paragraph — full rewrite (editorial+ only)rebalance-cluster — split a Cluster onto two pageschange-affinity — adjust an affinity propEach patch is applied to working/draft.jsx, the validator re-runs, then Wave 3 renders again.
Edit tracking (editorial mode): every paragraph rewrite is logged with before/after to working/edits.jsonl. The completion record includes this log.
Goal: Final PDF, signed URL, completion record.
Process:
brochurify-output/{org_id}/{job_id}.pdfbrochure_jobs row:
UPDATE brochure_jobs SET
status = 'completed',
iter = $iter,
current_grade = $grade,
page_scores = $pageScoresJson,
pdf_r2_key = $r2Key,
pdf_url = $signedUrl,
completed_at = now()
WHERE id = $jobId;
{type:"complete", url, grade, iter} to brokerenhancement-log.jsonlEvery wave appends to working/trace.jsonl:
{"ts":"...","wave":1,"agent":"ingest-author","iter":1,"status":"start"}
{"ts":"...","wave":1,"agent":"ingest-author","iter":1,"status":"complete","blocks":127}
{"ts":"...","wave":2,"iter":1,"status":"complete","errors":0}
{"ts":"...","wave":3,"iter":1,"status":"complete","pages":8,"render_ms":2340}
{"ts":"...","wave":4,"iter":1,"page":1,"grade":85,"status":"complete"}
{"ts":"...","wave":4,"iter":1,"page":2,"grade":68,"status":"complete","issues":2}
...
This trace is stored in brochure_jobs.payload.trace for forensic review.
Typical 8-page brochure, 2 iterations: ~1 + 16 + 4 = ~21 model calls total. All on Max plan. Zero per-job API cost.
Exceeding any cap → job fails with structured error; no partial billing.
| Failure | Recovery | |---|---| | Validator fails repeatedly | Try page-size change (Letter → Legal → Digest) before failing job | | Vision agent disagrees with itself | Lock grade after 3 iterations of same page; mark "best-effort" | | Convergence not reached at iter=10 | Ship best version, flag low-graded pages, log to enhancement | | Paged.js render fails | Fall back to direct PDF; flag low-quality iteration | | R2 upload fails | Retry 3x then fall back to Supabase storage URL |
Direct user invocation: rdc:brochurify <source-url-or-path> [--mode] [--theme] [--page-size]
Programmatic invocation: a monkey_dispatch job arriving with skill="brochurify" and the job payload as args.
Either path executes the same 6-wave loop. Direct user invocation also returns the trace and the PDF URL to the calling session.
development
Read recent enhancement-log entries, cluster failures by pattern, generate candidate verifier rules, test them against the known-good corpus and the failure corpus, and propose pull requests adding the highest-confidence rules to forbidden-patterns.json. Use this skill on a nightly cadence (3 AM PT), or manually when the user says "extract verifier rules", "promote enhancement log", "what new rules should we add", or after a significant brochure run produced many failures.
devops
The mandatory contract for authoring brochure JSX using @lifeai/brochure-kit. Use this skill EVERY TIME any AI engine (Claude, Cursor, Copilot, /design, Cowork, v0) generates JSX intended for the Brochurify pipeline — whether the user says "write a brochure," "make a one-pager," "draft a PDF report," or any equivalent. Also trigger when a file imports from @lifeai/brochure-kit. Failing to read this skill before authoring is a defect.
testing
Usage `rdc:housekeeping [--fix]` — Weekly maintenance audit: directory structure verification, PUBLISH.md URL validation, CLAUDE.md freshness, orphan detection, places compliance, and stale version scan. Produces `.rdc/reports/YYYY-MM-DD-housekeeping.md`. With `--fix`, auto-remediate safe issues.
tools
Convert Office documents to/from Markdown with the build-corpus CLI: .docx/.pptx/.ppt → Markdown (Word OMML equations become KaTeX-readable TeX; tables, images, headings preserved), and Markdown → Word (.docx) where inline $...$ and display $$...$$ LaTeX become NATIVE Office Math (OMML) that Word renders as real equations. Use this skill whenever the user asks to convert a Word/PowerPoint document to Markdown, build a Markdown corpus from Office files, turn Markdown into a .docx (optionally with a .dotx template), or "open the report" to edit. Install build-corpus straight from GitHub and run it in the session.