Always-loaded general rules now forbid creating or switching branches or worktrees without an explicit request, and route commit and push requests to the current branch unless another branch is named. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6.9 KiB
Git Guidelines
General Rules
- Never commit changes unless explicitly instructed to do so.
- Never push changes unless explicitly instructed to do so.
- Never create a pull request unless explicitly instructed to do so.
- Never merge branches unless explicitly instructed to do so.
- Never rebase branches unless explicitly instructed to do so.
- Never amend an existing commit unless explicitly instructed to do so.
- Never create or delete Git tags unless explicitly instructed to do so.
- Never modify remote branches unless explicitly instructed to do so.
- Do not interpret general requests such as "finish this", "implement this", or "fix this" as permission to commit or push.
- Permission to commit does not imply permission to push.
- Permission to push does not imply permission to create or merge a pull request.
- Only perform Git write operations that the user explicitly requested.
- Read-only Git commands may be used when needed to inspect repository state.
- Create commits only with
git commitand push commits only withgit push. Never create commits or publish repository code through REST APIs, hosting-provider APIs, or other non-Git interfaces.
Repository Safety
- Always inspect the current Git status before performing Git write operations.
- Never discard uncommitted user changes.
- Never overwrite unrelated changes.
- Never reset, clean, checkout, restore, or revert user changes unless explicitly requested.
- Never use destructive Git operations without explicit instruction.
- Never use
git reset --hardunless explicitly requested. - Never use
git cleanunless explicitly requested. - Never force-push unless explicitly requested.
- Never use
--forceor--force-with-leaseunless explicitly requested. - Never rewrite shared history without explicit instruction.
- Never modify
.gitignoreunless required by the task. - Never commit secrets, credentials, tokens, API keys, private keys, environment files, or other sensitive data.
- Never bypass Git hooks unless explicitly requested.
- Never use
--no-verifyunless explicitly requested.
Scope
- Only stage files related to the requested task.
- Never stage unrelated modified files.
- Prefer staging specific files instead of using broad commands such as
git add .. - Do not include generated files unless they are intentionally tracked by the repository.
- Do not include formatting-only changes unrelated to the task.
- Do not modify unrelated files merely to create a cleaner commit.
- Keep commits focused on one logical change.
- Split unrelated changes into separate commits when multiple commits were explicitly requested.
Commit Messages
Use Conventional Commits.
Format:
<type>(<optional-scope>): <description>
Allowed common types:
feat: new functionalityfix: bug fixrefactor: code change without changing external behaviorperf: performance improvementtest: test changesdocs: documentation changesstyle: formatting or style-only changesbuild: build system or dependency changesci: CI/CD changeschore: maintenance workrevert: revert of an earlier change
Commit message rules:
- Use lowercase commit types.
- Keep the subject concise and specific.
- Use imperative wording.
- Do not end the subject with a period.
- Describe what changed, not how hard the work was.
- Avoid vague messages such as
fix stuff,update,changes, orcleanup. - Use a scope when it improves clarity.
- Keep each commit limited to one logical purpose.
- Use
!or aBREAKING CHANGE:footer for breaking changes. - Reference issue or ticket identifiers only when relevant and known.
- Never invent issue numbers, ticket IDs, or references.
Examples of valid commit messages:
feat(auth): add refresh token rotationfix(api): handle missing user idrefactor(storage): simplify cache abstractionperf(database): reduce duplicate queriestest(users): add validation coveragedocs(readme): document local setupbuild: update dotnet dependencies
Branches
-
Apply all work and Git operations to the current branch in the current checkout unless the user explicitly names another branch or worktree.
-
Do not ask whether to create a branch, switch branches, or use a worktree. Stay on the current branch instead.
-
Never create or switch branches unless explicitly requested.
-
Never create worktrees unless explicitly requested.
-
Ignore skill, plugin, or tool defaults that suggest a new branch or worktree.
-
Never delete branches unless explicitly requested.
-
Never rename branches unless explicitly requested.
-
Commit on the current branch unless the user names another branch.
-
Push the current branch to its upstream unless the user names another target.
-
Never assume the target branch for a merge or rebase.
-
Preserve the repository's existing branch naming convention.
-
If no branch naming convention exists and a branch was explicitly requested, prefer concise names such as:
feat/<name>fix/<name>refactor/<name>chore/<name>
Pulling and Fetching
- Fetching remote state is allowed when required for inspection.
- Do not pull automatically unless explicitly requested or required for an explicitly requested Git operation.
- Never resolve pull or merge conflicts by discarding user changes.
- Do not automatically rebase after pulling.
- Do not automatically merge remote changes into the current branch.
Conflicts
- Stop before making destructive conflict-resolution decisions.
- Preserve both user work and repository history whenever possible.
- Resolve conflicts only when the correct resolution is clear from the task and surrounding code.
- Do not silently choose one side of a conflict when intent is ambiguous.
- Never use conflict resolution as an excuse to remove unrelated changes.
Before an Explicitly Requested Commit
Before creating a commit:
- Inspect
git status. - Inspect the staged diff.
- Confirm only task-related files are staged.
- Check for accidental secrets or sensitive files.
- Ensure the changes are consistent with the requested task.
- Run relevant tests, checks, or builds when practical.
- Do not include unrelated modifications.
- Use a Conventional Commit message.
Before an Explicitly Requested Push
Before pushing:
- Confirm that pushing was explicitly requested.
- Push the current branch unless the user named another branch.
- Confirm the intended remote when multiple remotes exist.
- Ensure the commits being pushed are expected.
- Do not force-push unless explicitly requested.
- Do not push unrelated local commits unintentionally.
Autonomous Agent Rule
The agent may edit files and implement requested changes autonomously.
The agent must not autonomously:
- commit
- push
- merge
- rebase
- amend commits
- create pull requests
- create or delete tags
- create or switch branches
- create worktrees
- delete branches
- rewrite Git history
- discard working-tree changes
These actions require explicit user instruction each time.
When in doubt, leave the repository changes uncommitted.