Guardrails for AI coding assistants and shell workflows with two interchangeable delivery modes:
- Declarative CLI skills (
SKILL.md) for Codex/OpenAI-style tool loading - MCP server (
mcp-server/) for MCP-aware clients
This repository provides a production-friendly baseline for teams that want:
- strong classification of destructive actions
- explicit approval gates for risky commands
- workspace-boundary safety checks
- secret redaction and deterministic payload matching
- safe test coverage that avoids running destructive commands
| Class | Meaning | Required approval | Examples |
|---|---|---|---|
| Class 0 | Read-only work | No | git status, git diff, ls |
| Class 1 | Bounded local mutation | No | Edit one file, update one function |
| Class 2 | Destructive local state change | Yes | git clean -fdx (after preview), recursive delete |
| Class 3 | Cloud credentials / remote execution / install risk | Yes | terraform apply, `curl ... |
| Class X | Hard refuse (never executes) | Not applicable | Disk wipe, system boot/root deletion, global security disablement |
- Class 2:
APPROVE-DESTRUCTIVE:
- Class 3:
APPROVE-CLOUD:(primary)APPROVE-RISKY:(accepted alias for compatibility)
Approval payload shape:
APPROVE-DESTRUCTIVE:
payload_id: <slug>
workdir: .
commands:
- <command 1>
- <command 2>
- No
APPROVE-DESTRUCTIVEorAPPROVE-CLOUDpayload may use aworkdiroutside the resolved workspace root. - Payload matching normalizes line endings and trims trailing spaces before comparison.
- Class X actions are never bypassed by approval.
- No embedded credentials, tokens, private keys, or connection strings in policy/docs/code examples.
- Deterministic behavior across clients (stable approvals, predictable classification outputs).
- Non-destructive tests only; destructive behavior is simulated and never executed against real system resources.
Contains one folder per supported AI CLI:
guard-users-claudeguard-users-codexguard-users-geminiguard-users-chatgptguard-users-aiderguard-users-openhandsguard-users-qwenguard-users-llama
Each folder includes:
SKILL.md- policy for that interfaceagents/openai.yaml- loader metadata for OpenAI-style orchestrators
Python implementation of a Guard Users MCP server.
mcp_server/server.py- protocol loop, classification engine, approval payload builder/validatormcp_server/skills_loader.py- discovers and loadsguard-users-*skills fromskills/mcp-server/tests/test_guard_users_mcp.py- non-destructive test suite for all major policy outcomesmcp-server/README.md- focused server usage notesmcp-server/CHANGELOG.md- MCP release notes
All policy documents share the same core model:
- Class 0: read-only
- Class 1: bounded local mutation
- Class 2: destructive local mutation, requires explicit payload + approval
- Class 3: credential/cloud/network execute risk, requires strict approval
- Class X: non-permissible actions (catastrophic/system destructive)
Rules can be interpreted directly by humans and by MCP clients.
For Class 2 and Class 3, approvals are generated from exact payloads.
Key properties:
- exact text block matching
- workspace-aware
workdirvalidation - optional digest (
payload_sha256) for tamper evidence - strict CRLF/whitespace normalization behavior
- deterministic parser that can be tested in CI
The MCP implementation always resolves workdir and candidate targets against a workspace root (git root if present, else process cwd) and rejects writes/mutations that escape scope.
Classifier output masks known secret shapes (for example AWS-style keys, GitHub tokens, JWT-like strings, private key blocks) when present in prompts or output.
Set-Location <REPO_ROOT>
cd <REPO_ROOT>
Set-Location mcp-server
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .
python -m mcp_serverSet-Location <REPO_ROOT>\mcp-server
python -m pip install -e .
guard-users-mcpUse stdio transport with working directory pointing at the repo:
{
"mcpServers": {
"guard-users-mcp": {
"command": "python",
"args": ["-m", "mcp_server"],
"cwd": "<REPO_ROOT>\\mcp-server"
}
}
}If you prefer a script entry point:
{
"mcpServers": {
"guard-users-mcp": {
"command": "guard-users-mcp",
"args": [],
"cwd": "<REPO_ROOT>\\mcp-server"
}
}
}List all available guard skill variants.
Classify user text into action blocks and return policy metadata.
Useful output includes:
policy_versionandschema_version- overall and per-block
classification approval_requiredapproval_prefixfor Class 2/3deny_codeand sanitized preview of request
Construct exact approval payload text for Class 2/3 execution.
- supports
payload_id - supports multi-command payloads
- validates
workdirinside workspace - optional digest emission
Validate user reply text against proposed payload with strict normalization rules.
- checks exact payload body match
- checks optional digest hash when present
- supports
APPROVE-RISKY:alias for Class 3
If your environment uses direct skill loading instead of MCP, each SKILL.md is a first-class, versioned policy file:
- choose one by CLI family (
guard-users-codex,guard-users-gemini, etc.) - keep exactly one active policy format per tool integration
- legacy root-level skill files were intentionally removed in favor of per-CLI folders
All existing tests are read-only and do not write outside test fixtures.
Run with:
Set-Location <REPO_ROOT>\mcp-server
$env:PYTHONPATH = (Resolve-Path ".").Path
python -m unittest discover -s tests -p "test_guard_users_mcp.py"The suite validates:
- skill discovery from
skills/ - command-class synthesis for read-only, class 2, class 3, and class X paths
- payload construction and strict validation behavior
- CRLF normalization behavior for safe approval matching
- secret redaction and escape checks
- MCP policy version:
1.4.1 - Added action-block classification output
- Added workspace-aware payload validation
- Added
payload_sha256integrity checks - Added
APPROVE-RISKYcompatibility for Class 3 approvals - Added expanded test vectors for mixed-class chains and safe validation
See mcp-server/CHANGELOG.md for the full timeline.
When adding new CLI variants:
- create
skills/guard-users-<cli>/SKILL.md - include deterministic action classes and approval wording
- add/adjust any
agents/openai.yamlmetadata - add test vectors in
mcp-server/testsif classification behavior changes - ensure tests remain read-only and non-destructive
- Do not add dangerous destructive commands into new docs/tests.
- Keep destructive or networked operations behind approval gates.
- Assume all patterns are high-risk until proven bounded and local.
- Class X should remain non-overridable by confirmation wording.
This repository intentionally contains no real secrets. Test coverage includes synthetic token-shaped fixtures (for redaction-path verification) and verifies those values are never reflected in sanitized outputs.
Release checks include:
- No token-like hardcoded credentials in policy files
- No environment variable snapshots or secret dumps in logs
- No credential-bearing example commands without explicit masking guidance
- README and examples written for reuse by third parties without exposing internal/private state
This repository ships guardrails; it does not remove your responsibility to review risky operations.