docx-placeholder-replacement

docx-placeholder-replacement is a skill for Claude Code, Codex from cxcscmu/SkillLearnBench. It costs 34 tokens per session (566 once invoked), scanned A, original, MIT.

A Word document guide for replacing placeholder tokens such as {{CANDIDATE_NAME}} with real values. It also covers placeholders split across text runs and locations such as tables, headers, and footers.

In plain words
What is it for?
Use it to fill reusable Word templates with data throughout the document.
Why use it?
It avoids missed replacements caused by Word storing one visible token as several internal pieces.

Skill for Claude CodeCodex

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

Good fit Use it to fill reusable Word templates with data throughout the document.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cxcscmu/skilllearnbench/docx-placeholder-replacement
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-placeholder-replacement
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-placeholder-replacement

README.md
[![agentmods](https://agentmods.dev/badge/skills/cxcscmu/skilllearnbench/docx-placeholder-replacement.svg)](https://agentmods.dev/skills/cxcscmu/skilllearnbench/docx-placeholder-replacement)
Your own site
<a href="https://agentmods.dev/skills/cxcscmu/skilllearnbench/docx-placeholder-replacement"><img src="https://agentmods.dev/badge/skills/cxcscmu/skilllearnbench/docx-placeholder-replacement.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 566 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.00034 $0.00566
Opus 5 $0.00017 $0.00283
Sonnet 5 $0.00007 $0.00113
Haiku 4.5 $0.00003 $0.00057

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

Security

Grade A, and why

docx-placeholder-replacement 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-placeholder-replacement/SKILL.md · 80 lines

How it starts

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

Robust Placeholder Replacement in Word Documents

The Split-Run Problem

Word's XML engine often breaks a single word like {{CANDIDATE_NAME}} across multiple runs:

run[0]: '{{CANDI'
run[1]: 'DATE_NAME}}'

A naive run.text.replace() will miss these. Always reconstruct from para.text.

Safe Replacement Algorithm

import re

def replace_in_paragraph(para, data):
    """Replace all {{KEY}} placeholders in paragraph, handling split runs."""
    full_text = para.text
    pattern = re.compile(r'\{\{([A-Z0-9_]+)\}\}')

    if not pattern.search(full_text):
        return  # Nothing to do

    # Build replacement
    def replacer(m):
        key = m.group(1)
        return str(data[key]) if key in data else m.group(0)

    new_text = pattern.sub(replacer, full_text)

    if new_text != full_text and para.runs:
        # Put all text in first run, clear the rest
        para.runs[0].text = new_text
        for run in para.runs[1:]:
            run.text = ''

Apply to Entire Document

def replace_all_placeholders(doc, data):
    """Replace placeholders everywhere: body, tables, headers, footers."""

    # Body paragraphs
    for para in doc.paragraphs:
        replace_in_paragraph(para, data)

    # Tables (with nested table recursion)
    def process_table(table):
        for row in table.rows:
            for cell in row.cells:
                for para in cell.paragraphs:
                    replace_in_paragraph(para, data)
                for nested in cell.tables:
                    process_table(nested)

    for table in doc.tables:
        process_table(table)

    # Headers and footers
    for section in doc.sections:
        for para in section.header.paragraphs:
            replace_in_paragraph(para, data)
        for para in section.footer.paragraphs:
            replace_in_paragraph(para, data)

Notes

  • Only the first run's formatting is preserved after merging. If parts of the placeholder text have different formatting (e.g., bold {{NAME}}), that formatting is lost — which is usually acceptable for template filling.
  • Unknown placeholders (keys not in data) are left as-is by default. Adjust the replacer function to raise errors or substitute empty strings if needed.

Read the full file on GitHub · 80 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 · 80 lines · 34 tokens per session scan A 4496ef016949

Subscribe to this mod's changes

docx-placeholder-replacement is a skill published in the GitHub repository cxcscmu/SkillLearnBench (83 stars, last pushed 1mo ago), licensed MIT. It adds 34 tokens to every session and 566 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.