Module 08 · Lesson 8.5
Maintenance and Incident Readiness
On this page
- What you will learn
- Why maintenance and incident readiness matter
- Keep dependencies up to date safely
- Monitor what matters, and test your backups
- An incident checklist: what to do when something goes wrong
- Step-by-step workflow: build your maintenance plan
- What the assistant does and what you do
- Conclusion and your next step
- Reusable prompt
- Expected output
- Common errors and fixes
- Validation checklist
- Hands-on exercise
- Knowledge check
- Frequently asked questions
- References
A new car is not finished when you drive it home. It needs oil, tyres and a yearly check, and it needs a plan for the day it breaks down. Software is the same. Launch is the start of its working life.
In this lesson you plan the long life of Tidewell's booking system. You set a schedule for updating the packages it depends on. You decide what to watch, and you run small scripts that check the email outbox and prove a backup can be restored. Then you write an incident checklist, so that when something goes wrong, people know what to do and whom to tell.
What you will learn
- Plan safe, regular dependency updates with automated pull requests and an audit.
- Choose what to monitor, and check the email outbox and a backup with scripts.
- Write an incident checklist from detection to a blameless review.
- Name who is told, and who decides, by role.
Before you start
- Completed Review, Ownership and Data Handling, or have owners and review rules of your own.
- Access to any capable AI assistant.
- Optional: Node.js and the project from earlier lessons, if you want to run the examples.
Why maintenance and incident readiness matter
Most of a system's life comes after launch. Packages get security fixes, keys expire, disks fill up and someone makes a mistake on a busy Monday. Maintenance is the routine care that stops small problems growing. Incident readiness is the plan for the problems that happen anyway.
- Dependency
- A package your code relies on. It is like a part bought from a supplier: you did not make it, but your product breaks if it fails.
- Vulnerability
- A known weakness in a package that someone could misuse.
- Monitoring
- Watching signs of health, such as whether the site answers and whether emails are going out, so that you hear about trouble before your users do.
- Incident
- An event that harms or threatens the service or its data, such as a long outage or a leak.
- Blameless review
- A meeting after an incident that asks what happened and how the system can be safer, not who to blame.
- Restore test
- Proving that a backup can really be turned back into a working database.
| Routine job | Example frequency | Owner (role) |
|---|---|---|
| Review and merge dependency update pull requests | Weekly | Developer |
Run npm audit and read the result | Weekly, and before each release | Developer |
| Look at the email outbox and error reference ids | Daily | Developer, with front desk reporting problems |
| Run the smoke test on the live site | After every release, and on a schedule | Developer |
| Restore the latest backup into a scratch database | Every quarter | Developer, confirmed by the clinic owner |
| Reread the README, notes, policy and owners list | Every quarter, and after an incident | Developer, with each area owner |
The frequencies are examples. Agree your own with the people who own the risk, and write them down in the operating notes.
Keep dependencies up to date safely
A Next.js project can depend on hundreds of packages, directly and through other packages. Old ones gather known weaknesses. But a rushed update can also break the app. The safe habit is small, regular updates, one at a time, each one tested.
Tools can open the update pull requests for you. Dependabot is a GitHub feature, and Renovate is a separate tool that works with several hosts. Both read a small configuration file. PromptFable recommends neither as best. Read the Dependabot options reference (opens in a new tab) or the Renovate documentation (opens in a new tab) for the current options.
version: 2
updates:
- package-ecosystem: "npm"
schedule:
day: "monday"
interval: "weekly"
open-pull-requests-limit: 5
directory: "/"
- package-ecosystem: "github-actions"
schedule:
interval: "monthly"
directory: "/"A weekly check for packages and a monthly check for the pipeline's own tools. Parsed with the yaml package below.
What each part does
version: 2is the format of the file.- Each entry under
updatesis one kind of thing to keep current: npm packages, and the tools the pipeline uses. schedulesays how often to look. Monday is a good day, because there is a whole week to fix a problem.open-pull-requests-limitstops a flood. At most five update pull requests are open at once.
A file like this is easy to get wrong with a typo. This small script reads it back as plain sentences. It proves the file parses as YAML and says what it asks for. It does not check the file against GitHub's rules.
// scripts/show-update-config.ts: read the update schedule back in plain words.
import { readFileSync } from "node:fs";
import { parse } from "yaml";
interface Update {
"package-ecosystem": string;
schedule: { interval: string; day?: string };
"open-pull-requests-limit"?: number;
}
const config = parse(readFileSync(".github/dependabot.yml", "utf8")) as { updates: Update[] };
for (const u of config.updates) {
const when = u.schedule.day ? `${u.schedule.interval}, on ${u.schedule.day}` : u.schedule.interval;
const limit = u["open-pull-requests-limit"] ? `, at most ${u["open-pull-requests-limit"]} open pull requests` : "";
console.log(`${u["package-ecosystem"]}: ${when}${limit}`);
}Tested with the TypeScript compiler and run below.
npx tsx scripts/show-update-config.tsnpm: weekly, on monday, at most 5 open pull requests
github-actions: monthlyRules for taking an update
- Take one update at a time, so that a break points to one cause.
- Read the changelog. Look for the words 'breaking' and 'removed'. The version number can hint at this, as in Semantic Versioning 2.0.0 (opens in a new tab), but it is a promise from the author and not a guarantee.
- Run
npm run checkandnpm testbefore you merge. The pipeline from Module 7 does this for you. - Take security fixes sooner than other updates, and say so in the pull request.
- Run
npm auditfor known vulnerabilities. It only reports. Read each finding, and be careful with automatic fixes that change many versions at once. See the npm audit documentation (opens in a new tab). - Add a line to the AI record if an assistant helped to choose or apply an update, and say what you tested.
Monitor what matters, and test your backups
You cannot watch everything, so watch what hurts patients first. For Tidewell that is four signs, plus the backups.
| Sign | What to look at | A first rule (an example) |
|---|---|---|
| The site is up | The smoke test from Module 7, run on a schedule. | Two failures in a row means tell the developer. |
| Errors | How many 500 responses, and their reference ids. | A sudden rise after a release means consider a rollback. |
| Rows in the outbox that are failed, or pending for too long. | Any failed row is looked at the same day. | |
| Sign-in | Many failed sign-ins, or patients reporting that links do not arrive. | A spike means check the email service and for misuse. |
| Backups | That the backup ran, and that the last restore test passed. | No backup for a day means tell the clinic owner. |
Check the email outbox with a script
Failed emails are a quiet fault. Nobody sees an error, but patients stop getting messages. This script asks the outbox table from Module 6 two questions: which rows failed, and which are still pending after too long. It builds an in-memory database with five synthetic rows and a fixed clock so that the result is repeatable. The report shows ids and error text only, never addresses or message bodies. See The Transactional Outbox Pattern: Reliable Event Publishing with AI for the pattern.
// scripts/ops-health.ts: a daily look at the email outbox, using the same table the sender job uses.
import { PGlite } from "@electric-sql/pglite";
import { readFileSync } from "node:fs";
import type { Db } from "../src/lib/db";
const STUCK_AFTER_MINUTES = 15; // an example value: agree your own with the practice manager
export async function healthReport(db: Db, now: Date): Promise<{ lines: string[]; needsAttention: boolean }> {
const failed = await db.query<{ id: string; last_error: string | null }>(
"SELECT id, last_error FROM email_outbox WHERE status = 'failed' ORDER BY id",
);
const cutoff = new Date(now.getTime() - STUCK_AFTER_MINUTES * 60_000);
const stuck = await db.query<{ n: string }>(
"SELECT count(*) AS n FROM email_outbox WHERE status = 'pending' AND created_at < $1",
[cutoff],
);
const stuckCount = Number(stuck.rows[0].n);
const lines = [
`Failed emails: ${failed.rows.length}`,
...failed.rows.map((r) => ` id ${r.id}: ${r.last_error ?? "no error recorded"}`),
`Pending for more than ${STUCK_AFTER_MINUTES} minutes: ${stuckCount}`,
];
return { lines, needsAttention: failed.rows.length > 0 || stuckCount > 0 };
}
/** An in-memory database with the real outbox migration and five synthetic rows. */
export async function outboxDatabase(): Promise<PGlite> {
const db = new PGlite();
await db.exec(readFileSync("db/migrations/005_email_outbox.sql", "utf8"));
await db.exec(`
INSERT INTO email_outbox (to_address, subject, body, idempotency_key, status, attempts, last_error, created_at) VALUES
('patient.a@example.com', 'Booking confirmed', 'Synthetic text', 'k1', 'sent', 1, NULL, '2026-11-30T08:00:00Z'),
('patient.b@example.com', 'Booking confirmed', 'Synthetic text', 'k2', 'failed', 5, 'provider answered 401', '2026-11-30T08:05:00Z'),
('patient.c@example.com', 'Offer for a freed slot', 'Synthetic text', 'k3', 'failed', 5, 'no answer within 5000 ms', '2026-11-30T08:10:00Z'),
('patient.d@example.com', 'Booking confirmed', 'Synthetic text', 'k4', 'pending', 0, NULL, '2026-11-30T09:35:00Z'),
('patient.e@example.com', 'Booking confirmed', 'Synthetic text', 'k5', 'pending', 0, NULL, '2026-11-30T09:58:00Z');`);
return db;
}
if (process.argv[1] && import.meta.filename === process.argv[1]) {
const report = await healthReport(await outboxDatabase(), new Date("2026-11-30T10:00:00Z"));
console.log(report.lines.join("\n"));
console.log(report.needsAttention ? "Status: needs attention" : "Status: OK");
process.exitCode = report.needsAttention ? 1 : 0;
}Tested with the TypeScript compiler and run below. Fifteen minutes is an example value to agree with the practice manager.
What each part does
healthReportruns two queries with parameters. The first lists failed rows. The second counts pending rows older than the cut-off time.- It returns text lines and a flag, so that a scheduler can turn the flag into an alert.
outboxDatabasecreates a test database with the real migration and five synthetic rows: one sent, two failed, one pending for a long time and one pending for a short time.- The last block prints the report and sets a failing exit code when something needs attention.
npx tsx scripts/ops-health.tsFailed emails: 2
id 2: provider answered 401
id 3: no answer within 5000 ms
Pending for more than 15 minutes: 1
Status: needs attentionThe report finds two failed emails and one stuck pending email, and says what went wrong with each. The operating notes say what to do next. On a real system you would run a check like this from a scheduler and send the result to the developer. Hosting services often provide uptime and error alerts as well. Use what your host offers, and keep the rules simple.
Prove that a backup can be restored
A backup is a copy of the database, taken so that you can recover from a mistake or a disaster. But a backup you have never restored is a hope, not a plan. A restore test brings a backup back into a separate, empty database and compares it with the original. The clinic owner decides where backups are held and for how long, as part of the clinic's data-protection duties (CON-01). A restored copy holds real personal data, so delete it after the test.
This script shows the idea. It uses the test database as a stand-in. A real project would use the backup tool of its database host and a scratch database. The shape is the same: take a copy, restore it somewhere else, then compare row counts and a checksum.
// scripts/restore-test.ts: the idea of a restore test, using PGlite as a stand-in for a real backup tool.
import { PGlite } from "@electric-sql/pglite";
import { outboxDatabase } from "./ops-health";
const SUMMARY = "SELECT count(*) AS rows, md5(string_agg(idempotency_key || status, ',' ORDER BY id)) AS checksum FROM email_outbox";
const original = await outboxDatabase();
const backup = await original.dumpDataDir(); // a "backup": a copy of the whole database
const restored = new PGlite({ loadDataDir: backup }); // restore it into a separate, empty database
const before = (await original.query<{ rows: string; checksum: string }>(SUMMARY)).rows[0];
const after = (await restored.query<{ rows: string; checksum: string }>(SUMMARY)).rows[0];
console.log(`Original: ${before.rows} rows. Restored copy: ${after.rows} rows.`);
console.log(before.checksum === after.checksum ? "Checksums match: the backup can be restored." : "Checksums differ: do not trust this backup.");
await original.close();
await restored.close();Tested with the TypeScript compiler and run below. PGlite stands in for a real backup tool.
npx tsx scripts/restore-test.tsOriginal: 5 rows. Restored copy: 5 rows.
Checksums match: the backup can be restored.The row counts and the checksum agree, so this backup can be restored. A real restore test also runs the app against the copy and the smoke test, as the operating notes say.
An incident checklist: what to do when something goes wrong
In an incident, people are stressed and time matters. A checklist spares them from deciding the order of things while under pressure. It follows seven steps.
- Detect. Someone or something notices: an alert, a failing smoke test or a phone call from front-desk staff. Write down when and how.
- Decide the severity. How bad is it? The table below gives an example scale. Pick a level quickly, and change it if you learn more.
- Tell the people affected, by role. Say who needs to know now. For Tidewell that is the practice manager when patients are affected, and the clinic owner when personal data may be at risk.
- Reduce the harm. Roll back, switch something off, revoke a key or put a message on the phone line. Fix the cause later. Stop the damage first.
- Keep a timeline. Write each event with its time, including what you tried that did not work.
- Hold a blameless review within a week. Ask what happened, why the checks did not catch it and what would make it less likely. Do not look for someone to blame.
- Record follow-up actions. Each one has an owner role and a date. An action with no owner will not happen.
| Severity | Meaning (an example scale) | Example | Who is told |
|---|---|---|---|
| 1 | Patients cannot book, or personal data is at risk. | The booking site is down in opening hours. A key or data leak. | Developer, practice manager and clinic owner at once. |
| 2 | A feature is broken, with a workaround. | Sign-in emails fail, so front desk books by phone. | Developer and practice manager. |
| 3 | A nuisance with no harm to patients. | A typo in a message. | Developer. Fix in the next release. |
Keep a blank record ready, so nobody invents a layout in the middle of an incident. This one is in docs/incident-record.md.
# Incident record
Copy this file for each incident. Fill it in as you go, not afterwards.
## Summary
- Title:
- Severity (1 = patients cannot book or data is at risk, 2 = a feature is broken, 3 = a nuisance):
- Detected by and when:
- Roles told, and when:
## Timeline
Write one line for each event, with the time. Include what you tried that did not work.
## What was done to reduce harm
Rollback, a switched-off feature, a phone message, a revoked key.
## Review within one week (blameless)
- What happened, in plain words:
- Why the checks did not catch it:
- Follow-up actions. Each one has an owner role and a date:Copy this file for each incident, and fill it in as you go, not afterwards.
A short worked example
On a Monday morning, front-desk staff say that patients are not receiving sign-in emails. The developer runs the outbox check and sees failed rows with the error 'provider answered 401'. That points to a key problem. They rate it severity 2, because patients can still phone, and tell the practice manager. The developer replaces the expired key, sets the failed rows back to pending as the operating notes say and watches them send. Front desk phones the patients who had urgent bookings.
The blameless review finds that nothing watched the outbox, so the fault ran for two days. There are three follow-up actions. Run the outbox check every morning (developer, by Friday). Add the key's expiry date to the quarterly review (developer). Ask the clinic owner to confirm who receives provider alerts. Notice that no action says 'be more careful'. Each one changes the system. The blog post Writing a SEV1 Incident Post-Mortem with AI: Prompt Templates for On-Call Engineers goes further, and the Postmortem Culture chapter (opens in a new tab) of Google's SRE book explains why blamelessness works.
Step-by-step workflow: build your maintenance plan
Step 1: List the routine jobs and their owners
Start with the table in this lesson. Put a frequency and an owner role on each job.
What you should see: A maintenance schedule in the operating notes.
Step 2: Turn on dependency updates
Add a configuration file for your update tool, run
npm auditand set up the pipeline to run your checks on every update pull request.What you should see: Small, tested update pull requests arrive on a schedule.
Step 3: Choose your signs of health
Pick the four or five that matter to patients. Add a simple first rule for each and write who gets told.
What you should see: A monitoring table, and at least one working check such as the outbox script.
Step 4: Test a backup
Restore the latest backup into a scratch database, compare it with the original, run the smoke test, then delete the copy.
What you should see: A dated restore-test note.
Step 5: Write the incident checklist and the blank record
Use the seven steps and the severity table. Name the roles that are told at each level.
What you should see: A checklist that a tired person can follow.
Step 6: Rehearse once
Run a small drill, such as 'the key has expired'. Time how long it takes, and fix every step that did not work.
What you should see: A plan that has been used at least once.
- Updates
Small and tested
- Monitoring
Signs that matter
- Backups
Restore tested
- Incident
Detect, decide, tell
- Reduce harm
Roll back or switch off
- Review
Blameless, with owners
Routine care keeps the system healthy. The checklist covers the day it is not.
What the assistant does and what you do
| Task | Assistant's part | Your part |
|---|---|---|
| Reading update changelogs | Can summarise what changed and flag breaking changes. | Read the changelog yourself for risky updates, and run the checks. |
| Drafting the incident checklist | Can draft it from your roles and severity scale. | Fix the roles, the contacts and the rules. Rehearse it. |
| Writing a timeline or review | Can tidy your notes into a timeline and suggest follow-ups. | Supply the facts. Decide the causes and the owners. |
| Diagnosing a live fault | Can suggest causes from an error type. | Keep real logs and personal data out of the prompt. Use reference ids and synthetic examples. |
| Deciding on severity and who is told | Not its job. | Decide by role. The clinic owner decides on personal data. |
Conclusion and your next step
Launch is the start of the work of keeping a system healthy. Update dependencies in small, tested steps. Watch the signs that matter to patients, and test your backups by restoring them. Keep an incident checklist that moves from detection to a blameless review, with follow-up actions owned by a role. Then rehearse it once.
Your next step: you have now finished all eight modules. Go to the program page, New Project Creation, and open its capstone section. There you build, test, release and document a small application of your own, with a record of how the assistant was used and what you reviewed.
For practice material, try the Appointment Booking Portal or the Inventory Workflow Service. The module overview, Documentation and Governance, lists the handover assignment and checklist.
Reusable prompt
Draft a blameless incident timeline and review from my notes
Turns your own incident notes into a timeline, causes without blame and follow-up actions with owner roles, and lists what it could not know.
You are helping me write a blameless incident review. Use only my notes. Do not invent times, causes or people. Name roles, not people. Do not assign blame.
Notes (synthetic):
- Mon 08:10 front-desk staff reported that patients were not getting sign-in emails.
- 08:20 the developer ran the outbox check: 14 failed rows, last_error "provider answered 401".
- 08:35 the email key was found to have expired.
- 08:50 a new key was set and the failed rows were set back to pending.
- 09:05 emails were sending again. 09:15 the practice manager was told.
- Front desk phoned patients with urgent bookings.
- Nothing was watching the outbox, so the fault ran from Saturday evening.
Tasks:
1. Write a timeline table with time, event and role.
2. Write what went well and what did not, as facts about the system.
3. Suggest follow-up actions, each with an owner role and a due date left blank for me. Each must change the system, not say "be more careful".
4. List the questions you could not answer from my notes.Show the reusable template
Replace each {{placeholder}} with your own details.
You are helping me write a blameless incident review. Use only my notes. Do not invent times, causes or people. Name roles, not people. Do not assign blame.
Notes (synthetic):
{{incident_notes}}
Tasks:
1. Write a timeline table with time, event and role.
2. Write what went well and what did not, as facts about the system.
3. Suggest follow-up actions, each with an owner role and a due date left blank for me. Each must change the system, not say "be more careful".
4. List the questions you could not answer from my notes.Expected output and limitations
A timeline table built only from your notes, a short list of what went well and what did not, follow-up actions that change the system with owner roles, and a list of open questions.
| Time | Event | Role |
| --- | --- | --- |
| Mon 08:10 | Staff reported that sign-in emails were not arriving | Front desk |
| Mon 08:20 | Outbox check showed 14 failed rows, error "provider answered 401" | Developer |
| Mon 08:35 | Email key found to have expired | Developer |
| Mon 09:05 | Emails sending again | Developer |
Did not go well: nothing watched the outbox, so the fault ran from Saturday evening.
Follow-up: run the outbox check every morning (developer, due: ...). Record the key's expiry date in the quarterly review (developer, due: ...).
Questions: when exactly did the failures start? Which patients missed an urgent message?Limitations to keep in mind
- The assistant may fill gaps with a likely cause. Compare every line with your notes.
- It may suggest a vague action such as 'improve monitoring'. Ask for the specific check, the owner role and the date.
- It does not know what the clinic owner decided about telling patients or authorities. That decision stays with the owner.
Common errors and how to fix them
Updates are left for months, and then taken all at once.
Why it happens: Nobody owned the schedule, and an update felt risky.
Fix: Take small updates weekly, one at a time, with the checks running. A small update is easier to undo than fifty.
The backup job reports success, but nobody has ever restored one.
Why it happens: A green tick was taken as proof.
Fix: Run a restore test into a scratch database every quarter, compare counts, run the smoke test and delete the copy.
The incident review ends with 'be more careful'.
Why it happens: The review looked for a person to blame, not a gap in the system.
Fix: Ask why the checks did not catch it. Write follow-up actions that change the system, each with an owner role and a date.
Validation checklist
Tick each item once you have confirmed it.
Hands-on exercise
A maintenance plan and incident record for Ferngate Cycle Repairs
Write a five-job maintenance schedule for Ferngate's parts tracker. Then fill in an incident record for the scenario below, using the seven steps.
You will need
- Roles: developer, workshop owner. The owner reorders parts every Friday from the tracker's low-stock list.
- The workshop's internet connection is unreliable, and mechanics share one tablet.
- Scenario: on Wednesday afternoon, after a Tuesday update, the tablet shows every part as having zero stock. A mechanic notices at 14:10.
- A backup is taken each night by the hosting service. It has never been restored.
Acceptance criteria
Your work is done when every one of these is true.
Hints (2)
- Ask what the workshop owner would order on Friday if nobody noticed.
- Ask which cheap check would have caught zero stock for every part right after the update.
Show a model answer
A strong answer rates the incident severity 2 or 3, because mechanics can still work and the owner reorders only on Friday, and it says why. It tells the workshop owner early, so that nobody reorders from the wrong list. It rolls back the Tuesday update first, and the timeline shows the times and what was tried. The review notes that no check compared stock counts before and after the update, and the follow-up action adds one, with an owner role and a date. The schedule includes weekly update pull requests, a weekly audit, a daily look at errors, a quarterly restore test and a quarterly reread of the documents.
Knowledge check
Choose an answer, then check it. Nothing is recorded — this is for you.
Show the answer and explanation
Answer: B. A passing check is useful, but it only covers what the tests cover. Merging on trust is tempting, but the update still changes your system and deserves a review. Closing every update leaves known weaknesses in place.
Show the answer and explanation
Answer: B. A job can succeed while producing a copy that cannot be restored. A green tick is tempting evidence, but only a restore test shows that the copy works. A large file says nothing about whether it is complete.
Show the answer and explanation
Answer: B. Reducing harm protects patients while you investigate. Finding the root cause first is tempting because it feels thorough, but the harm continues while you search. The report comes after the review.
Frequently asked questions
How often should I update dependencies?
Small updates every week or two are easier than a big one every year. Use an automated tool to open the pull requests, take them one at a time and run your checks. Take security fixes sooner. The right rhythm depends on your team, so agree one and write it down.
What is a blameless post-mortem?
It is a review after an incident that asks what happened and what to change in the system, not who made a mistake. People then share facts freely. The result is a short list of follow-up actions with owners.
What should an incident response checklist include?
Detect the problem, decide how serious it is, tell the affected people, reduce the harm, keep a timeline, hold a blameless review and record follow-up actions with owners. Add a severity scale and the roles to contact at each level.
What is a restore test?
It is a trial in which you bring a backup back into a separate, empty database and check that the data is complete and the app works with it. Only a restore test proves that a backup is usable. Delete the copy afterwards if it holds real data.
- Written by
- PromptFable Editorial
- Last updated 19 Nov 2026
- Review
- Reviewed by Waseem Nadir, Technical Reviewer
- Last reviewed 27 Nov 2026
References
Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.
- Dependabot options reference - GitHub Docs(opens in a new tab)
GitHub · Official documentation · The settings for automated update pull requests on one hosting tool.
- npm-audit | npm Docs(opens in a new tab)
npm · Official documentation · What the audit command reports. The page shows one version of the documentation.
- Google SRE - Blameless Postmortem for System Resilience(opens in a new tab)
Google · Why reviews after incidents work best when they do not blame people.
- Incident management | National Cyber Security Centre(opens in a new tab)
National Cyber Security Centre (UK) · Official documentation · Official guidance on planning for and responding to cyber incidents.
- Mend Renovate CLI Docs(opens in a new tab)
Mend Renovate · A separate tool for automated update pull requests.
PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.