Install
$ agentstack add skill-matthewye-opencode-toolbox-git-guardrails ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Git Guardrails
Sets up permission.bash rules in opencode.jsonc to require confirmation (ask) before executing dangerous git commands.
What Gets Guarded
git push(all variants including--force,--force-with-lease)git reset --hardgit clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
When guarded, OpenCode will prompt for confirmation before executing any of these commands.
Steps
1. Ask scope
Ask the user: install for all projects (global) or this project only?
| Scope | Config path | |-------|-------------| | Global | ~/.config/opencode/opencode.jsonc | | Project | /opencode.jsonc |
2. Read existing config
Read the target config file. Note existing permission block, especially any existing bash rules.
If the file does not exist, create it with a minimal structure:
{
"$schema": "https://opencode.ai/config.json",
"permission": {}
}
3. Add guardrail rules
Add or update the following rules under permission.bash. Use "ask" level — the agent must request confirmation before executing these commands:
"permission": {
"bash": {
// ... existing rules ...
"git push *": "ask",
"git reset --hard *": "ask",
"git clean -f*": "ask",
"git branch -D *": "ask",
"git checkout .*": "ask"
}
}
Rules to write:
| Pattern | Guards | |---------|--------| | "git push *": "ask" | All git push variants | | "git reset --hard *": "ask" | Hard reset only | | "git clean -f*": "ask" | Forced clean | | "git branch -D *": "ask" | Force delete branch | | "git checkout .*": "ask" | Discard working tree changes |
Merge carefully: If the file already has a permission.bash block with existing rules, merge the new rules into it — never overwrite unrelated settings.
4. Ask about customization
Ask if the user wants to:
- Add additional dangerous commands to guard (e.g.,
git stash drop,git reflog expire) - Remove any of the 5 default patterns
- Change any rule from
"ask"to"deny"(block without confirmation)
Edit the config accordingly.
5. Verify
Read back the modified config file and confirm:
- All 5 guardrail patterns are present under
permission.bash - Existing unrelated rules are preserved
- JSONC syntax is valid (no trailing commas, matching braces)
Report the final state to the user with a summary of what's now guarded.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: MatthewYe
- Source: MatthewYe/opencode-toolbox
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.