eliasoulkadi/shokunin/kagen
Claude Code and agent skill by eliasoulkadi/shokunin
- community
Checking that the SKILL.md file is still in the repository.
Convert Kami HTML templates to production-grade PDF via Chromium/Playwright. Complements Kami (design) with PDF rendering. Use when user asks to generate PDF files, render HTML to PDF, or export documents.
Install
npx vskill@latest install eliasoulkadi/shokunin/kagenSKILL.md
kagen · 紙源
紙源 · かげん - paper source. PDF generation companion to Kami.
Kami designs, Kagen ships. Converts Kami HTML templates to production-grade PDF using Chromium (Playwright), bypassing WeasyPrint's Windows limitations.
Why Kagen
| Problem | Solution | |
|---|---|---|
| WeasyPrint doesn't work on Windows (no GTK) | Kagen uses Playwright/Chromium — works everywhere | |
| WeasyPrint cold-start ~630ms per render | Playwright warm ~13ms per render | |
| WeasyPrint can't execute JS | Chromium renders fully (charts, dynamic content) | |
| wkhtmltopdf is deprecated and unmaintained | Playwright is actively maintained by Microsoft |
Based on benchmarks (pdf4.dev 2026), engineering discussions (HN, Stack Overflow, BrowserStack), and production experience from DocRaptor, customjs.space, and print-css.rocks.
Prerequisites
- Node.js 20+
- Playwright (
npx playwrightauto-installs on first use) - Chromium browser installed (
npx playwright install chromium) - Kami HTML templates (any valid HTML with print CSS)
Quick start
Or from Node.js:
Production settings (from professional research)
Page options
Critical CSS rules for reliable PDF output
Visual patterns by document type
Each document type needs its own set of visual patterns. Apply accordingly:
| Type | Required patterns | Optional patterns | |
|---|---|---|---|
| Pentest / Security report | Severity badges (red/orange/green), risk bar, code blocks with left border, impact/remediation boxes | Finding-header with metadata, findings table with badges | |
| One-pager / Executive summary | Glance grid (4 metrics), lead paragraph, takeaway box, cover with large title + decorative line | Callout for key data point, footer with contact | |
| White paper / Long doc | Chapter breaks in dense sections, table of contents, callouts, keep-together on critical blocks | Quotes, diagrams, appendix | |
| Letter | Wide margins (25mm), formal greeting and closing, no columns, no tables | Letterhead, signature | |
| Resume | Dense body (9.2pt), metric row, project bullets with action + result | Timeline, skills grid | |
| Slides | Assertion-evidence titles, one idea per slide, one-line bullets, pinned callout | Code cards, 2x2 table |
Rule: if the document type isn't in the table, choose the closest one and adapt.
Near-empty pages prevention
Nothing looks more amateur than a page with 2 lines. Causes and solutions:
| Cause | Solution | Auto-detection | |
|---|---|---|---|
| Heading with 1 short paragraph at the end | Merge with previous section | If a chapter has only 1 h2 + 1 p, it doesn't deserve its own page | |
break-before: page on every section | Only use on chapters with >1/3 page of content | Count paragraphs + tables + lists. If they add up to less than 5 elements, don't force a break | |
break-inside: avoid on large block that doesn't fit | Relax break-inside or split the block | If a keep-together measures more than 1 page, don't force it | |
| Source list at the end spilling onto a separate page | Move to consolidated sources chapter | Sources go in one place, not repeated in each chapter |
AI anti-patterns in documents
Validate that content inherited from Kami doesn't have these marks:
| Anti-pattern | Problem | Fix | |
|---|---|---|---|
Repeated em dash — as label/value separator | Black Box — no credentials, multiple lines in a row | Parentheses, comma, colon. The dash is for genuine asides, not for separating labels | |
| Uniform tables without color | All rows identical, no visual indication of severity or priority | Color badges, subtle zebra rows, highlighted first column | |
| Code blocks without contrast | They blend with the body, don't look like code | Left blue border, ivory background, monospace, generous padding | |
| Same structure on every page | Every page is title + table or title + list | Vary: finding box, risk bar, flowchart, callout. Alternate rhythm | |
| Claims without source | "LLMs hallucinate 15-20%" without attribution | "According to Vectara HHEM 2026, LLMs..." |
Best practices from professionals
| Practice | Source | Why | |
|---|---|---|---|
Always set printBackground: true | BrowserStack, Playwright docs | Kami uses parchment bg #f5f4ed — Chromium strips it by default | |
Use file:// protocol | Stack Overflow, DocuPotion | Avoids auth/CORS issues with local files | |
Set waitUntil: 'networkidle' | BrowserStack | Ensures fonts, CSS fully loaded | |
| Lock browser version in CI | BrowserStack, blog.rasc.ch | Chromium updates can change rendering | |
Use @page margins, not Playwright margins | print-css.rocks, CSS Paged Media spec | CSS margins are more predictable for paged media | |
-webkit-print-color-adjust: exact | MDN, Chromium docs | Critical for parchment backgrounds and brand colors | |
| Reuse browser instance (warm) | pdf4.dev benchmark | 42ms → 3ms speedup (14x) | |
| Validate PDF visually in CI | BrowserStack | Page count, whitespace, font check |
Warm mode (production pipeline)
Font embedding
Chromium embeds system fonts by default. For custom fonts (like TsangerJinKai02 in Kami):
Place font files relative to the HTML and use relative src paths. Chromium resolves them from the HTML file's directory.
Troubleshooting
| Problem | Fix | |
|---|---|---|
| White background instead of parchment | Add printColorAdjust: exact in CSS and printBackground: true in JS | |
| Fonts not rendering | Use relative paths in @font-face, check font file exists | |
| Page breaks wrong | Check break-inside: avoid on tables, pre, callout | |
| Near-empty page (2 lines alone) | Merge short section with previous; avoid break-before: page on light chapters | |
| Content overflow | Use page-break-inside: avoid on large blocks | |
| Chinese chars as boxes | Include CJK font in @font-face or use system CJK fallback | |
| PDF too large | Remove unnecessary images, compress embedded fonts | |
| Slow first render | Keep browser instance alive (warm mode) |
CSS visual pattern snippets
Concrete patterns to include in the HTML by document type:
Self-review protocol (mandatory)
Don't generate the PDF without passing this checklist. Each item is a real failure documented in previous iterations.
Structural (blocking)
- [ ] Each chapter has enough content to fill >1/3 of a page
- [ ] No sections with just heading + 1 short paragraph (merge)
- [ ] No near-empty pages (2 lines alone)
- [ ]
break-before: pageonly on chapters with dense content
Visual (high priority)
- [ ] Visual elements match the document type (badges, risk bars, code blocks, etc.)
- [ ] Tables have proper styling (optional zebra, padding, clear headers)
- [ ] Code blocks are distinguishable from body (border, background, monospace)
- [ ] No repeated em dashes
—used as label/value separators - [ ] There's variety in visual rhythm (not all pages the same)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.pack/skills/kagen/SKILL.md
Popularity
- Repository stars
- 91
- Repository forks
- 10
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/eliasoulkadi/shokunin/kagen)