← MarketplaceGet started free
Guide

How to Generate Conventional Commit Messages Automatically

What You'll Build

A git hook or CI step that reads your staged diff and returns a properly formatted conventional commit message — scoped, typed, and ready to commit.

Prerequisites

  • Runcept account and API key
  • git 2.x+
  • Option A — Git Prepare-Commit-Msg Hook

    #!/bin/sh
    

    # .git/hooks/prepare-commit-msg

    DIFF=$(git diff --cached | head -c 6000)

    if [ -z "$DIFF" ]; then exit 0; fi

    RESPONSE=$(curl -sS -X POST https://www.runcept.com/api/v1/run \

    -H "Authorization: Bearer $RUNCEPT_API_KEY" \

    -H "Content-Type: application/json" \

    -d "{\"agent\": \"commit-messages\", \"input\": {\"diff\": \"$(echo "$DIFF" | head -c 4000 | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))" | tr -d '"')\"}}")

    JOB_ID=$(echo $RESPONSE | jq -r '.job_id')

    for i in {1..15}; do

    sleep 3

    RESULT=$(curl -sS https://www.runcept.com/api/v1/jobs/$JOB_ID \

    -H "Authorization: Bearer $RUNCEPT_API_KEY")

    if [ "$(echo $RESULT | jq -r '.status')" = "complete" ]; then

    MSG=$(echo $RESULT | jq -r '.output.message')

    echo "$MSG" > "$1"

    break

    fi

    done

    Make it executable: chmod +x .git/hooks/prepare-commit-msg

    Option B — Node.js Script

    import { execSync } from 'child_process'
    
    

    const diff = execSync('git diff --cached').toString().slice(0, 6000)

    const { job_id } = await fetch('https://www.runcept.com/api/v1/run', {

    method: 'POST',

    headers: {

    Authorization: Bearer ${process.env.RUNCEPT_API_KEY},

    'Content-Type': 'application/json',

    },

    body: JSON.stringify({ agent: 'commit-messages', input: { diff } }),

    }).then(r => r.json())

    // Poll

    while (true) {

    await new Promise(r => setTimeout(r, 3000))

    const job = await fetch(https://www.runcept.com/api/v1/jobs/${job_id}, {

    headers: { Authorization: Bearer ${process.env.RUNCEPT_API_KEY} },

    }).then(r => r.json())

    if (job.status === 'complete') {

    console.log(job.output.message)

    // e.g. "feat(auth): add OAuth2 PKCE flow"

    break

    }

    }

    Output Format

    The agent returns conventional commit format:

    {
    

    "message": "feat(api): add rate limiting per API key tier",

    "type": "feat",

    "scope": "api",

    "breaking": false,

    "body": "Adds per-key rate limiting using Redis sliding window..."

    }

    Next Steps

  • Add this hook to your team's setup script for consistent adoption
  • Use with the code review agent for full pre-commit automation
  • Browse developer tool agents
  • Use this agent on Runcept

    View commit-messages agent →

    Related guides

    Call an AI Agent API from Node.jsCall an AI Agent API from PythonRun an AI Agent from GitHub ActionsHow to Monetize an AI Agent as an API