From ec546c4e96c2d90cb99db6fb84721a8d458dba47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=8B=9C=EC=9B=90?= Date: Thu, 7 May 2026 20:44:51 +0900 Subject: [PATCH] Forbid auto-creating git branches in agent workflows Codex and other coding subagents have been creating branches like experiments/foo and feature/bar without being asked. This fragments review, hides work from the user, and requires manual cleanup. The project intentionally develops on main with frequent small commits. AGENTS.md adds an explicit "Git Branching Policy" section: no checkout -b, switch -c, branch , or PR-from-new-branch unless the user asks for it in the current task. Includes a pass-through clause so this propagates to subagents the main agent spawns. CLAUDE.md adds a one-line pointer with the same pass-through note, since CLAUDE.md mandates AGENTS.md is read at session start. Co-Authored-By: Claude Opus 4.7 (1M context) --- AGENTS.md | 37 +++++++++++++++++++++++++++++++++++++ CLAUDE.md | 6 +++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 4b30dd3..f7e644e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -357,3 +357,40 @@ contention slows both unevenly and breaks the comparison. - Before committing, run `uv run ruff check .` and at least the relevant pytest subset. For Deep CFR changes, run `uv run pytest -q tests/games/classic/test_deep_cfr_trainer.py`. + +## Git Branching Policy (READ THIS) + +**DO NOT create new git branches unless the user explicitly asks for one in +the current task. Work on whatever branch is currently checked out (default +`main`). This is a hard rule — no exceptions for "safety", "isolation", +"experiments", "work-in-progress", or any other self-justified reason.** + +Why this rule exists: +- This project intentionally develops on `main` with frequent small commits. +- Auto-created branches like `experiments/foo`, `feature/bar`, `wip/baz` + fragment review, hide work from the user, and require manual cleanup. +- The user has not authorized branch creation as a default behavior. If + they want a branch, they will say so explicitly ("make a branch", "PR + this", "isolate this in a branch", etc.). + +What you MUST do instead: +- Make commits directly on the currently checked-out branch. +- If you think a branch is justified, **stop and ask the user first** — + do not preemptively create one. +- If a tool or subagent invocation auto-suggests creating a branch + (e.g. PR-style workflows), refuse the branch creation step and commit + to the current branch. +- If you find yourself already on a non-default branch you didn't expect, + stop and ask the user — do not switch, do not create a new one, do not + reset. + +Forbidden without explicit user instruction: +- `git checkout -b ` +- `git switch -c ` +- `git branch ` +- `gh pr create` from an auto-created branch +- Any worktree creation that implicitly creates a new branch + +This rule applies to the main agent and to every subagent or tool the main +agent invokes. Pass it through in subagent prompts when delegating +git-touching work. diff --git a/CLAUDE.md b/CLAUDE.md index 6eac8ee..9c8784e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,4 +5,8 @@ This repository uses AGENTS.md as the canonical coding-agent instruction file. **MANDATORY: At the start of every session, read AGENTS.md in full before doing anything else — including answering questions, exploring code, or running commands.** Notes: -- this project uses uv. don't mess with .venv or the system python. \ No newline at end of file +- this project uses uv. don't mess with .venv or the system python. +- **DO NOT create new git branches unless the user explicitly asks.** Work + on the currently checked-out branch (default `main`). See AGENTS.md + "Git Branching Policy" for the full rule. This applies to all + subagents you spawn — pass the policy through. \ No newline at end of file