Skip to content

hjun1052/xgit

Repository files navigation

xgit

Twitter header - 1

CI License: MIT Status

xgit — AI-powered Git workflows: resolve conflicts, debug regressions, and review diffs from your terminal.

Install

macOS / Linux (one-liner)

curl -fsSL https://raw.githubusercontent.com/hjun1052/xgit/main/scripts/install.sh | bash

Windows PowerShell

irm https://raw.githubusercontent.com/hjun1052/xgit/main/scripts/install.ps1 | iex

From source

git clone https://github.com/hjun1052/xgit.git
cd xgit
go build -o xgit ./cmd/xgit
./xgit init --provider mock --non-interactive

Quick demo

1) Generate a commit message

Input

xgit commit

Example output

feat(auth): add refresh token rotation

- rotate refresh tokens on every successful refresh
- invalidate previous token family on reuse detection
- add tests for replay and expiry behavior

2) Review a branch before opening PR

Input

xgit review --base main

Example output

Risk score: medium
- [auth/service.go] Missing nil-check on token claims can panic
- [api/handler.go] 401/403 paths are inconsistent for expired sessions
Suggested fixes:
1) Guard claims before type assertions
2) Normalize auth error mapping in middleware

3) Resolve an active merge conflict

Input

xgit merge

Example output

Generated patch (preview):
diff --git a/auth/service.go b/auth/service.go
...
Patch check passed. Apply this patch now? [y/N]:

4) Find the commit that introduced a regression

Input

xgit hist-debug --good v1.2.0 --bad HEAD --test "go test ./..." --flaky-retries 3 --format json

Example output

{
  "first_bad_commit": "944424a9a28c9f2c1a1703ae05f964e140a3b35e",
  "analysis": "Off-by-one introduced in Add(): return a + b + 1",
  "patch_detected": true
}

5) Propose a fix from failing tests

Input

xgit test-fix --test "go test ./..."

Example output

Generated test-fix patch:
diff --git a/calc.go b/calc.go
...
Re-running tests: go test ./...
ok  	project/calc	0.114s

Why this exists

Git is excellent at storing snapshots and tracking text changes, but it does not understand code intent.

xgit bridges that gap:

  • Keep using normal Git repositories and workflows
  • Add semantic reasoning only where it helps (merge, review, debugging)
  • Preserve human control with patch validation + approval gates

In short: xgit is not a new VCS. It is a practical AI layer over the Git you already use.

Features

  • AI merge conflict resolution (xgit merge)

    • Context-aware conflict analysis
    • Unified diff generation + git apply --check validation
    • Safe fallback for complex conflicts (submodule/symlink/binary/rename variants)
  • Regression debugging (xgit hist-debug)

    • git bisect orchestration + AI root-cause analysis
    • Supports flaky test handling (--flaky-retries)
    • Optional patch suggestion + validation
  • Commit/review productivity

    • xgit commit: generate high-quality commit messages from diffs
    • xgit review: structured risk-focused diff review
    • xgit enhance: low-risk refactor suggestions from current changes
    • xgit explain history: summarize commit timeline, turning points, and hotspots
  • Automation helpers

    • xgit test-fix: propose and validate fixes for failing tests
    • xgit doc: generate/update project docs
    • xgit auto: state-aware automation (conflict/test/diff driven)
  • Workflow scaling

    • xgit alias: compose multiple xgit commands into one reusable command
    • xgit rebase: AI-assisted rebase conflict handling
    • xgit safe-refactor: conservative patch + validation + rollback
    • xgit pr-split: suggest/apply logical PR chunking by file groups
    • xgit deadcode: heuristic dead/unused code candidate discovery
  • Provider flexibility

    • API providers: OpenAI, Claude, Ollama
    • CLI provider: codex-cli
    • Mock provider for local testing
  • Production-minded resilience

    • Retry/backoff for transient model/API failures
    • Partial-output parsing fallback for malformed responses
    • Prompt budget management for large diffs/logs
    • Built-in terminal progress spinner for long-running steps (AI calls/bisect/tests)
    • Optional debug telemetry (XGIT_DEBUG=1)

Usage example

1) Initial setup

xgit init --provider codex-cli --non-interactive
# or:
xgit config set provider openai
xgit config set api-key-env openai OPENAI_API_KEY

2) Daily workflow

# Generate commit message from staged diff
xgit commit

# Review current branch changes vs main
xgit review --base main

# Suggest improvements on current diff
xgit enhance --focus readability

# Explain recent branch history
xgit explain history main..HEAD --limit 40

3) High-impact workflows

# Resolve active merge conflicts
xgit merge
# or bias resolution direction with custom guidance
xgit merge --direction ours --guidance "prefer API compatibility and keep current error handling"
# by default merge blocks patches touching non-conflict files
xgit merge --allow-out-of-scope

# Automate next best action based on repo state
xgit auto --base main

# Rebase with AI conflict resolver
xgit rebase main --auto-resolve

# Create reusable command bundles
xgit alias set ship "review --base main" "commit --apply"
xgit ship

# Find and analyze regression introduction
xgit hist-debug --good v1.2.0 --bad HEAD --test "go test ./..." --flaky-retries 3

# Auto-fix failing tests (with patch validation)
xgit test-fix --test "go test ./..."

# Split branch into logical PR chunks
xgit pr-split --base main

# Heuristic dead code discovery
xgit deadcode --lang go

# Security toggles
xgit config set allow-shell off
xgit config set prompt-redaction on

Known limitations (v0.1.0 beta)

  • Best validated on macOS/Linux. Windows support is included, but deep real-world validation is still ongoing.
  • AI output quality depends on provider/model and prompt context budget.
  • Very large/binary-heavy repositories may require narrower command scope for best results.
  • xgit always prefers safe fallback over risky auto-edits when confidence is low.

Comparison with alternatives

Tool What it does well Limits Where xgit fits
Git CLI Reliable history/snapshots/branching No semantic reasoning for intent/conflicts Adds AI reasoning while keeping native Git flow
General AI coding agents Broad code generation and refactor support Not Git-workflow-centric by default Purpose-built commands for merge/review/bisect workflows
PR review bots Automated PR comments in hosted workflows Mostly post-hoc, remote, PR-stage Works locally during development before PR
Custom scripts + hooks Team-specific automation Hard to maintain, limited inference Reusable AI-assisted CLI with validation and fallbacks

If this project is useful, please consider starring the repo and opening issues for edge cases you want covered next.

Release notes

About

AI-powered Git workflows: resolve conflicts, debug regressions, and review diffs from your terminal.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors