Skip to content

feat: Add /commit command for AI-assisted git commits #106

@CarGDev

Description

@CarGDev

Summary

Add a /commit command that analyzes staged changes and generates meaningful commit messages.

Why It's Needed

  • Git Workflow: Streamline the commit process
  • Better Messages: AI generates descriptive commit messages
  • Consistency: Follow commit conventions automatically
  • Competitor Parity: Claude Code has this feature

Usage

# In TUI
/commit                    # Auto-generate message from staged changes
/commit "hint about change" # Use hint to guide message generation

# CLI
codetyper commit           # Same as /commit
codetyper commit --amend   # Amend last commit

Workflow

1. Check for staged changes (git diff --cached)
   └─ If none, offer to stage modified files
   
2. Analyze diff content
   └─ Identify type of change (feat, fix, refactor, docs, etc.)
   
3. Generate commit message
   └─ Follow conventional commits or repo's convention
   └─ Include scope if identifiable
   └─ Keep under 72 chars for subject
   
4. Show preview
   └─ Display generated message
   └─ Show files being committed
   
5. Confirm and execute
   └─ User can edit message
   └─ Execute: git commit -m "message"
   
6. Show result
   └─ Display commit hash
   └─ Show success message

Commit Message Format

<type>(<scope>): <subject>

<body>

<footer>

Types: feat, fix, docs, style, refactor, test, chore

Example Output

📝 Analyzing staged changes...

Files to commit:
  M src/services/auth.ts
  M src/utils/validation.ts
  A src/tests/auth.test.ts

Generated commit message:
──────────────────────────────
feat(auth): add JWT token refresh mechanism

- Add automatic token refresh before expiry
- Add validation for refresh tokens
- Add unit tests for auth service
──────────────────────────────

[c]ommit  [e]dit  [a]bort

Acceptance Criteria

  • /commit command in TUI
  • codetyper commit CLI command
  • Auto-detect conventional commits style
  • Generate meaningful commit messages
  • Preview before committing
  • Allow message editing
  • Support --amend flag
  • Handle no staged changes gracefully

Effort Estimate

2 days

Future Enhancements

  • /pr command for pull request creation
  • Auto-generate PR descriptions
  • Link to issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority-criticalCritical priority - implement first

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions