Summary
Expand Nibble's git awareness beyond branch display (#14) into a first-class git integration layer: git status, staged/unstaged diff, worktree support, and session-scoped branch management.
Motivation
Nibble already operates on files within a git repository, but it has no awareness of the repository's state. A deeper integration would let Nibble understand what changed, work safely in isolated branches, and give the user meaningful context about the impact of each session — all without leaving the TUI.
Proposed Features
1. Git Status Panel
Show a compact git status summary in the TUI (dirty/clean, number of modified/staged/untracked files):
main ●くろまる3 +1 ?2 ^ ^ ^ │ │ └─ untracked files │ └──── staged files └─────── unstaged modifications
2. Session-scoped Worktrees
Allow each Nibble session to optionally operate in a dedicated git worktree, fully isolated from the main working tree:
- On session start, Nibble can create a worktree on a new branch (e.g.
nibble/session-20260710)
- All file edits happen in that worktree — the main branch stays clean
- At the end of the session, the user can merge, discard, or keep the worktree branch
- This pairs naturally with Perfect Mode (#13), where autonomous changes could otherwise break the main branch
`
/worktree new nibble/fix-auth
Created worktree at .git/nibble/fix-auth — working on branch nibble/fix-auth
`
3. Diff View
After a session (or on demand), show a summary of all git changes Nibble made:
- Per-file diff accessible from the TUI
- Highlights additions/deletions with the existing lipgloss styling
/diff command to trigger at any point during a session
4. Auto-commit Checkpoints
Optionally create a git commit after each tool execution batch, acting as a checkpoint:
- Commits are lightweight and use a consistent message format:
nibble: checkpoint after <tool>
- Easy to
git reset or git rebase -i afterwards to clean up history
- Configurable via
nibble.json:
json { "git": { "autoCheckpoint": true, "worktreeOnSession": false, "checkpointMessage": "nibble: checkpoint" } }
5. Branch Switching from the TUI
Allow the user to switch branches without leaving Nibble:
`
/branch checkout feature/new-ui
Switched to branch feature/new-ui
`
6. Git Context in System Prompt
Inject relevant git context into the agent's system prompt automatically:
- Current branch
- Repo root
- List of files changed since last commit (to help the agent understand the current state)
Relationship to Existing Issues
- Extends #14 (git branch display in status bar) — the branch indicator becomes part of a broader git status component
- Pairs well with #13 (Perfect Mode) — worktrees provide a safe sandbox for autonomous sessions
Implementation Notes
- A new
internal/git package would centralise all git operations (status, diff, worktree management, branch ops)
- Git commands should be executed via the existing shell infrastructure (
internal/shell) rather than a third-party Go git library, to avoid CGO and keep the dependency footprint small
- All git features should degrade gracefully when not inside a git repository
## Summary
Expand Nibble's git awareness beyond branch display (#14) into a first-class git integration layer: git status, staged/unstaged diff, worktree support, and session-scoped branch management.
## Motivation
Nibble already operates on files within a git repository, but it has no awareness of the repository's state. A deeper integration would let Nibble understand what changed, work safely in isolated branches, and give the user meaningful context about the impact of each session — all without leaving the TUI.
## Proposed Features
### 1. Git Status Panel
Show a compact git status summary in the TUI (dirty/clean, number of modified/staged/untracked files):
`
main ●くろまる3 +1 ?2
^ ^ ^
│ │ └─ untracked files
│ └──── staged files
└─────── unstaged modifications
`
### 2. Session-scoped Worktrees
Allow each Nibble session to optionally operate in a dedicated **git worktree**, fully isolated from the main working tree:
- On session start, Nibble can create a worktree on a new branch (e.g. `nibble/session-20260710`)
- All file edits happen in that worktree — the main branch stays clean
- At the end of the session, the user can merge, discard, or keep the worktree branch
- This pairs naturally with Perfect Mode (#13), where autonomous changes could otherwise break the main branch
`
/worktree new nibble/fix-auth
> Created worktree at .git/nibble/fix-auth — working on branch nibble/fix-auth
`
### 3. Diff View
After a session (or on demand), show a summary of all git changes Nibble made:
- Per-file diff accessible from the TUI
- Highlights additions/deletions with the existing lipgloss styling
- `/diff` command to trigger at any point during a session
### 4. Auto-commit Checkpoints
Optionally create a git commit after each tool execution batch, acting as a checkpoint:
- Commits are lightweight and use a consistent message format: `nibble: checkpoint after <tool>`
- Easy to `git reset` or `git rebase -i` afterwards to clean up history
- Configurable via `nibble.json`:
`json
{
"git": {
"autoCheckpoint": true,
"worktreeOnSession": false,
"checkpointMessage": "nibble: checkpoint"
}
}
`
### 5. Branch Switching from the TUI
Allow the user to switch branches without leaving Nibble:
`
/branch checkout feature/new-ui
> Switched to branch feature/new-ui
`
### 6. Git Context in System Prompt
Inject relevant git context into the agent's system prompt automatically:
- Current branch
- Repo root
- List of files changed since last commit (to help the agent understand the current state)
## Relationship to Existing Issues
- Extends **#14** (git branch display in status bar) — the branch indicator becomes part of a broader git status component
- Pairs well with **#13** (Perfect Mode) — worktrees provide a safe sandbox for autonomous sessions
## Implementation Notes
- A new `internal/git` package would centralise all git operations (status, diff, worktree management, branch ops)
- Git commands should be executed via the existing shell infrastructure (`internal/shell`) rather than a third-party Go git library, to avoid CGO and keep the dependency footprint small
- All git features should degrade gracefully when not inside a git repository