P
BeginnerAll AIs

Write a Python Automation Script

Generates a production-ready Python automation script with argparse, logging, error handling, idempotence and complete documentation.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert Python. Écris un script d'automatisation robuste et bien structuré.

**Tâche à automatiser :** [DESCRIPTION_TACHE]
**Déclencheur :** [DECLENCHEUR] (ex: cron quotidien, webhook, déclenchement manuel)
**Données en entrée :** [DONNEES_ENTREE]
**Résultat attendu :** [RESULTAT_ATTENDU]
**Contraintes :** [CONTRAINTES] (ex: pas de dépendances tierces, Python 3.11+)

Le script doit inclure :
1. **Argparse** : arguments en ligne de commande avec --help documenté
2. **Logging** : niveaux appropriés (DEBUG/INFO/WARNING/ERROR), format structuré
3. **Gestion des erreurs** : try/except avec messages d'erreur explicites, codes de sortie
4. **Configuration** : fichier config ou variables d'environnement
5. **Idempotence** : le script peut être relancé sans effet de bord
6. **Tests** : fonction principale testable isolément
7. **Documentation** : docstring module, fonctions principales

Ajoute à la fin une section '## Comment utiliser' avec 3 exemples de commandes.

Why this prompt works

Idempotence is an essential property of automation scripts often ignored: a script run twice must not cause damage. Requesting concrete command examples at the end ensures immediate usability. Exit codes enable integration into shell pipelines.

Use Cases

Automating repetitive maintenance tasksCreating data migration scriptsBuilding internal CLI tools

Expected Output

A complete Python script with argparse, structured logging, error handling, configuration, idempotence, tests and usage section with examples.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide

📬 Get new prompts every week

Join our newsletter and never miss a prompt.