Commandpython

/commit Command

Stage files and create conventional commit with AI-generated message

View Source

šŸŽÆ ACTION: Create Conventional Commit

Run linting and pre-commit checks, stage changes, generate a conventional commit message, and commit.

See @CONSTITUTION.md for project-specific commit conventions and pre-commit requirements.

šŸ“‹ STEPS

  1. Run linting and formatting - Execute project's lint and format commands to ensure code quality
  2. Run pre-commit checks - Execute any pre-commit hooks or validation scripts
  3. Stage all changes - Run git add -A to stage all modified, deleted, and new files
  4. Check for changes - Verify there are staged changes with git diff --cached --quiet
  5. Show what will be committed - Display git status --short and git diff --cached --stat
  6. Analyze changes - Review diff to determine commit type and scope
  7. Generate commit message - Create conventional commit message following format
  8. Present for approval - Show message and ask user to proceed, edit, or cancel
  9. Validate message - Ensure format matches type(scope): description or type: description
  10. Execute commit - Use HEREDOC format for multi-line commit
  11. Update PLAN.md - Ask if @PLAN.md should be updated to reflect these changes
  12. Suggest next step - Recommend pushing or making additional changes

šŸ’” CONTEXT

Conventional commit types:

  • feat - New features or capabilities
  • fix - Bug fixes
  • docs - Documentation only
  • refactor - Code restructuring without behavior change
  • test - Test changes
  • chore - Maintenance tasks (dependencies, tooling, config)
  • ci - CI/CD changes
  • perf - Performance improvements
  • style - Code style changes (formatting, linting)
  • build - Build system changes
  • security - Security improvements

Commit message rules:

  • Use imperative mood: "add" not "added"
  • Start with lowercase
  • No period at the end
  • Keep under 72 characters
  • Be specific and descriptive

Scope detection:

  • Extract primary directory or module being changed
  • Omit scope if changes span multiple unrelated areas
  • Keep scope short (1-2 words max)

HEREDOC commit format:

git commit -m "$(cat <<'EOF'
type(scope): description

šŸ¤– [Your signature and fun comment!]
EOF
)"

šŸ”— Follow-up Commands

  • /plan - Update the project plan
  • /learn - Extract lessons from the work
  • Push changes when ready

Related