← Back to all skills

engineering / Git & commits

git-commit

Commits staged files using a temp-file commit message to avoid shell-substitution pitfalls.

Markdown workflowYou or your agent

Put it to work.

Ask your agent to use git-commit, or let it load the skill when your task matches the description.

Use the git-commit skill

Invocation syntax varies by agent. Use the skill name in your prompt, or your agent’s supported slash command.

About this skill

Safe commit-message workflow using a temp file and git commit -F.

  • Avoids shell quoting/injection pitfalls with multi-line commit messages
  • Uses a deterministic sequence (touch → read → write → commit → cleanup)
  • Pairs with /commit-conventions for message structure

Install

bash
npx skills@latest add smeltery/skills

Or copy just this skill:

bash
mkdir -p ~/.claude/skills/git-commit
curl -fsSL https://raw.githubusercontent.com/smeltery/skills/main/skills/engineering/git-commit/SKILL.md \
  -o ~/.claude/skills/git-commit/SKILL.md

Usage

Use whenever committing, especially when the message includes punctuation, multiple lines, or trailers.

Files

  • SKILL.md — canonical skill definition.
Read the full SKILL.md

Pattern

Write the commit message to a temp file, then use git commit -F to read it. This avoids all shell substitution, quoting, and injection issues.

Never use: git commit -m "...", heredocs, $(), backticks, or echo > to write the message.

Exact steps (in order)

  1. Stage files (if not already staged):

    bash
    git add <file1> <file2> ...
  2. Touch the temp file so the Read tool can open it:

    bash
    touch /tmp/commit_msg.txt
  3. Read the temp file with the Read tool — required before Write will accept it:

    text
    Read: /tmp/commit_msg.txt
  4. Write the message with the Write tool (never echo/cat):

    text
    Write: /tmp/commit_msg.txt
    ---
    feat: your commit title here
    
    Optional body paragraph.
  5. Commit:

    bash
    git commit -F /tmp/commit_msg.txt
  6. Clean up:

    bash
    rm /tmp/commit_msg.txt

Message format

Follow the repo's commit-conventions:

  • First line: type: short description (under 72 chars)
  • Blank line, then optional body

Example (full sequence)

text
Bash:   touch /tmp/commit_msg.txt
Read:   /tmp/commit_msg.txt
Write:  /tmp/commit_msg.txt  ←  content below
---
feat: extract shared serializer module

Moves shared text serialization into a focused module, keeping the
domain package centered on data models.
---
Bash:   git add packages/domain/src/index.ts packages/api/src/serializeText.ts
Bash:   git commit -F /tmp/commit_msg.txt
Bash:   rm /tmp/commit_msg.txt

The Smeltery library

Find your next step.

Good places to start

smeltery / skills

A little direction goes a long way

What’s next?