---
description: Smart commit command with automatic validation and conventional commits
---

# Smart Commit Command

You are an AI agent that helps create well-formatted git commits. This command handles the complete commit workflow including validation, testing, and pushing changes.

## Instructions for Agent

When the user runs this command, execute the following workflow:

### 1. **Smart Repo Analysis (Automatic)**

**Before doing anything, analyze the repo state:**

```bash
# Check current branch and status
git status
git branch --show-current

# Check recent commits for style
git log --oneline -5
```

### 2. **Analyze Changes**
- Run `git status` to see all untracked files
- Run `git diff` to see both staged and unstaged changes
- Run `git log --oneline -5` to see recent commit style
- Identify the scope of changes

### 3. **Stage Files Intelligently**
**Auto-stage based on change type:**
- If modifying agents → stage `agents/`
- If modifying skills → stage `skills/`
- If modifying commands → stage `commands/`
- If modifying context → stage `context/`
- If modifying hooks → stage `hooks/`
- If modifying docs → stage `docs/`
- If modifying CI/CD → stage `.github/workflows/`
- If user provides specific files → stage only those

**Never auto-stage:**
- `node_modules/`
- `.env` files
- Temporary directories

### 4. **Generate Commit Message**

**Follow Conventional Commits (NO EMOJIS):**
```
<type>(<scope>): <description>

[optional body]
```

**Types:**
- `feat` - New features
- `fix` - Bug fixes
- `refactor` - Code restructuring
- `test` - Test additions
- `docs` - Documentation updates
- `chore` - Maintenance tasks
- `ci` - CI/CD changes
- `perf` - Performance improvements

**Scopes:**
- `agents` - Agent changes
- `skills` - Skill changes
- `commands` - Command changes
- `context` - Context file changes
- `hooks` - Hook changes
- `mcp` - MCP server changes
- `docs` - Documentation changes

**Examples:**
```
feat(agents): add new code-generator agent
fix(skills): correct brainstorming skill logic
refactor(commands): split commit command into modules
docs(readme): update installation instructions
chore(deps): upgrade dependencies
```

### 5. **Execute Commit**
```bash
git add <relevant-files>
git commit -m "<type>(<scope>): <description>"
git status  # Verify commit succeeded
```

### 6. **Post-Commit Actions**

**Ask user:**
```
✅ Commit created: <commit-hash>
📝 Message: <commit-message>

Would you like to:
1. Push to remote (git push origin <branch>)
2. Create another commit
3. Done
```

## Error Handling

### If No Changes Detected
```
ℹ️ No changes to commit. Working tree is clean.

Recent commits:
<git log --oneline -3>
```

### If Merge Conflicts
```
⚠️ Merge conflicts detected. Please resolve conflicts first.

Conflicted files:
<list-files>
```

## Success Criteria

A successful commit should:
- ✅ Follow conventional commit format (NO EMOJIS)
- ✅ Have appropriate scope
- ✅ Be atomic (single purpose)
- ✅ Have clear, concise message
- ✅ Not include sensitive information
- ✅ Not include generated files
