AgentStack
SKILL verified MIT Self-run

Git Guardrails

skill-matthewye-opencode-toolbox-git-guardrails · by MatthewYe

Set up OpenCode permission rules to guard against dangerous git commands (push, reset --hard, clean, branch -D, checkout/restore .) before they execute. Use when user wants to prevent destructive git operations, add git safety guardrails, or block dangerous git commands.

No reviews yet
0 installs
16 views
0.0% view→install

Install

$ agentstack add skill-matthewye-opencode-toolbox-git-guardrails

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No 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.

Are you the author of Git Guardrails? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

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 --hard
  • git clean -f / git clean -fd
  • git branch -D
  • git 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:

  1. All 5 guardrail patterns are present under permission.bash
  2. Existing unrelated rules are preserved
  3. 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.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.