docx-templates-fastapi-service

Sub-skill of docx-templates: FastAPI Service.

5 stars

Best use case

docx-templates-fastapi-service is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Sub-skill of docx-templates: FastAPI Service.

Teams using docx-templates-fastapi-service should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/fastapi-service/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/_archive/data/office/docx-templates/fastapi-service/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/fastapi-service/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How docx-templates-fastapi-service Compares

Feature / Agentdocx-templates-fastapi-serviceStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Sub-skill of docx-templates: FastAPI Service.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# FastAPI Service

## FastAPI Service


```python
"""
Document generation service with FastAPI.
"""
from fastapi import FastAPI, HTTPException, UploadFile, File
from fastapi.responses import FileResponse
from pydantic import BaseModel
from typing import Dict, Any, List, Optional
from docxtpl import DocxTemplate
from pathlib import Path
import tempfile
import uuid

app = FastAPI(title="Document Generation Service")

# Template storage
TEMPLATES_DIR = Path("./templates")
OUTPUT_DIR = Path("./generated")
OUTPUT_DIR.mkdir(exist_ok=True)


class GenerateRequest(BaseModel):
    """Request model for document generation."""
    template_name: str
    data: Dict[str, Any]
    output_filename: Optional[str] = None


class BatchGenerateRequest(BaseModel):
    """Request for batch generation."""
    template_name: str
    records: List[Dict[str, Any]]
    filename_field: str = "id"


@app.get("/templates")
async def list_templates():
    """List available templates."""
    templates = []
    for f in TEMPLATES_DIR.glob("*.docx"):
        templates.append({
            "name": f.stem,
            "filename": f.name
        })
    return {"templates": templates}


@app.post("/generate")
async def generate_document(request: GenerateRequest):
    """Generate a single document."""
    template_path = TEMPLATES_DIR / f"{request.template_name}.docx"

    if not template_path.exists():
        raise HTTPException(404, f"Template '{request.template_name}' not found")

    try:
        template = DocxTemplate(str(template_path))
        template.render(request.data)

        # Generate output filename
        output_name = request.output_filename or f"{uuid.uuid4()}.docx"
        if not output_name.endswith(".docx"):
            output_name += ".docx"

        output_path = OUTPUT_DIR / output_name
        template.save(str(output_path))

        return FileResponse(
            str(output_path),
            media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
            filename=output_name
        )

    except Exception as e:
        raise HTTPException(500, f"Generation failed: {str(e)}")


@app.post("/generate/batch")
async def generate_batch(request: BatchGenerateRequest):
    """Generate multiple documents."""
    template_path = TEMPLATES_DIR / f"{request.template_name}.docx"

    if not template_path.exists():
        raise HTTPException(404, f"Template '{request.template_name}' not found")

    generated = []
    errors = []

    for record in request.records:
        try:
            template = DocxTemplate(str(template_path))
            template.render(record)

            filename = f"{record.get(request.filename_field, uuid.uuid4())}.docx"
            output_path = OUTPUT_DIR / filename

            template.save(str(output_path))
            generated.append(filename)

        except Exception as e:
            errors.append({
                "record": record.get(request.filename_field),
                "error": str(e)
            })

    return {
        "generated": len(generated),
        "failed": len(errors),
        "files": generated,
        "errors": errors
    }


@app.post("/templates/upload")
async def upload_template(file: UploadFile = File(...)):
    """Upload a new template."""
    if not file.filename.endswith(".docx"):
        raise HTTPException(400, "Only .docx files are supported")

    template_path = TEMPLATES_DIR / file.filename

    content = await file.read()
    with open(template_path, "wb") as f:
        f.write(content)

    return {"message": f"Template '{file.filename}' uploaded", "name": Path(file.filename).stem}


# Run with: uvicorn service:app --reload
```

Related Skills

background-service-manager

5
from vamseeachanta/workspace-hub

Create and manage long-running background processes with start/stop/status controls, logging, and monitoring. Use for batch processing jobs, data pipelines, continuous services, or any long-running tasks.

fitness-for-service

5
from vamseeachanta/workspace-hub

Expert FFS engineer applying API 579-1/ASME FFS-1 methodology to corroded and damaged offshore equipment. Use for RSF calculations, MAWP re-rating, remaining life projection, UT grid inspection data, run-repair-replace decisions, and Level 1/2/3 assessment workflows. type: reference

docx

5
from vamseeachanta/workspace-hub

Comprehensive Word document toolkit for reading, creating, and editing .docx files. Supports text extraction, document creation with python-docx, and tracked changes via redlining workflow. Use for legal, academic, or professional document manipulation.

n8n-8-workflow-templates-and-subworkflows

5
from vamseeachanta/workspace-hub

Sub-skill of n8n: 8. Workflow Templates and Subworkflows.

airflow-integration-with-aws-services

5
from vamseeachanta/workspace-hub

Sub-skill of airflow: Integration with AWS Services.

testing-tdd-london-example-1-service-orchestration-test

5
from vamseeachanta/workspace-hub

Sub-skill of testing-tdd-london: Example 1: Service Orchestration Test (+2).

github-swarm-pr-1-pr-templates-for-swarm

5
from vamseeachanta/workspace-hub

Sub-skill of github-swarm-pr: 1. PR Templates for Swarm.

github-swarm-issue-issue-templates-for-swarms

5
from vamseeachanta/workspace-hub

Sub-skill of github-swarm-issue: Issue Templates for Swarms.

github-swarm-issue-1-issue-templates

5
from vamseeachanta/workspace-hub

Sub-skill of github-swarm-issue: 1. Issue Templates (+3).

github-multi-repo-microservices-coordination

5
from vamseeachanta/workspace-hub

Sub-skill of github-multi-repo: Microservices Coordination (+2).

pandoc-5-custom-latex-templates

5
from vamseeachanta/workspace-hub

Sub-skill of pandoc: 5. Custom LaTeX Templates (+1).

plotly-built-in-templates

5
from vamseeachanta/workspace-hub

Sub-skill of plotly: Built-in Templates (+1).