Recoverable file and Git operations for coding agents, with shared recovery and redaction tools, a DSH shell adapter and audit records; optional native text-read protection is off by default.
Install
# from npm (prebuilt)
dsh plugin --profile web add @mokuyoaxis/agent-guard
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:mokuyoaxis/agent-guard
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
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 zero-dependency deterministic safety checkpoints, transaction-level recovery, value-free multi-channel egress checks, and empirical L0/L1/L2 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; inline-script deletion blocks; Cleanup Copilot inventory and reviewed maintenance tasks; workspace budgets, rate/repeat limits, protected paths and controlled regenerable patterns; on-demand quarantine storage measurement (--measure-storage), read-only restore previews, selective path restore with reconciled transaction states, manual GC, and optional local MCP tools (15 default / 16 Codex) |
Skill & CLI · Cleanup Copilot · Deletion limits · Unified queries · Recovery & GC · MCP tools · MCP doctor |
| Exfil-guard | Value-free outbound scanning for documented credential formats, secret source references, and host-identifying paths; plan-verified redaction and opt-in metadata-only audit; bounded whole-file redacted reads (agent-guard-safe-read & MCP safe_read); scalar-free JSON/dotenv/TOML config views (safe_view); policy-allowlisted local scalar config edits (agent-guard-config-edit); bounded export preflight (agent-guard-exfil-export), local Git hooks, MCP tools, and opt-in Bash checks |
Skill & CLI · Safe read · Guarded config edit · Rules & export · Safe config view · Git hooks |
| Guard-lab & Doctor | Controlled experiments in disposable fixtures using four loopback controls plus L0 paired lifecycle calibration (lifecycle-calibration), synthetic markers, and matched guard-off / guard-on runs; read-only agent-guard-doctor workspace checks for deletion and config-edit policies, Skill links, Git hooks, and hidden Unicode carrier smuggling |
Lab guide · Lifecycle calibration · Workspace doctor · Four-control example |
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.3 release into a stable, user-owned prefix:
npm install --prefix /absolute/path/to/agent-guard-install @mokuyoaxis/agent-guard@0.3.3
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.3) or npm (0.3.3). See Getting started for offline tarball installation, upgrades, and full dependency/platform details (including Node 22 for the optional DSH read prototype, Python 3.11+ for TOML safe_view and Kimi TOML helpers, POSIX descriptors for agent-guard-exfil-export / safe_read, and Linux xattr support for agent-guard-config-edit).
| Release | Key additions |
|---|---|
| 0.3.3 | Exfil-guard bounded redacted reads (agent-guard-safe-read & 15th default / 16th Codex MCP tool safe_read) and allowlisted operator config editor (agent-guard-config-edit for JSON/single-line .env, 17 npm CLI bins, 7 exfil-guard Skill entrypoints); Delete-guard on-demand quarantine storage measurement (status --view overview --measure-storage, Top-10 verified transactions) and multi-receipt reconciled selective restore (restore --path / MCP paths); cross-platform doctor workspace config_edit_policy check; Nov 28 Anniversary Special Edition README emblem |
| 0.3.2 | Exfil-guard TOML safe view, opt-in audit, 3 MCP tools, local Git hooks, 8 modern credential rules, agent-guard-exfil-export, opt-in Bash checks; Delete-guard protect/regenerable policy CLI with whole-tree secret-store guards, read-only restore.py preview & MCP restore_preview (14 default / 15 Codex), inline-script deletion blocks, Windows PowerShell handoff; L0 paired lifecycle-calibration, read-only agent-guard-doctor workspace with Unicode carrier-smuggling checks |
| 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 & bounded file access without leaking secrets: Use
safe_viewto inspect supported JSON,.env, and TOML (Python 3.11+) schemas without displaying scalar values; useagent-guard-safe-read(or MCPsafe_read, POSIX) for bounded whole-file redacted line reads of ordinary workspace text files; and use the operator-onlyagent-guard-config-edit(Linux with descriptor and xattr support) for policy-allowlisted non-sensitive JSON/single-line.envscalar edits with--previewand terminalAPPLY. For explicit export sets, runagent-guard-exfil-export(POSIX) before packaging or sharing files.
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).
The MCP & maintenance column uses the recorded 0.3.0 pre-release checkpoints unless another Agent Guard version is listed. Native hook evidence retains each adapter's recorded test checkpoint. 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 to its tested host versions and tool paths. Capability matrix · 0.3.0 acceptance report
| Host | Tested version | MCP & maintenance | 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 |
| Cursor CLI | 2026.11.22-e9042b2 |
Published Agent Guard 0.3.3 passed selective restore and occupied-origin conflict handling through opt-in local stdio MCP |
Native shell and editor hooks await separate validation | Project MCP 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 workspace checks local deletion and config-edit policies, Skill links, Git Hook wrappers, and whitelisted persistent carriers for hidden Unicode smuggling without writing files, while doctor.py kimi|claude --probe and --check-drift inspect host hook 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 & workspace doctor 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.3 release notes · 0.3.2 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.
Links
More in this category
kenryu42/cc-safety-net★ 2123
Pre-execution guard that blocks destructive Git and filesystem commands and access to secrets such as SSH keys and .env files before a tool call runs.
ADWMC/helm-d#helmd★ 1589
Security-analysis plugin for DeepSeek Harness: 33 tools spanning six security domains, evidence/reporting and toolbox, plus the case lifecycle, routing and tool ledger; a session-bound case workflow with an evidence chain, E-id validation and reproducible findings; 362 on-demand references; three hot-swappable persona profiles; and a four-tab workbench (armor / case / intercept / about) with case-state recovery after context compaction.
SeaOf0/dsh-redteam-model★ 934
Authorized-security DSH collection: nine work modes (redteam coordinator, pentest, code audit, binary analysis, attack-defense, AV evasion, incident response, cloud security, CTF solving) and fifteen runtime plugins, managed from a settings page with one-click deploy, install, update and uninstall.
toby-bridges/api-relay-audit★ 934
Runs local security audits of AI API relays and LLM proxies from DeepSeek Harness, producing Markdown reports for prompt injection, model substitution signals, tool-call rewriting, error leakage, stream integrity, and profile-gated Web3 risks.
howmp/dsh-pentest★ 624
Authorized pentest mode for DeepSeek Harness — exploration chain, assets and findings with a Web view.
Jueze-2019/dsh-redteam-mode#packages/redteam-bundle★ 316
Red-team engagement mode: send one target organization name; a planner session runs five execution roles (recon, asset triage, vulnerability discovery, exploitation, internal pivot) with configurable concurrency; preflight checks skills/resources; scoring uses four stages (recon, internet, boundary, internal) with server-side caps and privilege-wins dedup; findings stay in a local SQLite fact base. The persistent right-side console has nine pages and includes asset mapping, agents, sessions/tunnels, findings, score targets, reports, POC knowledge base and skill library. v0.15.2 adds automatic HTTP evidence/action records, batch ingest, scope check, tunnel pivot probe, data proof, cleanup ledger and T0-T3 asset admission to prevent scope drift. 59 redteam_* tools; 38 bundled skills.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.