agentleFS
HighwayofLifeHighwayofLife/agent-kaizen/skills/guardrails/SKILL.md

guardrails

Skill1 starsChanged 33 days agoMITView on GitHub

Install hooks for big reads, images, compaction, and Agent tier allowances, each with an override.

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use evaluation, statechart and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • NVIDIASkill

    evaluation

    Compatibility name for modelopt-evaluation. Evaluate model accuracy with NeMo Evaluator Launcher.

    Also in 3 projects that use this

  • shiwenbin1617Skill

    statechart

    Check a TLA+ model of a system that moves between states, such as a product flow, a protocol, or a service, and draw it as a Mermaid statechart. The report gives the shortest path to each state that breaks a rule. Use for /statechart, or to show a bug as a path through states.

    Also in 3 projects that use this

  • GoogleSkill

    wayfinder

    Plan a huge chunk of work — more than one agent session can hold — as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.

    Also in 3 projects that use this

  • GoogleSkill

    prototype

    Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

    Also in 4 projects that use this

  • NVIDIASkill

    research

    Before designing a feature, research how comparable libraries solve the problem, check best practices, known pitfalls, and upstream changes. Use when starting a new feature, investigating an unfamiliar area, or the user asks to research something.

    Also in 3 projects that use this

  • MicrosoftSkill

    handoff

    Compact the current conversation into a handoff document for another agent to pick up.

    Also in 3 projects that use this

  • +3 more from google

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Not in Claude Code?: Read docs/hosts.md in the plugin root first.

    line 11
  2. Distinctive:

    Stop the most expensive habits automatically: whole-file reads of big files, images landing in the wrong context, and sessions that grow …

    line 13
  3. Distinctive:

    After a decision, the guard prunes counters and logs older than 30 days when it can take their locks.

    line 80

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Guardrail hooks, each with an escape hatch

Plugin root: ${CLAUDE_PLUGIN_ROOT}. If that is still a ${...} placeholder, use the folder that contains skills/ (this file is skills/<name>/SKILL.md), and substitute that path, in quotes, wherever this skill uses CLAUDE_PLUGIN_ROOT. Not in Claude Code? Read docs/hosts.md in the plugin root first. Skip steps that only work in Claude Code, and follow its propose-only rule before changing any host configuration.

Stop the most expensive habits automatically: whole-file reads of big files, images landing in the wrong context, and sessions that grow without limit. Each guardrail has a documented override, so an agent with a real need is never blocked.

Changes: adds hook scripts and settings.json entries, after you approve. Back up settings.json first.

Autonomy: follow ${CLAUDE_PLUGIN_ROOT}/docs/autonomy.md. The mode comes from the skill argument (propose, safe, auto or yolo), else docs/kaizen/config.json, else agent-kaizen.json in your Claude config dir ($CLAUDE_CONFIG_DIR or ~/.claude), else propose. In safe and auto, read every "wait for my OK" below as: apply it yourself if the mode allows (backup, verify, roll back on failure, ledger row), otherwise list it as a proposal. Hard stops always ask. At most maxChangesPerRun changes (default 3). End with a summary of what was applied, skipped and rolled back.

In this skill, <Claude config dir> means $CLAUDE_CONFIG_DIR or ~/.claude, and <Codex home> means $CODEX_HOME or ~/.codex.

Task

Propose Claude Code hooks that stop wasteful patterns. Check the current Claude Code hooks documentation for the exact input fields and the deny/allow output format before writing any script.

The plugin ships no live loop guard. Use Stuck turns as the evidence gate: if they are a large share of cost over two audits, first propose fixes for their causes. A heuristic hook with no model call is a later option, not a shipped guard.

  1. Big-read guard (PreToolUse on Read): deny a Read of a code, data, scene or log file over ~400 lines when no line limit is given. The denial message must:
    • name the file and its line count;
    • point at the cheaper path (tools/codemap outline FILE, rg -n PATTERN FILE, jq or yq for data, tail or rg for logs);
    • say plainly: "If you really need the whole file, Read it again with an explicit limit; that is allowed." Any Read with an explicit limit passes. Never block small files or non-code files.
  2. Image guard: if images are being read by the main session or by agents that don't review visuals (see the audit), deny those Reads and point at one designated image reviewer (an agent or a script). Allow the image-review agents.
  3. Compaction: check the docs for a setting that controls when a session auto-compacts (a context window or threshold). If one exists, propose a value that suits me (the author used 250k with a large-context main model), plus a SessionStart hook on "compact" that tells the session to re-read its plan files and git status instead of relying on memory.

For each hook: write the script under <Claude config dir>/hooks/, test it by piping sample JSON into it (blocked case, allowed case, override case), then show me the settings.json change. Back up settings.json first. Add ledger rows.

Bundled resources

Bundled, tested hooks: ${CLAUDE_PLUGIN_ROOT}/hooks/limit-big-read.sh, ${CLAUDE_PLUGIN_ROOT}/hooks/block-image-read.sh, ${CLAUDE_PLUGIN_ROOT}/hooks/after-compact.sh, ${CLAUDE_PLUGIN_ROOT}/hooks/subagent-context.sh, with wiring in ${CLAUDE_PLUGIN_ROOT}/templates/settings.example.json. Copy them to <Claude config dir>/hooks/ and adapt them, rather than writing new ones.

Opt-in Agent tier guard

Copy ${CLAUDE_PLUGIN_ROOT}/hooks/tier-guard.sh to <Claude config dir>/hooks/ and merge the settings template's PreToolUse entry with matcher Agent. Install jq and Python 3.9 or later if needed. Add rules to <Claude config dir>/agent-kaizen.json.

{"guardrails": {"agentTiers": [
  {"pattern": "deep-*", "freeSpawns": 2, "reasonRegex": "^Tier reason:[ \\t]*\\S"}
]}}

The first case-sensitive glob matching tool_input.subagent_type sets the free allowance per session, including requests that omit model. After the allowance, retry with a non-empty Tier reason: <why> line. The guard searches the prompt on each reason line with the configured Python regex and multiline anchors. Disable it by removing the Agent entry, clearing agentTiers, or setting global enabled to false.

The counter tracks allowed PreToolUse requests even if the spawn later fails. The config directory must be owner-owned and not group- or world-writable, or the guard silently stays off. A lock can be reclaimed when its owner exits or its PID belongs to a different process. If a live owner holds the lock past the short wait, the request is allowed. Owner-only state lives in <Claude config dir>/kaizen-tier-guard/. Log entries contain only a timestamp, rule and supplied reason. Keep sensitive details out of the reason. Input, config, dependency, state and lock errors allow the request. After a decision, the guard prunes counters and logs older than 30 days when it can take their locks.

Done when

fewer whole-file reads and images in the audit, and shorter sessions. Nothing becomes impossible; the expensive path just needs an explicit choice.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.