mokuyoaxis / @mokuyoaxis/agent-guard
Make destructive AI-agent actions reversible by default — quarantine + audit + human escalation for rm/git destructive operations. Reliability infrastructure, not a sandbox.
About this plugin
Written by the registry from verified metadata, not from the README.
@mokuyoaxis/agent-guard is a DSH plugin published from the mokuyoaxis/agent-guard repository.
Capabilities and topics
Coding agents fail in predictable ways: an over-broad rm wipes uncommitted work, a diagnostic dump leaks credentials, or a CLI update silently breaks a hook. Agent Guard puts deterministic safety checkpoints and empirical verification around your coding agent, backed by a shared Python Core (3.9+) and optional host integrations.
[!IMPORTANT] AI agents configuring this repository: Before editing host configuration or bridges, read
adapters/INTEGRATION.md, the setup workflow, and the adapter guide for your target host. Verify against the live host version and its official hook docs, then report only observed coverage—installing a Skill or copying config does not prove interception is active.
Capabilities at a glance
| Capability | What it does | Guides & contracts |
|---|---|---|
| Delete-guard | Recoverable deletion and Git snapshots before destructive overwrites; Cleanup Copilot inventory and reviewed maintenance tasks; workspace budgets, rate/repeat limits, and protected paths; transaction restore, manual GC, and optional local MCP tools | Skill & CLI · Cleanup Copilot · Deletion limits · Recovery & GC · MCP tools · MCP doctor |
| Exfil-guard | Outbound scanning for documented credential formats, secret source references, and host-identifying paths; plan-verified redaction; scalar-free JSON/dotenv inspection (safe_view) | Skill & CLI · Rules · Safe config view |
| Guard-lab | Controlled experiments in disposable fixtures using four zero-model calibration controls, synthetic markers, declared-channel observers, and matched guard-off / guard-on runs | Lab guide · Four-control example · Evidence levels |
Core and adapters form shared infrastructure across all three modules. After an incident, recovery-audit provides a separate workflow for reconstructing a workspace from surviving Git, session, and cache records.
How Agent Guard works (and what it does not claim)
- Guidance vs. enforcement: Skills teach the agent safe habits, while automatic interception depends on an active host hook (
PreToolUseor the DSH plugin) and its covered tools. The optional local MCP server exposes explicit maintenance tools—it does not intercept native shell or editor calls that bypass it. - Reliability infrastructure, not an OS sandbox: Agent Guard runs with the same OS privileges as the agent. It is built to catch mistakes—wrong working directories, mis-expanded commands, accidental leaks—rather than contain a determined adversary sharing the same user account (Threat model).
- Fail-closed decisions on destructive operations: All paths share a single verdict protocol (
ALLOW · SANITIZE · RELOCATE · SNAPSHOT · ASK · BLOCK, aggregated withBLOCK > ASK > RELOCATE/SNAPSHOT > SANITIZE > ALLOW). When Delete-guard recognizes a supported destructive command (or encounters unparseable shell syntax) and cannot statically determine its targets or effects—such as unresolved shell variables, command substitution, unbalanced quotes, indirect interpreters, or stdin-fed targets—it refuses withBLOCKrather than guessing. Unrecognized benign commands (such asprintf "$PWD"or$(pwd)) still returnALLOW_NOOP(Policy contract). - Per-workspace policies: Delete-guard budgets, rate limits, and protected paths apply per workspace root via
.agent-guard/delete-policy.json, falling back to built-in defaults for omitted keys (Workspace configuration).
Installation & versions
Core requires Python 3.9+ and Git (examples assume a POSIX shell). The optional local MCP server requires Python 3.10+ and its separately installed pinned MCP SDK.
Install the current 0.3.1 release into a stable, user-owned prefix:
npm install --prefix /absolute/path/to/agent-guard-install @mokuyoaxis/agent-guard@0.3.1
Your package root is /absolute/path/to/agent-guard-install/node_modules/@mokuyoaxis/agent-guard (keep the @mokuyoaxis/ scope). You can also run directly from a Git checkout:
git clone https://github.com/mokuyoaxis/agent-guard.git
cd agent-guard
Verify exact publication details on GitHub Releases (0.3.1) or npm (0.3.1). See Getting started for offline tarball installation, upgrades, and full dependency details (including Node 22 for the optional DSH read prototype and Python 3.11+ for Kimi TOML helpers).
| Release | Key additions |
|---|---|
| 0.3.1 | Cleanup terminal review overhaul (permanent-first, readable/exact sizes, >20-root summary + read-only list), unique CLI ID prefixes, multi-target --targets-file handoff, exact-txid and gc.py --task GC guidance, staged cross-filesystem recovery & manual_review_items, agent-guard-delete-policy CLI, three-Skill installer |
| 0.3.0 | Reviewed maintenance workflow (saved target plans, single-step operator approval, agent task execution/query), optional quarantine requirement, linked Skill installer, optional Codex native confirmation form |
| 0.2.9 | Read-only Cleanup directory overview (--discover) and targeted measurement (--measure), two read-only MCP tools, faster plan scans |
| 0.2.8 | Local MCP service diagnostics (doctor.py mcp) and protocol-interruption recovery checks |
| 0.2.7 | Cleanup Copilot plans, shared deletion admission (capacity, budgets, rate/repeat limits, protected paths), optional local MCP server |
| 0.2.6 | Optional Kimi Stop recovery feedback and doctor checks, DSH Lab preflight diagnostics, DSH 0.2.1-alpha.4 deletion support, Kimi 2.3.0 Bash profile |
| 0.2.5 / 0.2.4 | Earlier stable releases (explicit storage/GC/NOOP feedback, durable relocation, trash_index queries) |
| 0.2.5-rc3 / 0.2.4-hotfix.1 | Opt-in channels (npm tags rc and hotfix; neither replaces latest). 0.2.4-hotfix.1 backports quarantine control-path protection onto 0.2.4 |
Note: Deletion admission limits introduced in 0.2.7 can refuse high-volume or unprotected deletions that succeeded on 0.2.6 and earlier. Upgrading from an older version requires an explicit install/upgrade step; global Skills and host configurations are not updated automatically.
Core workflows
1. Recoverable deletion & reviewed cleanup (Delete-guard)
Run safe_delete.py from the workspace root you are protecting, pointing to your installed package or checkout root:
python3 /absolute/path/to/agent-guard/skills/delete-guard/scripts/safe_delete.py src/old_module.py --dry-run
python3 /absolute/path/to/agent-guard/skills/delete-guard/scripts/safe_delete.py src/old_module.py
python3 /absolute/path/to/agent-guard/skills/delete-guard/scripts/restore.py list
python3 /absolute/path/to/agent-guard/skills/delete-guard/scripts/restore.py '<txid>'
Execution & recovery guarantees:
- Relocate vs. discard: Valuable files move into workspace quarantine with exact recovery paths recorded in a transaction manifest. Provably regenerable, Git-ignored build artifacts may be deleted directly unless the operator requires quarantine.
- Git & restore safety: Supported Git overwrites snapshot tracked state first, and hard-reset collisions with untracked or ignored content are refused.
--forcerestore moves the current occupant to a separate quarantine transaction before restoring. - Non-destructive dry runs & advisory checks:
check.pyandsafe_delete.py --dry-runleave command targets untouched (they may create quarantine/audit metadata and a local Git exclude entry). Exit code0from an advisory check reports assessment completion—never permission to run aBLOCKorASKcommand. - Operational accounting: Quarantined files still occupy disk until you run manual garbage collection (GC).
ALLOW_NOOPmeans no supported destructive pattern was matched, not that arbitrary shell scripts are safe. Failed operations can leave partial state—check reportedtxids before retrying. See Recovery & GC and Audit metadata.
Reviewed batch maintenance (0.3.0): For multi-root cleanup, Cleanup Copilot separates proposal, human approval, and agent execution. Save an explicit target list (optionally requiring quarantine for regenerable artifacts), review the full selection in your terminal and approve once—or, when using the optional Codex native form, open the exported complete list (host_approval.review.file), review the selected targets, and confirm in the form—then let the agent execute and query by task ID via CLI or MCP while keeping all path protections, budgets, and rate limits active. Default read-only discovery/measurement (--discover, --measure) never authorizes deletion; --save-plan and --approve persist control metadata locally without moving files.
2. Outbound inspection & redaction (Exfil-guard)
Before writing drafts or sending prompts externally, scan with check_span.py or rewrite with sanitize.py. Call them from your workspace pointing to your installed package or checkout root (or omit the prefix when already at the repository root):
python3 /absolute/path/to/agent-guard/skills/exfil-guard/scripts/check_span.py --channel file-write --json < draft.md
python3 /absolute/path/to/agent-guard/skills/exfil-guard/scripts/sanitize.py --channel file-write < draft.md
Try a synthetic credential constructed at runtime:
python3 -c 'print("config: sk-proj-" + "AbCdEf0123456789GhIjKl")' |
python3 /absolute/path/to/agent-guard/skills/exfil-guard/scripts/sanitize.py --channel file-write
# -> config: sk-<REDACTED>
Design split:
check_span.pyis read-only: Returns a verdict (ALLOW,SANITIZE,ASK,BLOCK) and a verified redaction plan without modifying input. Exit0indicatesALLOW/SANITIZE.sanitize.pyrewrites only on safe paths: Outputs allowed or redacted text to stdout onALLOW/SANITIZE; suppresses stdout completely onASK,BLOCK, or validation errors.- What is covered: Documented credential formats, value-free secret source references (e.g., environment dumps), and host-identifying paths—not general repository-wide secret auditing or deliberate encoding obfuscation. The caller remains responsible for emission and egress audit logging.
- Configuration structure without secrets: Use
safe_viewto inspect supported JSON and.envschemas without displaying scalar values; it is a read-only view, not an automatic read hook.
See the Exfil-guard Skill, Detection rules, and Channel contract.
3. Controlled behavioral verification (Guard-lab)
Guard-lab tests whether a real harness and guard integration behave as expected without using real secrets. It seeds a disposable fixture with non-secret synthetic markers and harmless bait while keeping the controller and tamper-detecting hash-chained evidence outside the workspace exposed to the agent.
Its methodology enforces three steps:
- Calibrate: Confirm observers, marker scans, and the hash-chained evidence pipeline pass all four zero-model controls.
- Establish baseline exposure: Confirm an unguarded trial triggers the target channel (a silent unguarded run cannot prove mitigation).
- Compare guarded runs: Re-run with guards active under identical host version, model, task, protocol, and non-guard settings.
From the installed package root or checkout root, run a single zero-model calibration control (installed packages also expose agent-guard-lab):
lab_run="$(mktemp -d)"
python3 guard_lab.py run --case clean --output-dir "$lab_run/clean" --json
Or from a package or checkout containing the calibration example, run all four zero-model controls (clean, mock-positive, mock-injection, snapshot-positive):
blue_run="$(mktemp -d)"
python3 docs/lab/examples/blue-team-calibration.py --output-dir "$blue_run/controls"
[!NOTE] A passing control verifies instrument calibration, not model safety. The hash chain flags corrupted or altered evidence as
INCONCLUSIVE, though a process sharing the same OS privileges can still modify local logs and hashes. Observations apply strictly to declared channels rather than arbitrary file reads or unmonitored network egress. See the Lab guide, Four-control example, Blue-team research, and existing Kimi / DSH reports.
Host integrations & observed coverage
Give your coding agent the shared setup prompt along with adapters/INTEGRATION.md to configure the installed package root and workspace. Where available, pair MCP maintenance tools with a verified blocking hook (install_skill.py links skills/delete-guard into compatible Skill directories; see Skill installation).
In the table below, entries in the MCP & maintenance (0.3.0) column come from their respective recorded 0.3.0 pre-release checkpoints (not a per-host re-run of the final published artifact), whereas Native hook evidence retains each adapter's own recorded test checkpoint (for example, DSH 0.2.1-alpha.4 default deletion was validated at the 0.2.6 checkpoint, and scripted Claude Bash hooks at 2.1.270 / 2.1.273). Every row applies only to those tested host versions and tool paths; other combinations require separate validation (see the full Capability matrix and 0.3.0 acceptance report):
| Host | Tested version | MCP & maintenance (0.3.0) | Native hook evidence & known gaps | Guides |
|---|---|---|---|---|
| Codex | 0.165.0 | Passed fresh-approved 71-root batch, real cache task, and optional native-form model task with independent verification & restore | Native shell/editor interception requires separate validation; terminal approval remains the default | Report · Earlier trials |
| Kimi Code | 2.3.0 | Passed standard and fresh-approved MCP maintenance tasks | Observed root-Bash native block -> plan -> terminal approval -> original-session execution & restore; Stop and missing/timed-out hook caveats remain separate | Report · Setup |
| DSH | 0.2.0-rc.2 | Passed repaired original-root startup and fresh-approved MCP execution | Native 0.2.0-rc.2 / 0.2.1-alpha.4 plugin evidence; a later native trial hit an OS sandbox block under PRoot (separate zero-model local control passed) | Report · Compatibility · Setup |
| Claude Code | 2.1.311 / 2.1.270–273 | 2.1.311 connected and discovered 10 MCP tools; live model maintenance deferred | Scripted native Bash hook evidence is from 2.1.270 / 2.1.273; 2.1.311 native hooks remain unverified | Report · Setup |
| Other hosts | — | Skill / CLI / MCP cooperative usage | Use the adaptation guide for local setup; verify actual blocking before claiming native interception | Adaptation guide |
For ongoing configuration health, doctor.py kimi|claude --probe and --check-drift inspect local wiring against compatibility profiles (PASS validates local files, not live host hook loading). Optional live sentinels test one sampled root-agent Bash call and may use provider quota. See the Host drift guide.
Documentation
| Document | Focus |
|---|---|
| Getting started | Installation channels, setup prompt, and non-destructive verification |
| Documentation index | Full map of guides, design docs, Lab workflows, reports, releases, and history |
| Architecture | Core pillars, Decision Protocol, dialects, compensation, and adapter data flow |
| Threat model | Trust assumptions, attack vectors, and security-boundary upgrade paths |
| Compatibility | Adapter contracts, interface guarantees, and release rules |
| Blue-team research | Defensive methods, sanitized studies, and calibration baseline |
| 0.3.1 release notes · 0.3.0 notes | Release summaries, upgrade impacts, and verification scope |
Contributing
Bug reports, compatibility reports, documentation improvements, and focused PRs are welcome. Please read CONTRIBUTING.md before submitting defensive research or logs, and use Issues and Pull Requests. Never commit credentials, private configuration, or unredacted incident records.
Community
Project discussion thread on LINUX DO, maintained by the authors.
License
MIT — see LICENSE.
Badge
Listed here? Link back with this badge — paste the snippet into your repository README.
[](https://dsh-plugin.com/plugins/mokuyoaxis/agent-guard)