Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Audit Correct

ASecurity

Phase 4: Apply corrections to DOCX

21 stars
0 votes
0 copies
0 views
Added 9/19/2026
documentationpythongo

Works with

terminal

Security Analysis

A100/100

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add edwinhu/workflows --skill audit-correct --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Audit Correct?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Audit Correct
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/edwinhu-audit-correct/badge)](https://www.skillsdirectory.com/skills/edwinhu-audit-correct)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: audit-correct
description: "Phase 4: Apply corrections to DOCX"
user-invocable: false
disable-model-invocation: true
---

# Phase 4: Correct

**What this skill carries** — grep `references/` for any subject the names below miss:
!`d=${CLAUDE_SKILL_DIR}; command -v skill-toc >/dev/null 2>&1 && exec skill-toc "$d"; s=$HOME/.claude/skills/plugin-utils/bin/skill-toc; [ -x "$s" ] && exec "$s" "$d"; echo "(skill-toc unavailable: references and scripts are NOT listed here — install the plugin-utils plugin, or start a new session so its bin/ reaches PATH)"`

Apply approved corrections to the DOCX file via lxml XML manipulation.

## What This Phase Does

1. Back up the original DOCX
2. Apply corrections in order:
   a. Cross-reference resolution (fill `[_]` placeholders)
   b. Small caps for journal/periodical names (run-splitting)
   c. Small caps for book titles (italic -> small caps)
   d. Signal italic fixes
   e. Id. chain corrections
   f. Terminal period additions
   g. Other typeface fixes
3. Write corrected DOCX

## Run-Splitting Approach

When formatting a substring within a larger run:
1. Find the run containing the target text
2. Split into 3 runs: prefix (original) + target (new format) + suffix (original)
3. Clone `rPr` from original run via `deepcopy`
4. Add new formatting only to target run
5. Set `xml:space="preserve"` on all `<w:t>` elements

## Critical Gotchas

### NBSP Variants
All search operations MUST handle `\xa0` (non-breaking space):
```python
def find_in_run(text, target):
    if target in text:
        return text.find(target)
    nbsp_target = target.replace(' ', '\xa0')
    if nbsp_target in text:
        return text.find(nbsp_target)
    # Try regex with [\s\xa0] for mixed
    import re
    pattern = re.escape(target).replace(r'\ ', r'[\s\xa0]')
    m = re.search(pattern, text)
    return m.start() if m else -1
```

### footnoteRef Space Run Bug
The run after `<w:footnoteRef/>` often contains the full footnote text, not just a space. When replacing entire footnote content, keep ONLY the footnoteRef run and add an explicit space run.

### Cross-Run Text
`supra note 10` spans italic + roman runs. Target the specific run containing the text you need to change (e.g., just "note 10" in the roman run).

### Multi-Split Footnotes
Some footnotes need multiple formatting changes in the same run (e.g., FN91: italic the letter title AND small-caps the annual report title, both in one roman run). Process splits **sequentially left-to-right**:
1. First split creates 3 new runs from the original
2. Second split finds target text in one of the NEW runs and splits again
3. The `find_run()` search re-scans the footnote element each time, so it finds the new runs

Example: `Jamie Dimon, Chairman & CEO Letter to Shareholders, in JPMorgan Chase & Co., 2023 Annual Report 1 (2024)`
- Split 1: "Chairman & CEO Letter to Shareholders" → italic (creates 3 runs)
- Split 2: "JPMorgan Chase & Co., 2023 Annual Report" → small caps (splits the third run from Split 1)

### Italic Spillover Cleanup
After all substantive fixes, clean up trailing/leading spaces in italic runs. Word displays these fine, but they cause Gemini annotation issues on re-audit:
```python
# Find italic runs with trailing spaces
if text.endswith(' ') and is_italic:
    t.text = text.rstrip(' ')
    # Insert a new roman space run after
```

<EXTREMELY-IMPORTANT>
## Iron Law: Verify Every Fix

After each category of corrections, verify the fix was applied by reading back the modified XML. Silent failures from NBSP, run boundaries, or wrong-run targeting are common.

Skipping read-back verification is NOT HELPFUL — silent failures from NBSP or run boundaries mean the user's document still has errors.
</EXTREMELY-IMPORTANT>

## Correction Facts

- NBSP characters and run boundaries cause silent failures and wrong-run targeting — code that "applied" is not code that worked. A fix reported without XML read-back is an unverified claim presented as a correction.
- Verification batched to the end can't attribute a failure to the fix that caused it; verify after each category.
- Every footnote has a unique run structure — a pattern that worked on the last footnote proves nothing about this one.
- One XML corruption destroys the whole document; skipping the backup gambles the user's manuscript to save seconds.

## Gate: Exit Correct

Before proceeding to Verify phase:
- [ ] Backup DOCX exists (original preserved)
- [ ] Corrected DOCX exists
- [ ] Per-category fix counts logged
- [ ] Spot-check verification passed (at least 5 random fixes checked)

## Next Phase

Read `${CLAUDE_SKILL_DIR}/../../../../skills/bluebook-audit/skills/audit-verify/SKILL.md` and follow its instructions.

Attribution

edwinhuedwinhu
View sourceMore from edwinhu →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Context Fundamentals

Understand the components, mechanics, and constraints of context in agent systems. Use when designing agent architectures, debugging context-related failures, or optimizing context usage.

179001 votes

release-notes

Draft release notes and changelog entries from git history or merged PRs between two refs (tags/SHAs/branches), including breaking changes, migrations, and upgrade steps. Use when the user asks for release notes, changelog updates, or a GitHub Release draft.

1301 votes

docs-style-guide

Documentation style guide enforcer by @planetabhi. Applies and reviews the writing style guide when authoring or editing product documentation and tutorials. Use to check prose for voice, tense, word choice, inclusive language, formatting, code block, UI, Markdown, and number/date conventions.

11 votes

Caveman Help

Quick-reference card for all caveman modes, skills, and commands. One-shot display, not a persistent mode. Trigger: /caveman-help, "caveman help", "what caveman commands", "how do I use caveman".

1023330 votes

How It Works

Explain how claude-mem captures observations, when memory injection kicks in, and where data lives. Use when the user asks "how does claude-mem work?" or "what is this thing doing?".

929660 votes
View all in documentation →