Setup
If you haven’t already, start by installing the Checkly CLI, then create a repository that will be the ‘project’ that contains all your Checkly monitors managed as code. If you don’t already have a project, create one with:claude
command.
You’ll be prompted to sign in to or sign up for an Anthropic account.
Add the Playwright MCP
You can give Claude Code access to a browser by adding the Playwright MCP to your local configuration with:Give Claude Code Some Context
Everything we write into the CLI interface is part of a ‘prompt,’ and by default, Claude Code will add a bit of information to what we submit as ‘context’ on that prompt. Ideally, our requests written into Claude Code would include context about our specific project: its structure, language, and even its purpose. Because of thenpm create
command we ran above, our folder already has a boilerplate version of a Checkly project. We can’t feed in all of these files as context, but we can add a summary of our whole project as context by opening Claude Code and running the slash command:
CLAUDE.md
file. Claude Code will read that file and add it to our prompt every time it’s run within this project from now on.
Let’s add a bit more to this context, we want test files that make sense as a Checkly construct. Let’s add Checkly’s AI rules file to our CLAUDE.md
context file:
Create new URL Monitors
We’ll start with something easy. A URL monitor that will check an HTTP endpoint and alert if it doesn’t receive the right status code. With the context set from the section above, try a command like:Frequency
class here doesn’t accept arbitrary values, so we wondered if the context provided in CLAUDE.md
was enough for the tool to identify valid values for the check. We tried requesting a check that ran “every 17 seconds” and Claude Code prompted to run a find
on the project to identify valid values for frequency
. In the end, Claude Code did create valid code with this note in the process feed.
from Claude Code:"}
Create Playwright Synthetics Checks With Claude Code
With our context set up, and a browser available via the Playwright MCP, we can create more complex Playwright scripts for browser monitoring of our site. With specific instructions and clear prompting, you can get consistent performance of Claude Code writing our Browser checks.1. Start With a single test
First you’ll want to write a single check that does straightforward browsing and checking for page elements. With some context engineering, you can instruct Claude to navigate a page while recording the taken actions to generate a Playwright test. Read more about this approach and extensive prompt guidelines on our blog.checkly test
command will run any test that matches this pattern.
and making sure the test passes.
checkly test
command, this test isn’t running from our workstation but rather from the Checkly’s monitoring infrastructure.
Next we’ll want to create a .check.ts
file for this browser check, which sets some check-specific settings and assigns the check’s logical ID.
.check.ts
file generated by Claude, implementing the Checkly construct configuration. For better understanding of the configuration, you can ask for code comments:
.check.ts
configuration file, and the file name will be used as the logical ID.
2. Add our new Check to Claude’s Context
With this check created, let’s add the following lines to your updatedCLAUDE.md
file:
CLAUDE.md
.
3. Use Claude Code to create multiple Browser Checks
Now that we’ve got a working test and, let’s let Claude Code create another check for us:create signup-form-elements.check.ts
to configure the check.
You can prompt for multiple checks at the same time. As you can imagine, this unlocks the creation of a large number of synthetic monitors relatively quickly.
from Claude Code:"}
__checks__
folder
Error: expect.toBeVisible: Error: strict mode violation: getByText('Crime & Thrillers') resolved to 2 elements:
. As the error message implies, the issue is that this locator:
first()
to. Whatever route you take the result will be an edit to:
.first()
to the checks written above, everything was passing. If you’re having trouble reading the generated tests, take a look at Checkly’s Playwright documentation.
4. Going Further: Edit Multiple Checks and Configurations
Updating checks is another use case that may be useful for larger projects. Try prompting Claude Code with something like:from Claude Code:"}
npx checkly test
like we did above. Then it’s time to run them all.
Deploy With the Checkly CLI
In our example, we want to deploy a couple of checks at once, so it’s worth checking whether the project is properly set up before deployment. Many problems would have been revealed while runningtest
, but if, for example, some checks were unintentionally removed from our project, we’ll need to use deploy
to detect that. Run the deploy
command with the -p
preview flag:
deploy -p
you should just see a long list of created checks in the deployment command. For this tutorial, here’s the preview of a more complex project state:
- Checks that have no
.check.ts
config file are listed by their filename and will be named for their file name in the Checkly web UI. In general, it’s better to include a config file for every check since it gives you explicit control of the check’s logical ID. We’ve left out the config for five checks for demonstration purposes. - Checks with a config file are shown by their logical ID.
- Checks previously deployed from this project that are not present in this deployment will be deleted.
- Checks with a matching logical ID from a previous deployment will be listed as “Update and Unchanged”.
deploy
and you’re not sure why, it might be time to get in touch with the Checkly team. Join our Slack for deployment advice!
Once we’re happy with what will be deployed, it’s time to run npx checkly deploy
and create our checks!
Conclusion
AI-assisted coding tools like Claude Code can significantly accelerate the creation and deployment of monitoring checks with Checkly’s Monitoring as Code approach. By integrating AI into your development workflow, you can generate valid Checkly constructs—including URL monitors and Playwright-based browser checks—with minimal effort. One of the superpowers that an AI workflow can unlock is the mass updating of many files in your project. Updating a large number of test files can go much faster with the help of Claude Code. While AI can handle much of the boilerplate work, human oversight remains essential for ensuring best practices, refining assertions, and maintaining high-quality monitoring scripts. By combining AI efficiency with developer expertise, teams can achieve comprehensive monitoring coverage in minutes rather than days.Further Reading
Throughout this tutorial, we added a few lines to the CLAUDE.md context file. In all, those additions were (rewritten for clarity):- Generating end-to-end tests with AI and Playwright MCP - Stefan’s blog post makes a great starter for generalized Playwright development with an AI toolkit.
- Checkly CLI Documentation – Learn how to manage checks as code right from your command line.
- Playwright Testing Guide – Best practices for writing reliable browser checks.
- What is monitoring as code? — A comprehensive guide to infrastructure-as-code principles for monitoring.
- Checkly Community Slack – Join discussions and get support from the Checkly team and other users.