docx
하는 일
이 스킬은 AI 에이전트가 Microsoft Word 문서를 다루도록 합니다. 보고서, 편지, 메모를 Word 파일로 만들거나 기존 Word 파일을 읽고 고쳐야 하는 사람에게 맞습니다.
사용하는 경우
- ✓보고서, 편지, 메모를 .docx 파일로 만들어야 할 때.
- ✓기존 Word 파일에서 텍스트나 표를 뽑아내고 싶을 때.
- ✓Word 문서에 변경 추적이나 댓글을 추가해야 할 때.
스킬 링크
https://github.com/HKUDS/DeepTutor/blob/main/deeptutor/skills/builtin/docx/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 메모를 제목, 표, 페이지 번호가 있는 Word 보고서로 만들어 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 대부분의 작업에 python-docx 라이브러리를 쓰고, 변경 추적과 댓글 같은 고급 작업에는 Word XML을 직접 씁니다. 원본을 덮어쓰지 않고 새 출력 파일을 저장합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
DOCX (Microsoft Word)
A .docx is a ZIP of XML parts. Body text lives in word/document.xml. Two tiers:
- Default —
python-docx(preinstalled): create, read, and simple edits. Use for almost everything. - Advanced — raw OOXML via
zipfile: only for what python-docx cannot express — tracked changes (redlines), comments, and exact-fidelity edits that must preserve every untouched byte. See Raw OOXML.
Runtime
Use exec with complete Python source (language: python). python-docx is
preinstalled. Prefer creating, saving, reopening, and validating the deliverable
in one call; later calls can revise the same relative filename. Follow the
turn's User workspace instructions for locating inputs, output boundaries,
and presenting the finished file. When editing, write a new output unless the
user explicitly requested an authorized replacement.
Read / extract
from docx import Document
doc = Document("in.docx")
text = "\n".join(p.text for p in doc.paragraphs) # body paragraphs
for tbl in doc.tables: # tables
for row in tbl.rows:
print([c.text for c in row.cells])
doc.paragraphs skips text inside tables, headers/footers, and text boxes — iterate doc.tables and doc.sections[i].header/.footer for those. Each paragraph's style: p.style.name (e.g. "Heading 1").
To read tracked changes, parse the XML directly — python-docx ignores <w:ins>/<w:del>:
import zipfile, re
xml = zipfile.ZipFile("in.docx").read("word/document.xml").decode("utf-8")
# inserted text = <w:ins>…<w:t>… deleted = <w:del>…<w:delText>…
print(re.findall(r"<w:t[^>]*>(.*?)</w:t>", xml))
Create
from docx import Document
from docx.shared import Pt, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document() # default template page size
doc.add_heading("Quarterly Report", level=0) # 0 = title; 1..9 = H1..H9
p = doc.add_paragraph("Intro paragraph. ")
run = p.add_run("Bold tail.")
run.bold = True
doc.add_paragraph("First item", style="List Bullet") # real list style, never a "• " literal
doc.add_paragraph("Step one", style="List Number")
# Table — header row + data
tbl = doc.add_table(rows=1, cols=2)
tbl.style = "Light Grid Accent 1"
tbl.rows[0].cells[0].text, tbl.rows[0].cells[1].text = "Metric", "Value"
for k, v in [("Revenue", "1.2M"), ("Growth", "15%")]:
c = tbl.add_row().cells
c[0].text, c[1].text = k, v
doc.add_picture("chart.png", width=Inches(5)) # image, scaled to width
doc.add_page_break()
doc.save("out.docx")
# Validate immediately; later exec calls can also reopen this relative path.
check = Document("out.docx")
assert check.paragraphs, "generated DOCX has no paragraphs"
import zipfile
with zipfile.ZipFile("out.docx") as package:
assert package.testzip() is None, "generated DOCX has a corrupt ZIP member"
Rules:
- Never type bullet/number characters (
•,1.) into text — usestyle="List Bullet"/"List Number". Only list styles defined in the doc's template are available. - No
\ninside a run — each visual line is its ownadd_paragraph. - Built-in style names must match the template (e.g.
"Heading 1","List Bullet"); a wrong name raisesKeyError. - Units:
Pt,Inches,Cmfromdocx.shared. Colors:RGBColor(0x1F,0x4E,0x79).
Page setup, headers/footers, page numbers
from docx.shared import Inches
sec = doc.sections[0]
sec.page_width, sec.page_height = Inches(8.5), Inches(11) # Letter
sec.top_margin = sec.bottom_margin = Inches(1)
sec.header.paragraphs[0].text = "Confidential"
Page-number fields aren't in the python-docx API; inject the field XML into a footer run:
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
def add_page_number(paragraph):
for t in ("begin", "instr", "end"):
r = OxmlElement("w:r")
if t == "instr":
fld = OxmlElement("w:instrText")
fld.set(qn("xml:space"), "preserve")
fld.text = "PAGE"
else:
fld = OxmlElement("w:fldChar")
fld.set(qn("w:fldCharType"), t)
r.append(fld)
paragraph._p.append(r)
add_page_number(doc.sections[0].footer.paragraphs[0])
A clickable Table of Contents is also a field; Word shows "right-click → Update Field" until refreshed. Same pattern with instrText = TOC \o "1-3" \h \z \u.
Edit existing (simple)
python-docx preserves the rest of the doc
자주 묻는 질문
PDF나 Excel 파일도 다루나요?
아닙니다. 이 스킬은 Word 파일을 위한 것이며, PDF, Excel, PowerPoint, Google Docs는 범위 밖이라고 설명합니다.
목차를 추가할 수 있나요?
네. 목차와 페이지 번호를 다룹니다.
변경 추적을 만들 수 있나요?
네. 고급 방식으로 변경 추적과 댓글을 적용할 수 있습니다.
상세 정보
작성자의 원본 설명
Read, create, or edit Microsoft Word .docx files — extract/summarize text and tables, generate reports/letters/memos with headings, tables, images, TOC and page numbers, do find-and-replace, or apply tracked changes (redlines) and comments. Use whenever the user has a .docx or wants a Word deliverable. Not for PDF, .xlsx, .pptx, or Google Docs.
repo: HKUDS/DeepTutor
인기도
- GitHub 스타
- 54k
- 순위
- #3368
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
deeptutor-cli
54k에이전트가 학습 플랫폼 DeepTutor를 명령줄에서 설정하고 실행하도록 돕습니다. 지식 베이스, 노트북, 웹 앱을 포함합니다.
에이전트가 PDF 파일을 읽고, 병합하고, 나누고, 양식을 채우고, 새로 만들도록 돕습니다. 텍스트와 표를 뽑아내는 작업도 포함합니다.
pptx
54k에이전트가 PowerPoint 슬라이드 덱을 만들고 읽고 고치도록 돕습니다. 슬라이드 텍스트, 발표자 노트, 차트, 이미지를 포함합니다.
skill-creator
54k에이전트가 DeepTutor 스킬, 즉 특정 작업을 AI에 가르치는 짧은 지침 묶음을 쓰거나 개선하도록 돕습니다.
비슷한 스킬
feishu-doc
394k에이전트가 문서 도구를 사용해 텍스트, 이미지, 표를 포함한 Feishu 클라우드 문서를 읽고, 만들고, 편집하도록 돕습니다.
feishu-drive
394k에이전트가 봇과 공유된 Feishu 클라우드 폴더의 파일을 찾아보고, 정리하고, 댓글을 달도록 돕습니다.
feishu-perm
394k에이전트가 요청을 충족하는 가장 작은 권한을 골라, Feishu 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.