smart-commit-copilot-cli
v0.1.7
Published
CLI for AI-assisted commit review, commit message generation, Git workflow automation, and work reports.
Maintainers
Readme
smart-commit CLI
smart-commit CLI is a shell-first tool for AI-assisted commit review, commit-message generation, optional Git execution, and local reporting.
Use it when you want one repeatable workflow that can run from:
- your terminal
- shell scripts
- Git hooks
- IDE hooks
- external agents
It can:
- inspect staged changes
- run AI review and gate on the result
- generate or validate commit messages
- retry malformed review or commit-message responses with configurable correction passes
- use bundled review skills, including
c-code-review, with diff-aware generic fallback - optionally create a commit
- optionally push the current branch
- persist successful run history
- generate daily, yesterday, weekly, monthly, quarterly, or yearly Markdown work reports
Who This Is For
This tool is a good fit if you want to:
- review staged changes before committing
- standardize commit messages
- run the same workflow locally and in automation
- keep a lightweight history of successful review and commit runs
- generate periodic reports from local pass history
If you are using this for the first time, start with review-only mode and keep Git side effects disabled until you trust the workflow.
What Happens In A Typical Run
At a high level, smart-commit bridge does this:
- loads config from CLI flags, environment variables, config file, and defaults
- resolves
env:VAR_NAMEreferences such asenv:SMART_COMMIT_API_KEY - verifies the target
--repopath is inside a Git repository - reads the staged diff, or auto-stages if your config allows it
- runs AI review
- generates or validates the commit message
- optionally commits and pushes
- optionally records the successful run into pass history
flowchart TD
InstallCli[InstallCLI] --> PrepareConfig[PrepareConfig]
PrepareConfig --> ResolveConfig[RunConfigResolve]
ResolveConfig --> StageChanges[StageChanges]
StageChanges --> DryRun[RunBridgeDryRun]
DryRun --> ReviewOnly[RunReviewOnly]
ReviewOnly --> FullRun[OptionalFullRun]
FullRun --> ReportGenerate[OptionalReportGenerate]Prerequisites
Before you run the CLI, make sure you have:
Node.js >= 20gitavailable in your shell- a Git repository to operate on
- staged changes for
bridge, unless auto-stage is enabled - an OpenAI-compatible API endpoint, model, and API key for AI-backed commands
Important command requirements:
smart-commit bridgerequires--reposmart-commit report generaterequires--reposmart-commit config resolvedoes not require--reposmart-commit config resolvecan validate config structure without a complete connection blocksmart-commit bridgerequires a valid connection configuration
Install
Install globally:
npm install -g smart-commit-copilot-cliThen verify:
smart-commit --helpOr use npx without a global install:
npx smart-commit-copilot-cli --helpIf you are working from a repository checkout of this project:
npm install
npm run build
node out/cli.js --help5-Minute Quick Start
This section is the safest first-use path for a real repository.
1. Export your API key
export SMART_COMMIT_API_KEY="your-api-key"Why this matters:
- the config examples below use
env:SMART_COMMIT_API_KEY - environment references are resolved before validation
- if the variable is missing,
bridgecannot start
2. Create a minimal config file
Create smart-commit.json in your target repository:
{
"smartCommitCli": {
"connection": {
"baseUrl": "https://api.openai.com/v1",
"apiKey": "env:SMART_COMMIT_API_KEY",
"model": "gpt-5"
},
"git": {
"autoCommit": false,
"autoPush": false
}
}
}The three connection fields are the most important:
connection.baseUrl: your OpenAI-compatible API base URLconnection.apiKey: your API key, usually referenced throughenv:...connection.model: the model name sent to that endpoint
This minimal config is intentionally safe:
autoCommit=falseprevents local commitsautoPush=falseprevents remote pushes
3. Validate the merged config first
smart-commit config resolve --config ./smart-commit.jsonWhy start here:
- it shows the final merged config after CLI args, env vars, file config, and defaults
- it redacts secrets in output
- it catches validation problems before the CLI touches Git or the network
For a more readable terminal view:
smart-commit config resolve --config ./smart-commit.json --output textWhat you should expect:
- a valid merged config
- no missing environment variable errors
- no invalid booleans, regex patterns, or protocol settings
4. Stage a change
bridge works on staged content.
git add -A
git status --shortIf nothing is staged and autoStageWhenNothingStaged is disabled, bridge will block.
5. Run a safe preflight
smart-commit bridge --repo . --config ./smart-commit.json --dry-runWhy this step matters:
- it verifies the repo path
- it checks whether the repo is inside Git
- it checks whether staged diff input exists
- it validates that commit-message logic can be resolved
- it confirms the bridge input is ready
What you should expect:
status: "ready"when the bridge can runstatus: "blocked"when the repo is valid but required input is missingstatus: "error"when config or runtime setup is invalid
For a terminal-friendly version:
smart-commit bridge --repo . --config ./smart-commit.json --dry-run --output text6. Run review-only mode
smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-pushThis is the recommended first real run because it:
- runs review
- runs commit-message logic
- returns structured output
- avoids Git side effects
What you should expect:
status: "passed"if the review passesstatus: "blocked"if the review blocks or required input is missingstatus: "error"if execution fails
When the review returns a numeric score, the final pass or block result is determined by comparing that score with review.threshold.
Shortest safe path
If you want the shortest sequence to first success:
- install
smart-commit-copilot-cli - export
SMART_COMMIT_API_KEY - create
smart-commit.json - run
smart-commit config resolve - run
smart-commit bridge --dry-run - run
smart-commit bridge --no-commit --no-push
Configuration Examples
Minimal practical config
Use this when you want the smallest useful starting point:
{
"smartCommitCli": {
"connection": {
"baseUrl": "https://api.openai.com/v1",
"apiKey": "env:SMART_COMMIT_API_KEY",
"model": "gpt-5"
},
"git": {
"autoCommit": false,
"autoPush": false
}
}
}This gives you a safe review-first setup.
Safer team rollout config
Use this when you want a more realistic team default without enabling automatic commit or push:
{
"smartCommitCli": {
"connection": {
"baseUrl": "https://api.openai.com/v1",
"apiKey": "env:SMART_COMMIT_API_KEY",
"model": "gpt-5",
"llmResponseCorrectionRetryCount": 1
},
"review": {
"threshold": 6,
"language": "zh"
},
"git": {
"autoStageWhenNothingStaged": true,
"autoCommit": false,
"autoPush": false
},
"passHistory": {
"enabled": true,
"writeStage": "review_passed",
"dirPath": ".smart-commit-cli",
"maxEntries": 3000
},
"output": {
"format": "json",
"logLevel": "info"
}
}
}This is usually the best starting point for teams because it:
- keeps the workflow review-first
- allows local history for reporting
- stays safe for hooks and automation
Review skills and correction retries
Built-in review skills are bundled with the CLI. The default code-review skill stays generic, while domain skills such as frontend-code-review, python-code-review, c-code-review, cpp-code-review, and csharp-code-review add domain-focused guidance. These built-in review skills share a lightweight diff classifier: if the staged diff does not match the selected domain, the CLI falls back to generic review rules automatically without changing your configured skill id.
If you set review.skill.path, the CLI keeps the current file-based custom-skill behavior and loads that file as custom prompt input instead of the bundled built-in skill assets.
connection.llmResponseCorrectionRetryCount controls how many extra repair or regeneration attempts the CLI may request when a review result or generated commit message fails protocol, JSON-shape, or language validation. The default is 1, the supported range is 0..5, and network, HTTP, timeout, or provider failures are not retried by this setting.
About the example config in this repo
This repository ships a fuller example at examples/config/smart-commit.json.
That example is useful for learning the whole config surface, but note that it enables:
git.autoCommit = truegit.autoPush = true
For first use, do not copy those values blindly. Start with false for both and enable them later only if you want the CLI to own those Git side effects.
Choose The Right Command
Instead of memorizing every command, use this section by intent.
I want to verify my config
smart-commit config resolve --config ./smart-commit.jsonUse this when you want to:
- inspect the merged config
- confirm env var resolution
- catch validation issues early
Good to know:
--configis recommended, not required- if you omit
--config, the CLI uses CLI flags, env vars, and built-in defaults config resolveis the safest first command
I want to see whether bridge is ready
smart-commit bridge --repo . --config ./smart-commit.json --dry-runUse this when you want to:
- validate repo and staged diff readiness
- confirm commit-message logic can resolve
- avoid a real AI review or Git side effects
I want review only, with no commit or push
smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-pushUse this when you want to:
- review staged changes
- generate or validate a commit message
- integrate with hooks safely
- onboard the CLI without touching Git history
I want a full bridge run
smart-commit bridge --repo . --config ./smart-commit.jsonUse this only when your config intentionally allows the desired side effects.
Depending on config, the CLI may:
- review only
- review and create a local commit
- review, commit, and push
I want to generate a report
smart-commit report generate --repo . --config ./smart-commit.json --period weeklySupported --period values:
dailyyesterdayweeklymonthlyquarterlyyearly
If you omit --period, it defaults to weekly. yesterday always means the previous natural local day.
If passHistory.enabled=true, successful bridge runs are written locally and later summarized into a Markdown report.
Optional AI-enhanced reporting:
smart-commit report generate --repo . --config ./smart-commit.json --period weekly --report-aiIf AI report generation fails, the CLI falls back to local Markdown generation automatically.
I want a pull request summary after a passing review
smart-commit bridge --repo . --config ./smart-commit.json --no-commit --enable-pull-request-summaryWhen enabled, bridge writes a Markdown PR description after the reviewed action succeeds. It runs after review-only success, after local commit success when --no-push is used, or after push success when auto-push is enabled. Review blocks, dry runs, and commit/push failures do not generate a PR summary.
I want machine-readable schemas
smart-commit schema print --target bridgeSupported schema targets:
config-fileconfig-resolvebridgereport-generate
Examples:
smart-commit schema print --target config-file
smart-commit schema print --target config-resolve
smart-commit schema print --target bridge
smart-commit schema print --target report-generateCore Commands Reference
Help and version
smart-commit --help
smart-commit help
smart-commit --version
smart-commit versionResolve config
smart-commit config resolve --config ./smart-commit.jsonBridge preflight
smart-commit bridge --repo . --config ./smart-commit.json --dry-runReview-only bridge
smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-pushFull bridge execution
smart-commit bridge --repo . --config ./smart-commit.jsonGenerate a report
smart-commit report generate --repo . --config ./smart-commit.json --period weeklyPrint a schema
smart-commit schema print --target bridgeOutput Modes
Default output is machine-facing JSON:
smart-commit bridge --repo . --config ./smart-commit.jsonFor a human-friendly terminal summary:
smart-commit bridge --repo . --config ./smart-commit.json --output textRecommended usage:
- use
jsonfor hooks, agents, and scripts - use
textfor local debugging
For machine integrations, the usual pattern is:
- call
smart-commit bridgeorsmart-commit report generate - consume stdout as JSON
- branch on
schemaVersion,status, anderror.code
Exit Codes
These are especially useful in shell scripts, hooks, and automation.
bridge
0: success2: blocked3: config error4: runtime error
Typical interpretation:
0means the run completed successfully2means the change set or review result blocked progress3means your config or CLI input is invalid4means runtime execution failed
report generate
0: success3: config error4: runtime error
Configuration Rules
Config precedence from high to low:
- CLI arguments
- environment variables
smartCommitCliin a JSON config file- legacy
smartCommit.*keys - built-in defaults
Special rule:
- values like
env:SMART_COMMIT_API_KEYare resolved from the current process environment after merge and before validation
Canonical format:
smartCommitCliis the recommended long-term format- legacy
smartCommit.*is still accepted for migration
Common CLI Flags
Most practical flags for daily use:
--repo
--config
--output
--base-url
--api-key
--model
--threshold
--llm-response-correction-retry-count
--review-language
--code-review-skill-id
--commit-language
--commit-message-structure
--commit-message
--pass-history-write-stage
--enable-pull-request-summary
--pull-request-summary-language
--pull-request-summary-output-dir
--pull-request-summary-prompt
--no-commit
--no-push
--dry-runCommon reporting flags:
--period
--report-language
--report-output-dir
--report-aiCommon Environment Variables
Most practical ones:
SMART_COMMIT_API_KEY
SMART_COMMIT_BASE_URL
SMART_COMMIT_MODEL
SMART_COMMIT_THRESHOLD
SMART_COMMIT_LLM_RESPONSE_CORRECTION_RETRY_COUNT
SMART_COMMIT_REVIEW_LANGUAGE
SMART_COMMIT_CODE_REVIEW_SKILL_ID
SMART_COMMIT_COMMIT_LANGUAGE
SMART_COMMIT_COMMIT_MESSAGE_STRUCTURE
SMART_COMMIT_AUTO_COMMIT
SMART_COMMIT_AUTO_PUSH
SMART_COMMIT_PASS_HISTORY_WRITE_STAGE
SMART_COMMIT_REPORT_LANGUAGE
SMART_COMMIT_REPORT_OUTPUT_DIR
SMART_COMMIT_ENABLE_PULL_REQUEST_SUMMARY
SMART_COMMIT_PULL_REQUEST_SUMMARY_LANGUAGE
SMART_COMMIT_PULL_REQUEST_SUMMARY_OUTPUT_DIR
SMART_COMMIT_PULL_REQUEST_SUMMARY_PROMPTReporting
If passHistory.enabled=true, successful bridge runs are written to local history and can be summarized later:
smart-commit report generate --repo . --config ./smart-commit.json --period weeklypassHistory.writeStage controls the earliest successful stage that can create a record. Once a record exists, later successful stages update the same pass-history entry, so eventType always reflects the furthest successful stage reached by that run.
review_passedwrites as soon as review passes. If that same run later reaches a local commit or push, the existing record is upgraded instead of duplicated.commit_completedwaits until the local commit succeeds. If a later push succeeds, that same record is upgraded tocommit_push_completed.commit_push_completedwrites only after both the local commit and the push succeed.
If a run never reaches the configured write stage, no pass-history record is written. For example:
- with
passHistory.writeStage=commit_completed, a successful local commit is still preserved even if the later push cannot start, fails, or times out - with
passHistory.writeStage=commit_push_completed, those same push failures produce no pass-history record
Stored pass-history eventType values mean:
review_passed: review passed, and no later success stage was reachedcommit_completed: a local commit succeeded, and no later push success stage was reachedcommit_push_completed: both the local commit and the remote push succeeded
Report summaries use these records to show:
- total successful review passes
- local commit completions
- commit and push completions
Common First-Time Mistakes
connection.apiKey references missing environment variable
Your config contains something like:
"apiKey": "env:SMART_COMMIT_API_KEY"but the environment variable is not set in the current shell.
Fix:
export SMART_COMMIT_API_KEY="your-api-key"--repo is required
bridge and report generate require a repository path, or a path inside a Git repository.
Typical fix:
smart-commit bridge --repo . --config ./smart-commit.json --dry-runNo staged diff found
Possible causes:
- nothing is staged
- working tree is clean
- auto-stage is disabled
Try:
git add -A
smart-commit bridge --repo . --config ./smart-commit.json --dry-runI expected the config file to be auto-loaded
If you omit --config, the CLI does not magically discover every possible file name. It uses CLI flags, environment variables, and built-in defaults.
If you want a specific config file to participate in resolution, pass it explicitly:
smart-commit config resolve --config ./smart-commit.jsonI accidentally enabled auto-commit or auto-push too early
If your config or env vars enable git.autoCommit or git.autoPush, bridge may create side effects during a full run.
For first rollout, keep these disabled:
{
"smartCommitCli": {
"git": {
"autoCommit": false,
"autoPush": false
}
}
}Then use:
smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-pushRecommended First Rollout
For a new team or repository, use this order:
- create a minimal or safer team config
- run
smart-commit config resolve - run
smart-commit bridge --dry-run - run
smart-commit bridge --no-commit --no-push - embed the same review-only command into your hook or automation flow
- enable pass history
- add reporting
- only then consider automatic commit or push
This sequence keeps the first rollout safe while still letting you validate the entire workflow.
Where To Go Deeper
For deeper detail after the first successful run:
- getting started from source:
docs/getting-started.md - configuration details:
docs/configuration.md - integration patterns:
docs/integrations.md - machine-facing contracts:
docs/contracts.md
