Document Generator Process
Core process skill for generating professional business documents. Defines the end-to-end workflow from user request to delivered file.
Generation Workflow
Step 1: CLASSIFY
Determine the document type from the user's request:
| Keywords |
Document Type |
Default Format |
| proposal, bid, offer, pitch |
proposal |
DOCX |
| invoice, bill, receipt |
invoice |
PDF |
| estimate, quotation, quote, pricing |
estimate |
PDF |
| report, analysis, findings, research |
report |
DOCX |
| presentation, slides, deck, pitch deck |
presentation |
PPTX |
| contract, agreement, MSA, terms |
contract |
DOCX |
| NDA, non-disclosure, confidentiality |
nda |
PDF |
| act, certificate of completion |
act |
PDF |
| convert, transform, export |
conversion |
varies |
Step 1.5: CHECK USER PREFERENCES (MANDATORY)
You MUST check preferences before any generation. Scripts will reject requests if preferences are missing.
cat ~/.document-generator/preferences.json 2>/dev/null
- File missing → STOP. Run the onboarding interview (see user-preferences skill) before proceeding.
- File exists → load style preset, default company, language, and currency to pre-fill fields
Step 2: GATHER
Collect required data from the user. Each document type has specific required and optional fields.
Refer to the document-templates skill for complete field checklists per document type. It defines exactly which fields are required, which are optional, and the expected format for each.
If user preferences are loaded, pre-fill company info, currency, and language from the stored profile. Only ask for fields that aren't already known.
Step 3: SELECT FORMAT & ENGINE
| Type |
Format |
Engine |
Script |
Notes |
| Proposal |
DOCX |
docx-js |
generate_docx.js |
Default. Styled by the plugin (fonts, colours, cover page) |
| Proposal |
DOCX |
pandoc |
generate_docx.js (engine: "pandoc") |
Same HTML as the PDF, but pandoc drops the CSS: structure only, look from assets/reference.docx. Requires pandoc |
| Proposal (final) |
PDF |
playwright |
generate_pdf.js |
Full-page cover, TOC, sections |
| Invoice |
PDF |
playwright |
generate_pdf.js |
Always PDF |
| Report |
DOCX |
docx-js |
generate_docx.js |
Default. Styled by the plugin (fonts, colours, cover page) |
| Report (final) |
PDF |
playwright |
generate_pdf.js |
Full-page cover, TOC, sections |
| Presentation |
PPTX |
pptxgenjs |
generate_pptx.js |
Always PPTX |
| Contract |
DOCX |
docx-js |
generate_docx.js |
Default for editable contracts |
| Contract (final) |
PDF |
playwright |
generate_pdf.js |
Legal-grade formatting |
| Estimate |
PDF |
playwright |
generate_pdf.js |
Phase-based pricing, timeline |
| NDA |
PDF |
playwright |
generate_pdf.js |
Mutual or unilateral |
| Act / Certificate |
PDF |
playwright |
generate_pdf.js |
Multi-language support |
Engine selection for DOCX:
docx-js (default): Always works, full feature support (images, complex tables, headers/footers)
pandoc: Converts the same HTML templates to DOCX, but pandoc ignores CSS (inline style and <style> alike). Only the structure (headings, lists, tables) matches the PDF; fonts, colours and spacing come from assets/reference.docx. It does not look like the PDF — do not promise that. Set "engine": "pandoc" in input JSON. Requires pandoc installed (which pandoc).
Step 4: BUILD JSON Input
- Read the template file from
${CLAUDE_PLUGIN_ROOT}/templates/{type}_template.json
- Merge user data into the template structure
- Set
outputPath to: {cwd}/{type}_{sanitized_title}_{YYYY-MM-DD}.{ext}
- Write the complete JSON input to a temp file:
{cwd}/.doc_input.json
Input JSON structure:
{
"type": "proposal|invoice|estimate|report|contract|nda|act",
"engine": "playwright|pdfkit",
"outputPath": "./proposal_acme_2026-03-17.docx",
"template": { "...from template file..." },
"data": { "...user provided data..." }
}
Step 5: GENERATE
Run the appropriate script via Bash (${CLAUDE_PLUGIN_ROOT} is the plugin root; Claude Code substitutes the installed path — do not search for the plugin or cd into it):
node "${CLAUDE_PLUGIN_ROOT}/scripts/generate_docx.js" /absolute/path/to/.doc_input.json
Check dependencies first (use the centralized checker):
node "${CLAUDE_PLUGIN_ROOT}/scripts/check_deps.js"
If ready: false, show what's missing and ask user permission to install.
Script output (JSON to stdout):
- Success:
{ "success": true, "outputPath": "/abs/path/to/file.docx", "size": 12345 }
- Failure:
{ "success": false, "error": "description" }
Step 6: DELIVER
- Parse the script's JSON output
- Confirm the file exists and report its path and size
- Offer follow-up actions: "Want me to convert this to PDF?" or "Want to make changes?"
Format Conversion
For converting between formats, use the pandoc wrapper:
"${CLAUDE_PLUGIN_ROOT}/scripts/convert.sh" input.md output.pdf
Supported conversions: MD->PDF, MD->DOCX, MD->HTML, DOCX->PDF, DOCX->MD, HTML->PDF, HTML->DOCX, MD->PPTX
Error Handling
| Error |
Resolution |
warning: ONBOARDING_NOT_DONE |
Document generated with defaults. Offer to run /document-generator-ops:setup for custom styling |
| Module not found (docx, playwright, etc.) |
A marketplace install ships the npm modules (Claude Code installs them from package-lock.json). If the plugin is loaded in place (--plugin-dir), run npm ci in the plugin directory |
Playwright browser missing (playwright_browsers in check_deps.js output) |
npx playwright install chromium — the browser goes to the global Playwright cache and survives plugin updates. Without a browser, "engine": "pdfkit" still makes a simple PDF |
| pandoc not installed |
brew install pandoc (macOS) or apt install pandoc (Linux) |
| No PDF engine for pandoc |
brew install weasyprint / sudo apt install weasyprint (recommended), or Typst (brew install typst); pip install weasyprint also works where pip is not locked down (PEP 668). wkhtmltopdf is deprecated in pandoc and is not used |
| Playwright browser launch failed |
Add --no-sandbox flag (already in script) |
| Output file not created |
Check script stderr, verify output directory exists |
| Margin format mismatch |
Scripts auto-normalize (twips ↔ CSS units) via utils.js |
File Naming Convention
Pattern: {type}_{title}_{date}.{ext}
Sanitize title: lowercase, replace spaces with underscores, remove special characters, max 50 chars.
Examples:
proposal_acme_consulting_2026-03-17.docx
invoice_inv-001_2026-03-17.pdf
report_q1_analysis_2026-03-17.docx
presentation_product_launch_2026-03-17.pptx
contract_service_agreement_2026-03-17.docx
act_akt-001_2026-03-17.pdf
1---2name: document-generator-23description: Document generation process -- format selection, data collection, script invocation, and delivery. This skill should be used when generating any document (proposal, invoice, estimate, report, presentation, contract, NDA, certificate of completion), deciding which format or engine to use, or running generation scripts.4metadata:5 source: https://skillmd.com/skills/agents-store/document-generator-26---78# Document Generator Process910Core process skill for generating professional business documents. Defines the end-to-end workflow from user request to delivered file.1112## Generation Workflow1314### Step 1: CLASSIFY1516Determine the document type from the user's request:1718| Keywords | Document Type | Default Format |19|----------|--------------|----------------|20| proposal, bid, offer, pitch | **proposal** | DOCX |21| invoice, bill, receipt | **invoice** | PDF |22| estimate, quotation, quote, pricing | **estimate** | PDF |23| report, analysis, findings, research | **report** | DOCX |24| presentation, slides, deck, pitch deck | **presentation** | PPTX |25| contract, agreement, MSA, terms | **contract** | DOCX |26| NDA, non-disclosure, confidentiality | **nda** | PDF |27| act, certificate of completion | **act** | PDF |28| convert, transform, export | **conversion** | varies |2930### Step 1.5: CHECK USER PREFERENCES (MANDATORY)3132**You MUST check preferences before any generation. Scripts will reject requests if preferences are missing.**3334```bash35cat ~/.document-generator/preferences.json 2>/dev/null36```3738- **File missing** → **STOP. Run the onboarding interview** (see **user-preferences** skill) before proceeding.39- **File exists** → load style preset, default company, language, and currency to pre-fill fields4041### Step 2: GATHER4243Collect required data from the user. Each document type has specific required and optional fields.4445Refer to the **document-templates** skill for complete field checklists per document type. It defines exactly which fields are required, which are optional, and the expected format for each.4647If user preferences are loaded, pre-fill company info, currency, and language from the stored profile. Only ask for fields that aren't already known.4849### Step 3: SELECT FORMAT & ENGINE5051| Type | Format | Engine | Script | Notes |52|------|--------|--------|--------|-------|53| Proposal | DOCX | docx-js | `generate_docx.js` | Default. Styled by the plugin (fonts, colours, cover page) |54| Proposal | DOCX | pandoc | `generate_docx.js` (engine: "pandoc") | Same HTML as the PDF, but pandoc drops the CSS: structure only, look from `assets/reference.docx`. Requires pandoc |55| Proposal (final) | PDF | playwright | `generate_pdf.js` | Full-page cover, TOC, sections |56| Invoice | PDF | playwright | `generate_pdf.js` | Always PDF |57| Report | DOCX | docx-js | `generate_docx.js` | Default. Styled by the plugin (fonts, colours, cover page) |58| Report (final) | PDF | playwright | `generate_pdf.js` | Full-page cover, TOC, sections |59| Presentation | PPTX | pptxgenjs | `generate_pptx.js` | Always PPTX |60| Contract | DOCX | docx-js | `generate_docx.js` | Default for editable contracts |61| Contract (final) | PDF | playwright | `generate_pdf.js` | Legal-grade formatting |62| Estimate | PDF | playwright | `generate_pdf.js` | Phase-based pricing, timeline |63| NDA | PDF | playwright | `generate_pdf.js` | Mutual or unilateral |64| Act / Certificate | PDF | playwright | `generate_pdf.js` | Multi-language support |6566**Engine selection for DOCX:**67- `docx-js` (default): Always works, full feature support (images, complex tables, headers/footers)68- `pandoc`: Converts the same HTML templates to DOCX, but pandoc ignores CSS (inline `style` and `<style>` alike). Only the structure (headings, lists, tables) matches the PDF; fonts, colours and spacing come from `assets/reference.docx`. It does **not** look like the PDF — do not promise that. Set `"engine": "pandoc"` in input JSON. Requires pandoc installed (`which pandoc`).6970### Step 4: BUILD JSON Input71721. Read the template file from `${CLAUDE_PLUGIN_ROOT}/templates/{type}_template.json`732. Merge user data into the template structure743. Set `outputPath` to: `{cwd}/{type}_{sanitized_title}_{YYYY-MM-DD}.{ext}`754. Write the complete JSON input to a temp file: `{cwd}/.doc_input.json`7677**Input JSON structure:**78```jsonc79{80 "type": "proposal|invoice|estimate|report|contract|nda|act",81 "engine": "playwright|pdfkit",82 "outputPath": "./proposal_acme_2026-03-17.docx",83 "template": { "...from template file..." },84 "data": { "...user provided data..." }85}86```8788### Step 5: GENERATE8990Run the appropriate script via Bash (`${CLAUDE_PLUGIN_ROOT}` is the plugin root; Claude Code substitutes the installed path — do not search for the plugin or `cd` into it):91```bash92node "${CLAUDE_PLUGIN_ROOT}/scripts/generate_docx.js" /absolute/path/to/.doc_input.json93```9495**Check dependencies first (use the centralized checker):**96```bash97node "${CLAUDE_PLUGIN_ROOT}/scripts/check_deps.js"98```99If `ready: false`, show what's missing and ask user permission to install.100101**Script output** (JSON to stdout):102- Success: `{ "success": true, "outputPath": "/abs/path/to/file.docx", "size": 12345 }`103- Failure: `{ "success": false, "error": "description" }`104105### Step 6: DELIVER1061071. Parse the script's JSON output1082. Confirm the file exists and report its path and size1093. Offer follow-up actions: "Want me to convert this to PDF?" or "Want to make changes?"110111## Format Conversion112113For converting between formats, use the pandoc wrapper:114```bash115"${CLAUDE_PLUGIN_ROOT}/scripts/convert.sh" input.md output.pdf116```117118Supported conversions: MD->PDF, MD->DOCX, MD->HTML, DOCX->PDF, DOCX->MD, HTML->PDF, HTML->DOCX, MD->PPTX119120## Error Handling121122| Error | Resolution |123|-------|-----------|124| `warning: ONBOARDING_NOT_DONE` | Document generated with defaults. Offer to run `/document-generator-ops:setup` for custom styling |125| Module not found (docx, playwright, etc.) | A marketplace install ships the npm modules (Claude Code installs them from `package-lock.json`). If the plugin is loaded in place (`--plugin-dir`), run `npm ci` in the plugin directory |126| Playwright browser missing (`playwright_browsers` in `check_deps.js` output) | `npx playwright install chromium` — the browser goes to the global Playwright cache and survives plugin updates. Without a browser, `"engine": "pdfkit"` still makes a simple PDF |127| pandoc not installed | `brew install pandoc` (macOS) or `apt install pandoc` (Linux) |128| No PDF engine for pandoc | `brew install weasyprint` / `sudo apt install weasyprint` (recommended), or Typst (`brew install typst`); `pip install weasyprint` also works where pip is not locked down (PEP 668). `wkhtmltopdf` is deprecated in pandoc and is not used |129| Playwright browser launch failed | Add `--no-sandbox` flag (already in script) |130| Output file not created | Check script stderr, verify output directory exists |131| Margin format mismatch | Scripts auto-normalize (twips ↔ CSS units) via `utils.js` |132133## File Naming Convention134135Pattern: `{type}_{title}_{date}.{ext}`136137Sanitize title: lowercase, replace spaces with underscores, remove special characters, max 50 chars.138139Examples:140- `proposal_acme_consulting_2026-03-17.docx`141- `invoice_inv-001_2026-03-17.pdf`142- `report_q1_analysis_2026-03-17.docx`143- `presentation_product_launch_2026-03-17.pptx`144- `contract_service_agreement_2026-03-17.docx`145- `act_akt-001_2026-03-17.pdf`