Block push --delete and refspec delete syntax in agent mode#3
Closed
crcatala wants to merge 1 commit intomattzcarey:mainfrom
Closed
Block push --delete and refspec delete syntax in agent mode#3crcatala wants to merge 1 commit intomattzcarey:mainfrom
push --delete and refspec delete syntax in agent mode#3crcatala wants to merge 1 commit intomattzcarey:mainfrom
Conversation
Add guardrails to prevent agents from accidentally deleting remote branches. Changes: - AGENTS.md: Document blocked patterns - src/guardrails.zig: Add cmd_with_arg_prefix pattern, blocking rules, and tests Co-authored-by: Christian Catalan <crcatala@gmail.com>
mattzcarey
pushed a commit
that referenced
this pull request
Feb 18, 2026
Cherry-pick changes from PR #3 to block `git push --delete` and `git push origin :<branch>` refspec delete syntax in agent mode. Also reverts the task edit hint back to recommending 'tasks append'. https://claude.ai/code/session_01B6U9cKiYt9Dr1BrK8Bg9Hk
Owner
|
closed in favour of #15 Thanks for this!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Agents can accidentally delete remote branches using
git push --deleteor the equivalent refspec syntaxgit push origin :<branch>. Unlike other destructive commands, there's no "safe mode" or dry-run flag for remote branch deletion - the only safe alternative is to ask the user to do it manually.Solution
Block both deletion patterns when
ZAGI_AGENTis set:This aligns with existing guardrails for
push --force,stash drop, andstash clear.Changes
AGENTS.md: Added both patterns to blocked commands tablesrc/guardrails.zig:cmd_with_arg_prefixpattern type for refspec detection--delete,-d, and:<branch>syntaxTesting