Claude DOCX Generator
Paste & Produce — turn AI-generated JavaScript into real .docx files instantly, without editing a single file path.
Why This Exists
Scenario: AI Timed Out, But the DOCX Still Needs to Exist
You're working with an AI assistant to generate a 40-page report, proposal, thesis draft, or technical document. The AI successfully writes the JavaScript that builds the DOCX using the docx package — hundreds of lines of generated content. But then one of these things happens:
Session Timeout
The AI session times out before producing the actual .docx file.
Environment Paths
The generated script contains an environment-specific path such as /mnt/data/report.docx that doesn't exist on your machine.
Platform Mismatch
The code came from Claude, ChatGPT, Gemini, or another platform that saved files to a location you can't access locally.
You just want the document now — not another round of path fixing and debugging.
Instead of editing file paths throughout the script, you paste the generated code into paste_here.js and run node paste_here.js. This tool automatically intercepts the DOCX file write operation and redirects the output into the local outputs/ directory.
When an AI can generate the document code but cannot deliver the document itself, this repository bridges the gap.
Quick Facts
outputs/ is in .gitignore so generated DOCX files won't be committed accidentally.
Quick Start
Install the tool
npm install claude-docx-generator
Paste your DOCX-generating code
Paste your docx-generating code into paste_here.js. It already requires runner.js which redirects Buffer writes into outputs/.
Run it
node paste_here.js
# or
npm run paste
# or directly via npx
npx claude-docx-generator
How It Works
Many docx scripts follow this pattern:
Packer.toBuffer(doc).then(buffer =>
fs.writeFileSync('/some/absolute/path/my.docx', buffer)
);
runner.js monkey-patches fs.writeFileSync and fs.writeFile at runtime. When the patched functions detect a Buffer (the docx payload), they replace the destination path with outputs/<basename> — so you don't have to edit the original code.
File Map
paste_here.js
Development template where you paste code
runner.js
Intercepts Buffer writes and redirects into outputs/
generate2.js
Example generator included in the repo
generate2_to_docx.js
Example DOCX exporter
Best Practices
- Keep
outputs/small — it contains generated binary files and is git-ignored. - If your pasted script writes streams, custom promises, or uses other FS APIs, open an issue or ask to extend
runner.js.