---
description: Generate and validate commit messages
---

# Commit: Simple and Task-Based

## For Simple Commits (No Task)

Just commit directly:

```bash
git commit -m "fix: clear description of change"
git push
```

**Message format:**

- `fix:` for bug fixes
- `feat:` for new features
- `refactor:` for code restructuring
- `docs:` for documentation
- `chore:` for maintenance

---

## For Task-Based Commits (With Review.md)

## MANDATORY GATE 1: Find Active Task

Search Backlog MCP for In Progress tasks:

```typescript
backlog_task_list({ status: "In Progress" });
```

Then check each task for completed review.md file in `@backlog/tasks/[id]/review.md` with "What Changed:" section.

If no active task found: stop and ask which task to commit for.

## MANDATORY GATE 2: Validate Task Completion

Before committing, verify the active task has:

**@backlog/tasks/[TASK_ID]/prd.md:**

- [ ] Goal section filled
- [ ] Success Criteria section has checkboxes
- [ ] At least one success criterion marked [x]

**@backlog/tasks/[TASK_ID]/review.md:**

- [ ] "What Changed" section completely filled (not template)
- [ ] "What Skipped" section completely filled (not template)
- [ ] "Inconsistencies" section completely filled (not template)
- [ ] "Validation" section completely filled (not template)

**If ANY validation fails:** STOP. Ask user to run `/complete-task [TASK_ID]` first.

## Step 3: Analyze Git Changes

Compare git changes to task review:

**Check:**

- Does `git diff` show exactly what review.md says in "What Changed"?
- Are there any unexpected files modified?
- Are there uncommitted changes not documented in review.md?

**If mismatch detected:** STOP. Ask user to update review.md to match actual changes.

## Step 4: Generate Commit Message

Create commit message in format:

```
[AI] task-[TASK_ID] <type>: <description>

Type determination from PRD goal:
- feat: if PRD says "Add" or "Implement"
- fix: if PRD says "Fix" or "Resolve"
- refactor: if PRD says "Restructure" or "Reorganize"
- docs: if PRD says "Document" or "Update docs"
- test: if PRD says "Test" or "Add tests"

Description from PRD goal + what changed summary
```

## Step 5: Create Commit

Execute commit only if:

- Task has completed review.md
- Success criteria are marked [x]
- Changes match review documentation
- No unexpected modifications

**Commit with message linking task ID**

## Step 6: Verify Success

Display:

```
✅ COMMIT CREATED

Task: [TASK_ID]
Commit: [git hash]
Changes: [Files modified count]
Review: @backlog/tasks/[TASK_ID]/review.md

To complete task: /complete-task [TASK_ID]
```

---

**ANTI-HALLUCINATION: Simple commits proceed directly; task commits validate review.md**
