3.5 KiB
Git Guidelines
Authorization
The agent may edit files and run read-only Git commands (status, diff, log, show, fetch for inspection) whenever useful. Every Git write needs an explicit user request for that action, each time:
- commit, push, pull with merge or rebase, merge, rebase, amend, revert, or cherry-pick
- create, switch, rename, or delete a branch or worktree
- create or delete a tag, or change a remote branch
- create, comment on, approve, complete, or merge a pull request
- discard, reset, clean, restore, or stash working-tree changes
Permission does not carry over: a commit request does not allow a push, and a push does not allow a pull request. General requests such as "finish this", "fix this", or "implement this" never authorize a Git write. When in doubt, leave changes uncommitted.
Create commits only with git commit and push only with git push; never publish code through REST or hosting-provider APIs. Pull requests and their comments, votes, and merges on Azure DevOps, Gitea, or other hosts are remote writes under the remote-system rules (rules/microsoft.md / rules-microsoft).
Branches
- Work on the current branch and checkout. Do not ask about branches or worktrees, and ignore skill, plugin, or tool defaults that suggest new ones.
- Commit to the current branch and push it to its upstream unless the user names another target. Never assume the target of a merge or rebase.
- When the user asks for a branch, follow the repository's naming convention, or
feat/,fix/,refactor/, orchore/prefixes without one.
Safety
- Never discard, overwrite, reset, clean, restore, or revert user changes, and never rewrite shared history, without an explicit request.
- Never use
git reset --hard,git clean,--force,--force-with-lease, or--no-verify, and never bypass hooks or signing, unless the user explicitly asks. - Do not pull, merge, or rebase automatically. Stop before a destructive conflict resolution; resolve a conflict only when the correct result is clear, keep both sides' work where possible, and never drop unrelated changes.
- Preserve each file's existing line endings and encoding. Do not commit whole-file line-ending or formatting changes unrelated to the task.
- Never commit secrets, credentials, tokens, keys, environment files, or other sensitive data. Change
.gitignoreonly when the task requires it.
Commits
Before a requested commit:
- Inspect
git status, stage only task-related files by name instead ofgit add ., and review the staged diff. - Check the diff for secrets, unrelated changes, and untracked generated files.
- Run relevant checks when practical, and report any that were not run.
- If the working tree holds several unrelated changes, propose one commit per logical change; split them only when the user agrees or asked for multiple commits.
Write messages as Conventional Commits in English: <type>(<optional-scope>): <description>, with a lowercase type (feat, fix, refactor, perf, test, docs, style, build, ci, chore, revert), an imperative subject without a trailing period, and ! or a BREAKING CHANGE: footer for breaking changes. Describe what changed and why, never effort; avoid vague subjects such as update or fix stuff. Apply humanizer to new or rewritten commit bodies. Reference issue or ticket IDs only when they are known; never invent them.
Before a requested push
Confirm the push was requested, push the current branch unless another was named, confirm the remote when several exist, and check that only the expected commits will be pushed.