GPT Prompting Guide

A practical guide to getting the most out of ChatGPT and the OpenAI API — including GPT-4o, o1, and custom instructions. Focused on IT ops and sysadmin workflows.

Model Selection

Model Best For Notes
GPT-4o Code, analysis, fast response Default choice for most tasks
o1 / o3 Complex reasoning, debugging Slower; uses chain-of-thought internally
GPT-4o mini Quick lookups, simple tasks Fastest and cheapest; API default

Custom Instructions (ChatGPT)

Set persistent context in Settings → Personalization → Custom Instructions. Effective sysadmin setup:

What would you like ChatGPT to know about you?
I am a senior Linux sysadmin managing Ubuntu 22.04, RHEL 9, Docker,
Kubernetes, and AWS infrastructure. I prefer CLI-first solutions,
minimal dependencies, and well-commented scripts.

How would you like ChatGPT to respond?
Provide working code I can run immediately. Skip preamble.
Use code blocks for all commands. Flag any destructive operations
with a WARNING comment. Prefer bash over Python for simple automation.

System Prompt (API)

You are a senior DevOps engineer. When asked for scripts or configs:
1. Always include error handling (set -euo pipefail for bash).
2. Add inline comments for non-obvious lines.
3. State any required packages at the top.
4. Flag commands that require sudo or root with # REQUIRES ROOT.
Return ONLY code unless the user asks for explanation.

Sysadmin Prompt Templates

Task Prompt
Docker Compose Create a docker-compose.yml for [service] with: health checks, restart:unless-stopped, named volumes, and a .env file for secrets.
Regex Write a POSIX-ERE regex that matches [pattern]. Test it with: grep -E ‘[regex]’ and show 3 matching and 2 non-matching examples.
Firewall rules Generate iptables/ufw rules to: allow [ports] from [source], deny all else. Include rules to persist across reboots on Ubuntu 22.04.
Explain error Explain this error in plain English and give the most likely fix: [paste error]. OS: Ubuntu 22.04. Context: [what you were doing].
AWS CLI Write AWS CLI commands to [task]. Use –output json and pipe through jq to extract [fields]. Include the IAM permissions required.

Best Practices

  • Paste error messages verbatim — GPT-4o is excellent at interpreting stack traces.
  • Use the o1/o3 model for architecture planning and complex multi-step debugging.
  • For code reviews, ask: “Review for security issues, logic bugs, and edge cases only.”
  • Iterate: “The script works but fails when [edge case] — fix only that part.”
  • Use the file-upload feature to analyze configs, logs, or CSVs directly.
  • Enable memory/Projects for persistent context across sessions (ChatGPT Plus).