Project 9: Hello World Skill - Git Commit Assistant
Project 9: Hello World Skill - Git Commit Assistant
Build your first Claude Code skill that Claude auto-discovers and invokes when you mention commits.
Quick Reference
| Attribute | Value |
|---|---|
| Difficulty | Beginner |
| Time Estimate | 2-4 hours |
| Language | Markdown (SKILL.md) |
| Prerequisites | Basic git knowledge, understanding of Claude Code |
| Key Topics | Skills, skill discovery, prompt engineering, YAML frontmatter |
| Knowledge Area | Skills / Git / Developer Workflow |
| Main Book | โPro Gitโ by Scott Chacon |
1. Learning Objectives
By completing this project, you will:
- Understand the SKILL.md format: Master the YAML frontmatter and markdown body structure that defines a skill
- Grasp skill discovery mechanics: Learn how Claude matches skill descriptions to user intent
- Write effective skill descriptions: Create descriptions that trigger appropriately without over-matching
- Implement single-purpose design: Scope a skill to do one thing well
- Test skill activation: Verify that Claude discovers and invokes your skill correctly
- Apply prompt engineering: Write clear instructions that guide Claudeโs behavior
2. Theoretical Foundation
2.1 What Are Claude Code Skills?
Skills are the building blocks of Claude Code automation. They are declarative markdown files that define reusable capabilities Claude can invoke. Unlike slash commands (explicit user invocation), skills are implicitly discovered when Claude detects a matching description in the userโs request.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SKILL vs SLASH COMMAND โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ SKILL (Implicit Discovery) SLASH COMMAND (Explicit Invocation)โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ User: "I want to commit my changes" User: "/commit" โ
โ โ โ โ
โ โผ โผ โ
โ Claude: "Hmm, this matches the Claude: "User explicitly called โ
โ git-commit skill description" the commit command" โ
โ โ โ โ
โ โผ โผ โ
โ [Invokes skill automatically] [Invokes command directly] โ
โ โ
โ Key: Natural language triggers Key: Explicit command triggers โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2.2 The SKILL.md File Format
Every skill is defined in a SKILL.md file with two parts:
---
# YAML Frontmatter - Metadata
name: skill-name
description: What this skill does and when to use it
allowed-tools: # Optional: restrict available tools
- Bash
- Read
---
# Markdown Body - Instructions
When the user wants to [do something], follow these steps...
YAML Frontmatter Fields:
| Field | Required | Purpose |
|---|---|---|
name |
Yes | Unique identifier for the skill |
description |
Yes | Critical: This is what Claude matches against user intent |
allowed-tools |
No | Restrict which tools Claude can use (security/focus) |
2.3 Skill Discovery: How Claude Finds Skills
Claudeโs skill discovery works through semantic matching:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SKILL DISCOVERY FLOW โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ User Message: "I'm ready to commit my changes" โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Claude analyzes the message โ โ
โ โ looking for intent signals โ โ
โ โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Compare against all skill descriptionsโ โ
โ โ โ โ
โ โ git-commit: "Help create well- โ โโโโ MATCH! (commit, โ
โ โ formatted git commit messages..." โ changes, git) โ
โ โ โ โ
โ โ web-testing: "Automate web browser โ โโโโ No match โ
โ โ testing including login flows..." โ โ
โ โ โ โ
โ โ doc-generator: "Generate documentationโ โโโโ No match โ
โ โ for code modules..." โ โ
โ โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Best match: git-commit skill โ โ
โ โ โ Load and follow its instructions โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key insight: The description field is the most important part of your skill. It determines when Claude will choose to use it.
2.4 Skill Locations
Skills can be stored in two locations:
| Location | Scope | Path |
|---|---|---|
| User-level | Available in all projects | ~/.claude/skills/skill-name/SKILL.md |
| Project-level | Available in specific project | .claude/skills/skill-name/SKILL.md |
Project-level skills take precedence over user-level skills with the same name.
2.5 Progressive Disclosure
Skills support progressive disclosureโloading additional files only when needed:
skill-name/
โโโ SKILL.md # Always loaded when skill is invoked
โโโ REFERENCES.md # Loaded on-demand when referenced
โโโ templates/ # Loaded on-demand
โ โโโ format.md
โโโ scripts/ # Executed when called
โโโ helper.py
This keeps context small while maintaining access to rich resources.
2.6 Conventional Commits
This project teaches you to implement the Conventional Commits specification:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types:
| Type | When to Use |
|โโ|โโโโ-|
| feat | New feature for the user |
| fix | Bug fix for the user |
| docs | Documentation only changes |
| style | Formatting, no code change |
| refactor | Refactoring production code |
| test | Adding or refactoring tests |
| chore | Updating build tasks, configs, etc. |
Examples:
feat(auth): add login with OAuth2 support
fix(api): handle null response from payment gateway
docs: update API documentation for v2 endpoints
refactor(database): extract connection pooling logic
3. Project Specification
3.1 What You Will Build
A Claude Code skill that:
- Auto-discovers when users mention commits or staging changes
- Analyzes the current git state (staged, unstaged, untracked files)
- Suggests a well-formatted conventional commit message
- Confirms with the user before committing
3.2 Functional Requirements
- Skill Discovery: The skill should activate when users say things like:
- โI want to commit my changesโ
- โcommit thisโ
- โready to commitโ
- โhelp me create a commit messageโ
- Git State Analysis: When invoked, the skill should:
- Check staged changes (
git status) - Show what files are affected
- Analyze the nature of changes (
git diff)
- Check staged changes (
- Commit Message Generation: The skill should:
- Suggest appropriate commit type (feat, fix, docs, etc.)
- Identify scope from file paths if possible
- Write a concise description
- Include bullet points for body if multiple changes
- User Confirmation: Always confirm before committing
3.3 Non-Functional Requirements
- Precision: Donโt trigger on unrelated git commands (push, pull, branch)
- Helpful: Explain why a particular commit type was chosen
- Safe: Never commit without user confirmation
- Educational: Teach users about conventional commits
4. Real World Outcome
When you complete this project, hereโs exactly what youโll experience:
You: I'm ready to commit my changes
Claude: [Auto-discovers and invokes git-commit skill]
I'll help you create a well-formatted commit. Let me check your changes...
Staged Changes:
- src/auth/login.ts (modified)
- src/auth/logout.ts (new file)
- tests/auth.test.ts (modified)
Analyzing changes...
The changes appear to:
- Add a new logout function (new file)
- Update login to work with the new logout flow
- Add test coverage for logout
Based on these changes, here's a suggested commit message:
feat(auth): add logout functionality and update login flow
- Implement logout endpoint with token invalidation
- Update login to support remember-me option
- Add tests for new logout functionality
Commit Type: `feat` (new feature - the logout functionality is new)
Scope: `auth` (all changes are in the auth module)
Shall I proceed with this commit message, or would you like to modify it?
5. The Core Question Youโre Answering
โHow do I create reusable capabilities that Claude automatically discovers and invokes based on user intent?โ
This project answers that question by teaching you:
- The mechanics of skill discovery
- How to write descriptions that match intent
- How to structure instructions Claude follows
- The difference between skills (implicit) and commands (explicit)
6. Concepts You Must Understand First
Stop and research these before coding:
6.1 SKILL.md Structure
| Concept | Questions to Answer | Reference |
|---|---|---|
| YAML frontmatter | What fields are required? What are optional? | Claude Code Docs - โSkillsโ |
| Markdown body | What should go here? How detailed? | Claude Code Docs - โSkillsโ |
| Skill location | Where do skills live? User vs project level? | Claude Code Docs - โSkillsโ |
6.2 Skill Discovery
| Concept | Questions to Answer | Reference |
|---|---|---|
| Description matching | How does Claude decide to use a skill? | Claude Code Docs - โSkill Discoveryโ |
| Keyword importance | What words should be in the description? | Experiment with your skill |
| Avoiding over-matching | How do you prevent false positives? | Single-purpose design principle |
6.3 Git Operations
| Concept | Questions to Answer | Reference |
|---|---|---|
| Git status | What does git status tell you? |
โPro Gitโ Ch. 2 |
| Git diff | How do you see what changed? | โPro Gitโ Ch. 2 |
| Conventional commits | What are the types and when to use them? | conventionalcommits.org |
7. Questions to Guide Your Design
Before implementing, think through these:
7.1 Skill Scope
- Should this skill ONLY handle commits?
- Or should it cover all git operations (push, pull, branch)?
- Whatโs the right granularity?
Recommended: Single-purpose. A commit skill that does commits well is better than a git skill that does everything poorly.
7.2 Discovery Keywords
- What phrases should trigger this skill?
- โcommitโ, โcommit my changesโ, โcreate a commitโ
- How specific should the description be?
Recommended: Include multiple variations: โcommitโ, โcommit messageโ, โgit commitโ, โstage and commitโ
7.3 Instructions Content
- What should Claude do when this skill is invoked?
- Check staged changes?
- Suggest conventional commit format?
- Auto-stage related files?
Recommended: Always check status first, analyze changes, then suggestโnever auto-commit without confirmation.
8. Thinking Exercise
8.1 Design the SKILL.md
Before writing, sketch out the structure:
---
name: git-commit
description: ??? # What triggers discovery?
allowed-tools: # Should you restrict tools?
- Bash
- Read
---
# Instructions
When the user wants to commit changes...
## What to do:
1. ???
2. ???
3. ???
## Commit message format:
???
Questions to answer:
- What description will match โI want to commit my changesโ?
- Should you include โgitโ in the description?
- What tools does Claude need for this skill?
8.2 Trace Through Discovery
Imagine these user messages. Which should trigger your skill?
| User Message | Should Trigger? | Why/Why Not? |
|---|---|---|
| โI want to commit my changesโ | Yes | Direct intent |
| โcommit thisโ | Yes | Clear intent |
| โpush my changes to GitHubโ | No | Different operation |
| โwhat did I change?โ | Maybe | Could be checking before commit |
| โcreate a PRโ | No | Different workflow |
Adjust your description to match only the appropriate cases.
9. The Interview Questions Theyโll Ask
After completing this project, youโll be ready for:
- โHow would you create a reusable capability for an AI coding assistant?โ
- Expected: Explain skills as declarative capabilities with descriptions for discovery
- Bonus: Discuss trade-offs between skills (implicit) and commands (explicit)
- โWhatโs the difference between explicit and implicit invocation?โ
- Expected: Slash commands are explicit; skills are discovered from intent
- Bonus: When to use each approach
- โHow do you scope a skill to avoid over-matching?โ
- Expected: Specific descriptions, single-purpose design, testing
- Bonus: Discuss precision vs recall in skill matching
- โHow would you test that a skill is discovered correctly?โ
- Expected: Try various phrasings, check for false positives/negatives
- Bonus: Create a test matrix of inputs and expected behaviors
- โWhat are the security implications of skill auto-discovery?โ
- Expected: Skills can restrict tools, but users should understand whatโs activated
- Bonus: Discuss
allowed-toolsfor limiting capabilities
10. Solution Architecture
10.1 Skill Directory Structure
~/.claude/skills/git-commit/
โโโ SKILL.md # Your skill definition
10.2 SKILL.md Components
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SKILL.md STRUCTURE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ YAML FRONTMATTER โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ name: git-commit โ โโโโ Unique identifier โ
โ โ description: Help create well- โ โโโโ Discovery trigger โ
โ โ formatted git commit messages... โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ MARKDOWN BODY โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โ โ # Git Commit Assistant โ โโโโ Title โ
โ โ โ โ
โ โ ## 1. Check Current State โ โโโโ Step-by-step โ
โ โ Run `git status`... โ instructions โ
โ โ โ โ
โ โ ## 2. Analyze Changes โ โ
โ โ For each changed file... โ โ
โ โ โ โ
โ โ ## 3. Suggest Commit Message โ โ
โ โ Follow conventional commit format... โ โ
โ โ โ โ
โ โ ## 4. Confirm with User โ โ
โ โ Present suggestion and wait... โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
10.3 Workflow Diagram
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GIT COMMIT SKILL WORKFLOW โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ User: "I want to commit my changes" โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ Skill Discovery โ Match against "commit", "commit message", etc. โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ 1. Git Status โ Run: git status โ
โ โ Check state โ Identify: staged, unstaged, untracked โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ 2. Analyze Diff โ Run: git diff --staged โ
โ โ Understand โ Determine: what changed, what was added โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ 3. Determine โ Based on changes: โ
โ โ Commit Type โ - New file? โ feat โ
โ โ โ - Bug fix? โ fix โ
โ โ โ - Docs only? โ docs โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ 4. Suggest โ Format: type(scope): description โ
โ โ Message โ Include body if multiple changes โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ 5. Confirm โ "Shall I proceed with this commit message?" โ
โ โ with User โ Wait for explicit approval โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ 6. Execute โ Run: git commit -m "message" โ
โ โ (if approved)โ Report success/failure โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
11. Implementation Guide
11.1 Phase 1: Create the Skill Directory
# Create the skill directory
mkdir -p ~/.claude/skills/git-commit
# Create the SKILL.md file
touch ~/.claude/skills/git-commit/SKILL.md
11.2 Phase 2: Write the Frontmatter
---
name: git-commit
description: Help create well-formatted git commit messages following conventional commit format. Use this when the user mentions committing, staging, or preparing changes for git.
---
Why this description works:
- โcommit messagesโ - matches โI want to commitโ
- โconventional commit formatโ - signals this is about formatting
- โcommitting, staging, or preparing changesโ - covers related intents
11.3 Phase 3: Write the Instructions
# Git Commit Assistant
When the user wants to create a commit, follow these steps:
## 1. Check Current State
Run `git status` to see:
- What files are staged
- What files are modified but not staged
- What files are untracked
## 2. Analyze Changes
For each changed file, briefly understand what changed using `git diff --staged`.
If nothing is staged, suggest what should be staged.
## 3. Determine Commit Type
Based on the changes, select the appropriate type:
- `feat:` - A new feature
- `fix:` - A bug fix
- `docs:` - Documentation only changes
- `style:` - Formatting, missing semi colons, etc.
- `refactor:` - Code change that neither fixes a bug nor adds a feature
- `test:` - Adding or correcting tests
- `chore:` - Changes to build process or auxiliary tools
## 4. Identify Scope (Optional)
Look at file paths to determine scope:
- `src/auth/*` โ scope: auth
- `src/api/*` โ scope: api
- Multiple directories โ omit scope or use most significant
## 5. Suggest Commit Message
Format: `type(scope): brief description`
If there are multiple significant changes, include a body:
type(scope): brief description
- Detail about first change
- Detail about second change ```
6. Confirm with User
Present the suggested message and ask: โShall I proceed with this commit message, or would you like to modify it?โ
Never commit without explicit user approval.
### 11.4 Phase 4: Test the Skill
Test with various phrasings:
| Test Input | Expected Behavior |
|------------|-------------------|
| "I want to commit my changes" | Skill activates, checks status |
| "commit this" | Skill activates |
| "help me write a commit message" | Skill activates |
| "push to origin" | Skill should NOT activate |
| "create a new branch" | Skill should NOT activate |
---
## 12. Hints in Layers
If you're stuck, reveal hints one at a time:
<details markdown="1">
<summary><strong>Hint 1: Create the Directory</strong></summary>
Create `~/.claude/skills/git-commit/SKILL.md` (user-level) or `.claude/skills/git-commit/SKILL.md` (project-level).
The directory name should match the skill name for clarity.
</details>
<details markdown="1">
<summary><strong>Hint 2: Write the Frontmatter</strong></summary>
```yaml
---
name: git-commit
description: Help create well-formatted git commit messages following conventional commit format
---
Include keywords users might say: โcommitโ, โcommit messageโ, โstageโ, โchangesโ. </details>
Hint 3: Add Instructions
Tell Claude to:
- Check
git statusfirst - Analyze changes with
git diff --staged - Suggest a commit message following conventional commits
- Always confirm before committing
Be specific about the format you want.
Hint 4: Test Discovery
Ask Claude โI want to commit my changesโ and see if it mentions using the skill.
If it doesnโt activate:
- Check that the skill file is in the right location
- Verify the YAML frontmatter is valid
- Try more explicit triggers in your description
13. Common Pitfalls & Debugging
13.1 Frequent Mistakes
| Pitfall | Symptom | Solution |
|---|---|---|
| Skill not discovered | Claude doesnโt mention using the skill | Check description keywords, file location |
| YAML syntax error | Skill fails to load | Validate YAML, check indentation |
| Over-matching | Skill triggers on unrelated requests | Make description more specific |
| Under-matching | Skill doesnโt trigger when expected | Add more keyword variations |
| Committing without approval | Unsafe behavior | Add explicit confirmation step in instructions |
13.2 Debugging Steps
- Verify file location:
ls ~/.claude/skills/git-commit/SKILL.md - Check YAML validity: Use an online YAML validator
- Test explicitly: Ask Claude โUse the git-commit skillโ
- Review Claudeโs response: Does it mention loading the skill?
14. Extensions & Challenges
14.1 Beginner Extensions
- Add emoji to commit types (e.g.,
featgets sparkles) - Support for
--amendcommits - Show unstaged files and offer to stage them
14.2 Intermediate Extensions
- Add a REFERENCES.md with full conventional commit spec
- Support breaking change notation (
feat!:orBREAKING CHANGE:) - Integrate with git hooks for commit message validation
14.3 Advanced Extensions
- Multi-language commit message templates
- AI-powered commit message improvement suggestions
- Integration with issue trackers (add
Closes #123)
15. Books That Will Help
| Topic | Book | Chapter |
|---|---|---|
| Git workflows | โPro Gitโ by Scott Chacon | Chapter 5: Distributed Workflows |
| Conventional commits | conventionalcommits.org | Full Specification |
| Prompt engineering | โPrompt Engineering Guideโ | All sections |
| Git internals | โPro Gitโ by Scott Chacon | Chapter 10: Git Internals |
16. Self-Assessment Checklist
Before considering this project complete, verify:
Understanding
- I can explain what a SKILL.md file contains
- I understand how skill discovery works (description matching)
- I know the difference between skills and slash commands
- I can explain conventional commit format
Implementation
- My skill activates when I mention committing
- My skill does NOT activate for unrelated git commands
- Claude follows my instructions (check status, analyze, suggest)
- Claude always confirms before committing
Growth
- I tested with at least 5 different phrasings
- I can create a new skill from scratch
- I understand when to use skills vs slash commands
17. Learning Milestones
Track your progress:
| Milestone | Indicator |
|---|---|
| Skill is discovered when you mention commits | You understand discovery |
| Claude follows your instructions | You understand skill instructions |
| Commits are well-formatted | Youโve created a useful skill |
| No false positives on unrelated commands | Youโve scoped correctly |
18. Submission / Completion Criteria
Minimum Viable Completion:
- SKILL.md file exists in correct location
- Skill activates on โI want to commitโ
- Claude checks git status
Full Completion:
- Skill activates on multiple phrasings
- Claude suggests conventional commit format
- Claude explains commit type choice
- Claude confirms before committing
Excellence:
- Skill handles edge cases (nothing staged, untracked files)
- Includes scope detection from file paths
- Documentation explains design decisions
This guide was expanded from CLAUDE_CODE_MASTERY_40_PROJECTS.md. For the complete learning path, see the project index.