← Back to Mission Control

Commit Message Launch Sequence

AI-Powered Message Generation

Mission Phase 37 • Difficulty: Intermediate

Mission Briefing

Every spacecraft operation requires precise documentation in the mission log. In the same way, every code change needs a clear, descriptive commit message that tells the story of what changed and why.

Poor commit messages are like incomplete mission logs—they leave future astronauts (including yourself) guessing about what happened during critical operations. But crafting good commit messages consistently can be time-consuming and mentally taxing.

This is where your AI co-pilot shines! GitHub Copilot can analyze your staged changes and generate meaningful, professional commit messages that follow best practices and conventions.

Mission Objectives

Step 1: VS Code Source Control Magic

Let's start with the most straightforward approach using the built-in VS Code feature:

1. Make some changes to your code
2. Stage the changes (git add)
3. Open Source Control panel (Ctrl+Shift+G)
4. Look for the ✨ sparkle icon next to the commit message box
5. Select the sparkle icon to generate a commit message
6. Review and edit the suggestion if needed
7. Commit your changes

Step 2: Configure VS Code for Automatic Generation

Set up VS Code to automatically generate conventional commit messages using GitHub Copilot Chat:

// Open VS Code Settings (Ctrl+Shift+P → "Preferences: Open Settings (JSON)")
// Add this configuration to your settings.json:

{
  "github.copilot.chat.commitMessageGeneration.instructions": [
    { "text": "Use conventional commit format: type(scope): description" },
    { "text": "Use imperative mood: 'Add feature' not 'Added feature'" },
    { "text": "Keep subject line under 50 characters" },
    { "text": "Use types: feat, fix, docs, style, refactor, perf, test, chore, ci" },
    { "text": "Include scope when relevant (e.g., api, ui, auth)" },
    { "text": "Reference issue numbers with # prefix" }
  ]
}

How to Use Automatic Generation:

1. Stage your changes in Source Control (Ctrl+Shift+G)
2. Type "/generate commit" in the commit message field
3. Copilot generates a message based on your configured rules
4. Review the message, adjust if needed, commit

Understanding Commit Types:

Step 3: Enhanced Chat-Based Generation

For more detailed or customized commit messages, use Copilot Chat:

// Open Copilot Chat (Ctrl+Shift+I) and try these prompts:

"Summarize these changes for a commit message"

"Create a commit message following Conventional Commits format"

"Generate a detailed commit message that explains the WHY behind these changes"

"Create a commit message for a feature that improves user authentication"

Step 4: Conventional Commits Integration

Let's ensure our AI-generated messages follow the Conventional Commits specification:

Format Structure

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Common Types:

Step 5: Custom Prompt Engineering

Train Copilot to generate messages that match your team's style:

// Context-aware prompts:
"Generate a commit message in the style of: 
- Start with conventional commit type
- Maximum 50 characters for the subject
- Include ticket number format JIRA-123
- Focus on user impact rather than technical details"

// For specific scenarios:
"Create a commit message for a breaking change that updates the API"

"Generate a commit message for a hotfix that resolves a critical security issue"

Practical Examples

Scenario 1: Feature Addition

Without Copilot:

updated login stuff

With Copilot:

feat(auth): add OAuth integration for GitHub login

Implements secure authentication flow using GitHub OAuth2.
Users can now sign in with their GitHub accounts instead of
creating new credentials.

Closes #AUTH-142

Scenario 2: Bug Fix

Manual Approach:

fix bug

Copilot Enhancement:

fix(validation): resolve email format validation error

Corrects regex pattern that was rejecting valid email addresses
containing plus signs. Updates test cases to cover edge cases.

Fixes #BUG-089

Mission Control Best Practices

✅ Do:

❌ Don't:

Team-Wide Configuration

Share consistent commit message generation across your entire team by adding the configuration to your repository:

// Create or update .vscode/settings.json in your repo root:
{
  "github.copilot.chat.commitMessageGeneration.instructions": [
    { "text": "Use conventional commit format: type(scope): description" },
    { "text": "Use imperative mood: 'Add feature' not 'Added feature'" },
    { "text": "Keep subject line under 50 characters" },
    { "text": "Use types: feat, fix, docs, style, refactor, perf, test, chore, ci" },
    { "text": "Include scope when relevant (e.g., api, ui, auth)" },
    { "text": "Reference issue numbers with # prefix" },
    { "text": "Use scopes: frontend, backend, database, config" },
    { "text": "Append ticket numbers like PROJ-123" }
  ]
}

// Commit this file so everyone gets consistent messages!

Project-Specific Customization:

// Example: E-commerce project settings
{
  "github.copilot.chat.commitMessageGeneration.instructions": [
    { "text": "Use conventional commit format: type(scope): description" },
    { "text": "Scopes: cart, checkout, payment, product, user, admin, api" },
    { "text": "Include Jira ticket: SHOP-123" },
    { "text": "Mark breaking changes with BREAKING CHANGE footer" },
    { "text": "Keep description under 50 characters" }
  ]
}

Mission Challenge

Your Task:

  1. Create a simple HTML file in your repository
  2. Add some CSS styling to it
  3. Stage the changes
  4. Use Copilot to generate a commit message
  5. Refine the message to follow Conventional Commits format
  6. Commit with your enhanced message

Bonus: Try generating messages for different types of changes (feat, fix, docs, style) and compare the AI suggestions.

Mission Summary

Excellent work, astronaut! You've learned to harness your AI co-pilot for one of the most important but often overlooked aspects of development: clear communication through commit messages.

Key Achievements:

Next Mission: In the next chapter, you'll learn how to use Copilot for intelligent branch naming and Git alias creation.