DEV Community

Pawel
Pawel

Posted on Originally published at Medium

5 JsonLogic Mistakes Every AI Coding Agent Makes

Ask any LLM to write a JsonLogic rule and it will happily produce something that looks right. Then you run it and get false when you expected true, or an operator your library never implemented. I got tired of debugging hallucinated rules, so I packaged the fix as an open-source agent skill: jsonlogic-skill.

What it does

Drop it into your AI coding assistant and it picks JsonLogic up automatically. You describe the business requirement in plain language, and the assistant:

  • turns it into a valid JsonLogic rule (checked against the real standard, not vibes),
  • runs the rule against your data,
  • validates whether an existing rule is well-formed,
  • explains what a rule does, in words,
  • debugs rules that return the wrong result.

It knows the actual operator set from jsonlogic.com and, importantly, checks whether your language's JsonLogic library supports the operators it wants to use. JavaScript, Python, Ruby, PHP, Java: one rule, many runtimes, no surprises.

Install

It follows the open Agent Skills format, so it works with Claude Code, Cursor, GitHub Copilot, VS Code agent mode, Codex, and Gemini CLI. For Claude Code:

git clone https://github.com/valeryia-piatrova/jsonlogic-skill.git ~/.claude/skills/jsonlogic
Enter fullscreen mode Exit fullscreen mode

Restart the client and you are done. Every other client has its own one-liner in docs/installing.md.

A quick example

You type:

Give a 20% discount on orders over $200, or 10% over $100, otherwise no discount

The assistant produces:

{
  "if": [
    { ">": [{ "var": "total" }, 200] }, 0.20,
    { ">": [{ "var": "total" }, 100] }, 0.10,
    0
  ]
}
Enter fullscreen mode Exit fullscreen mode

...and validates it before showing it to you. No data shape? It asks. Data shape given? Field names come from your JSON, not from the model's imagination.

Why a skill and not a prompt

A prompt tells the model what JsonLogic is. A skill gives it a workflow: gather the data shape, write the rule incrementally, validate it with a real script, then answer. That validate-before-you-answer loop is the whole difference between "looks right" and "runs right."

Try it

The repo is MIT licensed and free: github.com/valeryia-piatrova/jsonlogic-skill. If it saves you a debugging session, leave a star. And if you hit a JsonLogic edge case it handles badly, open an issue: real-world rules are how it gets better.

Top comments (0)