audit-correct
Phase 4: Apply corrections to DOCX
What this skill does
# Phase 4: Correct
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>
## Rationalization Table
| Excuse | Reality | Do Instead |
|---|---|---|
| "The fix applied in code, no need to verify" | NBSP causes silent failures; run boundaries cause wrong-target | Read back the XML and verify |
| "I'll verify all at once at the end" | By then you can't tell which fix failed | Verify after each category |
| "This is the same pattern as last time" | Each footnote has unique run structure | Check each footnote individually |
| "I can skip the backup" | One XML corruption destroys the whole document | Always back up first |
## 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.
Related in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.