xarchitecture
Design, analyze, and evolve system architecture using Domain-Driven Design, 12-Factor App, and proven patterns
Automate git workflow - stage, commit with smart messages, and push to specified branch
How it fires
How this command gets triggered: by you, by Claude, or both.
/xgitContext preview
What this command does when you run it.
Automate git workflow - stage, commit with smart messages, and push to specified branch
description: Automate git workflow - stage, commit with smart messages, and push to specified branch tags: [git, commit, automation, workflow, branching]
Automate the complete git workflow with intelligent commit message generation and branch management.
**Basic automated workflow:**
/xgit
**Push to specific branch:**
/xgit --branch feature-123
**Create new branch and push:**
/xgit --create-branch fix-bug
**Custom commit message:**
/xgit --message "Custom commit"
**Help and options:**
/xgit --help
If $ARGUMENTS contains "help" or "--help": Display this usage information and exit.
First, verify this is a git repository and sync with remote: !git rev-parse --git-dir 2>/dev/null || echo "Not a git repository" !git pull 2>/dev/null || echo "Pull failed or no upstream configured" !git status --porcelain
Parse arguments to determine branch operations and custom messages: Based on $ARGUMENTS, extract:
Check if there are any changes to commit: !git diff --quiet && git diff --cached --quiet && [ -z "$(git ls-files --others --exclude-standard)" ] && echo "No changes to commit" || echo "Changes detected"
If no changes are found, exit. Otherwise, stage all changes: !git add .
Handle branch operations based on arguments:
**If creating new branch (--create-branch):** !git checkout -b "${TARGET_BRANCH}" 2>/dev/null || echo "Branch creation failed" !echo "Created and switched to new branch: ${TARGET_BRANCH}"
**If switching to existing branch (--branch):** !git pull 2>/dev/null || echo "Pull failed for current branch" !git checkout "${TARGET_BRANCH}" 2>/dev/null || echo "Branch switch failed - branch may not exist" !git pull 2>/dev/null || echo "Pull failed for target branch" !echo "Switched to branch: ${TARGET_BRANCH}"
**Current branch status:** !git branch --show-current
Analyze the staged changes to generate an intelligent commit message: !git diff --cached --stat !git diff --cached --name-only | head -10
**If custom message provided (--message):** Use the provided custom commit message directly.
**Otherwise, generate intelligent commit message:** Think step by step about the changes to determine the appropriate commit type:
Generate commit message following Conventional Commits format:
Execute the commit with generated or custom message: !git commit -m "Generated commit message based on changes" -m "📋 Change summary:
Co-Authored-By: Claude <noreply@anthropic.com>"
Check remote configuration and current branch: !git remote -v | grep origin || echo "No origin remote configured" !git branch --show-current
**Determine target branch for push:**
**Push to remote with upstream tracking:**
**If force push requested (--force):** !git push --force-with-lease origin ${TARGET_BRANCH} 2>/dev/null || echo "Force push failed - check remote configuration and conflicts"
**Standard push operation:** !git push --follow-tags --set-upstream origin ${TARGET_BRANCH} 2>/dev/null || git push --follow-tags 2>/dev/null || echo "Push failed - check remote configuration"
**If new branch creation:** !echo "New branch '${TARGET_BRANCH}' has been created and pushed to remote"
**Report results:** !git log -1 --oneline !echo "✅ Successfully staged, committed, and pushed changes to branch: $(git branch --show-current)"
If any step fails, provide clear error messages with troubleshooting guidance:
**Branch Issues:**
**Push Issues:**
**Validation:**
Transform Claude Code into a complete development platform with 45 AI-powered commands that automate your entire software development workflow. Now with improved git identity management!
Design, analyze, and evolve system architecture using Domain-Driven Design, 12-Factor App, and proven patterns
Manage project configuration files, environment variables, and application settings
Continue an execution plan from where it left off across sessions
Interactive debugging support with error analysis and fix suggestions - integrates with Debug Specialist sub-agent for complex…