Skip to content

Instantly share code, notes, and snippets.

@Zxce3
Created September 14, 2025 15:17
Show Gist options
  • Select an option

  • Save Zxce3/2f6d9ff6d1b183d9ccd3f6f774c4fa3c to your computer and use it in GitHub Desktop.

Select an option

Save Zxce3/2f6d9ff6d1b183d9ccd3f6f774c4fa3c to your computer and use it in GitHub Desktop.

Commit changes with structured messages

Generate structured commit messages following project conventions.

This prompt helps create consistent, well-formatted commit messages that align with the project's established patterns.

Given the current changes in the working directory, do this:

  1. Check the current git status to identify modified files:

    • Use git status to see what files have been changed
    • Use git diff --cached if files are already staged
    • Use git diff to see unstaged changes
  2. Analyze recent commit history for message structure:

    • Run git log --format="%h %s%n%b" -5 to see recent commit patterns
    • Identify the established conventions (prefixes, format, style)
  3. Generate a structured commit message that includes:

    • Type prefix: Use appropriate prefix (feat:, fix:, docs:, test:, refactor:, style:, chore:)
    • Brief summary: Concise description of the main change (50 chars max)
    • Detailed body: Bullet-pointed list explaining specific changes
    • Impact description: What problems are solved or features added
    • Test status: Mention if tests are passing/fixed
  4. Stage and commit the changes:

    • Use git add for relevant files
    • Use git commit -s -m "message" with the -s flag for signed-off-by
    • Ensure the message follows the project's established format

Commit Type Guidelines

  • feat: New features or significant enhancements
  • fix: Bug fixes and issue resolutions
  • docs: Documentation updates
  • test: Test additions or modifications
  • refactor: Code restructuring without functional changes
  • style: Code formatting, whitespace, etc.
  • chore: Build processes, dependencies, maintenance

Message Structure Template

type: brief summary of changes

- Specific change 1 with technical details
- Specific change 2 explaining what was modified
- Impact or problem solved by these changes
- Test results or validation performed

Examples

# Feature addition
git commit -s -m "feat: implement user authentication system

- Add JWT token-based authentication middleware
- Create login/logout API endpoints with validation
- Implement password hashing with bcrypt
- Add user registration with email verification
- All authentication tests passing successfully"

# Bug fix
git commit -s -m "fix: resolve database connection timeout issues

- Increase connection pool size from 10 to 25
- Add connection retry logic with exponential backoff
- Fix memory leak in database query caching
- Update configuration for production environment
- Database stress tests now passing without timeouts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment