# Rule playground

> Check a custom Keryn rule and scan a code sample.

Source: https://keryn.dev/playground/

The [Student guide](https://keryn.dev/docs/start/student/#with-the-cli) has a rule, sample code and expected results you can compare with a local scan.

The rule playground runs in the browser, so it is not reproduced here: https://keryn.dev/playground/

Rules use Keryn's Semgrep-compatible syntax, which is a subset of Semgrep's. Keryn runs pattern rules, including data-flow rules (`mode: taint`). Cross-file analysis and known-fix matching run in full scans.

In an empty folder, save the rule below as `my-rule.yml`.

```yaml
rules:
  - id: example.debug-print
    languages: [python]
    severity: WARNING
    message: Remove debugging output before shipping.
    pattern: print(...)
```

Save this sample as `example.py` in the same folder.

```python
print("debug")
```

Lint the rule, scan the folder and use `jq` to show the finding from this rule.

```sh
keryn rules lint my-rule.yml
keryn scan . --rules my-rule.yml --fail-on none --json result.json -q
jq -r '.findings[] | select(.ruleId == "example.debug-print") | "\(.path):\(.line) \(.ruleId)"' result.json
```

```text
my-rule.yml: 1 rule(s)
0 error(s), 0 warning(s)
example.py:1 example.debug-print
```

See [write your own rules](https://keryn.dev/docs/guides/custom-rules/).
