docx-shell-workaround
Qué hace
Esta skill cubre la lectura de archivos .docx mediante comandos de shell y análisis de XML cuando fallan las herramientas estándar. Está pensada para quienes su IA no puede leer sus archivos Word directamente.
Cuándo usarla
- ✓Cuando el lector de archivos no puede extraer el contenido de un archivo .docx.
- ✓Cuando el entorno aislado de código falla al crear o cambiar un archivo Word.
- ✓Cuando necesito una alternativa fiable para trabajar con el contenido de los archivos Word.
Link de la skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-workaround/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“La IA no puede leer mi archivo Word. Saca el texto usando la shell, para que podamos trabajar a partir de ahí.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La IA descomprime el XML del documento y lo analiza con ElementTree de Python en una ejecución de shell, recopilando el texto de cada párrafo.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
DOCX Shell Workaround
When to Use
Use this skill when:
read_filecannot extract content from .docx filesexecute_code_sandboxencounters failures when creating or modifying docx files- You need a reliable fallback for docx file manipulation
Reading DOCX Files
Step 1: Extract document.xml using unzip
Use run_shell to unzip the .docx file (which is a ZIP archive) and extract the main document XML:
unzip -p input.docx word/document.xml > document.xml
Step 2: Parse XML with ElementTree via run_shell
Extract text content by parsing the XML. Use run_shell to execute Python code:
python3 << 'EOF'
import xml.etree.ElementTree as ET
tree = ET.parse('document.xml')
root = tree.getroot()
namespace = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
text_content = []
for elem in root.iter():
if elem.tag.endswith('t'):
if elem.text:
text_content.append(elem.text)
text = ''.join(text_content)
print(text)
EOF
Step 3: Optional - More robust XML parsing
For better text extraction that handles paragraphs:
python3 << 'EOF'
import xml.etree.ElementTree as ET
tree = ET.parse('document.xml')
root = tree.getroot()
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
paragraphs = []
for p in root.findall('.//w:p', ns):
para_text = []
for t in p.findall('.//w:t', ns):
if t.text:
para_text.append(t.text)
if para_text:
paragraphs.append(''.join(para_text))
for para in paragraphs:
print(para)
EOF
Creating DOCX Files
Use python-docx via run_shell (NOT execute_code_sandbox)
When execute_code_sandbox fails for docx operations, use run_shell instead:
python3 << 'EOF'
from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document()
# Add heading
doc.add_heading('Document Title', 0)
# Add paragraph
doc.add_paragraph('Your content here.')
# Add section with heading
doc.add_heading('Section Title', level=1)
doc.add_paragraph('Section content with multiple paragraphs.')
# Add table if needed
table = doc.add_table(rows=3, cols=3)
table.style = 'Table Grid'
# Save document
doc.save('output.docx')
print("Document created successfully")
EOF
Example: Creating a structured business document
python3 << 'EOF'
from docx import Document
from docx.shared import Pt
doc = Document()
# Title
title = doc.add_heading('Business Strategy Memo', 0)
title.alignment = 1 # Center
# Executive Summary
doc.add_heading('Executive Summary', level=1)
doc.add_paragraph('Brief overview of key points and recommendations.')
# Market Overview
doc.add_heading('Market Overview', level=1)
doc.add_paragraph('Analysis of current market conditions and trends.')
# Recommendations
doc.add_heading('Recommendations', level=1)
doc.add_paragraph('Actionable recommendations based on analysis.')
doc.save('Strategy_Memo.docx')
EOF
Full Workflow Example
Complete example showing extraction and creation:
# Step 1: Extract content from existing docx
unzip -p existing.docx word/document.xml > doc.xml
# Step 2: Parse and transform content
python3 << 'EOF'
import xml.etree.ElementTree as ET
tree = ET.parse('doc.xml')
root = tree.getroot()
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
content = []
for p in root.findall('.//w:p', ns):
para_text = []
for t in p.findall('.//w:t', ns):
if t.text:
para_text.append(t.text)
if para_text:
content.append(''.join(para_text))
# Write extracted content to file for reference
with open('extracted.txt', 'w') as f:
for line in content:
f.write(line + '\n')
EOF
# Step 3: Create new docx with modified content
python3 << 'EOF'
from docx import Document
doc = Document()
doc.add_heading('Updated Document', 0)
with open('extracted.txt', 'r') as f:
for line in f:
if line.strip():
doc.add_paragraph(line.strip())
doc.save('updated.docx')
EOF
Key Points
- Always use
run_shell- Notexecute_code_sandboxfor docx operations - DOCX is a ZIP archive - Contains XML files including word/document.xml
- Use
unzip -p- The-pflag outputs to stdout, useful for piping - Handle XML namespaces - Word XML uses the
w:namespace prefix - Install python-docx if needed - Run
pip install python-docxin the shell if not avai
Preguntas frecuentes
¿Qué es ElementTree?
Es un módulo de la biblioteca estándar de Python para leer archivos XML.
¿Por qué analizar por párrafos?
Analizar por párrafos mantiene el texto ordenado, en lugar de unir todas las palabras.
¿Los ejemplos modifican el archivo?
No. Los ejemplos se centran en leer el texto del archivo.
Detalles
Descripción original del autor
Handle docx files using shell-based XML extraction and python-docx via run_shell when standard tools fail
repo: HKUDS/AgentPilot
Popularidad
- Estrellas en GitHub
- 7,8 mil
- Posición en el ranking
- #12871
- Licencia
- MIT
- Actualizada
- 1/11/2026
Comentarios
- …
Más skills de este repositorio
agentpilot
7,8 milAyuda a tu agente a mejorar un proyecto paso a paso, preparando una tarea y ejecutando el bucle de AgentPilot que propone, prueba y puntúa cambios.
openspace
7,8 milAyuda a tu agente a configurar OpenSpace, una herramienta que guarda y recupera skills de agentes, y a conectarla a tu app de IA mediante MCP.
rsi-arena
7,8 milAyuda a tu agente a configurar y ejecutar pruebas de referencia de IA conocidas, como AIME y Terminal-Bench, para comparar distintos métodos de mejora.
experiment-guide
7,8 milAyuda a tu agente a planificar experimentos pequeños, leer sus resultados y anotar conclusiones mientras investiga cómo mejorar un programa.
Skills parecidas
feishu-doc
394 milAyuda a tu agente a leer, crear y editar documentos en la nube de Feishu, incluidos texto, imágenes y tablas, usando la herramienta de documentos.
feishu-drive
394 milPermite que tu agente explore, organice y comente archivos de una carpeta de la nube de Feishu que se haya compartido con el bot.
feishu-perm
394 milAyuda a tu agente a revisar y cambiar quién puede acceder a un archivo de Feishu, eligiendo el permiso más pequeño que cumpla tu petición.