Autonomous Document Rendering Engine for AI Agents

The Document Generation Backend for AI Coding Agents

Connect Google Antigravity, Claude Code, Cursor, and custom LLM pipelines directly to high-fidelity Word templates and high-throughput batch generation APIs.

Workspace Skill

TRYDOKU Document Generation Skill

A drop-in agent skill for Google Antigravity (.agents/skills/), Claude Code, and Cursor. Teaches agents exact API contracts and placeholder rules.

---
name: "trydoku-generation"
description: "Batch document generation using TRYDOKU REST API and Word templates (.docx)."
---

# TRYDOKU Document Generation Skill

Use this skill to automate batch document generation (invoices, contracts, agreements, reports) from Microsoft Word (`.docx`) templates and structured datasets (Excel, CSV, JSON).

## API Specification & Contracts

- **Base URL:** `https://www.trydoku.com/api/v1`
- **Authentication:** Bearer token via `TRYDOKU_API_TOKEN` environment variable.
- **Header:** `Authorization: Bearer <TRYDOKU_API_TOKEN>`
- **Content-Type:** `application/json`
- **Accept:** `application/json`

### 1. Submit Generation Batch
- **Method:** `POST /api/v1/generate`
- **Payload Schema:**
  ```json
  {
    "template_base64": "<base64_encoded_docx_file_string>",
    "data": [
      {
        "client_name": "Acme Corp",
        "invoice_id": "INV-001",
        "amount": "$1,200.00",
        "is_discounted": true,
        "items": [
          { "description": "Consulting Services", "rate": "$800.00" },
          { "description": "System Integration", "rate": "$400.00" }
        ]
      }
    ]
  }
  ```
- **Response Schema (Pending):**
  ```json
  {
    "data": {
      "id": "batch_abc123",
      "status": "pending",
      "setup_status": "ready",
      "total_items": 1,
      "processed_items": 0,
      "failed_items": 0,
      "links": {
        "self": "https://www.trydoku.com/api/v1/batches/batch_abc123",
        "zip": null
      }
    }
  }
  ```

### 2. Poll Batch Status
- **Method:** `GET /api/v1/batches/{id}`
- **Response Schema (Completed):**
  ```json
  {
    "data": {
      "id": "batch_abc123",
      "status": "completed",
      "setup_status": "ready",
      "total_items": 1,
      "processed_items": 1,
      "failed_items": 0,
      "links": {
        "self": "https://www.trydoku.com/api/v1/batches/batch_abc123",
        "zip": "https://www.trydoku.com/api/v1/batches/batch_abc123/zip"
      }
    }
  }
  ```

## Template Placeholder Syntax Rules

1. **Scalars:** `{{ variable_name }}` (Must use letters, numbers, and underscores).
2. **Repeating Table Rows / Loops:**
   - In Word table cell 1: `{> items }}`
   - Inside row columns: `{{ description }}`, `{{ price }}`
   - In Word table last cell: `{< items }}`
3. **Conditional Sections:** `{% if is_discounted %} ... {% else %} ... {% endif %}`

## Agent Execution Best Practices

1. **Verify Variables First:** Before submitting bulk batches, inspect template placeholders or parse variables using TRYDOKU's free client-side tool at `https://www.trydoku.com/tools/word-template-variable-parser`.
2. **Handle Rate Limiting:** Apply exponential backoff (2s → 4s → 8s) when receiving HTTP 429 status codes.
3. **Credit Management:** Generation consumes 1 credit per non-empty row in the `data` array upon batch submission. Polling batch status (`GET /batches/{id}`) is completely free.
4. **Data Privacy & Retention:** Payload rows are encrypted at rest during queue processing, automatically cleared (`input_data = null`) immediately upon successful generation, and subject to an automated 72-hour pruning window for incomplete or failed batches. Encrypt tokens in environment variables and never commit secrets to repositories.
1. Google Antigravity: Save as .agents/skills/trydoku/SKILL.md
2. Claude Code: Append to CLAUDE.md or Project Knowledge
3. Cursor / Copilot: Add to .cursorrules as reference context
Machine-Readable Discovery

Built for LLMs, Crawlers & Agentic IDEs

TRYDOKU provides standardized machine-readable context files adhering to the llms.txt specification, enabling AI systems to discover our API capabilities without hallucinations.

Developer Guide

AI Document Generation: Best Practices

Follow these 5 architectural principles to build reliable, cost-effective agentic document rendering pipelines.

1

Anchor Agents with the OpenAPI Schema

Always feed /llms-full.txt or the OpenAPI JSON schema directly into your agent's system prompt or workspace context. This anchors the model to exact endpoint URLs (POST /api/v1/generate) and payload properties (template_base64, data), preventing URL and parameter hallucinations.

2

Strict Template Syntax Rules

Use standardized placeholder syntax: {{ var }} for single values, {> loop }} ... {< loop }} for table row repeats, and {% if var %} ... {% endif %} for conditionals. Avoid inventing unsupported custom delimiters.

3

Pre-Validate with Client-Side Tools

Before executing automated batch runs, inspect templates using the free Word Template Variable Parser. It extracts all placeholders client-side in browser RAM and exports a matching Excel template (.xlsx) with zero server uploads.

4

Batching Economics & Idempotency

TRYDOKU credits are billed per accepted row in your data array at batch creation time. Submitting 100 rows in a single batch request is significantly faster and more reliable than dispatching 100 individual single-row requests. Polling batch status is always free.

5

Resilient Rate Limiting & Backoff

Ensure your agentic scripts handle HTTP 429 rate limit responses gracefully. Implement exponential backoff (e.g. initial delay of 2 seconds, multiplied by 1.5 up to 8 seconds) rather than aggressively spamming generation endpoints.