AI-Native Document Generation Playbook
How Solanasis AI agents use GWS CLI to generate professional client deliverables autonomously.
1. Overview
This playbook documents the AI-native document generation workflow where Claude Code (or other AI agents) autonomously:
- Research a prospect or client
- Generate content for a deliverable
- Fill a Google Slides/Docs template with the content
- Export to PDF
- Optionally email the deliverable
The workflow uses generate-doc.py as the execution engine and Google Workspace templates as the design layer.
2. When to Use This Workflow
| Scenario | Use Document Generation? | Reason |
|---|---|---|
| Client proposal after discovery call | Yes | Templated proposal with client-specific content |
| Assessment report after engagement | Yes | Structured findings, recommendations |
| Executive one-pager for networking | Yes | Quick bio + capabilities summary |
| Mass email campaign | No | Use Brevo for bulk email with tracking |
| Complex data-heavy report | Maybe | If data exceeds template capacity, use reportlab or python-pptx |
| Internal meeting notes | No | Use Obsidian/markdown directly |
| Solanasis master pitch deck | No | Already built with python-pptx (500+ LOC, complex animations) |
3. End-to-End Example: Prospect Research to Proposal Email
Step 1: Research the Prospect
The AI agent researches the prospect using available tools:
Agent prompt: "Research Acme Corp -- company size, industry, key IT challenges,
decision makers. Prepare data for a Solanasis proposal."
Output: A structured data file (JSON) with prospect information:
{
"CLIENT_NAME": "Acme Corp",
"INDUSTRY": "Healthcare IT",
"COMPANY_SIZE": "150-300 employees",
"ENGAGEMENT_TYPE": "Operational Resilience Baseline (ORB)",
"PRICING": "$18,500",
"EXECUTIVE_SUMMARY": "Acme Corp is a mid-market healthcare IT provider facing increasing regulatory pressure around HIPAA compliance and business continuity. Their current DR posture has not been tested in 18+ months, and they lack a documented incident response plan.",
"FINDINGS": "1. No documented disaster recovery plan\n2. Backup verification not performed regularly\n3. No incident response playbook\n4. Single point of failure in email infrastructure",
"RECOMMENDATIONS": "1. Implement documented DR plan with quarterly testing\n2. Deploy automated backup verification\n3. Create incident response playbook with tabletop exercises\n4. Add email redundancy via secondary MX"
}Save this to a file: proposals/acme-corp-data.json
Step 2: Generate the Proposal
secret run solanasis-scripts -- python generate-doc.py proposal \
--client "Acme Corp" \
--data proposals/acme-corp-data.json \
--output /tmp/solanasis-docs/Acme_Corp_Proposal.pdf \
--email cto@acmecorp.com \
--email-subject "Solanasis Operational Resilience Proposal for Acme Corp"This command:
- Copies the proposal template to a new Google Slides file named “Solanasis Proposal - Acme Corp - 2026-04-11”
- Replaces all
{{PLACEHOLDER}}markers with values from the JSON data file - Exports the completed presentation to PDF
- Emails the PDF to the CTO
Step 3: Verify and Follow Up
The AI agent can verify the output:
- Check that the PDF was created:
ls -la /tmp/solanasis-docs/Acme_Corp_Proposal.pdf - Check file size (should be > 0 bytes, < 10 MB)
- Log the activity in the CRM
4. Template Design Guidelines for AI Agents
When AI agents design or recommend template changes:
Placeholder Density Rules
- Slides: Maximum 3-4 placeholders per slide. Dense slides are hard to read.
- Docs: No limit, but group related placeholders into logical sections.
- Short text placeholders (names, dates, prices): Can be inline with other text.
- Long text placeholders (summaries, findings): Should be in their own paragraph/text box.
Content Formatting
- Line breaks: Use
\nin replacement text for multi-line content. Google Slides/Docs will render these as actual line breaks. - No markdown: Replacement text is plain text. Do not include markdown formatting (**, , etc.) — it will render literally.
- Bullet points: Use
\n-or\n1.for list items. The template’s text style will apply. - Length limits: Keep replacement text under 5000 characters per placeholder. For longer content, split across multiple placeholders.
Image Replacement (POC Discovery)
replaceAllShapesWithImagerequires image URLs that are directly accessible (no authentication wall).- Drive-hosted images work. Set sharing to “Anyone with the link can view” and use the direct download URL format:
https://drive.google.com/uc?export=download&id=FILE_ID - Cloudflare-protected URLs do NOT work. If images are behind Cloudflare Access (OTP gate), the Google API cannot fetch them. Use Google Drive or another publicly accessible host for template images.
Data File Best Practices
- File format: JSON with string values for all placeholders
- Key naming: Match placeholder names without the
{{ }}delimiters (e.g.,CLIENT_NAMEnot{{CLIENT_NAME}}) - Encoding: UTF-8, no BOM
- Validation: The script validates that all required placeholders have values before making API calls
5. Integration with Claude Code Scheduled Tasks
Automated Proposal Generation
An AI agent can be triggered by CRM events to auto-generate proposals:
# In a scheduled task or webhook handler:
import subprocess
import json
# Prospect data from CRM
prospect_data = {
"CLIENT_NAME": "New Prospect Inc",
"INDUSTRY": "Financial Services",
"COMPANY_SIZE": "50-100",
"ENGAGEMENT_TYPE": "Security Assessment",
"PRICING": "$8,500"
}
# Write data file
data_path = "/tmp/prospect-data.json"
with open(data_path, "w") as f:
json.dump(prospect_data, f)
# Generate proposal
result = subprocess.run(
["python", "generate-doc.py", "proposal",
"--client", prospect_data["CLIENT_NAME"],
"--data", data_path,
"--output", f"/tmp/{prospect_data['CLIENT_NAME'].replace(' ', '_')}_Proposal.pdf"],
capture_output=True, text=True,
cwd="/home/zasage/_my/_solanasis/solanasis-scripts"
)
print(result.stdout)Headless Operation
For cron/scheduled tasks, ensure:
GOOGLE_WORKSPACE_CLI_KEYRING_BACKEND=fileis set (the script does this automatically)- GWS CLI is authenticated (credentials at
~/.config/gws/) - Run with secrets:
secret run solanasis-scripts -- python generate-doc.py ...
6. Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| ”gws not found” | GWS CLI not on PATH | npm install -g @googleworkspace/cli |
| ”not authenticated” | OAuth token expired | Re-auth on Windows: gws auth login, copy creds to WSL |
| ”Template ID is still a placeholder” | Config not updated with real IDs | Update config/template_ids.json with actual Google Drive file IDs |
| ”Failed to copy template” | Template ID invalid or no access | Verify the template exists in Google Drive and is shared with the authenticated account |
| ”Failed to export PDF” | Document too large (>10 MB) | Compress images in the template; simplify content |
| Placeholder not replaced | Typo in placeholder name | Ensure exact match including {{ }} and case; use matchCase: true |
| Email not sent | Gmail confirmation prompt | Use --email flag in generate-doc.py; if interactive confirmation blocks, fall back to Brevo SMTP |
| API calls fail with 403 | Required API not enabled in GCP project | Enable the Google Docs API (and/or Slides API, Drive API) in the GCP project at console.cloud.google.com > APIs & Services > Library |
| Image replacement fails | Image URL behind auth wall | Use Drive-hosted images with public sharing; Cloudflare Access-protected URLs cannot be fetched by Google APIs (see Section 4) |
7. Related Documents
- GWS CLI Playbook — Full GWS CLI reference
- GWS CLI Cheat Sheet — Quick command reference
- Template Design Specification — How to design templates
- ORB AI-Native Workflow — ORB-specific workflow
8. Extended Tool Landscape (April 2026)
The GWS CLI pipeline documented above remains the primary tool for client proposals and reports. In April 2026, a comprehensive evaluation of 19 document generation tools was completed. The following resources extend this playbook:
| Resource | Description |
|---|---|
| document-generation-tool-comparison-matrix | Scored comparison of 19 tools across 8 dimensions with tier recommendations |
| typst-setup-and-brand-template-guide | Setup guide for Typst + typst-py: offline branded PDF generation |
| marp-cli-setup-and-brand-theme-guide | Setup guide for Marp CLI: rapid Markdown-to-slides |
| pandoc-setup-and-brand-pipeline-guide | Setup guide for Pandoc: multi-format output from Markdown |
| document-generation-skills-roadmap | Prioritized Claude Code skills and agents to build next |
When to Use Which Tool
| Need | Tool | Guide |
|---|---|---|
| Client proposal (template-driven) | GWS CLI + Google Docs | This playbook (above) |
| Pitch deck (programmatic) | python-pptx | generate-pitch-deck.py |
| Offline branded PDF | Typst + typst-py | typst-setup-and-brand-template-guide |
| Quick internal slides | Marp CLI | marp-cli-setup-and-brand-theme-guide |
| Multi-format from Markdown | Pandoc | pandoc-setup-and-brand-pipeline-guide |
| DOCX deliverable | Pandoc + reference doc | pandoc-setup-and-brand-pipeline-guide |
Last updated: 2026-04-12