A cross-platform (Windows/macOS/Linux) system that helps developers safely recover from git issues:
- Merge conflicts
- Detached HEAD state
- Rebase-in-progress scenarios
Reversible by Design: Every action includes explicit undo paths. Dangerous operations require explicit opt-in.
gitguard-agent/
├── packages/
│ └── schema/ # Shared Zod schemas (SnapshotV1, PlanV1)
├── apps/
│ ├── cli/ # Node.js CLI for generating snapshots
│ └── web/ # Next.js web app with agent pipeline
└── demos/ # Reproducible test cases
- Node.js >= 18
- pnpm >= 8
pnpm installpnpm buildNavigate to a git repository with issues:
# From any git repo
npx gitguard snapshot --pretty > snapshot.json
# Or if installed globally
gitguard snapshot --pretty > snapshot.jsoncd apps/web
pnpm devOpen http://localhost:3000 and upload your snapshot.json.
gitguard snapshot [options]
Options:
-o, --output <file> Write snapshot to file instead of stdout
--pretty Pretty-print JSON output
-h, --help Display helpThe CLI collects:
git status --porcelain=v2 --branchgit branch -vvgit log --oneline --decorate -n 30git reflog -n 30- Conflict snippets from unmerged files (up to 2 files, 3 blocks each)
- Rebase state detection
- Collector: Normalizes snapshot into signals
- Classifier: Identifies issue type (merge_conflict, detached_head, rebase_in_progress)
- Planner: Generates step-by-step recovery plan with undo options
- Verifier: Validates progress when new snapshot is uploaded
- Diagnosis: View repository state and detected issues
- Plan: Step-by-step recovery with copy buttons and undo for each step
- Verify: Upload new snapshot to check progress
- Trace: View raw agent pipeline outputs
Set your Anthropic API key for enhanced planning:
export ANTHROPIC_API_KEY=your-key-hereWithout an API key, the system uses mock responses suitable for demo/development.
SQLite database (gitguard.db) stores:
- Sessions
- Snapshots
- Plans
- Agent traces
See the /demos directory for reproducible test cases:
The CLI uses git commands (not direct filesystem access) to ensure cross-platform compatibility:
git rev-parse --git-dirinstead of assuming.gitlocationgit rev-parse --git-pathfor rebase detection- Line ending normalization (CRLF → LF)
# Watch mode for schema package
cd packages/schema && pnpm dev
# Watch mode for CLI
cd apps/cli && pnpm dev
# Dev server for web
cd apps/web && pnpm dev- Never destructive by default: All suggested actions are reversible
- Explicit undo paths: Every step includes undo commands
- Dangerous operations gated:
reset --hard,push --forcerequire explicit flag - Reflog fallback: Always provides reflog-based recovery option
- Read-only CLI: Snapshot generation never modifies the repository
MIT