Agent Skills: Write Canary Tests

Write correct test blocks and assertions for Mission Control canary health checks. Use when creating canaries that need pass/fail conditions, adding test expressions, or writing assertions based on HTTP status, JSON response, exec output, or Kubernetes health.

UncategorizedID: flanksource/claude-code-plugin/write-canary-tests

Install this agent skill to your local

pnpm dlx add-skill https://github.com/flanksource/claude-code-plugin/tree/HEAD/skills/write-canary-tests

Skill Files

Browse the full folder contents for write-canary-tests.

Download Skill

Loading file tree…

skills/write-canary-tests/SKILL.md

Skill Metadata

Name
write-canary-tests
Description
Write correct test blocks and assertions for Mission Control canary health checks. Use when creating canaries that need pass/fail conditions, adding test expressions, or writing assertions based on HTTP status, JSON response, exec output, or Kubernetes health.

Write Canary Tests

Goal

Write correct test blocks for canary checks.


Golden Rules

  • The test result must be boolean (true / false).
  • Use null-safe access for optional fields (.? + orValue(...)).
  • Tests add assertions; they do not bypass built-in check failures.

Test Fields

| Field | Description | Example | | ------------ | ------------------------------------------------------- | ------------------------------------ | | expr | CEL expression that evaluates to boolean | code == 200 && json.status == 'ok' | | javascript | JavaScript expression/script returning true / false | code === 200 | | template | Go template rendering true / false | {{ eq .code 200 }} |


Common Test Context

Exact fields vary by check type.

| Variable | Description | Example | | --------------------- | ----------------------------------------------- | ---------------------------------- | | results | Primary result payload for many check types | size(results) > 0 | | code | HTTP status code (HTTP checks) | code in [200, 201, 301] | | json | Parsed JSON response body (HTTP checks) | json.headers['User-Agent'] != '' | | headers | HTTP response headers | 'Content-Type' in headers.keys() | | sslAge | SSL validity duration (HTTP TLS checks) | sslAge > Duration('7d') | | outputs.<checkName> | Previous named check outputs (with dependsOn) | outputs.getUuid.json.uuid != '' | | check | Current check metadata | check.name != '' | | canary | Current canary metadata | canary.namespace == 'prod' |


Canonical Snippets

1) HTTP status + JSON assertion

test:
  expr: "code == 200 && json.uuid != ''"

2) HTTP header assertion

test:
  expr: "! ('Authorization' in headers.keys())"

3) Exec stdout assertion

test:
  expr: 'results.stdout == "hello"'

4) Kubernetes health assertion

test:
  expr: dyn(results).all(x, k8s.isHealthy(x))

5) JUnit summary assertion

test:
  expr: results.failed == 0 && results.passed > 0

6) dependsOn output assertion

test:
  expr: "code == 200 && outputs.getUuid.json.uuid != ''"

7) Nil-safe list check

test:
  expr: results.?files.orValue([]).size() > 0

References

  • Canary Checker spec reference: https://flanksource.com/docs/reference/canary-checker/llms.txt