Incident report from a chat log, with a checkable timeline
Turn 57 lines of incident chat into a timeline with no invented times or causes. Every row cites a chat line, and a script checks the times and their order.
The incident ended at 11:05 and the channel holds 57 lines of chat. A timeline-first report is due tomorrow morning. The first attempt was the lazy one: paste the log, add "Write an incident report from this chat log", done.
It made up no times that are not in the log. What it did produce: the five people's names 40 times ("Lucas (deploy history)"), a "Date" line and a "2026-10-22 AM" deadline although the log has no dates at all, and an action table that assigns the root-cause check to three named people when the log only says "tomorrow morning". It also gave no way to see which chat line a table row came from, so verifying it means reading the whole log again. Below, every timeline row cites a source line, and a script checks the times and the order.
[1] Save the chat as a file and number the lines. The alert bot posts three times (09:41, 09:58, 10:28) and people post 54 lines. A few traps are planted on purpose: a message blaming the person who deployed, a "just a feeling" guess, an addendum posted at 10:38 about something seen "around 10:05", and chit-chat.
[09:41] alertbot: [WARN] checkout-api p95 latency 2,100ms (threshold 1,000ms)…[09:51] Lucas: there was a release yesterday at 15:10, checkout-api v4.12.0[09:52] Nina: feels slower since I got back from the standup tbh (just a feeling)[09:53] Nina: wasn't it Lucas's release? that has to be it[09:54] Maya: no conclusions until we read logs. treat it as a hypothesis only…[10:38] Nina: (addendum) around 10:05 I saw 900 jobs sitting in the retry queue and forgot to say so…$ awk '{printf "L%02d %s\n",NR,$0}' chat.en.txt > chat.en.num.txt[2] Build the prompt. The chat goes first inside <chat_log> and the instructions go below it, because Anthropic's long-context guidance puts long material above the question. The instructions also carry one sentence of reason, that the report is not meant to assign fault. The same guide's section on context says explaining why an instruction matters helps the model follow it.
Using the chat log above, write the timeline and cause sections of an incident report. The report exists so the next incident is caught sooner, not to assign fault. So do not use people's names; refer to roles instead (incident lead, deploy owner, cache/DB owner, support desk). Rules:- The timeline is one table with the columns `| Time | Phase | Fact | Source lines |`. Phase is one of Detection, Response, Recovery.- Copy the time from the [HH:MM] of the source line exactly. Do not round or guess. Order the rows from earliest to latest.- Write source lines as L07; if a row rests on several lines, write L07, L09.- Leave out chit-chat and lines that are not events.- If a line reports, after the fact, something that happened earlier than the line's own time, put it in the row for the time it happened and say in the Fact column that it was reported late.- Under the table add a `Cause` section. Start every bullet with `[Confirmed]` or `[Suspected]` and end it with the source lines. Use `[Confirmed]` only where someone in the log confirmed it as the cause.- Do not write numbers, causes or actions that are not in the log. Put what is unknown under a `Open items` section as `Unconfirmed`.- No text beyond those three sections.[3] Put the numbered chat in front, the instructions behind, and run it.
$ (echo "<chat_log>"; cat chat.en.num.txt; echo "</chat_log>"; cat tail.en.txt) > prompt.en.txt$ claude -p --model claude-sonnet-5-5 --max-turns 1 --tools "" --setting-sources "" --strict-mcp-config < prompt.en.txt > out.en.1.txtPart of the first result (5 of 43 rows, then the first cause bullet; the rest is cut):
| Time | Phase | Fact | Source lines ||---|---|---|---|| 09:41 | Detection | Alert: checkout-api p95 latency 2,100ms (threshold 1,000ms). | L01 || 09:51 | Detection | Deploy owner reported checkout-api v4.12.0 was released the previous day at 15:10. | L06 |…| 10:05 | Detection | Deploy owner reported v4.12.0 changed the cart cache key format and said they were not sure it was the cause. | L18 || 10:05 | Detection | About 900 jobs were in the order retry queue. Reported late, at 10:38. | L40 || 10:07 | Response | Incident lead chose rollback to v4.11.3 as the fastest option. | L20 |…- [Suspected] The v4.12.0 change to the cart cache key format is the possible cause. The cache hit ratio fell to 38% (normally around 90%) and the cart cache keys differed from the previous day's. The deploy owner said they were not sure it was the cause. L10, L16, L18The 10:38 addendum landed in the 10:05 row, the time the event happened, and says it was reported late. The blame message is gone from the timeline. Every cause bullet is [Suspected]; there is no [Confirmed], which is right, because nobody in the log confirmed a cause.
[4] The checking script looks at five things. Does the row's time appear in the cited line? Do the times ever go backwards? Are all three alert times in the table? Does every bullet in the cause section carry a label and source lines? Do any people's names appear? A single [Confirmed] stops the script with exit code 1. It cannot tell whether a confirmation is real, so it makes a person read the cited lines.
... (row extraction, order, alerts, names: see run/check.py) ok = [r for r in refs if 1 <= r <= len(chat)] if not any(t in chat[r - 1] for r in ok): fail.append(f"{t}: time not found in cited line(s) {refs}") for r in ok: # every other cited line must be the row's own minute or at most 2 minutes earlier if t in chat[r - 1]: continue sm = re.match(r"\[(\d\d):(\d\d)\]", chat[r - 1]) gap = hh * 60 + mm - (int(sm.group(1)) * 60 + int(sm.group(2))) if sm else None if gap is None or not 0 <= gap <= 2:...bullets, level = [], None # level = heading level of the open cause sectionfor l in rep: h = re.match(r"(#+)\s+(.*)", l) bold = re.fullmatch(r"\s*\*\*([^*]+)\*\*:?\s*", l) if h or bold: lv, title = (len(h.group(1)), h.group(2)) if h else (7, bold.group(1)) if level is None: if re.search(r"원인|Cause", title): level = lv elif lv <= level: # a heading at the same or a higher level closes the section level = lv if re.search(r"원인|Cause", title) else None continue if level is not None and l.strip() and l.strip() != "---": if re.match(r"\s*-\s*\[(확정|추정|Confirmed|Suspected)\]", l): bullets.append(l) else: fail.append(f"unlabelled line in cause section: {l.strip()[:40]}")[5] Run it on both results and on the one-line result.
$ python3 -I check.py chat.en.txt out.en.1.txttimeline rows: 43, alerts in log: 3, cause bullets: 3, marked confirmed: 0exit 0$ python3 -I check.py chat.en.txt out.en.2.txttimeline rows: 43, alerts in log: 3, cause bullets: 3, marked confirmed: 0exit 0$ python3 -I check.py chat.en.txt naive.en.out.txt | grep -v "no line"timeline rows: 12, alerts in log: 3, cause bullets: 0, marked confirmed: 0FAIL unlabelled line in cause section: **Leading hypothesis (unconfirmed):** v4…...FAIL no labelled cause bulletsFAIL person name in report: Lucas...exit 1The one-line result cites no lines at all, so every table row fails (filtered out above), and its cause section has 9 unlabelled lines, the opening paragraph included. The two prompted runs have the same 43 times in the same order. What differs is the phase column: in the second run 09:51, 10:03, both 10:05 rows and 10:11 are "Response" where the first run says "Detection", and 10:24, 10:34, 10:51 and 10:53 are "Recovery" where the first says "Response". Where a phase begins and ends is the report writer's call anyway.
[6] To see whether the script catches anything, the first result was broken by hand: a time changed, two rows swapped, an alert row deleted, the [Suspected] label removed, a label changed to [Confirmed], a person's name put in, a second cited line from another time added, an unlabelled bullet put under a sub-heading of the cause section. All 8 edits were caught with exit code 1 (inputs and outputs are in run/bad*.en.txt; they are not model output). One example:
$ python3 -I check.py chat.en.txt bad1.en.txtFAIL 10:15: time not found in cited line(s) [26]exit 1The first version of the script missed the two label edits, which were tested on the Korean result. It counted only bullets that already carried a label, so deleting a label just lowered the count from 4 to 3 with exit code 0, and relabelling a bullet [Confirmed] passed as well. The script now checks every line in the cause section and stops on [Confirmed]. Review then found two more holes: with several cited lines, one matching line let the others be wrong, and a sub-heading or bold title inside the cause section switched the check off. The other cited lines must now be from the same minute or at most 2 minutes earlier, and the section ends only at a heading of the same or a higher level.
[7] The script cannot see these, so read them.
- A time that appears in the cited line is not proof that the line says that fact. Two rows can share a minute, and swapping their citations still passes. Match each Fact cell to its source line once.
- The phase column changes between runs of the same input. Decide where detection ends yourself.
- A
[Suspected]bullet can still lean toward causation. Where a bullet treats metrics improving after the rollback as evidence of the cause, tone it down to "coincided with".