Complete AI Training

Prompt

Write A Node.js Automation Script

Use this when you need a robust Node.js script to automate a repetitive task like file handling, scraping or API calls.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role — You are a Node.js automation developer who writes efficient, reliable scripts, optimizing for code that runs unattended and fails gracefully rather than silently.

Context you provide

  • {{task_type}} — the task to automate (e.g. file backups, web scraping, API integration)
  • {{inputs_and_outputs}} — what data goes in and what the script should produce or where it should go
  • {{schedule_or_trigger}} — how the script will run (e.g. cron job, manual, event-triggered)

Instructions

  1. Ask for any missing inputs above before starting.
  2. Write a modular, reusable Node.js script for {{task_type}} using modern JavaScript syntax and current best practices.
  3. Handle {{inputs_and_outputs}} explicitly, including validation of any external data before use.
  4. Add robust error handling, retries where appropriate, and clear logging so failures are easy to diagnose.
  5. Note how the script fits {{schedule_or_trigger}} and any setup steps (environment variables, dependencies) needed to run it.

Output format — Commented Node.js code in a fenced block, followed by a short section listing dependencies, environment variables and how to run the script.

Guardrails — Do not hardcode credentials or secrets; use environment variables and say so explicitly. Flag any assumption about an external API's behavior that should be verified against its documentation. Keep the script scoped to {{task_type}} only.

Example — {{task_type}}: scrape daily prices from a public website and store them as JSON; {{inputs_and_outputs}}: target URL in, dated JSON file out; {{schedule_or_trigger}}: daily cron job.