Destructive Action Guard is a cross-platform Codex guardrail for destructive shell, filesystem, Git, and mirror commands.
It classifies risky commands before execution, prefers deterministic logic over prompt-only judgment, and fails closed when wrappers, wildcards, or target sets cannot be resolved safely.
The repository ships three things together:
- Python helper CLIs:
doctor,print-snippets, andevaluate-command - A Codex plugin manifest and bundled plugin assets
- Two skills:
destructive-action-guardand the compatibility shimsafe-delete-review
- Treats command-like prefixes such as
sudo,env,time,cmd.exe,powershell.exe, andbash -cas commands, not casual natural language. - Classifies risky destructive families such as
rm,del,Remove-Item,git clean,git reset --hard,robocopy /MIR, andrsync --delete. - Resolves exact filesystem targets when wildcard or relative paths can be expanded deterministically.
- Requires preview-first workflows for command families that support them.
- Marks targets that fall outside the reviewed project root.
- Validates either a source checkout or an installed package bundle with
doctor.
- Destructive natural-language requests that do not resolve to an exact reviewed target set
- Partial or unresolved wildcard expansion
- Wrapper chains that are too deep to classify safely
git clean,robocopy, andrsyncdelete flows that skip their preview step- Commands that look destructive but cannot be normalized with confidence
- Filesystem delete:
rm,del,erase,rmdir,rd,Remove-Item - Git cleanup:
git clean - Git hard reset:
git reset --hard - Mirror and sync deletion:
robocopy /MIR,/PURGE,/MOVE,/MOV, andrsync --delete - Common wrappers:
sudo,env,time,cmd.exe /c,powershell -Command,pwsh -Command,bash -c,sh -c,zsh -c
This repository is ready to build wheels and source distributions for PyPI, but if you are working from the repo today, install from a checkout or a locally built wheel.
python -m pip install -e .
doctor --plugin-root . --jsonpython -m pip install build
python -m buildpython -m pip install dist/destructive_action_guard-0.1.0-py3-none-any.whlAfter installation, these public helpers are available:
doctorprint-snippetsevaluate-command
Repo-local wrappers are also available under scripts/ for working
directly from a checkout.
evaluate-command accepts a command or request and returns one of five
classification outcomes:
safepreview-onlydestructiveambiguousforbidden
Exit codes are part of the public contract:
0:safeorpreview-only10:destructive11:ambiguous12:forbidden
argparse usage errors remain on their normal non-zero path and are not part of
that mapping.
JSON output is designed to stay stable where possible. Important fields include:
classificationnormalized_familypreview_strategyexact_targetsunresolved_targetsoutside_project_targetsapproval
print-snippets prints recommended Codex config and rules snippets without editing
the user environment.
doctor validates either:
- a source checkout with the repo-root plugin layout, or
- an installed package bundle with the plugin assets shipped inside the wheel
It does not rewrite Codex config or rules files.
Classify a destructive Git cleanup:
evaluate-command --command "git clean -fdx" --jsonClassify a preview-only cleanup:
evaluate-command --command "git clean -nfdx" --jsonClassify a wrapper-hidden destructive command:
evaluate-command --command "sudo rm -rf build" --cwd . --project-root . --jsonClassify a Windows PowerShell wrapper:
evaluate-command --command "powershell -NoProfile -Command \"Remove-Item temp.txt\"" --platform windows --jsonExpand a deterministic wildcard request:
evaluate-command --command "Remove *.log recursively" --cwd . --jsonPrint recommended snippets:
print-snippets --platform windows --section allInspect a source checkout or installed bundle:
doctor --plugin-root . --jsonExample JSON for a preview-required command:
{
"classification": "ambiguous",
"normalized_family": "git_clean",
"preview_strategy": {
"mode": "preview",
"commands": ["git clean -ndx"],
"notes": ["Run preview mode first and approve only the reviewed target set."]
},
"requires_approval": false,
"risk_level": "critical",
"refusal_reason": "git clean requires preview output before destructive approval."
}This project is not:
- a shell executor
- a general-purpose shell parser for every dialect and edge case
- a replacement for backups, snapshots, or version control
- a tool that silently edits global Codex safety configuration
docs/INSTALL.mddocs/EXAMPLES.mddocs/DESIGN.mddocs/THREAT_MODEL.mddocs/VERSIONING.mdREPO_LAUNCH_CHECKLIST.mdCONTRIBUTING.mdSECURITY.md
Released under the MIT License.