Commits must carry the identity that matches the remote; set it per repo, not
globally. Leaving the global user.email unset is deliberate — with no email git
silently commits a …@hostname.local address, which pollutes and de-anonymizes history.
Before committing, verify git config user.email is set for this repo; if empty or a
.local/(none) hostname value, set git config --local user.name/user.email first.
Automate it with git conditional includes so identity follows the remote URL:
# ~/.gitconfig (email is set only inside the includes; global email stays unset)
[includeIf "hasconfig:remote.*.url:https://github.com/**"]
path = ~/.gitconfig-github
[includeIf "hasconfig:remote.*.url:https://git.example.com/**"]
path = ~/.gitconfig-work
Scaffold this with .scripts/setup_git_identity.py add --host <host> --name <n> --email <e>.
Enforcement: the identity-guard pre-commit hook blocks a commit whose identity is
missing or auto-generated. Optionally require a domain per repo with
git config basicly.identityAllowEmail '@example\.com$'.
Repo Conventions
Never rewrite history or run destructive git commands without explicit confirmation.
Keep diffs minimal and avoid unrelated reformatting.
Trigger Examples
Should trigger: "Review my staged diff for regressions before commit."
Should trigger: "Show what changed in this branch compared to main."
Should not trigger: "Lint this shell script for POSIX issues."
1---2name: tool-git-23description: tool-git4---5# tool-git67## When To Use89- Inspect working tree state and commit history.10- Review and stage focused diffs before commit.11- Compare branches and verify what changed.1213## Trusted Commands1415```bash16git status --short17git --no-pager diff18git --no-pager diff --staged19git --no-pager log --oneline -n 2020git --no-pager show HEAD21git add path/to/file22git restore --staged path/to/file23```2425## Safe Defaults2627- Use `--no-pager` in non-interactive contexts.28- Stage only task-relevant files.29- Check status before and after edits to avoid accidental scope creep.3031## Common Pitfalls3233- Mixing unrelated edits into one commit.34- Using destructive reset/checkout patterns without explicit approval.35- Misreading staged vs unstaged columns in short status output.3637## Output Interpretation3839- `??` indicates untracked files.40- Left/right `M` columns in short status represent index/worktree changes.4142## Why It Matters For Agents4344- Git state determines safe automation and review boundaries.45- High-signal diff workflows prevent accidental regressions.4647## Commit Identity (per remote host)4849- Commits must carry the identity that matches the remote; set it **per repo**, not50 globally. Leaving the global `user.email` unset is deliberate — with no email git51 silently commits a `…@hostname.local` address, which pollutes and de-anonymizes history.52- Before committing, verify `git config user.email` is set for this repo; if empty or a53 `.local`/`(none)` hostname value, set `git config --local user.name/user.email` first.54- Automate it with git conditional includes so identity follows the remote URL:5556 ```gitconfig57 # ~/.gitconfig (email is set only inside the includes; global email stays unset)58 [includeIf "hasconfig:remote.*.url:https://github.com/**"]59 path = ~/.gitconfig-github60 [includeIf "hasconfig:remote.*.url:https://git.example.com/**"]61 path = ~/.gitconfig-work62 ```6364 Scaffold this with `.scripts/setup_git_identity.py add --host <host> --name <n> --email <e>`.65- Enforcement: the `identity-guard` pre-commit hook blocks a commit whose identity is66 missing or auto-generated. Optionally require a domain per repo with67 `git config basicly.identityAllowEmail '@example\.com$'`.6869## Repo Conventions7071- Never rewrite history or run destructive git commands without explicit confirmation.72- Keep diffs minimal and avoid unrelated reformatting.7374## Trigger Examples7576- Should trigger: "Review my staged diff for regressions before commit."77- Should trigger: "Show what changed in this branch compared to main."78- Should not trigger: "Lint this shell script for POSIX issues."
Run npx skillmds@latest add niksavis/tool-git-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
tool-git It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
niksavis (@niksavis) published this skill. Their other Agent Skills are listed on their SkillMD profile.