Back to Engineering

Building an on-call bot is easy

How I built an on-call helper over a week, turning routine investigations into a skill and then automating the first look at every alarm.

A red-orange title card, laid out across a grid of rectangles that halve in height down the card, reading "Building an on-call bot is easy", with a pale sphere rising behind the grid on the right.

By the time I acknowledged an alarm in PagerDuty and opened my terminal, Claude had usually finished a preliminary investigation. I built that setup over a week while doing my regular on-call work, drawing on dashboards and system knowledge I already had. The context kept improving as I used it.

A lot of people overestimate the difficulty of building a bot. In my case, each addition grew out of something I was already doing: investigating an alarm, finding the right dashboard, or figuring out who owned a service. Once I noticed myself repeating a task, I asked Claude to take it over.

This article follows that process. The exact tools will depend on your setup, but you can start getting benefits long before you have a complete bot.

Getting started: give Claude access

My first step was to give Claude access to the data sources I used on call, with profiles for the AWS CLI, Databricks, Datadog, PagerDuty, and so on. Whatever you have, find a way to start using it with AI.

If CLI or MCP integrations aren’t available, but your organization allows agent access through a browser, browser-control plugins can be another option. They let your agent interact with the websites you already use.

Once that access was in place, I could drop a link to an event into the session and ask Claude to investigate. It was already familiar with many of the tools we use, including CLIs, Datadog, and OpenSearch or Elasticsearch for logs. It started helping me from day one.

Existing Datadog dashboards from earlier monitoring work gave Claude starting points for discovering the relevant graphs and alarms. Screenshots made this faster: Shift-Control-Command-4 to capture the relevant part of the dashboard to the clipboard, then paste it into the chat. That saved me typing out widget names or copying individual links, trusting Claude to read the names and find the right data source through MCP. Whenever I found another useful graph, I shared it too and asked it to save a memory: what this tells us, where to find it again, and which source to trust. The context grew naturally out of the work.

Pointing it at the code

The graphs only tell part of the story. To investigate further, Claude also needed to understand the code. In my case, I started Claude from the main package of the application, so it could explore the code and use the repository’s instructions and context. It worked pretty well.

As you use the agent, you notice where it gets stuck or needs the same hint again. You can save those instructions for the next investigation and collect them into a skill. By a skill, I mean a reusable set of instructions and references that tells the agent how to approach a task. For on-call, that includes where to look, how to access the systems, and what to check when an alarm comes in.

When the code base stops helping

That worked until I started investigating issues involving multiple systems. The connections between them weren’t clear from the code base, so Claude needed to explore further to discover them.

The investigation spread across multiple packages. The code base was large and a little convoluted, with a lot of documentation files, and pulling more of it into the session brought in conflicting information. Investigations got slower and more expensive, and Claude started getting confused by all the incoming context. At that point this was just not working.

That was my turning point for building a dedicated on-call skill. Looking back, I could have started a little earlier.

So I took a step back to distill what we had learned into concise documentation that would be useful during an incident.

Building the skill: distill the context

I started a new session and said:

I'm building an on-call skill. To build the skill, I want to extract context about the system and how it works: names of the different queues, variables, Datadog scopes, any metrics, the components in the system, which AWS accounts to use, and how to connect to them. All the bits and pieces you should know when you're on call.

On-call is its own area of expertise. Knowing how to build a component and knowing how to recognize trouble across a running system are different skills. During an incident, your first job is to restore service. You need to direct your attention to the failing system, the failing component, and the most likely cause. Once you have a likely culprit, you can go deeper or involve people from that team. If resolving the issue means finding the right people who can help you, you do that.

That helped me decide what to keep in the skill. Part of the work was creating diagrams. In my case the diagrams were ASCII art: a compact text map of how the systems connect, so Claude didn’t have to reconstruct those connections from a large Terraform configuration each time.

It’s much easier to leave breadcrumbs here and there, references to specific areas where Claude can explore further. You don’t want to pollute the initial context with all the bits and pieces. You need directions, like road signs showing where to go.

Testing the skill with sub-agents

Previously investigated incidents became test cases for the skill. You can start a fresh session, but I asked Claude in an existing on-call session to create sub-agents: separate agents given the skill and selected context about an incident. Let’s take this event, which we know a lot about, hide some of the details, and see how they investigate it. Then collect the results and provide feedback.

The existing session had the clues I had supplied during the investigation: look here, look there. That gave it context for evaluating what the sub-agents did. The important part is controlling what the sub-agents receive. Give them the initial alarm and the context you want to test, and keep the known answer out of their starting material. Look at whether they find the relevant system and evidence, and where they need another hint.

If you have already put the incident’s resolution into the skill, replaying that incident tests whether the agent can use the documented answer. A new incident will still be a separate test of how well the skill generalizes.

After a couple of iterations I got a pretty decent, efficient skill. That was V1.

Automating the first look at every alarm

With every alarm, I was doing pretty much the same thing: looking at the metrics, then going to Claude and asking it to investigate. I thought: this is meat-proxy work, I don’t want to do that.

So I said to it: you’ve already investigated a couple of incidents using this skill. Please go ahead and create a monitoring script. In my case it was Python, looking at PagerDuty and Datadog alarms.

My setup is a Claude Code CLI session running in a terminal on my own laptop, which I keep awake so the session can run around the clock. I haven’t inspected how the script connects to Claude internally; Claude built it. From my side, it looks like a background process running inside the Claude environment. Every so often it wakes up and posts something into the chat. Claude picks that up and starts investigating using the skill. It depends on my laptop staying awake and the session staying open.

By the time I opened the terminal, there was usually a preliminary analysis waiting for me. If I’m not happy with the findings or the proposed solution, I ask follow-up questions and continue the investigation as I would have before the skill existed.

My agent now also shows snippets of dashboards, screenshots, graphs and so on, alongside the investigation.

Checking in before an alarm fires

The skill also includes a morning check-in, a midday check, and an evening checkout. In the morning it goes through dashboards and metrics, looking at how they are changing from day to day. That gives it a chance to notice something going wrong before an alarm fires.

During the day it repeats a similar process, with more attention to the daily peak. Are we going through it now? Is the system behaving normally? Are the deviations something we should look into, and does it look like an alarm might be coming soon?

The evening checkout is a summary of the day. Was it calm? Did everything look fine, or did we encounter alarms? What went well?

The issue I kept ignoring

The most surprising incident came out of those checks. One of our systems was still being built, and it didn’t have an alarm for the issue yet. During the day, the session running the skill said something like: something is weird in that subsystem. I thought, okay, it’s not very stable yet, and ignored it.

A couple of hours later: that part is still failing.

A different incident in another system had my attention. The two systems were connected through a data processing pipeline, with enough interdependencies that some unusual behavior elsewhere didn’t seem surprising while I was fighting the first issue.

Once the system I was stabilizing was working again, the other issue started looking suspicious. Had it started around the same time? Were the two related? I asked the agent: can you show me what is going on, and cross-check those two systems?

It already had context about how they were connected, and traced the messages passing between them through a message bus. That was interesting, because I didn’t expect that connection to produce this sort of side effect. I asked it to go deeper and compare the timing of events in both systems. The events lined up.

Then I thought: if this part connects multiple systems, maybe others are suffering from the same issue. We started looking further. I hadn’t checked those systems because I didn’t own them and assumed they had their own on-call engineers, who would get their own alarms.

Oops. Those systems were affected too, and their Datadog metrics were showing significant issues. At that point I brought in the people responsible for the broader infrastructure and handed over coordination of the larger incident.

The skill wasn’t even fully built out yet. But it kept checking systems while I was busy with something else, and kept bringing the same problem back to my attention. It was almost like: hey man, I already told you about this a couple of times, and you’re still ignoring it.

I still had to ask questions, connect the observations, and involve the right people. But those repeated checks helped me discover a much bigger problem than the one I thought I was dealing with.

Keeping the skill and shared context up to date

Once I figured out a specific issue, I said: we learned something new, let’s update the skill. General investigation guidance stays in the skill itself, while gotchas and an incident log live in external documentation. That can be Confluence, Notion, or a Google Doc, where you can update information without changing the skill.

A shared context page gives the teams involved the same starting point. It explains how to start your on-call day, who is responsible for different systems, how those systems connect, and where to find the main dashboards. You open the page and know where to start. It also explains how to install the skill.

The skill also reads that page, so updates help both people and the agent. If ownership changes or we introduce a new dashboard, we update the page and that’s it. We don’t need to update the skill too.

You can move more of the system-specific context onto that page to make the skill easier to reuse elsewhere. The agent then needs to fetch the page before it can use that context. For me, having a page that both people and the agent can use is worth that extra step.

After about three days of use and refinement, the skill was ready to share with the team. Every so often I repeated the sub-agent tests: take one incident I had just investigated, update the skill, then ask it to spin up a couple of sub-agents to poke holes in the skill and see where it still needed work.

Posting updates to Slack

After a while, I also wanted to share my findings with the team, so they could see what was going on with incidents in production. I created a Slack channel and asked Claude to update the skill so it posts there every so often.

To let other people choose when to share updates, I asked it to add a special command to the skill: you run it, and it starts publishing updates in that channel. It uses threads for specific alarms or specific incidents.

If your team uses the Slack integration with PagerDuty, and PagerDuty reports incidents as threads, you can ask the same skill to report in those existing threads, so you keep everything together. You can also ask it to update alarms in PagerDuty or whatever else you use. It depends on your current culture; different companies do it slightly differently, but you get the point.

Rerouting: answering “who owns this?”

The last major version came from people reaching out with questions: what is going on here? I see this alarm, what do I do? I had become a sort of switchboard operator, connecting one person to another. And anyone can do this if they know where to look.

So I added a special mode to my on-call skill for rerouting. You start the skill and ask: who is responsible for this system? What is going on here? What do I do next? It gives you a list of the people currently on call for the service. If you give it a URL to an alarm or an alarm ID, it checks which team it belongs to, who changed it last, and what the current status is. If a team is assigned to the alarm, it checks the escalation policy to find the current on-call engineers and managers. You can even ask it to contact them on Slack with questions.

Since sharing it with a broader audience, those questions have stopped coming to me. I hope it’s because people are using the skill to find the right people. In some cases people were reaching out about things completely unrelated to the service we own, and I just happened to know how to find those people through PagerDuty and other systems.

What to keep in mind

  • Start small and observe. Give it a dashboard, investigate an incident, save what you learn, and let it develop over a couple of weeks. Later I kept my session running even when I wasn’t on call, shadowing the work to see whether it was helping. You don’t need to cover every possible incident before getting value.
  • Build operational context. Keep the skill useful independently of the code base. Give it high-level maps of dependencies and data flows, sources of truth, and directions for drilling down or finding the right people. Include the reasoning behind metrics too. For example, Little’s Law tells us that at the same throughput, higher average latency means more work in flight. With synchronous calls, that can tie up workers and create pressure to scale, depending on capacity and autoscaling rules. This gives the agent a reason to investigate when two graphs move together.
  • Match evaluation and permissions to what it can do. I didn’t need a formal evaluation dataset to start observing and reviewing its suggestions. Replaying incidents and checking its findings were still part of the work. My bot wasn’t changing production: proposed code changes went through human review before merging. Before giving a bot automatic remediation or wider organizational responsibility, I would add explicit evaluations of its decisions and enforce permissions outside the model. For example, a custom MCP tool could expose specific operations and check authorization before executing them, instead of giving the agent unrestricted Kubernetes commands.

Beyond your laptop

This setup was useful enough for me to stop there. The next step could be a service running 24/7, connected to Datadog and the other production tools, first for one team and then for more of the organization. It would need someone to own its operation and keep its context current.

At a very large organization, I suspect several bots with knowledge of their own systems, able to exchange findings, may be more practical than one bot trying to know everything. That’s a possible direction, not something I’ve built. You can start with one useful helper and let experience tell you how far to take it.

If you keep repeating a task, try offloading it to an agent. Start with that one thing and make your life a little easier.