local-model-safety

local-model-safety is a cursor rule for Cursor from sthamann/nyx-local-ai. It costs 0 tokens per session (528 once invoked), scanned A, original, MIT.

A set of safety rules for an AI coding agent that handles model responses, secrets, stored conversations, and file changes.

In plain words
What is it for?
Use it when changing the agent's model client, memory or session storage, tool-result handling, token cleanup, or tool-call parsing.
Why use it?
It prevents unwanted model tokens from being saved and keeps source files and command output unchanged when the agent reads them. It also requires tests when tool-call parsing changes.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when changing the agent's model client, memory or session storage, tool-result handling, token cleanup, or tool-call parsing.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/sthamann/nyx-local-ai/local-model-safety
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sthamann/nyx-local-ai

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for local-model-safety

README.md
[![agentmods](https://agentmods.dev/badge/rules/sthamann/nyx-local-ai/local-model-safety/github.svg)](https://agentmods.dev/rules/sthamann/nyx-local-ai/local-model-safety)
Your own site
<a href="https://agentmods.dev/rules/sthamann/nyx-local-ai/local-model-safety"><img src="https://agentmods.dev/badge/rules/sthamann/nyx-local-ai/local-model-safety/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for local-model-safety

Your own site · 80×15
<a href="https://agentmods.dev/rules/sthamann/nyx-local-ai/local-model-safety"><img src="https://agentmods.dev/badge/rules/sthamann/nyx-local-ai/local-model-safety.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 528 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00528
Opus 5 $0.00000 $0.00264
Sonnet 5 $0.00000 $0.00106
Haiku 4.5 $0.00000 $0.00053

Measured 10d ago against content hash 4d3573eac1f4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

local-model-safety scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/local-model-safety.mdc · 49 lines

How it starts

The opening of the file, as written. The whole thing — 49 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Local-model safety invariants

Special tokens never survive into persisted state

Leaked model tokens (DSML fragments, <|end▁of▁sentence|>) poison future prompts: once stored in memory/sessions, models start imitating the junk. stripSpecialTokens (src/models/client.ts) must therefore be applied at these boundaries:

  • assistant content at stream end (client.ts, extract mode)
  • web-sourced tool results only (fetch_url, web_search in agent.ts)
  • memory writes and the one-time migration in MemoryStore
  • stored histories in AgentSession.loadMessages

Never sanitize file/command/MCP tool outputs (read_file, run_command, …): the agent must see workspace content byte-faithfully — sanitizing file reads once corrupted source that merely mentioned DSML tokens and sent a model analyzing phantom bugs.

When adding a new boundary (new tool, new store), wire it in and add a case to .harness/smoke.mjs.

Tool-call parsing changes require smoke tests

Any change to parsing in src/models/client.ts (JSON extraction, DSML, function-style calls, repair) needs a matching test in .harness/smoke.mjs. Run node .harness/smoke.mjs — it must print ALL PASS.

Other invariants

  • Secrets: API keys live in SecretStorage only (MachineStore); never write them into settings, session files, or logs. The webview receives hasApiKey, never the key.
  • File writes go through applyWriteWorkspaceEdit (undo/dirty-buffer safe) with checkpoint recording (recordCheckpointFile) and backups. Don't add direct fs.writeFile paths for workspace files.
  • Processes: anything long-running goes through ProcessManager so Stop (abort signal) actually kills it. No bare exec without a signal.
  • Untrusted content: anything fetched from the network is wrapped with wrapUntrusted before entering the prompt; fetch_url keeps its SSRF guard.
  • Tool outputs are truncated (truncate, 20k chars) — unbounded strings blow up the context and the session files.

Read the full file on GitHub · 49 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 49 lines · 0 tokens per session scan A 4d3573eac1f4

Subscribe to this mod's changes

local-model-safety is a cursor rule published in the GitHub repository sthamann/nyx-local-ai (137 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 528 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.