메뉴
HN
Hacker News 21일 전

AI 에이전트용 워드 문서 편집 CLI 'docx-cli' 공개

IMP
7/10
핵심 요약

AI 에이전트가 워드 문서를 읽고 편집할 때 발생하는 토큰 낭비와 시간 지연을 절반으로 줄여주는 CLI 도구입니다. 기존 방식의 XML 직접 수정이 아닌 명령어 기반으로 작동해 파일 깨짐 없이 서식과 변경 추적(Redline)을 완벽하게 보존합니다. 개발 및 실무 작업의 효율성을 극대화할 수 있는 오픈소스 유틸리티로, 별도 설치 없이 실행할 수도 있습니다.

번역된 본문

docx-cli는 AI 에이전트를 위해 제작된 .docx 명령줄 인터페이스(CLI) 도구입니다. 서식을 깨뜨리거나 콘텐츠를 손상하지 않고 워드 문서에 주석을 남기고, 수정 사항(Redline)을 제안하며 편집할 수 있게 해줍니다. 이후 사용자는 워드에서 해당 변경 사항을 수락하거나 거부할 수 있습니다. Claude나 Codex 같은 AI 모델에 .docx 파일을 전달하면, 주석과 함께 수정된 사본을 받아볼 수 있으며 평소처럼 워드에서 열어 승인 또는 거부하면 됩니다.

AI 에이전트는 문자 단위 오프셋을 포함한 안정적인 위치 식별자(예: p3:5-20)를 통해 텍스트를 찾아내며, 사용자는 디스크에 저장된 정상적인 워드 서식 그대로 문서를 확인합니다. 사용자 지정 스타일, 테마 색상, 포함된 개체 등 모든 요소가 그대로 유지됩니다. 이 도구는 정보 손실이 발생할 수 있는 모델 재생성 방식 대신, XML을 직접 그 자리에서 수정(in-place)합니다.

왜 docx-cli가 필요할까요? 기존에 AI 에이전트가 워드 문서를 편집하는 기본 방식은 .docx 파일의 압축을 풀고 내부의 OOXML 코드를 직접 수정하는 것이었습니다. 이 방식은 제대로 작동하기 위해 고성능 모델이 필요하고 토큰을 과도하게 소모하며, 종종 워드에서 열리지 않는 깨진 파일을 생성했습니다. 하지만 docx-cli는 에이전트에게 단순한 텍스트 명령어와 주석이 달린 마크다운(Markdown) 보기를 제공하므로, AI가 복잡한 XML을 직접 다룰 필요가 없습니다.

실제로 공정한 비교 테스트(A/B 테스트)를 진행했습니다. 6가지 실제 문서 작업(NDA 작성, 인보이스 작성, 이력서 스타일 변경, 계약서 수정안 작성, 계약서 완성, 저널 작성)을 동일한 원본 파일로 시작하여, 독립적인 평가자가 워드로 렌더링된 결과물을 채점했습니다. 각 모델 그룹(Haiku: 저렴/약한 모델, Sonnet: 강력한 모델)별로 3번의 테스트를 진행한 결과는 다음과 같습니다.

  • 해결된 작업 수 (6개 중): docx-cli는 Haiku에서 4.3개(4-5), Sonnet에서 6.0개를 기록했습니다. 기본 방식은 Haiku에서 0.7개(0-1), Sonnet에서 4.0개에 그쳤습니다.
  • 정상 렌더링률 (6개 중): docx-cli는 두 그룹 모두 6개로 완벽했습니다. 기본 방식은 Haiku 3.7개, Sonnet 4.7개였습니다.
  • 완전히 깨진 문서 수: docx-cli는 0건이었으나, 기본 방식은 실행당 평균 1건(최대 2건)이 발생했습니다.
  • 입력 토큰 및 소요 시간: docx-cli는 기본 방식에 비해 토큰은 약 2.22.6배, 시간은 약 1.72배 절감되었습니다.

특히 저렴한 Haiku 모델에서 정확도 격차가 가장 크게 벌어졌으며(약 6배 차이), 강력한 Sonnet 모델조차 기본 방식으로는 최대 4/6점에 그쳐 계약서 수정이나 이력서 작업 등에서 실패했습니다. 비용과 속도 패널티는 모델에 영향을 받지 않아 일관되게 개선 효과를 보였습니다. 기본 방식이 생성한 36개의 결과물 중 5개는 워드에서 아예 열리지 않았지만, docx-cli가 생성한 36개의 파일은 모두 첫 번째 시도에서 정상적으로 열렸습니다. 자세한 평가 방법론과 과제별 채점 기준은 저장소의 벤치마크 문서를 확인해 주세요.

설치 방법 (npm — 가장 간단한 방법, Bun >= 1.3 필요): bun add -g bun-docx

또는 설치 없이 실행:

bunx bun-docx read doc.docx

독립 실행형 바이너리 (Bun 불필요): 모든 릴리스는 빌드된 바이너리와 SHA256SUMS 매니페스트를 제공하며, 설치 프로그램은 설치 전에 바이너리의 SHA-256을 검증합니다. curl -fsSL https://raw.githubusercontent.com/kklimuk/docx-cli/main/install.sh | sh 이 스크립트는 PREFIX(기본값 $HOME/.local/bin) 및 VERSION(기본값 latest) 환경 변수를 지원하며 linux/x64, linux/arm64, darwin/x64, darwin/arm64, windows/x64 환경에 맞춰 사전 빌드되어 있습니다. 코드를 직접 검사하고 싶다면 최신 릴리스에서 플랫폼에 맞는 바이너리와 SHA256SUMS를 다운로드한 뒤 검증하고, chmod +x로 실행 권한을 준 다음 PATH에 추가하시면 됩니다.

빠른 예시: NDA 작성하기 저장소에는 tests/fixtures/mnda.docx 경로에 Common Paper 상호 NDA 템플릿이 포함되어 있습니다. 아래는 AI 에이전트가 표지를 작성하고 추적 변경(redline)을 남기기 위해 조합할 수 있는 기본 명령어들입니다. 모든 명령어는 실제 파일에 대해 엔드투엔드로 검증되었습니다.

복사본을 먼저 만드세요. (CLI가 파일을 덮어쓰기 때문에 git을 기록으로 사용합니다)

cp tests/fixtures/mnda.docx mnda-filled.docx

에이전트가 어떤 빈칸(placeholder)이 있는지 알 수 있도록 표지 테이블 읽기

docx read mnda-filled.docx --from t1 --to t1

노란색으로 강조된 괄호 안의 빈칸 채우기

docx replace mnda-filled.docx " Fill in: today's date " " May 6, 2026 " docx replace mnda-filled.docx " fill in state and/or county " " California " docx replace mnda-filled.docx " fill in state " " California " docx replace mnda-filled.docx " Fill in, if any. " " None. "

채워야 할 부분이 남아있는지 확인 (정규식으로 검색)

docx find mnda-filled.docx ' [(Fill|fill)[^]]*] ' --regex --all

수정안 작성(Redline)을 위해 변경 내용 추적 기능 켜기

docx track-changes mnda-filled.docx on

"having a reasonable need to know" 구간을 더 구체적으로 수정...

원문 보기
원문 보기 (영어)
docx-cli A .docx CLI built for AI agents. Leave comments, suggest redlines, and edit Word documents without breaking the formatting or losing content — a human accepts or rejects in Word afterward. Hand a .docx to Claude or Codex and get back a redlined copy with comments — open it in Word, accept or reject as usual. Agents address text by stable locators with character offsets ( p3:5-20 ); humans see normal Word formatting on disk. Custom styles, theme colors, embedded objects — all of it survives. The CLI mutates XML in place rather than re-emitting from a lossy model. Why docx-cli? The default way agents edit Word docs is to unzip the .docx and hand-write the OOXML inside. That takes a strong model to get right, burns tokens, and routinely produces a file Word won't open. docx-cli hands the agent plain commands plus an annotated-Markdown read view, so it never has to reason about the XML. We measured it — a controlled A/B bake-off: six real document tasks (fill an NDA, fill an invoice, restyle a résumé, redline a contract, finalize a contract, author a journal), the same starting files, and one independent judge grading every result from the Word-rendered pages . Three runs per arm at each of two model tiers: Haiku (weak, cheap) Sonnet (strong) docx-cli default skill docx-cli default skill Tasks solved (of 6) 4.3 (4–5) 0.7 (0–1) 6.0 (6–6) 4.0 (4–4) Rendered correctly (of 6) 6 3.7 6.0 4.7 Outright-broken documents 0 ~1/run (up to 2) 0 0 Input tokens 2.4M 6.1M (2.6×) 1.6M 3.6M (2.2×) Wall-clock 924 s 1,882 s (2.0× slower) 1,175 s 2,029 s (1.7× slower) The correctness gap is widest on the cheap Haiku tier (~6×) , and a frontier model never closes it — the default skill caps at 4/6, losing the contract redline and the résumé every Sonnet run. The cost and speed penalties are model-independent — ~2.2–2.6× more tokens and ~1.7–2× slower at both tiers, with token/time ranges that never overlap. Word couldn't reliably open the default skill's work — it failed to open 5 of 36 of its outputs; all 36 of docx-cli's opened on the first try. Full methodology, per-task rubric, and side-by-side renders: the bake-off writeup . Install npm — the simplest path (requires Bun >= 1.3): bun add -g bun-docx # or run without installing: bunx bun-docx read doc.docx Standalone binary (no Bun required). Every release publishes prebuilt binaries plus a SHA256SUMS manifest, and the installer verifies the binary's SHA-256 before installing: curl -fsSL https://raw.githubusercontent.com/kklimuk/docx-cli/main/install.sh | sh Honors PREFIX (default $HOME/.local/bin ) and VERSION (default latest ). Pre-built for linux/x64, linux/arm64, darwin/x64, darwin/arm64, windows/x64. Prefer to inspect first? Download docx-<platform> + SHA256SUMS from the latest release , verify, chmod +x , and put it on PATH . Quick example: filling out an NDA The repo includes a Common Paper Mutual NDA template at tests/fixtures/mnda.docx . Below are the primitives an agent would compose to fill in the cover page and leave redline edits — the same flow shown in the video above. Every command was verified end-to-end against the fixture: # Make a copy first — there's no undo (git is the history; the CLI overwrites in place) cp tests/fixtures/mnda.docx mnda-filled.docx # Read the cover-page table so the agent knows what placeholders exist docx read mnda-filled.docx --from t1 --to t1 # Fill the yellow-highlighted bracketed placeholders docx replace mnda-filled.docx " Fill in: today's date " " May 6, 2026 " docx replace mnda-filled.docx " fill in state and/or county " " California " docx replace mnda-filled.docx " fill in state " " California " docx replace mnda-filled.docx " Fill in, if any. " " None. " # Verify nothing's left to fill (bare locator lines, one per match; nothing → exit 0) docx find mnda-filled.docx ' \[(Fill|fill)[^]]*\] ' --regex --all # Flip on tracked changes for the redline pass docx track-changes mnda-filled.docx on # Tighten "having a reasonable need to know" in the Use & Protection clause docx replace mnda-filled.docx \ " having a reasonable need to know " \ " with a documented need to know " # Leave a comment for the human reviewer — addresses an existing span with --at docx comments add mnda-filled.docx --at p7:0-30 \ --text " Should we narrow 'representatives' to a named list? " Open mnda-filled.docx in Word: tracked changes and comments appear in the review pane, ready to accept, reject, or reply. Or run docx track-changes accept mnda-filled.docx --all to bake them in from the CLI. Use as an agent skill docx-cli ships as an Agent Skill — one SKILL.md that works across Claude Code, Codex, Pi, and the other harnesses that read the open skill format. The skill teaches the locator model and the redline / comment / fill workflows, then defers to docx <command> --help at runtime, so it can't go stale. Why a skill? docx-cli is built for the weakest, cheapest agents. In our weak-agent benchmark — 6 real document tasks (fill a contract, redline, comment, restyle, author from scratch), graded against Word renders, 3 runs each — Haiku driving docx-cli completed 4.3/6 tasks versus 0.7/6 for the default Claude skill, at roughly 2.5× fewer tokens ; with Sonnet it's 6/6 vs 4/6 , with roughly 2x fewer tokens. And every docx-cli output opened cleanly in Word on the first try — it never emits a file the renderer rejects. (Methodology and harness: .claude/skills/weak-agent-test .) Install Any agent ( skills.sh ) — one cross-harness command, installs into whichever agent you're using: npx skills add kklimuk/docx-cli Claude Code — one-line plugin install: /plugin marketplace add kklimuk/docx-cli /plugin install docx-cli@docx-cli Codex — add the marketplace (the plugin's skills auto-discover): codex plugin marketplace add kklimuk/docx-cli Pi — one-command install (the pi manifest in package.json pulls in the skill), then invoke /skill:docx-cli : pi install git:github.com/kklimuk/docx-cli # global; add -l for a project (team-shared) install # manual alternative: pi --skill /path/to/docx-cli/skills/docx-cli Any harness / manual — drop skills/docx-cli/ into your agent's skills directory (e.g. ~/.claude/skills/ or the cross-tool ~/.agents/skills/ ). On first activation the skill's scripts/bootstrap.sh installs the docx binary (and self-updates a stale one). Keeping the skill current The binary is the source of truth: docx info skill prints the canonical SKILL.md for the installed version, and a CI test fails if the committed copy drifts. Regenerate after any change with: docx info skill > skills/docx-cli/SKILL.md docx <command> --help is the authoritative contract Agents: run docx <command> --help before composing a call. Every command's --help is the source of truth for its flags, locator forms, and exact output shape — this README is a map, not the territory. Two more must-reads: docx info locators — the canonical locator grammar ( --json for a machine-readable form). The top-level docx --help says it outright: "It is highly recommended to agents to run docx info locators to understand their capabilities." docx info schema — the AST type definitions ( --ts for TypeScript source) that read --ast emits. Command reference docx <verb> and docx <noun> <verb> . Every command has --help . Two groups: read/query commands print data to stdout; mutate commands change the file (and accept --dry-run , -o/--output PATH , -v/--verbose ). Read & query (print to stdout, never write the file) docx read FILE [--from LOC] [--to LOC] [--accepted | --baseline | --current] [--comments] docx read FILE --ast # JSON-AST instead of Markdown (disables the markdown-only flags) docx find FILE QUERY [--regex] [--ignore-case] [--all] [--nth N] [--current | --baseline] [--exact] [--json] docx find FILE (--highlight COLOR | any | --color HEX | --bold | --italic | --underline) [--all] [--json] # find by formatting (no QUERY) docx wc FILE [LOCATOR] [--accepted | --baseline | --current] [--json] docx outline FILE [--style-prefix S] [--json] d