| name | local-git-specialist |
| description | Applies safe local-only git hygiene for status inspection, diff review, commit crafting, and non-destructive history usage. Trigger on "git commit", "git status", "branch management", "commit message", "diff review". Do NOT use for release-engineering (tagging/publishing), isolation-guidance (worktree strategy), or deployment-pipeline (CI/CD). |
| license | Apache-2.0 |
| compatibility | {"clients":["openai-codex","gemini-cli","opencode","github-copilot"]} |
| metadata | {"owner":"codex","domain":"local-git-specialist","maturity":"draft","risk":"low","tags":["local","git","specialist"]} |
Purpose
Provides safe, precise local git operations for AI agents: what's safe to do autonomously, what requires confirmation, common traps to avoid. Emphasizes non-destructive operations and clear commit hygiene for agent-generated changes.
Key constraint: This skill covers local git read/write only. Do not assume GitHub APIs, PR automation, or remote pushes are available. Keep commit scope aligned to the ticket being worked on.
When to use this skill
Use when:
- Making commits as part of implementation work
- Checking repository state before/after changes
- Working with branches for ticket-based development
- Reviewing history or diffs
Do NOT use when:
- Pushing to remote (different risk profile)
- Complex merge/rebase operations (require human oversight)
- Repository administration (permissions, hooks, etc.)
Operating procedure
1. Safe operations (autonomous OK)
Status inspection
git status --short
git status
git diff --stat
git diff
git diff --cached
git log --oneline -10
git log --oneline --all -10
git branch -v
Reading history
git show <commit>
git log --oneline --follow -- <file>
git blame <file>
git log --oneline -p -- <file>
Diffing
git diff <branch1>..<branch2>
git diff HEAD~3
git diff --name-only <ref>
2. Safe write operations (autonomous OK)
Staging changes
git add <file>
git add -p
git reset HEAD <file>
Committing
git commit -m "tkt-XXX: description"
git commit --amend -m "new message"
Commit message format:
tkt-XXX: Brief description (50 chars max)
- Detail 1
- Detail 2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Branch operations
git checkout -b tkt-XXX-description
git checkout main
git branch -d <branch>
3. Requires confirmation
Destructive operations (NEVER autonomous)
git reset --hard
git clean -fd
git push --force
git branch -D <branch>
git rebase
Merge operations (confirm first)
git merge <branch>
git pull
4. Common traps to avoid
Trap: Editing on wrong branch
Prevention:
git branch --show-current
Trap: Committing sensitive data
Prevention:
git diff --cached --name-only
Trap: Large binary files
Prevention:
find . -type f -size +1M -not -path "./.git/*"
Trap: Merge commits when not intended
Prevention:
git pull --rebase origin main
git fetch && git merge --no-ff origin/main
Trap: Lost work from stash
Prevention:
git stash list
5. Agent commit hygiene
Commit frequency
- Commit after each logical change, not at end of session
- Each commit should pass tests (if applicable)
- Prefer many small commits over few large ones
Commit message rules
git commit -m "tkt-042: Add user authentication endpoint
- Implement /api/auth/login route
- Add JWT token generation
- Include rate limiting middleware"
git commit -m "updates"
git commit -m "fixed stuff"
Before committing checklist
git branch --show-current
git diff --cached --stat
git diff --cached --name-only | grep -E '\.(env|key|pem)$'
npm test
6. Recovery operations
Undo last commit (keep changes)
git reset --soft HEAD~1
git reset HEAD~1
Recover deleted file
git checkout HEAD -- <file>
git checkout <commit> -- <file>
Find lost commits
git reflog
git checkout <reflog-sha>
Output defaults
For any git operation, report:
- What was done
- Current state after operation
- Any warnings or concerns
Example:
Committed: tkt-042: Add auth endpoint
Branch: tkt-042-authentication
Status: Clean working tree, 1 commit ahead of main
References
Failure handling
- Merge conflict: Do not auto-resolve. Report conflict files, request guidance
- Detached HEAD: Warning! Create branch to save work:
git checkout -b recovery-branch
- Uncommitted changes blocking checkout: Either commit, stash (with confirmation), or abort
- Push rejected: Never force push. Fetch, resolve locally, push normally