AI-Assisted Infrastructure Engineering›02 · AI in daily engineering work

Lesson 02 of 14 · Modules

AI in daily engineering work

Where AI saves real hours in an infrastructure engineer's day: writing and hardening scripts, turning notes into runbooks and RCAs, documentation, query languages, and understanding unfamiliar code, with prompting patterns that give better results and rules for handling sensitive data.

Beginner → Practitioner
Key wordsdaily engineeringscriptsrunbooksRCA draftingdocumentationjqPromQLregexexplaining codepromptingcontextdata handling

Where the hours go (and come back)

Task How AI helps How you verify
Scripts (Bash, Python) Draft, add error handling, explain edge cases shellcheck/ruff, tests, dry runs
Query languages (jq, PromQL, LogQL, KQL, regex) Translate intent into queries Run against real data
Runbooks Turn rough notes into clear steps Walk through it; have someone else follow it
RCAs Structure notes into the eight-part shape (see SRE & Production Incident Response, lesson 01) Facts checked by the incident team
Docs & READMEs Draft from code and notes Read and correct
Understanding code/charts Explain unfamiliar code, Helm values, Terraform modules Cross-check with source and docs
Commit messages & PR descriptions Summarise diffs Read before submitting

AI is like a helper who writes a first draft of your homework in seconds. It's great for getting started, but you're still the one handing it in, so you read every line, fix the mistakes, and make sure it answers the actual question.

Prompting patterns that work

Goal:        Write a Bash script that lists pods in CrashLoopBackOff across all namespaces
             and prints namespace, pod, restarts, and last termination reason.
Context:     kubectl 1.31 available; jq available; runs from a jump host.
Constraints: set -euo pipefail; no other dependencies; handle zero results; exit 0.
Output:      The script, then a list of assumptions and how to test it.
  • Give context (versions, environment) and constraints (style, dependencies, safety).
  • Ask for assumptions and a test plan alongside the answer.
  • Iterate: paste the error or wrong output back and ask for a fix.
  • For transformations, give sample input and expected output.

A worked example: jq

$ kubectl get pods -A -o json | jq -r '
    .items[]
    | select(.status.containerStatuses[]?.state.waiting.reason == "CrashLoopBackOff")
    | [.metadata.namespace, .metadata.name,
       ([.status.containerStatuses[].restartCount] | add),
       (.status.containerStatuses[0].lastState.terminated.reason // "n/a")]
    | @tsv'

A typical AI draft of this filter might forget the ? (errors on pods without statuses) or the // "n/a" default. Test on real output, including pods without restarts.

Data handling

  • Follow your organisation's approved tools and data rules.
  • Sanitise before pasting: remove secrets, tokens, customer data; replace internal hostnames/IPs with placeholders.
  • If a secret is pasted by mistake, treat it as leaked: rotate it.
  • Prefer tools with enterprise data controls for work content.

Try it: one real task, end to end

  1. Pick a real, low-risk task from your week (a script, a query, a runbook) and write a structured prompt (goal, context, constraints, output).
  2. Review the draft line by line; list every change you made and why.
  3. Verify: run linters (shellcheck), test with normal and failure inputs.
  4. Ask the assistant to write tests for its own script, then check the tests actually catch a bug you introduce.
  5. Estimate time saved versus doing it by hand, including review time.

Going deeper: making it a team habit

  • Keep a shared prompt library for recurring tasks (runbook template, RCA template, script conventions).
  • Encode conventions in project memory (e.g. a CLAUDE.md file, lesson 04) so the tool follows your standards automatically.
  • Review AI-assisted changes exactly like any other change.

Recap

  • Biggest daily wins: scripts, queries, runbooks, RCAs, docs, understanding code.
  • Prompt with goal, context, constraints, output, examples, and ask for assumptions and tests.
  • Verify with linters, tests and real data.
  • Sanitise prompts; rotate anything leaked.

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.