Aller au contenu
Skillpedia
Programmation générale7.8k · #12880

fallback-file-creation

Ce qu’il fait

Ce skill offre à l'IA une méthode manuelle, basée sur le shell, pour créer et contrôler des fichiers lorsque les outils d'exécution de code échouent sans cesse. Il s'adresse aux personnes qui ont besoin de formats de fichiers précis produits de façon fiable.

Quand l’utiliser

  • ✓Quand les outils d'exécution de code ou les assistants shell ont échoué plusieurs fois sur une tâche de fichier.
  • ✓Quand j'ai besoin de créer un fichier PDF ou Word et que les outils habituels ne fonctionnent pas.
  • ✓Quand je veux que chaque fichier soit contrôlé après son écriture.

Lien du skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-file-creation/SKILL.md

Copiez-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

Utilise ce skill pour m’aider : https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-file-creation/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Les outils de code échouent sans cesse sur mon fichier. Vérifie le dossier, écris le script dans le shell et confirme que le fichier est bien là.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'IA confirme le dossier de travail, écrit les scripts avec un heredoc shell, les lance avec un chemin explicite et vérifie que chaque fichier de sortie existe.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

Fallback File Creation Workflow

Use this skill when execute_code_sandbox or shell_agent fails repeatedly for file creation tasks. This pattern provides a manual but reliable approach to create and verify files.

When to Use

  • Code execution tools fail after multiple retries
  • You need to create specific file formats (PDF, DOCX, etc.)
  • Direct shell commands are more reliable than generated scripts
  • You need explicit verification of file outputs

Step-by-Step Instructions

Step 1: Verify Working Directory

Before any file operations, confirm your current location:

pwd
ls -la

This ensures you're creating files in the correct workspace directory.

Step 2: Create Scripts via Heredoc

Use shell heredocs to create scripts with properly escaped syntax:

cat > /path/to/script.sh << 'EOF'
#!/bin/bash
# Your script content here
# Variables are NOT expanded inside 'EOF' (quoted)
echo "Creating file..."
# Commands to generate output
EOF

Key escaping rules:

  • Use 'EOF' (quoted) to prevent variable expansion inside the heredoc
  • Use EOF (unquoted) if you want shell variables to expand
  • Escape any $, backticks, or special characters if using unquoted EOF

Step 3: Execute with Explicit Path

Always run scripts with their full or explicit relative path:

chmod +x /path/to/script.sh
/path/to/script.sh
# or
bash /path/to/script.sh

Avoid relying on . or implicit paths.

Step 4: Verify Output

After execution, verify files were created correctly:

# Check file exists and size
ls -lh /path/to/output.file

# For PDFs: inspect metadata
pdfinfo /path/to/output.pdf

# For DOCX: check structure
unzip -l /path/to/output.docx | head -20

# For any file: check content preview
file /path/to/output.file
head -c 500 /path/to/output.file

Step 5: Iterative Debugging

If verification fails:

  1. Check error messages from script execution
  2. Verify all dependencies are available (which command)
  3. Test individual commands from the script manually
  4. Re-run with verbose output (bash -x script.sh)

Example: Creating a PDF Document

# Step 1: Verify directory
pwd
ls -la

# Step 2: Create conversion script
cat > /workspace/create_pdf.sh << 'EOF'
#!/bin/bash
cd /workspace
libreoffice --headless --convert-to pdf checklist.odt --outdir .
EOF

# Step 3: Execute
chmod +x /workspace/create_pdf.sh
/workspace/create_pdf.sh

# Step 4: Verify
ls -lh /workspace/checklist.pdf
pdfinfo /workspace/checklist.pdf

Example: Creating a DOCX Document

# Step 1: Verify directory
pwd
ls -la

# Step 2: Create document script
cat > /workspace/create_docx.sh << 'EOF'
#!/bin/bash
cd /workspace
pandoc -f markdown -t docx action_tracker.md -o action_tracker.docx
EOF

# Step 3: Execute
chmod +x /workspace/create_docx.sh
/workspace/create_docx.sh

# Step 4: Verify
ls -lh /workspace/action_tracker.docx
unzip -l /workspace/action_tracker.docx | head -20

Best Practices

  1. Always verify before and after - Check directory state before starting and after completion
  2. Use absolute or explicit paths - Avoid ambiguity in file locations
  3. Quote heredoc delimiters - Use 'EOF' to prevent unwanted variable expansion
  4. Make scripts executable - Always chmod +x before running
  5. Inspect file metadata - Use format-specific tools (pdfinfo, unzip -l, file) to verify content
  6. Keep scripts simple - Each script should do one thing well
  7. Clean up temporary files - Remove intermediate files after successful completion

Troubleshooting

Issue Solution
Script not found Use full path: /workspace/script.sh
Permission denied Run chmod +x script.sh
File not created Check script output, verify working directory in script
Wrong file format Verify conversion tool supports target format
Corrupted output Re-run with verbose mode, check intermediate files
Questions fréquentes

Pourquoi utiliser un heredoc ?

Il permet à l'IA d'écrire un script complet dans un fichier en une seule commande shell.

Pourquoi vérifier d'abord le dossier de travail ?

Cela garantit que les fichiers sont créés dans le bon espace de travail.

Les variables sont-elles développées dans le script ?

Avec un marqueur EOF entre guillemets, non, ce qui conserve le texte du script exactement tel qu'il est écrit.

Détails

Description originale de l’auteur

Fallback pattern for reliable file creation when code execution tools fail

repo: HKUDS/AgentPilot

Popularité

Étoiles GitHub
7.8k
Position au classement
#12880
Licence
MIT
Mis à jour
01/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires