Git Workspace

Cortex provides a full git porcelain interface executed through the agent workspace. Ten subcommands provide complete git version control with agent-powered features like auto-generated commit messages and diff analysis.

Architecture

┌──────────────────────────────────────────────────────────┐
│                    Git Workspace                           │
│                                                           │
│  CLI (cortex git) ──► git-cmd.ts ──► Git Operations       │
│                              │                            │
│                              ▼                            │
│                     Agent Integration                      │
│              (commit messages, diff analysis,              │
│               branch suggestions, PR descriptions)        │
└──────────────────────────────────────────────────────────┘

Subcommands

CommandDescriptionAgent Integration
statusWorking tree statusSuggestions for next actions
logCommit historyAnalysis of commit patterns
diffChanges between commitsSummarized diff explanations
addStage filesIntelligent staging suggestions
commitCreate commitAuto-generated commit messages
pushPush to remotePR-ready push workflows
pullPull from remoteConflict resolution assistance
cloneClone repositoryAutomatic setup
branchBranch managementNaming convention enforcement
remoteRemote managementRemote URL validation

Agent-Powered Features

When invoked with the --agent flag, git commands leverage the Cortex agent to:

  1. Commit Messages: Analyze diffs and generate conventional commit messages (feat:, fix:, refactor:, etc.)
  2. Diff Analysis: Summarize changes in natural language for code review
  3. Branch Naming: Suggest consistent branch names based on convention
  4. Conflict Detection: Identify potential merge conflicts before they occur
  5. PR Descriptions: Generate comprehensive pull request descriptions from commit history

Pipeline Integration

Git operations flow through the Cortex pipeline system, enabling hooks at each stage:

  • Pre-commit: Content safety checks, secret detection
  • Post-commit: Memory consolidation of changes
  • Pre-push: Validation of commit quality
  • Post-clone: Automatic project setup

See also: GitHub Integration, Pipeline System