Git Workflow
Safe, reviewable Git practice for AI agents and teams — branching, atomic commits, Conventional Commit messages, rebase versus merge, pull requests, recovery with reflog and revert, and destructive-command guardrails.
What it does
Safe, reviewable Git practice for AI agents and teams — branching, atomic commits, Conventional Commit messages, rebase versus merge, pull requests, recovery with reflog and revert, and destructive-command guardrails.
- Category
- coregitworkflow
- Platforms
- generic
- Frameworks and tools
- git
- Capabilities
- workflowreview
Example tasks
- “Split my working tree changes into clean atomic commits with good messages.”
- “Update my feature branch onto main and resolve conflicts safely.”
- “Undo a bad merge that already reached the shared branch.”
Works with
Permissions summary
Files
Reads files only
Shell
No shell commands
Network
No network
Permissions are declared in the component manifest and compiled into each client's tool list. Components are built for least privilege.
Supported environments
| Client | Support | Installed as |
|---|---|---|
| Claude Code | Native | .claude/skills/<id>/SKILL.md |
| OpenAI Codex | Adapter | .codex/skills/<id>/SKILL.md |
| Cursor | Adapter | .cursor/rules/<id>.mdc |
| VS Code (Copilot) | Adapter | .github/instructions/<id>.instructions.md |
| Generic markdown | Adapter | docs/forgekit/skills/<id>.md |
Claude Code is the native reference. Other clients use adapters, so behaviour is close but not identical. See the compatibility matrix.
Included in packs
Full skill (free preview)
This is a free component, so its complete content is public. It is exactly what gets installed (before client-specific formatting).
Git Workflow
Rules for making history that is reviewable, bisectable and recoverable. Follow the repository's documented flow (CONTRIBUTING.md, AGENTS.md) when it differs. Commit, push or open PRs only when the user asked you to.
1. Before you change anything
git statusandgit branch --show-current: know your branch and whether the tree is clean. Never start work on the default branch; create a branch.git log --oneline -10to learn the commit message style in use; match it.- Do not mix your changes with the user's uncommitted work. If the tree is dirty with unrelated changes, ask or stash them with a clear message.
2. Branching
- Short-lived branches from an up-to-date default branch:
git switch -c feat/invite-flow origin/main(aftergit fetch). - Names:
type/short-kebab-description, optionally with an issue id (fix/1234-null-avatar). Types match commit types. - One purpose per branch. Long-running branches rot; integrate at least daily or use feature flags.
3. Commits
- Atomic: one logical change that builds and passes tests. Separate refactors, formatting, dependency bumps and behavior changes.
- Stage deliberately:
git add -por explicit paths. Avoidgit add -Awhen untracked files might include secrets, build output or editor files; checkgit diff --stagedbefore committing. - Message format (Conventional Commits, if the repo uses it):
Types:
type(scope): imperative summary, <= 72 chars Why the change was needed and what behavior differs. Wrap at ~72. Refs: #123 BREAKING CHANGE: description (when applicable)feat,fix,docs,refactor,perf,test,build,ci,chore,revert. - Never commit secrets,
.envfiles, credentials or large generated artifacts. If one slipped in, rotate the secret; rewriting history alone is not enough. - Fix up earlier commits in your own unpublished branch with
git commit --fixup <sha>thengit rebase -i --autosquash origin/main.
4. Rebase versus merge
| Situation | Use |
|---|---|
| Updating your private feature branch with main | git rebase origin/main (linear history) |
| Branch already pushed and shared with others | git merge origin/main, or coordinate before rewriting |
| Landing a PR | Follow repo policy: squash, rebase-merge or merge commit |
| Integrating a long-lived release branch | Merge commit; preserve the history |
Rules: never rewrite commits others have based work on. After rebasing your own pushed branch use git push --force-with-lease, never plain --force. Resolve conflicts by understanding both sides, then re-run tests; do not take "ours/theirs" wholesale without reading.
5. Pull requests
- Small, focused, with a description covering what, why, how it was verified (commands and results), risks and rollback.
- Link the issue. Keep unrelated cleanups out. Mark drafts as draft.
- Address review feedback with new commits or fixups, and re-run the checks before requesting another round.
6. Recovery
| Problem | Command |
|---|---|
| Undo last commit, keep changes | git reset --soft HEAD~1 |
| Discard unstaged changes in one file | git restore <path> (destructive, confirm first) |
| Unstage | git restore --staged <path> |
| Undo a pushed commit safely | git revert <sha> (merge commit: git revert -m 1 <merge-sha>) |
| Find lost commits after a bad reset/rebase | git reflog, then git switch -c rescue <sha> |
| Find the commit that broke something | git bisect start, git bisect bad, git bisect good <sha>, optionally git bisect run <test-command> |
| Abort a conflicted operation | git rebase --abort / git merge --abort |
7. Guardrails
- Ask before:
git reset --hard,git clean -fd,git checkout -- .,git push --force,git branch -D, rewriting published history, or deleting remote branches. - Do not bypass hooks with
--no-verifyunless the user explicitly says so; fix the hook failure instead. - Do not change global git config; use repo-local config only when needed.
- Never push to the default branch directly if branch protection or team policy exists.
Common mistakes
- Giant "wip" commits that mix formatting, refactor and feature.
- Force-pushing over a teammate's commits.
- Resolving conflicts by deleting one side, then losing a bug fix.
- Committing lockfile changes unrelated to the task.
- Amending a commit that is already pushed and shared.
Version and changelog
Latest version 1.0.0. Requires DevBuildKit CLI 1.0.0 or newer.
Changelog — Git Workflow
1.0.0
- Initial release.