| name | git |
| description | Safe Git workflow - commit with conventional format and branch safety, create branches, reset with backup, and multi-repo status. Use when committing, creating branches, resetting, or checking git status in multi-repo workspaces. |
/commit - Smart Git Commit
Overview
You are a git commit specialist that creates conventional commits with automatic type detection and safety checks.
Steps
-
Branch Safety Check:
- Check if currently on main/master branch
- If yes and using
/commit (without --main flag), automatically create a feature branch based on the changes detected
- If using
/commit --main, allow direct commit to main/master branch (emergency fixes only)
-
Analyze Changes:
- Run
git status and git diff --cached (or git diff for all changes if --all flag is used)
- Detect conventional commit type from changes:
feat: New features, components, functionality
fix: Bug fixes, error corrections
chore: Dependencies, build, config, tooling
docs: Documentation changes
style: Code formatting, style changes
refactor: Code restructuring without behavior change
test: Adding or updating tests
- Check for Linear issue references in commit message or staged changes
-
Generate Commit Message:
- Format:
<type>(<scope>): <description>
- Scope should be component/area affected (optional)
- Description should be concise and clear
- Use present tense, imperative mood
- Include Linear issue references (e.g.,
ENG-123, PROJ-456) in description for auto-linking
-
Execute Commit:
- Use heredoc format for multi-line commit messages
- Commit only staged changes (unless
--all flag is used)
- If
--all flag is used, stage and commit all changes (unstaged + staged)
- Confirm successful commit with git log
-
Validation:
- Ensure commit follows conventional format
- Verify only intended changes were committed
Auto Branch Creation
When on main/master branch and using /commit (without --main flag):
- Analyze Changes: Detect commit type from staged/unstaged changes
- Generate Branch Name:
- For features:
feature/<type>-<short-description>
- For fixes:
fix/<short-description>
- For chores:
chore/<short-description>
- For docs:
docs/<short-description>
- Create Branch:
git checkout -b <generated-branch-name>
- Proceed with Commit: Continue with normal commit process
Example Branch Names:
feature/feat-user-auth (for new authentication feature)
fix/login-bug (for login bug fix)
chore/update-deps (for dependency updates)
Safety Checks
- ❌ Never commit to main/master without explicit approval (unless using
--main flag)
- ❌ Never commit unstaged changes without being asked (unless using
--all flag is used)
- ❌ Never push automatically
- ✅ Always validate conventional commit format
- ✅ Always show what will be committed before executing
- ✅ Include Linear issue references for GitHub auto-linking
- ✅ Automatically create feature branch when on main/master
- ⚠️
--main flag bypasses main/master protection - use only for emergency fixes
Examples
With staged changes to authentication system:
git commit -m "$(cat <<'EOF'
feat(auth): add JWT token validation middleware
- Implement token verification for protected routes
- Add error handling for expired tokens
- Update authentication flow documentation
Closes ENG-123
EOF
)"
With all changes (including unstaged):
/commit --all
Emergency fix directly to main branch:
/commit --main
Emergency fix with all changes to main branch:
/commit --main --all
Auto branch creation when on main/master:
/commit
/commit --all
Linear Integration:
- Include Linear issue IDs (e.g.,
ENG-123, PROJ-456) in commit messages
- Use magic words like "Closes", "Fixes", "Resolves" followed by issue ID
- Linear will auto-link commits to issues when GitHub integration is enabled
- Reference: https://linear.app/docs/github#enable-autolink
Arguments
Arguments: $ARGUMENTS (optional: additional commit message details)
- Use
/commit for staged changes only (default behavior)
- Use
/commit --all to stage and commit all changes (unstaged + staged)
- Use
/commit --main to commit directly to main/master branch (emergency fixes only)
- Use
/commit --main --all to stage and commit all changes directly to main/master branch (emergency fixes only)
/git-branch
Description
Safe branch creation following project conventions and best practices.
Workflow
- Create feature branches from main/master unless specified otherwise
- Use descriptive branch names following project conventions
- Ensure branch is created from correct base branch
- Switch to new branch after creation
- Provide feedback on branch naming and setup
Naming Conventions
feature/description - New features
fix/description - Bug fixes
chore/description - Maintenance tasks
hotfix/description - Critical fixes
docs/description - Documentation updates
refactor/description - Code refactoring
test/description - Test improvements
Examples
/git-branch feature/user-authentication
/git-branch fix/login-bug
/git-branch chore/update-dependencies
Safety Features
- Prevents creation of branches with invalid names
- Validates base branch exists
- Checks for existing branch conflicts
- Provides naming suggestions if invalid
Integration
- Works with Linear issue references
- Integrates with PR creation workflow
- Supports multi-repository workspaces
/git-reset
Description
Safe reset with automatic backup and recovery options.
Workflow
- Create backup/stash before any destructive operations
- Use git status and git log to understand current state
- Offer different reset options (soft, mixed, hard) with explanations
- Always confirm before executing destructive operations
- Provide recovery instructions if something goes wrong
Reset Types
- Soft: Keep changes in staging area
- Mixed: Keep changes in working directory (default)
- Hard: Discard all changes (destructive)
Safety Measures
- Always stash uncommitted changes first
- Never run without understanding current state
- Require explicit user approval for --hard reset
- Create automatic backups before destructive operations
- Provide recovery instructions
Examples
/git-reset --soft HEAD~1
/git-reset HEAD~1
/git-reset --hard HEAD~1
/git-reset --soft abc1234
Backup Strategy
- Create stash before destructive operations
- Save current state information
- Provide rollback instructions
- Document what will be lost
Recovery Options
- Restore from stash
- Recover from backup
- Use git reflog for commit recovery
- Provide step-by-step recovery guide
Integration
- Works with multi-repository workspaces
- Integrates with branch protection
- Supports Linear issue references
- Compatible with PR workflow
/git-status
Description
Multi-repository aware status check with comprehensive workspace analysis.
Workflow
- Check current working directory and understand repository boundaries
- Never assume single git repository in multi-repo workspace
- Identify which specific repository changes belong to
- Show status for current repo and detect other repos in workspace
- Provide clear indication of which repo each change belongs to
Multi-Repository Handling
- When working with staged changes, identify which specific repository they belong to
- Provide clear indication of repository boundaries
- Show status for each repository found in workspace
- Highlight any cross-repository dependencies or conflicts
Error Prevention
- Always ask for clarification when workspace structure is unclear
- Confirm target repository before running git commands
- Use non-destructive git commands first (git stash, git log) to understand situation
Output Format
Repository: /path/to/repo1
Branch: main
Status: clean
Staged: 2 files
Modified: 1 file
Untracked: 3 files
Repository: /path/to/repo2
Branch: feature/new-feature
Status: dirty
Staged: 0 files
Modified: 2 files
Untracked: 0 files
Examples
/git-status
/git-status /path/to/specific/repo
/git-status --all
Safety Features
- Non-destructive operations only
- Clear repository identification
- Conflict detection and reporting
- Workspace boundary awareness