u/Extreme_Ad5709

Image 1 — laya-guard: a local guardrail that judges every tool call your coding agent makes
Image 2 — laya-guard: a local guardrail that judges every tool call your coding agent makes

laya-guard: a local guardrail that judges every tool call your coding agent makes

laya-guard: A local guardrail for coding agents that checks every tool call

I built laya-guard, a local guardrail that checks tool calls made by your coding agent and decides whether to allow, review, or block them.

It runs entirely locally, needs no API key, and takes around 90 ms per command on a CPU.

  • Regex rules catch obvious risks like rm -rf /, curl ... | sh, and leaked API keys.
  • Simple commands like ls and npm test skip the model entirely.
  • Everything else is evaluated by Laya, a ~322M local model.

It supports Claude Code, Codex CLI, Cursor, Gemini CLI, Copilot CLI, and 6 other agents.

I also tested it on AgentDojo at the judge level: it blocked 25 of 27 attacks while allowing 92 of 97 benign tasks. These are my own measurements, and the README documents the current limitations.

It's free and MIT-licensed. Install it with pip install laya-guardrail.

I'd especially appreciate feedback on commands that slip through or cases where legitimate commands get blocked. Those are the areas I'd most like to improve.

u/Extreme_Ad5709 — 4 days ago
▲ 30 r/LLMDevs

I use a ~322M local model to judge every tool call my coding agents make (about 90 ms on CPU, no API)

Coding agents run shell commands constantly. I wanted each one checked before it executes, and I didn't want to send every command to a paid API.

laya-guard runs on your machine and answers allow, review, or block for each tool call. Regex policies catch known-dangerous patterns first (rm -rf /, curl … | sh, secrets, auth bypass). Plain commands like ls, git status and npm test skip the model, but only when there's no piping, chaining or redirecting, no -exec-style flag, and no sensitive path. Everything else is judged by Laya (~322M, Apache-2.0) on the CPU in about 85 to 90 ms.

The results are self-reported and the scripts are in the repo. On AgentDojo v1 (judge-level) it blocks 25 of 27 attacks and keeps 92 of 97 benign tasks. On my own 50-command shell set it gets 48 right.

Two caveats. The model is tuned mostly on Korean, so English natural-language prompts get overblocked more often. And if the server is down, the hooks fail open.

It has hooks for Claude Code, Codex CLI, Cursor, Gemini CLI, Copilot CLI and 6 other agents.

Repo: https://github.com/scs0209/laya-guard (install with pip install laya-guardrail)

u/Extreme_Ad5709 — 4 days ago