lovstudio-fill-form
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Fill in Word document form templates (.docx) with user-provided data. Reads a template containing tables with label→value cell pairs, detects all fillable fields, and outputs a completed document. Handles CJK/Latin mixed text with proper font switching. Use this skill when the user wants to fill in a form template, complete an application form, populate a Word table form, or automate document filling. Also trigger when the user mentions "填表", "填写表格", "fill form", "fill template", "表格填写", "申请表", "登记表", or has a .docx template with blank fields to fill.
68installs
Sourcelovstudio/skills
Added on
NPX Install
npx skill4agent add lovstudio/skills lovstudio-fill-formTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →fill-form — Fill Word Form Templates
This skill fills in Word document form templates (.docx) with user-provided data.
It detects table-based form fields (label in one cell, value in the adjacent cell)
and populates them automatically.
When to Use
- User has a form template with blank fields to fill
.docx - User wants to fill in an application form, registration form, etc.
- Document uses Word tables for form layout (label | value cell pairs)
- User mentions 填表, 申请表, 登记表, or wants to automate form filling
Workflow (MANDATORY)
You MUST follow these steps in order:
Step 1: Scan the template
Discover all fillable fields:
bash
python lovstudio-fill-form/scripts/fill_form.py --template <path> --scanStep 2: Pre-fill from known context
Before asking the user, try to fill as many fields as possible from:
- User memory — name, title, organization, etc.
- Context files — if the user provides reference documents (e.g. STARTER-PROMPT.md, project docs), extract relevant info to fill content-heavy fields
- Conversation context — anything already mentioned
For content-heavy fields (e.g. "主要内容/简介/摘要"), actively compose the content
by synthesizing from context files, user's known expertise, and the topic/title.
Step 3: Ask only what you don't know
Use to collect ONLY the fields you cannot fill from context.
AskUserQuestion- Group fields into a single question
- If ALL fields are unknown, list them all
- If the user says some fields can be left blank (e.g. "其他朋友会帮我填"), respect that and leave those empty
- Do NOT force the user to provide every field
Step 4: Fill and save
Write a JSON data file (avoids shell escaping issues with long text), then run:
bash
python lovstudio-fill-form/scripts/fill_form.py \
--template <path> \
--data-file /tmp/form_data.jsonOutput path rules:
- Default: (same directory as the template)
<template_dir>/<name>_filled.docx - If the template is in a temp directory or system path, save to user's document directory or ask the user where to save
- Use to override explicitly
--output
CLI Reference
| Argument | Default | Description |
|---|---|---|
| (required) | Path to template .doc/.docx file |
| | Output .docx path |
| false | List all detected form fields |
| | JSON string with field→value mapping |
| | Path to JSON file with field→value mapping |
| Platform CJK serif | Font name for filled text |
| | Font size in points |
How Field Detection Works
- Table-based (primary): Scans all tables for rows with label→value cell pairs. A label cell contains short text (CJK or Latin); the adjacent cell is the value field.
- Merged rows: Detects full-width merged cells with "Label:" pattern as large text areas.
- Paragraph fallback: If no tables found, detects "Label:value" patterns in paragraphs.
Limitations
- files are auto-converted to
.docvia macOS.docx, which loses table structure. For best results, usetextutiltemplates directly. If you only have.docx, convert with LibreOffice first:.doclibreoffice --headless --convert-to docx file.doc - Fields are matched by normalized label text (whitespace removed). If a label contains
unusual formatting, the match may fail — use to verify detection.
--scan
Dependencies
bash
pip install python-docx --break-system-packages