Skip to content

kholmatov/codex-commit-generator

Repository files navigation

Codex Commit Generator

Codex Commit Generator is a VS Code extension that generates commit messages from Git diffs using a local Codex CLI and can optionally help with a reviewed commit or commit-and-push workflow from Source Control.

The extension uses Codex non-interactively through codex exec. It never runs plain interactive codex mode, never calls network APIs directly, and never commits or pushes without explicit user confirmation.

Features

  • Commands:
    • Codex: Generate Commit Message (codexCommit.generate)
    • Codex: Smart Commit (codexCommit.smartCommit)
    • Codex: Smart Commit and Push (codexCommit.smartCommitPush)
  • Available in:
    • Command Palette
    • Source Control title area (scm/title)
  • Uses the built-in Git extension API to:
    • select the active repository or prompt in multi-repo workspaces
    • read staged diff by default
    • optionally fallback to unstaged diff for generate-only mode
    • stage changes where the Git API supports it
    • commit and push where the Git API supports it
    • write generated text to repo.inputBox.value
  • Uses safe git command fallbacks for staging, committing, and pushing when needed.
  • Runs the Codex CLI using child_process.spawn.
  • Passes the prompt to codex exec as a positional argument by default.
  • Captures stdout from codex exec and uses stdout.trim() as the commit message.
  • Logs repository, diff, command, stderr, exit, staging, commit, and push steps in the Output Channel.

Commands

Codex: Generate Commit Message

Generates a commit message and inserts it into the Source Control input box.

This command:

  • reads staged diff by default
  • can fallback to unstaged diff when codexCommit.fallbackToUnstaged is enabled
  • generates a message through codex exec
  • writes the result to repo.inputBox.value
  • does not stage, commit, or push

Codex: Smart Commit

Generates a commit message and commits after review.

This command:

  • checks for staged changes
  • asks whether to stage all changes when nothing is staged
  • generates a message from the staged diff
  • inserts the generated message into the Source Control input box
  • opens an editable review box for the final commit message
  • commits only after the user confirms the reviewed message
  • does not push

Codex: Smart Commit and Push

Generates a commit message, commits after review, then pushes after another confirmation.

This command:

  • follows the same flow as Smart Commit
  • asks Commit and push to remote?
  • commits only after message review and push confirmation
  • pushes the current branch to its configured upstream
  • shows friendly errors if no upstream exists or push fails

Extension Settings

This extension contributes the following settings:

  • codexCommit.cliCommand (string)

    • Codex CLI executable.
    • Default: codex
    • Set this to a full path if codex is not available on PATH.
  • codexCommit.subcommand (string)

    • Codex CLI subcommand used for non-interactive execution.
    • Default: exec
  • codexCommit.promptTransport (argument | stdin)

    • How to pass the generated prompt to codex exec.
    • Default: argument
    • argument runs codex exec ...extraArgs "<prompt>".
    • stdin runs codex exec ...extraArgs and writes the prompt to stdin. Keep this only as an optional fallback if your Codex CLI supports it in practice.
  • codexCommit.extraArgs (string array)

    • Additional arguments passed after the subcommand and before the prompt.
    • Default: []
    • Example: ["--model", "gpt-5.4"]
  • codexCommit.promptTemplate (string)

    • Prompt template sent to Codex.
    • Placeholders:
      • {{diff}}
      • {{diffFile}} is retained for compatibility and resolves to an empty string
    • Default:
    Generate a concise git commit message from this diff. Return only the commit message text. Use conventional commits if appropriate.
    
    {{diff}}
    
  • codexCommit.useStagedOnly (boolean)

    • Use staged diff first in generate-only mode.
    • Default: true
  • codexCommit.fallbackToUnstaged (boolean)

    • If staged diff is empty, fallback to unstaged diff in generate-only mode.
    • Default: false
  • codexCommit.onExistingMessage (replace | append | prepend | ask)

    • How generate-only mode handles an existing Source Control commit message.
    • Default: replace
  • codexCommit.timeoutMs (number)

    • CLI timeout in milliseconds.
    • Default: 30000
  • codexCommit.maxDiffChars (number)

    • Maximum diff characters included in the prompt.
    • Default: 12000
  • codexCommit.confirmBeforeCommit (boolean)

    • Require a review step before committing.
    • Default: true
    • The extension still requires explicit user action before committing.
  • codexCommit.confirmBeforePush (boolean)

    • Use a modal confirmation before pushing in Smart Commit and Push.
    • Default: true
    • The extension still asks before pushing.
  • codexCommit.autoStageWhenNeeded (boolean)

    • Makes Stage All Changes the first action when Smart Commit finds no staged changes.
    • Default: false
    • The extension still asks before staging.
  • codexCommit.pushAfterCommitDefault (boolean)

    • Makes Push the first action in the Smart Commit and Push confirmation.
    • Default: false
    • The extension still asks before pushing.
  • codexCommit.stageScope (all | trackedOnly)

    • Controls what gets staged when staging is requested.
    • Default: all
    • all stages tracked and untracked changes.
    • trackedOnly stages only tracked changes.
  • codexCommit.debug (boolean)

    • Enable verbose logging.
    • Default: false
    • When enabled, logs include the full prompt argument. Leave disabled if logs may contain sensitive code.

Example Settings

Default non-interactive codex exec setup:

{
  "codexCommit.cliCommand": "codex",
  "codexCommit.subcommand": "exec",
  "codexCommit.promptTransport": "argument",
  "codexCommit.extraArgs": []
}

Smart Commit settings:

{
  "codexCommit.confirmBeforeCommit": true,
  "codexCommit.confirmBeforePush": true,
  "codexCommit.autoStageWhenNeeded": false,
  "codexCommit.pushAfterCommitDefault": false,
  "codexCommit.stageScope": "all"
}

Pass additional Codex exec flags:

{
  "codexCommit.cliCommand": "codex",
  "codexCommit.subcommand": "exec",
  "codexCommit.promptTransport": "argument",
  "codexCommit.extraArgs": ["--model", "gpt-5.4"]
}

Use stdin only if your codex exec installation supports prompt input through stdin:

{
  "codexCommit.promptTransport": "stdin"
}

If stdin mode fails with a terminal-related error such as stdin is not a terminal, switch back to:

{
  "codexCommit.promptTransport": "argument"
}

Usage

Generate only:

  1. Stage your changes.
  2. Open Source Control.
  3. Run Codex: Generate Commit Message.
  4. Review the generated message in the Source Control commit input.
  5. Commit manually when ready.

Smart Commit:

  1. Stage changes, or let the extension ask whether to stage all changes.
  2. Run Codex: Smart Commit.
  3. Review or edit the generated commit message.
  4. Press Enter to commit, or cancel to stop.

Smart Commit and Push:

  1. Stage changes, or let the extension ask whether to stage all changes.
  2. Run Codex: Smart Commit and Push.
  3. Review or edit the generated commit message.
  4. Confirm Commit and push to remote?.
  5. The extension commits, then pushes to the configured upstream.

Local Development

npm install
npm run compile

Then press F5 in VS Code to launch an Extension Development Host.

Notes

  • No OpenAI SDK is used.
  • No direct network calls are made by this extension.
  • The extension never commits or pushes without confirmation.
  • codexCommit.inputMode has been removed. Use codexCommit.promptTransport instead.

About

VS Code extension that generates commit messages from Git diffs using local Codex CLI.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors