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:

  1. Research a prospect or client
  2. Generate content for a deliverable
  3. Fill a Google Slides/Docs template with the content
  4. Export to PDF
  5. 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

ScenarioUse Document Generation?Reason
Client proposal after discovery callYesTemplated proposal with client-specific content
Assessment report after engagementYesStructured findings, recommendations
Executive one-pager for networkingYesQuick bio + capabilities summary
Mass email campaignNoUse Brevo for bulk email with tracking
Complex data-heavy reportMaybeIf data exceeds template capacity, use reportlab or python-pptx
Internal meeting notesNoUse Obsidian/markdown directly
Solanasis master pitch deckNoAlready 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:

  1. Copies the proposal template to a new Google Slides file named “Solanasis Proposal - Acme Corp - 2026-04-11”
  2. Replaces all {{PLACEHOLDER}} markers with values from the JSON data file
  3. Exports the completed presentation to PDF
  4. 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 \n in 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)

  • replaceAllShapesWithImage requires 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_NAME not {{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:

  1. GOOGLE_WORKSPACE_CLI_KEYRING_BACKEND=file is set (the script does this automatically)
  2. GWS CLI is authenticated (credentials at ~/.config/gws/)
  3. Run with secrets: secret run solanasis-scripts -- python generate-doc.py ...

6. Troubleshooting

IssueCauseFix
”gws not found”GWS CLI not on PATHnpm install -g @googleworkspace/cli
”not authenticated”OAuth token expiredRe-auth on Windows: gws auth login, copy creds to WSL
”Template ID is still a placeholder”Config not updated with real IDsUpdate config/template_ids.json with actual Google Drive file IDs
”Failed to copy template”Template ID invalid or no accessVerify 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 replacedTypo in placeholder nameEnsure exact match including {{ }} and case; use matchCase: true
Email not sentGmail confirmation promptUse --email flag in generate-doc.py; if interactive confirmation blocks, fall back to Brevo SMTP
API calls fail with 403Required API not enabled in GCP projectEnable the Google Docs API (and/or Slides API, Drive API) in the GCP project at console.cloud.google.com > APIs & Services > Library
Image replacement failsImage URL behind auth wallUse Drive-hosted images with public sharing; Cloudflare Access-protected URLs cannot be fetched by Google APIs (see Section 4)


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:

ResourceDescription
document-generation-tool-comparison-matrixScored comparison of 19 tools across 8 dimensions with tier recommendations
typst-setup-and-brand-template-guideSetup guide for Typst + typst-py: offline branded PDF generation
marp-cli-setup-and-brand-theme-guideSetup guide for Marp CLI: rapid Markdown-to-slides
pandoc-setup-and-brand-pipeline-guideSetup guide for Pandoc: multi-format output from Markdown
document-generation-skills-roadmapPrioritized Claude Code skills and agents to build next

When to Use Which Tool

NeedToolGuide
Client proposal (template-driven)GWS CLI + Google DocsThis playbook (above)
Pitch deck (programmatic)python-pptxgenerate-pitch-deck.py
Offline branded PDFTypst + typst-pytypst-setup-and-brand-template-guide
Quick internal slidesMarp CLImarp-cli-setup-and-brand-theme-guide
Multi-format from MarkdownPandocpandoc-setup-and-brand-pipeline-guide
DOCX deliverablePandoc + reference docpandoc-setup-and-brand-pipeline-guide

Last updated: 2026-04-12