Skip to main content

Commit Changes

System Prompt

⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:

  1. IMMEDIATELY execute - no questions, no explanations first
  2. ALWAYS show full output from script/tool execution
  3. ALWAYS provide summary after execution completes

DO NOT:

  • Say "I don't need to take action" - you ALWAYS execute when invoked
  • Ask for confirmation unless requires_confirmation: true in frontmatter
  • Skip execution even if it seems redundant - run it anyway

The user invoking the command IS the confirmation.


Usage

/commit [options]

Create commits for: $ARGUMENTS

Arguments

$ARGUMENTS - Commit Context (optional)

Specify commit approach:

  • Auto-analyze: No arguments - analyzes changes and proposes commits
  • Single commit: "Create commit for all changes"
  • Multiple commits: "Create logical commits for each component"
  • With message: "Commit with message: Add user authentication"
  • With attribution: "--co-author" or "--claude" to add Claude co-author attribution

Default Behavior

If no arguments:

  • Analyzes git status and diff
  • Groups related changes logically
  • Drafts conventional commit messages
  • Presents plan for user confirmation
  • Creates commits after approval

Commit Changes

You are tasked with creating git commits for the changes made during this session.

Process:

  1. Think about what changed:

    • Review the conversation history and understand what was accomplished
    • Run git status to see current changes
    • Run git diff to understand the modifications
    • Consider whether changes should be one commit or multiple logical commits
  2. Plan your commit(s):

    • Identify which files belong together
    • Draft clear, descriptive commit messages
    • Use imperative mood in commit messages
    • Focus on why the changes were made, not just what
  3. Present your plan to the user:

    • List the files you plan to add for each commit
    • Show the commit message(s) you'll use
    • Ask: "I plan to create [N] commit(s) with these changes. Shall I proceed?"
  4. Execute upon confirmation:

    • Use git add with specific files (never use -A or .)
    • Create commits with your planned messages
    • Show the result with git log --oneline -n [number]

Attribution Options:

  • Default: No co-author attribution (commits authored solely by user)
  • With --co-author or --claude flag: Adds Claude attribution:
    🤖 Generated with [Claude Code](https://claude.com/claude-code)

    Co-Authored-By: Claude <noreply@anthropic.com>
  • Write commit messages as if the user wrote them (unless attribution requested)

Remember:

  • You have the full context of what was done in this session
  • Group related changes together
  • Keep commits focused and atomic when possible
  • The user trusts your judgment - they asked you to commit

Action Policy

<default_behavior> This command implements changes by default when user intent is clear. Proceeds with:

  • Git status analysis and change review
  • Conventional commit message generation
  • Automatic staging and committing of changes
  • Pre-commit hook execution (if configured)
  • Co-authored-by Claude attribution

Provides concise progress updates during commit execution. </default_behavior>

After commit execution, verify: - Git status checked before commit - Changes staged appropriately - Conventional commit format used (type(scope): description) - Commit message accurately describes changes - Co-authored-by Claude attribution added - Pre-commit hooks executed successfully (if applicable) - Git status shows clean working tree or expected untracked files - Next recommended action provided (push, continue development)

Output Templates

Commit Plan Template

## Proposed Commits

### Commit 1
**Files:** 3 files
- `src/auth/login.ts` (modified)
- `src/auth/logout.ts` (new)
- `tests/auth.test.ts` (modified)

**Message:**
feat(auth): Add logout functionality with session cleanup

Implements secure logout with token invalidation.
- Clear session tokens on logout
- Revoke refresh tokens
- Add logout tests

🤖 Generated with Claude Code

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

**Ready to commit?** [Y/n]

Result Template

✅ Commit Created

**Hash:** abc1234
**Branch:** feature/auth
**Message:** feat(auth): Add logout functionality with session cleanup
**Files:** 3 changed (+45, -10)

**Next:** `git push` or continue development

Verification Steps

Before creating commit:

  1. Run git status to see all changes
  2. Run git diff to review modifications
  3. Group related files logically
  4. Draft conventional commit message (type(scope): description)
  5. Present plan to user for approval
  6. Stage specific files (never git add . or -A)
  7. Create commit with planned message
  8. Verify with git log --oneline -1

Success Output

When commit completes successfully:

✅ COMMAND COMPLETE: /commit
Commits: N created
Files: M staged
Hash: <commit-hash>
Next: git push or continue development

Completion Checklist

Before marking complete:

  • Git status analyzed
  • Changes grouped logically
  • Commit message(s) drafted
  • Commit(s) created successfully
  • Result shown to user

Failure Indicators

This command has FAILED if:

  • ❌ No changes to commit
  • ❌ Pre-commit hook failed
  • ❌ Git staging failed
  • ❌ Commit creation failed

When NOT to Use

Do NOT use when:

  • No changes in working tree
  • Changes need manual review first
  • Want to commit specific files only (use git directly)

Anti-Patterns (Avoid)

Anti-PatternProblemSolution
Commit without reviewBad commitsAlways review changes first
Vague messagesUnclear historyUse conventional commit format
Skip pre-commit hooksQuality issuesLet hooks run

Principles

This command embodies:

  • #9 Based on Facts - Analyzes actual changes
  • #6 Clear, Understandable - Conventional commit messages
  • #3 Complete Execution - Full commit workflow

Full Standard: CODITECT-STANDARD-AUTOMATION.md