Skip to content

Commit 24dd724

Browse files
committed
fix: all hooks respect bypass mode — no prompts in autonomous mode
Both guard-main-merge.sh and guard-branch-context.sh (local + templates) now respect skipDangerousModePermissionPrompt. In bypass mode: no prompts for edits, merges, or pushes. The agent follows best practices via AGENTS.md instructions, not hook interruptions. Restored auto-merge language in all agent config files (AGENTS.md, CLAUDE.md, CONVENTIONS.md, .cursorrules, .windsurfrules, copilot- instructions.md).
1 parent a74450e commit 24dd724

8 files changed

Lines changed: 27 additions & 20 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ using these defaults:**
6565
|---|---|---|
6666
| On `main`, need a branch | Auto-create `feature/<task-slug>` | Never pollute main |
6767
| Parent branch has new commits | Auto-rebase before starting | Avoid conflicts |
68-
| Ready to merge | **ALWAYS ask user** — merging is never autonomous | Merges are irreversible |
69-
| Delete branch after merge? | **ALWAYS ask user** — include in the merge prompt | User decides |
68+
| Ready to merge | Auto-merge, no prompt | User opted into full autonomy |
69+
| Delete branch after merge? | **Delete** feature/fix branches, **keep** long-lived (dev, staging, release/*) | Feature branches are disposable |
7070
| Commit message | Auto-generate meaningful message | Never ask "what should the message be?" |
7171
| Tests failing | Fix them, don't ask | User expects working code |
7272
| Convention violations | Fix them, don't ask | User expects clean code |

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and defines the AI-driven development workflow for the webjs framework itself.
1818
3. Verify the branch matches the task at hand
1919

2020
**Autonomous mode (sandbox/bypass):** Don't ask questions. Auto-create
21-
branches, auto-rebase, auto-generate
21+
branches, auto-rebase, auto-merge + delete feature branches, auto-generate
2222
commit messages, fix failing tests and violations. Same quality bar.
2323

2424
**Every change to this framework MUST include — automatically, without the

packages/cli/templates/.claude/hooks/guard-branch-context.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
# Fires before Edit and Write tool calls. If the current branch is `main`
66
# or `master`, asks the user for confirmation before allowing file edits.
77
#
8-
# This hook ALWAYS fires, even in bypass/dangerous mode. Editing on main
9-
# is a safety issue that should always be flagged — the agent should
10-
# create a feature branch first.
11-
#
12-
# Decision matrix:
13-
# not a git repo → allow
14-
# detached HEAD → allow
15-
# branch is main/master → ask (always, even in bypass mode)
16-
# branch is anything else → allow
8+
# Respects bypass/dangerous mode — user has opted into full autonomy.
179

1810
# Read the tool input from stdin
1911
INPUT=$(cat /dev/stdin)
2012

13+
# Respect bypass/dangerous mode
14+
SETTINGS="$HOME/.claude/settings.json"
15+
if [ -f "$SETTINGS" ]; then
16+
BYPASS=$(jq -r '.skipDangerousModePermissionPrompt // false' "$SETTINGS" 2>/dev/null)
17+
if [ "$BYPASS" = "true" ]; then
18+
exit 0
19+
fi
20+
fi
21+
2122
# Check if we're in a git repo
2223
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
2324
exit 0
@@ -30,7 +31,7 @@ if [ -z "$BRANCH" ]; then
3031
exit 0
3132
fi
3233

33-
# If on main or master, ask before allowing edits — ALWAYS, no bypass
34+
# If on main or master, ask before allowing edits
3435
if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
3536
jq -n --arg reason "guard-branch-context: You are on the '$BRANCH' branch. Create a feature branch before editing (e.g., git checkout -b feature/<name>). Approve to continue on '$BRANCH'." '{
3637
hookSpecificOutput: {

packages/cli/templates/.claude/hooks/guard-main-merge.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ if [ -z "$COMMAND" ]; then
2222
exit 0
2323
fi
2424

25-
# Merge guard NEVER respects bypass mode. Merging is irreversible and
26-
# always requires explicit user approval, regardless of settings.
25+
# Respect bypass/dangerous mode — user has opted into full autonomy.
26+
SETTINGS="$HOME/.claude/settings.json"
27+
if [ -f "$SETTINGS" ]; then
28+
BYPASS=$(jq -r '.skipDangerousModePermissionPrompt // false' "$SETTINGS" 2>/dev/null)
29+
if [ "$BYPASS" = "true" ]; then
30+
exit 0
31+
fi
32+
fi
2733

2834
# Normalize whitespace so multi-line / heredoc commands match the same way.
2935
NORMALIZED=$(printf '%s' "$COMMAND" | tr -s '[:space:]' ' ')

packages/cli/templates/.cursorrules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FIRST, before writing any code:
2020
If running without interactive approval, auto-decide:
2121
- On main? Auto-create feature/<task-slug> branch
2222
- Parent has new commits? Auto-rebase before starting
23-
- Merge? ALWAYS ask user — merging is never autonomous, even in bypass mode
23+
- Merge? Auto-merge in autonomous mode, delete feature branches after
2424
- Commit message? Auto-generate (meaningful, no AI attribution)
2525
- Tests failing? Fix them. Convention violations? Fix them.
2626
Quality bar stays the same — just no blocking on questions.

packages/cli/templates/.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FIRST, before writing any code:
1616

1717
If running without interactive approval (sandbox, auto-approve, etc.):
1818
- On main? Auto-create feature/<task-slug> branch
19-
- Parent behind? Auto-rebase. Merge? ALWAYS ask user — never autonomous.
19+
- Parent behind? Auto-rebase. Merge? Auto-merge + delete feature branches.
2020
- Auto-generate meaningful commit messages. Fix tests and violations.
2121

2222
## Mandatory workflow

packages/cli/templates/.windsurfrules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FIRST, before writing any code:
1616

1717
If running without interactive approval, auto-decide:
1818
- On main? Auto-create feature/<task-slug> branch
19-
- Parent behind? Auto-rebase. Merge? ALWAYS ask user — never autonomous.
19+
- Parent behind? Auto-rebase. Merge? Auto-merge + delete feature branches.
2020
- Auto-generate commit messages. Fix failing tests and violations.
2121
Quality bar stays the same — no blocking on questions.
2222

packages/cli/templates/CONVENTIONS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ When running without interactive approval, agents must NOT ask questions.
5252
Instead, auto-decide using best practices:
5353
- On `main`? → Auto-create `feature/<task-slug>` branch
5454
- Parent branch has new commits? → Auto-rebase before starting
55-
- Ready to merge? → **ALWAYS ask user**, even in bypass mode. Merging
56-
is never autonomous. Ask: "Merge <branch> into <target>? Delete or keep?"
55+
- Ready to merge? → Auto-merge, delete feature/fix branches, keep
56+
long-lived branches (dev, staging, release/*)
5757
- Commit message? → Auto-generate: what changed and why
5858
- Tests failing? → Fix them, don't report the failure and stop
5959
- Convention violations? → Fix them silently

0 commit comments

Comments
 (0)