-
Notifications
You must be signed in to change notification settings - Fork 20
feat: refactor rules generation to ai-context with skill output #1199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Rename src/rules to src/ai-context and enhance the context generation: - Extract example configs to separate context.ts module with doc references - Generate both checkly.rules.md and skills/monitoring/SKILL.md - Add YAML frontmatter for skill metadata (stripped from rules output) - Support inline exampleConfig in addition to exampleConfigPath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Refactors how Checkly AI context (“rules.md”) content is generated so it can also produce a Vercel-compatible SKILL.md under a root-level skills/ directory.
Changes:
- Move rules/context sources to
src/ai-context/and update therulescommand to read fromdist/ai-context/checkly.rules.md. - Replace the old
compile-rules.tspipeline withcompile-ai-context.ts, generating bothdist/ai-context/checkly.rules.md(without frontmatter) andskills/monitoring/SKILL.md(with frontmatter). - Add a centralized
EXAMPLE_CONFIGSconfiguration and new fixtures for the generation flow.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cli/src/commands/rules.ts | Updates base rules path to new dist/ai-context output location. |
| packages/cli/src/ai-context/context.ts | Adds centralized example/placeholder config (including inline code samples + doc references). |
| packages/cli/src/ai-context/context.fixtures.json | Adds fixtures used to generate example code via import plan. |
| packages/cli/src/ai-context/checkly.context.template.md | Introduces skill-style frontmatter and adjusts template to rely on injected examples. |
| packages/cli/scripts/compile-rules.ts | Removes the old rules compiler script. |
| packages/cli/scripts/compile-ai-context.ts | Adds new compiler that outputs both SKILL.md and stripped checkly.rules.md. |
| packages/cli/package.json | Renames generation script and wires it into prepare. |
Comments suppressed due to low confidence (3)
packages/cli/src/ai-context/checkly.context.template.md:108
- There’s still a hard-coded “Reference [the docs…]” link here, while other sections moved references into the generated example blocks. For consistency (and to avoid duplicated/competing references), consider removing this link and relying on the per-example
referenceinjected by the compiler.
packages/cli/src/ai-context/checkly.context.template.md:132 - Grammar: “All alert are described…” should be “All alerts are described…”. Since this template content is distributed to users/AI tooling, it’s worth fixing the wording.
packages/cli/src/ai-context/checkly.context.template.md:79 - This line reads awkwardly/incorrectly (“if your tasked”). Please fix the grammar (e.g., “Use
pwProjectsif you’re tasked with reusing a Playwright project.”) since this text is shipped in generated AI context.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'resources/browser-checks/example-browser-check/example-browser-check.check.ts', | ||
| reference: 'https://www.checklyhq.com/docs/constructs/browser-check.md', | ||
| }, | ||
| PLAYRIGHT_CHECK: { |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config key is spelled PLAYRIGHT_CHECK but everything else refers to “Playwright”. Renaming this to PLAYWRIGHT_CHECK would avoid confusion and prevent future lookups by key from breaking due to the typo.
| PLAYRIGHT_CHECK: { | |
| PLAYWRIGHT_CHECK: { |
| name: "Multi-browser check suite", | ||
| playwrightConfigPath: "./playwright.config.ts", | ||
| // Playwright Check Suites support all browsers | ||
| // defined in your \`playwight.config\` |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the embedded Playwright example, the comment references playwight.config (typo). This should be playwright.config to avoid propagating incorrect file names into generated code.
| // defined in your \`playwight.config\` | |
| // defined in your \`playwright.config\` |
| const RULES_OUTPUT_DIR = join(__dirname, '../dist/ai-context') | ||
| const SKILL_OUTPUT_DIR = join(__dirname, '../../../skills/monitoring') | ||
|
|
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SKILL_OUTPUT_DIR points outside the packages/cli workspace (../../../skills/monitoring). Because this script runs from prepare, builds in environments that only have the package folder (or read-only parent dirs) can fail or leave unexpected artifacts. Consider making the skill output optional (env flag) or moving skill generation to a dedicated release step so normal builds only write under dist/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sorccu This is similar to my concerns, I phrased in the description. I'm up for ideas. :)
We could of course, also write to the dist folder in /cli and then "snatch" it from the monorepo config, but yeah... Very keen on another opinion.
| const SKILL_OUTPUT_DIR = join(__dirname, '../../../skills/monitoring') | ||
|
|
||
| function stripYamlFrontmatter (content: string): string { | ||
| const frontmatterRegex = /^---\n[\s\S]*?\n---\n+/ |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripYamlFrontmatter only matches LF (\n). If the template ever uses CRLF (\r\n) or has a UTF-8 BOM, the YAML frontmatter won’t be stripped and the generated checkly.rules.md will include it. Consider making the regex tolerant of \r?\n (and optionally trimming a BOM) to keep output stable across platforms.
| const frontmatterRegex = /^---\n[\s\S]*?\n---\n+/ | |
| const frontmatterRegex = /^(?:\uFEFF)?---\r?\n[\s\S]*?\r?\n---\r?\n+/ |
Affected Components
Notes for the Reviewer
This PR changes how Checkly AI context files (aka
rules.md) are generated to align with upcoming skill conventions in the AI ecosystem. The primary concern is to provide aSKILL.mdfor MaC and be compatible with Vercel's new skills tooling:For that to work, the repo needs to include a
skillsdirectory in the root, which contains all the provided markdown skills (skills/monitoring/SKILL.md). For that, I repurposed the script of thecheckly.rules.mdand reached out of theclirepo to write files outside of/packages/cli. It's not pretty, and I'm open to ideas for doing it differently.Generally, I changed the naming convention from
rulestoai-contextbecause the script now generates our "rules" (rules.md) and a Checkly "monitoring" skill (skills/monitoring/SKILL.md). The content is more or less the same, though. I've chosen themonitoringskill name to be flexible in creating more skills (e.g. aplaywright-best-practicesskill) in the future. We'll see how this plays out.Additionally, I extracted the configuration code from the actual script into its own file so that there's a single config file.
Content-wise, I expect multiple iterations on the new "context" files, but I still made some adjustments on the way:
checkly.configcode is now part of the generated context files. To do so, the code config now supports inline code samples bccheckly.configandpwCheckSuitesaren't part of the exported files used for the existing code generation..mdroutes defined in the context config.@sorccu
The generated
skills/monitoring/SKILL.mdis not included in this PR (yet), it needs to be generated and committed on CLI release to be available for tools likenpx skills add. How do you think we should go about it? Commit in theprebuildhook, quick'n'dirty? 🤔To check later
We need to make sure that the configuration in the marketing site still works and provides the generated file from GitHub.