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 :
- Argparse : arguments en ligne de commande avec --help documenté
- Logging : niveaux appropriés (DEBUG/INFO/WARNING/ERROR), format structuré
- Gestion des erreurs : try/except avec messages d'erreur explicites, codes de sortie
- Configuration : fichier config ou variables d'environnement
- Idempotence : le script peut être relancé sans effet de bord
- Tests : fonction principale testable isolément
- Documentation : docstring module, fonctions principales
Ajoute à la fin une section '## Comment utiliser' avec 3 exemples de commandes.
Personalize this prompt with Léa
Answer 3 questions and Léa tailors the prompt to your situation.
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
Expected Output
A complete Python script with argparse, structured logging, error handling, configuration, idempotence, tests and usage section with examples.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Pour structurer le logging, pensez à intégrer un `RotatingFileHandler` avec un format JSON pour faciliter l'analyse dans des outils comme Splunk. Ajoutez aussi une option `--dry-run` pour valider les actions sans effet.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.