docx-conditional-sections

docx-conditional-sections is a skill for Claude Code, Codex from cxcscmu/SkillLearnBench. It costs 40 tokens per session (879 once invoked), scanned A, original, MIT.

A Word template guide for showing or hiding sections based on conditions. It uses markers around text, such as relocation information, and removes those markers from the final document.

In plain words
What is it for?
Use it to generate personalized Word documents with optional paragraphs or sections.
Why use it?
It prevents conditional text from appearing when it does not apply and handles sections that span several paragraphs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to generate personalized Word documents with optional paragraphs or sections.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cxcscmu/skilllearnbench/docx-conditional-sections
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cxcscmu/SkillLearnBench --skill docx-conditional-sections
Clone the repo
git clone --depth 1 https://github.com/cxcscmu/SkillLearnBench

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for docx-conditional-sections

README.md
[![agentmods](https://agentmods.dev/badge/skills/cxcscmu/skilllearnbench/docx-conditional-sections.svg)](https://agentmods.dev/skills/cxcscmu/skilllearnbench/docx-conditional-sections)
Your own site
<a href="https://agentmods.dev/skills/cxcscmu/skilllearnbench/docx-conditional-sections"><img src="https://agentmods.dev/badge/skills/cxcscmu/skilllearnbench/docx-conditional-sections.svg" alt="Measured on agentmods" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 879 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00040 $0.00879
Opus 5 $0.00020 $0.00439
Sonnet 5 $0.00008 $0.00176
Haiku 4.5 $0.00004 $0.00088

Measured 3d ago against content hash 62737b279ea4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

docx-conditional-sections scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/b1-one-shot-claude-sonnet-4-6/offer-letter-generator/docx-conditional-sections/SKILL.md · 124 lines

How it starts

The opening of the file, as written. The whole thing — 124 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Conditional Sections in Word Templates

Pattern

Templates use markers like:

{{IF_RELOCATION}}You are eligible for a relocation package...{{END_IF_RELOCATION}}

Rules:

  • Condition is true: Keep the content between markers, remove the markers themselves.
  • Condition is false: Remove the entire block including markers.

Cases to Handle

Conditional blocks may span:

  1. Single paragraph — start and end markers are in the same paragraph
  2. Multiple paragraphs — start marker in one paragraph, end marker in another

Single-Paragraph Conditional

import re

def handle_single_para_conditional(para, condition_key, should_include, data):
    """Handle {{IF_KEY}}...{{END_IF_KEY}} within a single paragraph."""
    start = '{{IF_' + condition_key + '}}'
    end = '{{END_IF_' + condition_key + '}}'

    text = para.text
    if start not in text or end not in text:
        return False  # Not applicable

    if should_include:
        # Strip markers, keep content, then replace placeholders
        inner = re.search(re.escape(start) + r'(.*?)' + re.escape(end), text, re.DOTALL)
        new_text = inner.group(1) if inner else text.replace(start, '').replace(end, '')
        # Replace any remaining placeholders in the content
        new_text = re.sub(r'\{\{([A-Z0-9_]+)\}\}', lambda m: str(data.get(m.group(1), m.group(0))), new_text)
    else:
        new_text = ''

    if para.runs:
        para.runs[0].text = new_text
        for run in para.runs[1:]:
            run.text = ''
    return True

Multi-Paragraph Conditional

When markers span multiple paragraphs, collect and process paragraph-by-paragraph:

from docx.oxml.ns import qn

def remove_paragraph(para):
    """Remove a paragraph element from the document."""
    p = para._element
    p.getparent().remove(p)

def handle_multi_para_conditional(doc, condition_key, should_include, data):
    """Handle conditional block that may span multiple paragraphs."""
    start_marker = '{{IF_' + condition_key + '}}'
    end_marker = '{{END_IF_' + condition_key + '}}'

    paragraphs = list(doc.paragraphs)
    inside = False
    to_remove = []

    for para in paragraphs:
        text = para.text
        starts = start_marker in text
        ends = end_marker in text

        if starts and ends:
            # Entire block in one paragraph
            handle_single_para_conditional(para, condition_key, should_include, data)
        elif starts:
            inside = True
            if not should_include:
                to_remove.append(para)
            else:
                # Strip start marker
                new_text = text.replace(start_marker, '')
                if para.runs:
                    para.runs[0].text = new_text
                    for run in para.runs[1:]: run.text = ''
        elif ends:
            inside = False
            if not should_include:
                to_remove.append(para)
            else:
                new_text = text.replace(end_marker, '')
                if para.runs:
                    para.runs[0].text = new_text
                    for run in para.runs[1:]: run.text = ''
        elif inside:
            if not should_include:
                to_remove.append(para)

    for para in to_remove:
        remove_paragraph(para)

Read the full file on GitHub · 124 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 124 lines · 40 tokens per session scan A 62737b279ea4

Subscribe to this mod's changes

docx-conditional-sections is a skill published in the GitHub repository cxcscmu/SkillLearnBench (83 stars, last pushed 1mo ago), licensed MIT. It adds 40 tokens to every session and 879 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.