pdf-extract-shell-first
Ce qu’il fait
Ce skill donne un ordre d'utilisation des outils pour extraire le texte des PDF, avec l'outil shell en premier car il est le plus fiable. Il s'adresse aux personnes qui ont besoin du texte d'un PDF et veulent moins de tentatives échouées.
Quand l’utiliser
- ✓Quand un PDF se trouve sur mon ordinateur et que j'ai besoin de son texte le plus rapidement possible.
- ✓Quand un PDF se trouve à une adresse web et doit être téléchargé avant lecture.
- ✓Quand j'ai besoin de l'extraction la plus fiable et que je veux disposer de tous les outils de repli.
Lien du skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-e27e0c/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Obtiens le texte de ce PDF, qu'il soit local ou issu d'un lien web. Utilise d'abord l'outil shell, puis les outils Python si nécessaire.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
Si le PDF est en ligne, l'IA le télécharge avec une requête de type navigateur. Elle tente ensuite la lecture simple, lance pdftotext depuis le shell, et utilise Python en dernier recours.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
PDF Extract with Shell-First Tool Cascade
This skill provides an optimized workflow for extracting text content from PDF documents (local files or downloaded URLs) using a prioritized tool cascade that favors shell-based extraction before falling back to Python libraries.
Why Shell-First?
Analysis of execution patterns shows:
read_fileon PDFs sometimes returns binary/image data instead of textrun_shellwithpdftotexthas higher success rate and fewer sandbox errorsexecute_code_sandboxcan fail with "unknown error" in constrained environments- Shell tools are more reliable for PDF text extraction when available
Entry Point: Determine Your Starting Point
Before beginning, identify your scenario:
| Scenario | Start Here | Skip |
|---|---|---|
| PDF already on local disk | Step 1 (Try read_file) | Shell download steps |
| PDF at a web URL | Shell download, then Step 1 | None |
| Need maximum reliability | Full cascade (all 3 tools) | None |
Complete Workflow
Step 0: Download PDF (URL Only)
If your PDF is at a web URL, download it first using browser user-agent:
curl -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" -o target.pdf "URL_HERE"
Key flags:
-L: Follow redirects-A: Set user-agent header to mimic a real browser-o: Specify output filename
If you already have the PDF locally, skip to Step 1.
Step 1: Try read_file (Primary Attempt)
First, attempt to extract text using the read_file tool:
read_file(filetype="pdf", file_path="target.pdf")
Evaluate the response:
| Response Type | Interpretation | Next Action |
|---|---|---|
| Clean readable text | Success | Proceed to content analysis |
| Binary data / PNG image / garbled | read_file returned raw data |
Go to Step 2 immediately |
| Error / timeout | Tool failure | Go to Step 2 immediately |
Critical: If read_file returns binary image data or garbled content, do not retry read_file. Immediately proceed to Step 2.
Step 2: Use run_shell with pdftotext (Preferred Fallback)
When read_file fails or returns binary data, use run_shell with pdftotext:
run_shell(command="pdftotext target.pdf output.txt")
Then read the extracted text:
read_file(filetype="txt", file_path="output.txt")
If pdftotext is not found, install it first:
run_shell(command="apt-get update && apt-get install -y poppler-utils")
# Or for macOS:
run_shell(command="brew install poppler")
Then retry:
run_shell(command="pdftotext target.pdf output.txt")
Verify extraction quality:
- Check that
output.txtexists and has content - Sample the text to ensure it's readable (not garbled)
- If extraction looks corrupted, proceed to Step 3
Step 3: Use execute_code_sandbox with PyMuPDF (Last Resort)
If pdftotext is unavailable or produces poor results, use Python's PyMuPDF via execute_code_sandbox:
import fitz # PyMuPDF
doc = fitz.open("target.pdf")
text = ""
for page in doc:
text += page.get_text()
doc.close()
with open("output.txt", "w") as f:
f.write(text)
print(f"Extracted {len(text)} characters from {len(doc)} pages")
Execute via:
execute_code_sandbox(code="<python code above>")
Then read the result:
read_file(filetype="txt", file_path="output.txt")
Note: execute_code_sandbox may fail with "unknown error" in some environments. If this occurs, document the failure and proceed to Step 4.
Step 4: Graceful Degradation to Domain Knowledge
If all extraction methods fail:
- Document the specific failure mode for each tool attempted
- Extract any partial content that was successfully retrieved
- Supplement missing content from established domain knowledge
- Clearly mark which portions are from source vs. generated from knowledge
- Provide citations for any claimed requirements or specifications
Example degradation documentation:
EXTRACTION FAILURE REPORT:
- Source: [URL or file path]
- read_file: Returned binary/image data (no text extraction)
- run_shell/pdftotext: [Tool not available / produced garbled output / succeeded]
- execute_code_sandbox/PyMuPDF: [Failed with unknown error / succeeded]
NOTE: Content below combines partial extraction with established domain
knowledge for [topic]. Verify against official sources when available.
``
Questions fréquentes
Pourquoi l'outil shell passe-t-il en premier ?
Le guide indique que pdftotext a un taux de réussite plus élevé et provoque moins d'erreurs de bac à sable.
Comment un PDF web est-il téléchargé ?
Avec curl, en utilisant un en-tête de type navigateur et en suivant les redirections.
Et si tous les outils échouent ?
La cascade du guide parcourt les trois outils, de sorte que la dernière option Python est essayée avant d'abandonner.
Détails
Description originale de l’auteur
PDF text extraction with tool cascade prioritizing shell pdftotext before Python fallback
repo: HKUDS/AgentPilot
Popularité
- Étoiles GitHub
- 7.8k
- Position au classement
- #12917
- Licence
- MIT
- Mis à jour
- 01/11/2026
Commentaires
- …
Autres skills de ce dépôt
agentpilot
7.8kAide votre agent à améliorer un projet étape par étape, en préparant une tâche et en lançant la boucle AgentPilot qui propose, teste et note les changements.
openspace
7.8kAide votre agent à installer OpenSpace, un outil qui enregistre et retrouve les skills des agents, et à le relier à votre application IA grâce à MCP.
rsi-arena
7.8kAide votre agent à configurer et lancer des tests de référence standard en IA, comme AIME et Terminal-Bench, pour comparer différentes méthodes d'amélioration.
experiment-guide
7.8kAide votre agent à planifier de petites expériences, à lire leurs résultats et à noter les conclusions pendant qu'il cherche comment améliorer un programme.
Skills similaires
feishu-doc
394kAide votre agent à lire, créer et modifier des documents cloud Feishu, y compris du texte, des images et des tableaux, grâce à l'outil de document.
feishu-drive
394kPermet à votre agent de parcourir, organiser et commenter des fichiers d'un dossier cloud Feishu partagé avec le bot.
feishu-perm
394kAide votre agent à vérifier et modifier qui peut accéder à un fichier Feishu, en choisissant la plus petite autorisation qui répond à votre demande.