6.2 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.
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
-
Do not create a branch unless explicitly requested.
-
Do not switch branches unless necessary for the requested task.
-
Never delete branches unless explicitly requested.
-
Never rename branches unless explicitly requested.
-
Never assume the target branch for a merge, rebase, or push.
-
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.
- Confirm the intended 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
- 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.