agentsclimarketplace

Run2 docx processing

Skill cxcscmu/SkillLearnBench/skills/b2-self-feedback-gemini-3.1-flash-lite-preview/offer-letter-generator/run2_docx_processing

A robust skill for template processing in DOCX files, handling placeholders and complex conditional blocks spanning multiple paragraphs.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run2_docx_processing

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.5 KB, 288 tokens by cl100k_base, as published. Nobody here has run it

Overview

This skill improves upon the basic replacement pattern by providing a robust mechanism to process conditional blocks in DOCX files, even when they span across paragraphs.

Code Pattern

from docx import Document

def process_doc_with_conditionals(doc_path, output_path, data, conditional_map):
    doc = Document(doc_path)
    
    # 1. Simple replacements
    for paragraph in doc.paragraphs:
        for k, v in data.items():
            key = f"{{{{{k}}}}}"
            if key in paragraph.text:
                paragraph.text = paragraph.text.replace(key, str(v))

    # 2. Advanced Conditional Block Processing
    # This logic identifies {{IF_TAG}} and {{END_IF_TAG}} and handles the text in between
    for tag, should_keep in conditional_map.items():
        start_tag = f"{{{{IF_{tag}}}}}"
        end_tag = f"{{{{END_IF_{tag}}}}}"
        
        in_block = False
        for paragraph in doc.paragraphs:
            if start_tag in paragraph.text:
                paragraph.text = paragraph.text.replace(start_tag, "")
                in_block = True
            
            if end_tag in paragraph.text:
                paragraph.text = paragraph.text.replace(end_tag, "")
                in_block = False
            
            if in_block and not should_keep:
                paragraph.text = ""
                
    doc.save(output_path)

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.