Back to Skills

create-git-commit

majiayu000
Updated Today
58
9
58
View on GitHub
Metadesign

About

This Claude Skill enforces structured git commits with mandatory type and scope fields for all changes. It provides scope discovery from your codebase structure and prevents bypassing the format, even during emergencies or pressure. Use it whenever creating a git commit to ensure consistent, machine-parsable commit messages.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/majiayu000/claude-skill-registry
Git CloneAlternative
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/create-git-commit

Copy and paste this command in Claude Code to install this skill

Documentation

Git Commits

Overview

Mandatory discipline for ALL new git commits. Every commit MUST follow commit format with a required scope, discovered from codebase structure.

Core Principle: Consistent, machine-parsable commit messages enable automated change-log generation, semantic versioning, and clear project history. Commit messages are names for changes and follow the same self-contained naming principles as code identifiers.

[!attention] The Iron Law NO COMMIT WITHOUT TYPE, SCOPE, DESCRIPTION

This applies to ALL commits: simple fixes, typos, documentation, emergencies - everything. No exceptions.

When to Use

MANDATORY:

  • Before creating ANY new git commit
  • When Bash tool executes git commit command

OPTIONAL:

  • When revising past commits for consistency

FORBIDDEN:

  • Bypassing format "just this once"
  • Skipping scope because "it doesn't fit"
  • Using vague scopes like "misc" or "various"

Format Structure

Required Format

<type>(<scope>): [US#.#] [Task #.#.#] <description>

[optional body]

[optional footer(s)]

Note: User story and task numbers are included in the description line when available. If no task number exists, include only the user story number. If working without user stories, omit the bracketed identifiers.

Supported Types (Extended Common Set)

TypePurposeSemVer Impact
featNew featureMINOR
fixBug fixPATCH
docsDocumentation only-
choreMaintenance (deps, configs)-
refactorCode restructure, no behavior change-
testTest additions/modifications-
perfPerformance improvementsPATCH
ciCI/CD pipeline changes-
buildBuild system changes-
styleCode formatting, whitespace-

Breaking Changes: Include BREAKING CHANGE: footer (triggers MAJOR)

Scope Discovery Process

THE PRIMARY FAILURE MODE: Agents abandon entire format when scope is ambiguous. This section prevents that.

The Mandatory Scope Rule

[!attention] Every commit MUST include a scope.

How to Discover Scope

  1. Run scope discovery commands:

    git status
    git diff --name-only
    
  2. Identify patterns in changed files:

    • Top-level directories: src/, docs/, tests/
    • Module names: auth, api, ui, database
    • Component names: LoginForm, UserProfile
    • Package names: @workspace/package-name
  3. Apply the Primary Scope Rule:

    • Single module: Use that module name
    • Multiple modules, one area: Use area name
    • Cross-cutting changes: Pick the PRIMARY changed layer
    • Truly global: Use core, config, or global
    • Can't decide in 30 seconds: Use top-level directory from first changed file

Scope Selection Examples

Changed FilesCorrect ScopeReasoning
src/auth/*.ts onlyauthSingle module
docs/README.mdreadmeSpecific doc file
.github/workflows/*workflows or ciCI area
Multiple test filesintegration or unitTest type
src/auth/form.tsx, src/api/auth.ts, src/utils/validate.tsauthPrimary layer is auth, even though utils touched
src/*.ts (many files, no pattern)coreGlobal/core changes

The 30-Second Rule

If you can't decide on scope after 30 seconds:

  1. Pick the directory name of the first changed file
  2. Or use the most specific layer touched
  3. Never skip scope because it's ambiguous

Any scope is better than no scope. Imperfect scope > abandoned format.

Description Quality (Self-Contained Naming)

Commit descriptions follow the project's Self-Contained Naming Principles - they are names for changes:

Rules

  1. Descriptive Labels: The <type>(<scope>): <description> format distinguishes operation type, system scope, and outcome
  2. Immediate Understanding: Anyone should understand what the commit does without reading the diff
  3. Confusion Prevention: Be specific enough to eliminate ambiguity

Description Guidelines

  • Include user story and task numbers when available: [US#.#] [Task #.#.#]
  • Focus on WHAT and WHY, not HOW
  • Complete the sentence: "This commit will..."
  • Be specific: "add" not "update", "fix" not "change"
  • Keep under 72 characters (excluding US/task identifiers)
  • Lowercase first word (after US/task identifiers if present, or after type if not)
  • No period at end

Examples:

  • fix(auth): fix bug - Too vague
  • fix(auth): update code - What code? What changed?
  • fix(auth): prevent null pointer on missing OAuth state
  • feat(api): add email validation to login endpoint
  • feat(citation-manager): [US2.3] [Task 2.3.1] implement link extraction from markdown
  • docs(readme): [US1.2] add installation instructions for CLI

Footer Management

Footer Format

One blank line after body (or description if no body), then footers.

Required Footer Types

1. AI Coding Assistant Attribution (ALWAYS include):

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

2. Breaking Changes (when applicable):

BREAKING CHANGE: description of what broke and migration path

3. Issue/Task References (when applicable):

Refs: #123
Closes: #456
Fixes: #789

4. Review/Approval Metadata (when applicable):

Reviewed-by: Name <email>
Approved-by: Name <email>

Footer Assembly Order

  1. Breaking changes first (if any)
  2. Issue references (if any)
  3. Review metadata (if any)
  4. Claude attribution (always last)

Complete Example

feat(auth)!: add OAuth 2.0 support

Replaces legacy session-based auth with OAuth 2.0 flow.
Adds Google and GitHub providers.

BREAKING CHANGE: Session middleware removed, use OAuth tokens
Closes: #234
Reviewed-by: Tech Lead <lead@example.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

The Iron Law - Enforcement

[!attention] ALL NEW COMMITS MUST FOLLOW COMMIT FORMAT

This applies to:

  • "Simple" commits (typos, formatting)
  • "Quick fixes"
  • "Just updating a comment"
  • Commits under time pressure
  • End-of-day commits
  • Emergency hotfixes
  • Documentation changes
  • Configuration changes

No exceptions. Ever.

Violating the letter of the rules is violating the spirit of the rules.

Red Flags - STOP Immediately

If you're thinking any of these, STOP and apply the format correctly:

  • "This commit is too simple for the format"
  • "I'll fix the message in the next commit"
  • "The format doesn't add value here"
  • "Following the spirit, not the letter"
  • "Time pressure makes this exception okay"
  • "Scope doesn't fit / is ambiguous" ← Primary failure mode
  • "Scope adds minimal value"
  • "Can't decide on scope"
  • Using vague scopes like "misc", "various", "other"
  • Skipping scope entirely
  • Vague descriptions like "fix bug" or "update code"
  • "US/task numbers are just context, put them in body" ← Common rationalization
  • "US/task numbers make description too long" ← They don't count toward 72-char limit
  • "Description should be purely technical without US numbers"

All of these mean: Stop. Apply the format correctly with a specific scope and US/task numbers in description.

Common Rationalizations

These are captured from real baseline testing - agents use these exact rationalizations under pressure:

RationalizationReality
"Too simple for commit format"Simple commits still need clear history. Takes 5 seconds.
"I'll clean it up later"Later never comes. Do it now.
"Scope doesn't matter for docs"Docs have structure too. Use appropriate scope (readme, api-docs, guides).
"Emergency hotfix, no time"Hotfixes especially need clear documentation. 10 seconds won't delay deployment.
"Following the spirit"The letter IS the spirit. Format enables tooling and immediate understanding.
"Description is obvious from diff"People read commits without diffs. Make it self-contained.
"Cross-cutting change, scope is arbitrary"Pick the PRIMARY layer. Auth + API + utils? Primary is auth. Use auth.
"Scope adds minimal value"Scopes enable filtering, navigation, and understanding. Mandatory for tooling.
"Can't decide scope after thinking"Use the 30-Second Rule: pick first file's directory or most specific layer.
"Multiple layers, can't pick one"Primary Scope Rule: pick the layer that changed MOST or is MOST important to the feature.
"US/task numbers are context, not metadata"Context belongs in body. Identifiers belong in description. US/task numbers are identifiers for traceability.
"Description should be purely technical"US/task numbers ARE technical metadata. They link commits to requirements for impact analysis.

Common Mistakes

Mistake 1: Abandoning Format When Scope Unclear

Wrong:

Add email validation to login flow

Right:

feat(auth): add email validation to login flow

Fix: Even if scope seems ambiguous (auth? validation? ui?), pick the PRIMARY one. In this case, the primary feature is authentication, so use auth.

Mistake 2: Vague Scope

Wrong:

fix(misc): update validation

Right:

fix(auth): prevent null pointer in email validation

Fix: "misc" and "various" are red flags. Use the specific module or component.

Mistake 3: Missing Scope Entirely

Wrong:

docs: update README

Right:

docs(readme): add installation instructions

Fix: Scopes are MANDATORY. For docs, use the specific doc file or section.

Mistake 4: Capitalized Description

Wrong:

fix(auth): Fix OAuth bug

Right:

fix(auth): fix OAuth null pointer error

Fix: Description should be lowercase (except proper nouns).

Mistake 5: US/Task Numbers in Body Instead of Description

Wrong:

feat(citation-manager): implement link extraction from markdown

Adds LinkExtractor component for US2.3.
Part of Task 2.3.1 implementation.

Right:

feat(citation-manager): [US2.3] [Task 2.3.1] implement link extraction from markdown

Adds LinkExtractor component to extract and parse markdown links from
content for validation and content extraction phases.

Fix: US/task numbers are identifiers that belong in the description line, not narrative context in the body. Check implementation plans, user story documents, or commit context for US/task numbers before committing.

Integration with Bash Tool

The Bash tool's git commit workflow references this skill:

Before creating commit:

  1. Announce: "I'm using the create-git-commit skill to format this commit message."
  2. Run scope discovery: git status and git diff --name-only
  3. Select type based on changes
  4. Apply Primary Scope Rule to pick scope
  5. Craft self-contained description
  6. Structure body (optional)
  7. Assemble footer in correct order

Commit message template:

git commit -m "$(cat <<'EOF'
<type>(<scope>): [US#.#] [Task #.#.#] <description>

[Optional body explaining why]

[Optional: BREAKING CHANGE: details]
[Optional: Refs: #123]
[Optional: Reviewed-by: Name <email>]

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"

Note: When working within user stories, always check implementation plans or context for US/task numbers. If no user story context exists, omit the bracketed identifiers.

Quick Reference

ElementRequirementExample
TypeREQUIREDfeat, fix, docs
ScopeREQUIREDauth, api, readme
US/Task IDsWhen available[US2.3] [Task 2.3.1]
DescriptionREQUIRED, lowercase, <72 charsadd email validation
BodyOptionalExplain why, not what
Breaking changeWhen applicableBREAKING CHANGE: footer
Issue refsWhen applicableCloses: #123
AttributionALWAYSClaude Code footer

The Bottom Line

[!attention] Commit format is a discipline, not a suggestion.

Like test-driven development, it feels like overhead until you experience the benefits: automated changelogs, semantic versioning, clear history, easy filtering, tool compatibility.

The scope requirement is non-negotiable because it's where agents rationalize away the entire format.

When in doubt: Pick a scope in 30 seconds and move on. Any scope > no scope.

GitHub Repository

majiayu000/claude-skill-registry
Path: skills/create-git-commit

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

creating-opencode-plugins

Meta

This skill provides the structure and API specifications for creating OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It offers implementation patterns for JavaScript/TypeScript modules that intercept and extend the AI assistant's lifecycle. Use it when you need to build event-driven plugins for monitoring, custom handling, or extending OpenCode's capabilities.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

Algorithmic Art Generation

Meta

This skill helps developers create algorithmic art using p5.js, focusing on generative art, computational aesthetics, and interactive visualizations. It automatically activates for topics like "generative art" or "p5.js visualization" and guides you through creating unique algorithms with features like seeded randomness, flow fields, and particle systems. Use it when you need to build reproducible, code-driven artistic patterns.

View skill