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
- Generate commit messages using VS Code Source Control Panel
- Use Copilot Chat for enhanced commit message creation
- Apply Conventional Commits formatting to AI-generated messages
- Customize commit messages to match team standards
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:
- feat: New features (feat(auth): add OAuth2 login)
- fix: Bug fixes (fix(api): handle null response)
- docs: Documentation changes (docs: update API docs)
- style: Code formatting, no logic changes
- refactor: Code restructuring without new features
- perf: Performance improvements
- test: Adding/changing tests
- chore: Build system, dependencies
- ci: CI/CD changes
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:
- feat: A new feature
- fix: A bug fix
- docs: Documentation changes
- style: Code formatting, no logic changes
- refactor: Code restructuring without changing functionality
- test: Adding or updating tests
- chore: Maintenance tasks
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:
- Review and edit AI suggestions before committing
- Ensure the message accurately describes your changes
- Add context that AI might miss (ticket numbers, reasons)
- Maintain consistency with your team's commit style
❌ Don't:
- Blindly accept every AI suggestion
- Forget to include breaking change indicators
- Let AI generate messages for complex multi-part commits
- Skip manual review for critical or sensitive changes
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:
- Create a simple HTML file in your repository
- Add some CSS styling to it
- Stage the changes
- Use Copilot to generate a commit message
- Refine the message to follow Conventional Commits format
- 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:
- Mastered VS Code Source Control panel AI features
- Learned advanced Copilot Chat techniques for commit messages
- Applied Conventional Commits formatting to AI suggestions
- Developed custom prompting strategies
Next Mission: In the next chapter, you'll learn how to use Copilot for intelligent branch naming and Git alias creation.