본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #13014

document-direct-python

하는 일

이 스킬은 AI 에이전트가 Python을 직접 실행해 Excel 통합 문서, PDF 보고서, 양식 같은 문서를 만들도록 안내합니다. 셸 에이전트의 지연 없이 이 파일들이 필요한 사람을 위한 스킬입니다.

사용하는 경우

  • ✓Python으로 PDF 문서, 체크리스트 또는 보고서가 필요할 때.
  • ✓문서 작업에 여러 단계가 있고 에이전트 제한을 넘을 수 있을 때.
  • ✓셸 에이전트가 서식 작업이나 통합 문서 읽기에서 실패할 때.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-merged/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-merged/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 데이터로 reportlab을 써서 PDF 보고서를 만들고, openpyxl로 Excel 통합 문서를 만들어 주세요. 코드를 직접 실행해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 Python 코드를 파일로 쓰고 셸에서 python3로 실행합니다. 코드는 문서 라이브러리로 파일을 만들고, 에이전트는 출력된 내용에서 오류가 있는지 확인합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Direct Python Execution for Document Generation Tasks

When to Use This Skill

Use direct run_shell with Python scripts for document operations when:

  • Reading or writing complex Excel files with multiple sheets
  • Generating PDF documents, checklists, or reports
  • Applying formulas, formatting, or data transformations
  • Working with openpyxl, pandas, reportlab, FPDF, or similar libraries
  • The operation involves multiple steps that could exceed agent step limits
  • You need precise control over error handling and debugging
  • Complex scripts benefit from file-based execution for better reliability

Why Direct Execution?

The shell_agent tool can:

  • Hit maximum step limits on complex multi-step operations
  • Produce unexplained errors on formatting operations
  • Fail on intricate document reads/writes due to iterative parsing
  • Fail to parse heredoc syntax correctly, causing 'unknown error' failures

Direct run_shell with Python is more reliable because it:

  • Executes in a single step with no iteration limits
  • Provides clearer, immediate error messages
  • Handles complex operations without step constraints
  • Gives full control over library imports and execution flow
  • Writing scripts to .py files first avoids shell_agent parsing issues with heredocs

How to Use

Handling Web Research Failures

When web research tools (search_web, read_webpage) fail or return 'unknown error':

  1. Assess what you need: Determine if the information is from well-documented regulatory frameworks, standards, or common knowledge that you can provide from internal knowledge.
  2. Proceed with available knowledge: For pharmacy compliance, OSHA standards, GDPR requirements, and similar well-established frameworks, generate documents using your training knowledge rather than waiting for web access.
  3. Document assumptions: Clearly note that materials were generated based on standard practices when source verification was unavailable.
  4. Use direct Python execution: Continue with the recommended run_shell pattern to generate documents even without web-sourced content.

Example contingency workflow for pharmacy compliance:

# When web research fails, proceed with established regulatory knowledge
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

checklist_items = [
    "Verify pharmacist license is current and displayed",
    "Maintain controlled substance inventory logs",
    "Ensure proper storage temperatures for medications",
    "Keep patient counseling records for controlled substances",
    "Display required pharmacy signage and notices"
]
# Generate PDF using these standard compliance items

This approach was successfully used in task 045aba2e-4093-42aa-ab7f-159cc538278c_phase2 where all web tools failed but pharmacy compliance PDFs were still created successfully.

Recommended Pattern: Write Script to File First

For complex multi-line scripts, especially when using shell_agent as executor:

# Step 1: Write the Python script to a file
cat > generate_document.py << 'EOF'
import openpyxl
from openpyxl import Workbook

# Your document code here
wb = openpyxl.load_workbook('file.xlsx')
# ... operations ...
wb.save('output.xlsx')
print('Success')
EOF

# Step 2: Execute the script
python3 generate_document.py

Alternative Pattern: Inline Heredoc (Simple Scripts Only)

For short, simple scripts when NOT using shell_agent as the executor:

python3 << 'EOF'
import pandas as pd
df = pd.read_excel('input.xlsx')
df.to_excel('output.xlsx', index=False)
print('Done')
EOF

Spreadsheet Examples

Example 1: Read and Transform Excel Data

Write to file first, then execute:

import pandas as pd

# Load data from specific sheet
df = pd.read_excel('input.xlsx', sheet_name='Revenue')

# Apply transformations
df['Net_Revenue'] = df['Gross_Revenue'] * (1 - df['Tax_Rate'])

# Save results
df.to_excel('output.xlsx', index=False, sheet_name='Processed')

Example 2: Multi-Sheet Operations with openpyxl

from openpyxl import load_workbook

wb = load_workbook('tour_data.xlsx')

# Iterate through sheets
for sheet_name in wb.sheetnames:
    ws = wb[sheet_name]
    # Apply formatting or calculations
    for row in ws.iter_rows(min_row=2, max_col=5):
        # Process cells
        pass

wb.save('tour_data_processed.xlsx')

PDF Generation Examples

Example 3: Generate PDF Checklist with reportla

자주 묻는 질문

직접 실행의 가장 큰 장점은 무엇인가요?

스킬은 한 단계에서 실행되고, 오류 메시지를 즉시 명확하게 보여 준다고 설명합니다.

Word 파일도 만들 수 있나요?

네, 스킬은 Word 문서를 지원하는 출력 형식으로 언급합니다.

에이전트는 항상 파일을 먼저 쓰나요?

스킬은 복잡하고 여러 줄로 된 코드에는 스크립트를 파일로 쓰라고 권합니다.

상세 정보

작성자의 원본 설명

Use direct Python execution for reliable document creation including spreadsheets, PDFs, and structured reports

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#13014
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬