PraisonAI CLI provides deep Git integration for tracking changes, auto-committing with AI-generated messages, and managing your version control workflow seamlessly.
# In interactive mode>>> /diff # Show current changes>>> /commit # Commit with AI message>>> /undo # Undo last commit# Or use Python APIfrom praisonai.cli.features import GitIntegrationHandlerhandler = GitIntegrationHandler()handler.initialize(repo_path=".")handler.show_status()
Five /git-* commands drive GitManager directly from a praisonai code session.
>>> /git-status # branch + staged/modified/untracked files>>> /git-diff [--staged] # uncommitted diff (or the staged diff)>>> /git-log [n] # last n commits (default 10)>>> /git-commit [message] # stage + commit; message auto-generated when omitted>>> /git-undo # undo the last commit, keeping changes in the tree
These are operator commands, not agent tools. Committing is a decision, not a step the model should take on its own — so the agent can’t call them. The same reasoning keeps /map operator-only.
They sit alongside the older /diff, /commit, /undo — the /git-* names are the explicit, git-scoped surface backed by GitManager (get_status, get_diff_content, get_log, commit, undo).
/git-status parsing was fixed alongside these commands: get_status() previously ran .strip() on the whole porcelain output, eating the leading space of the first line, so " M a.txt" parsed as status "M " and path ".txt" — reported as staged. It now strips only trailing newlines, so " M a.txt" is correctly modified, not staged.
# Show diffdiff_content = handler.show_diff()# Show staged diff onlystaged_diff = handler.show_diff(staged=True)# Get diff for specific filefile_diff = git.get_diff_content(file_path="src/main.py")
from praisonai.cli.features import ( GitIntegrationHandler, AutonomyModeHandler)autonomy = AutonomyModeHandler()autonomy.initialize(mode="suggest")git = GitIntegrationHandler()git.initialize()# In suggest mode, commit requires approval# In auto_edit mode, commit is auto-approved# In full_auto mode, all git operations are auto-approved
# Default commit message styleexport PRAISONAI_COMMIT_STYLE=conventional# Auto-commit after AI changesexport PRAISONAI_AUTO_COMMIT=false# Git author for AI commitsexport PRAISONAI_GIT_AUTHOR="PraisonAI <ai@praison.ai>"
# Set up git for AI commitsgit config user.name "Your Name"git config user.email "you@example.com"# Optional: Sign AI commitsgit config commit.gpgsign true
from praisonai.cli.features.git_integration import GitManagergit = GitManager(repo_path="/path/to/repo")# Check if repo existsif not git.is_repo: print("Not a git repository") return# Handle commit errorscommit = git.commit("message")if commit is None: print("Commit failed - check for conflicts or empty changes")