CLI Reference
Every command in the docex command-line tool. Install with git clone https://github.com/favstats/docex.git and run with node cli/docex-cli.js or create an alias.
# Create an alias (add to your shell profile)
alias docex="node /path/to/docex/cli/docex-cli.js"
# Verify it works
docex --version
# docex 0.4.0
replace
Replace text with tracked changes. The old text appears as strikethrough and the new text as an insertion in Word's review pane.
docex replace paper.docx "12,847" "300,000" --author "Alex"
Output:
Replaced "12,847" with "300,000" (tracked change by Alex)
Saved paper.docx (verified: 212 paragraphs, 156.2 KB)
insert
Insert a new paragraph at a position. The selector uses after: or before: prefix to target headings or text.
docex insert paper.docx "after:Methods" "We used a mixed-methods approach."
Output:
Inserted paragraph after "Methods"
Saved paper.docx (verified: 213 paragraphs, 156.8 KB)
delete
Delete text (tracked). Shows as strikethrough in Word.
docex delete paper.docx "redundant sentence here"
Output:
Deleted "redundant sentence here" (tracked change)
Saved paper.docx
comment
Add a comment anchored to a text phrase.
docex comment paper.docx "digital wellbeing" "Needs citation" --by "Reviewer 2"
Output:
Added comment by "Reviewer 2" on "digital wellbeing": "Needs citation"
Saved paper.docx
reply
Reply to an existing comment. The reply shows as a threaded response in Word.
docex reply paper.docx 1 "Added Johnson 2022 citation." --by "Alex Chen"
Output:
Replied to comment #1 by "Alex Chen": "Added Johnson 2022 citation."
Saved paper.docx
list
List document contents by type.
docex list paper.docx headings
Output:
Headings in paper.docx:
H1 The Effects of Social Media on Sleep Quality
H2 Abstract
H2 Introduction
H2 Literature Review
H3 Methodological Framework
H2 Methods
H3 Data Collection
H3 Classification Pipeline
H2 Results
H3 Effect Size Analysis
H2 Discussion
H2 Conclusion
H2 References
docex list paper.docx comments
Output:
Comments in paper.docx:
#1 [Research Assistant] Strong framing. Consider whether reviewers might...
#2 [Research Assistant] Verify: is this the total from the research dataset...
#31 [Editor Williams] TYPO: The abstract contains "scraped from..."
docex list paper.docx figures
Output:
Figures in paper.docx:
[1] word/media/image1.png (5486400 x 3657600 emu)
[2] word/media/image2.png (5486400 x 3657600 emu)
...
docex list paper.docx revisions
Output:
Tracked changes in paper.docx:
#17 DEL by Research Assistant: "12,847 records"
#18 INS by Research Assistant: "12,847 records extracted from the research dataset"
#21 DEL by Research Assistant: "10.4 days"
#22 INS by Research Assistant: "10.4 calendar days"
...
figure
Insert a figure after a heading or paragraph.
docex figure paper.docx "after:Results" fig03.png --caption "Figure 3. Effect sizes by study." --width 5
Output:
Inserted figure fig03.png after "Results" (5" wide)
Caption: "Figure 3. Effect sizes by study."
Saved paper.docx
table
Insert a table from a JSON data file.
docex table paper.docx "after:Results" data.json --style booktabs --caption "Table 1."
Where data.json contains:
[["Study", "N", "Effect Size"],
["Smith 2023", "342", "d = 0.45"],
["Lee 2022", "289", "d = 0.38"]]
count
Get word counts broken down by section.
docex count paper.docx
Output:
Word count for paper.docx:
Body text: 6,800
Headings: 45
Abstract: 250
Captions: 120
Footnotes: 85
----------------------
Total: 7,300
doctor
Check document health. Detects corruption, orphaned images, broken relationships, and structural issues.
docex doctor absolute_chaos.docx
Output:
Document health check: absolute_chaos.docx
[PASS] Valid ZIP structure
[PASS] document.xml present
[PASS] All relationships valid
[PASS] No orphaned media files
[PASS] No duplicate paragraph IDs
[WARN] Heading hierarchy: H3 appears without H2 parent
Result: 5 passed, 1 warning, 0 errors
diff
Compare two documents and produce a new .docx with tracked changes showing what changed.
docex diff paper.docx paper-v1.docx --output diff.docx
Output:
Comparing paper.docx vs paper-v1.docx
12 insertions, 8 deletions, 3 replacements
Saved diff.docx
style
Apply a journal formatting preset.
docex style paper.docx --preset polcomm
Available presets:
| Preset | Journal | Font | Margins |
|---|---|---|---|
academic | Generic academic | Times New Roman 12pt | 1" all |
polcomm | Political Communication | Times New Roman 12pt | 1" all |
apa7 | APA 7th Edition | Times New Roman 12pt | 1" all |
jcmc | Journal of Computer-Mediated Communication | Times New Roman 12pt | 1" all |
joc | Journal of Communication | Times New Roman 12pt | 1" all |
verify
Validate a document against journal submission requirements.
docex verify paper.docx --preset polcomm
Output:
Verification against polcomm preset:
[PASS] Word count: 7,300 (limit: 8,000)
[PASS] Abstract: 250 words (limit: 300)
[PASS] Font: Times New Roman
[WARN] Figure 3 resolution: 150 DPI (recommended: 300)
[FAIL] Margins: left=0.9" (required: 1.0")
Result: 3 passed, 1 warning, 1 failure
accept / reject
Accept or reject tracked changes.
# Accept all tracked changes
docex accept paper.docx
# Accept only change #5
docex accept paper.docx 5
# Reject all changes (revert to original text)
docex reject paper.docx
clean
Create a clean copy with all tracked changes accepted and markup removed.
docex clean paper.docx -o clean.docx
decompile / compile
Convert between .docx and .dex formats.
# Decompile to stdout
docex decompile paper.docx
# Decompile to file
docex decompile paper.docx -o paper.dex
# Compile .dex back to .docx
docex compile paper.dex -o paper-updated.docx
bold / italic / highlight
Apply formatting from the command line.
docex bold paper.docx "significant findings"
docex italic paper.docx "p < 0.05"
docex highlight paper.docx "needs review"
footnote
Add a footnote anchored to text.
docex footnote paper.docx "measurement validity" "See appendix B for methodology."
meta
Show document metadata.
docex meta paper.docx
Output:
Metadata for paper.docx:
Title: The Effects of Social Media on Sleep Quality
Creator: Alex Chen
Created: 2026-02-15
Modified: 2026-03-18
Pages: 24
Words: 7,300
anonymize
Anonymize a document for blind peer review.
docex anonymize paper.docx
latex / html / markdown
Export to other formats.
docex latex paper.docx > paper.tex
docex html paper.docx > paper.html
docex markdown paper.docx > paper.md
cite
List citation patterns or inject Zotero citations.
# List citation patterns
docex cite paper.docx --list
# Inject Zotero citations
docex cite paper.docx --zotero-key API_KEY --zotero-user USER_ID
Global options
| Option | Description |
|---|---|
--author <name> | Author name for tracked changes (default: git user.name) |
--by <name> | Alias for --author (used with comments) |
--output <path> | Save to a different file (default: overwrite) |
--untracked | Disable tracked changes |
--safe <path> | Wrap save through safe-modify.sh for manuscript protection |
--dry-run | Preview without saving |
--help | Show help |
--version | Show version |