Task‑oriented usage for humans and automation. For full options, use diffk help <command> (add --output json for structured help).
Tip: In automation, default to --output json; add --debug for diagnostics.
Detailed guide: see usage-detailed.en.md for per-command usage, examples, and exit codes.
-
Ensure session (idempotent)
- On current work (auto snapshot):
diffk init --mode=new-branch --source main --if-missing --dirty commit --snapshot-message "Warmup snapshot" --output json
- Switching source with dirty worktree:
diffk init --mode=new-branch --source main --if-missing --dirty stash --snapshot-message-file .snapshot-msg.txt --output json
- On current work (auto snapshot):
-
Commit all or selected files
diffk commit --title "AI: update" --output jsondiffk commit --title "AI: update" --paths "a,b" --output json
-
Selective (staged‑hunks via patch)
- Pre‑check:
diffk stage --stdin --check-only --output json < patch.diff - Apply:
diffk stage --stdin --output json < patch.diff - Commit:
diffk commit --title "AI: apply selected hunks" --output json
- Pre‑check:
-
Merge & finish
- Dry‑run:
diffk merge --to main --strategy=squash --dry-run --output json - Merge:
diffk merge --to main --strategy=squash --message "Squash: session" --output json - End:
diffk end --output json
- Dry‑run:
init --mode new-branch|current --source <branch> [--dirty commit|stash|block|keep] [--if-missing] [--snapshot-message "<msg>"|--snapshot-message-file <path>]commit --title "<msg>" [--paths <p1,p2,...>] [--message-file <path>] [--allow-empty]stage (--stdin | --patch-file <path>) [--check-only] [--three-way] [--unidiff-zero] [--recount] [--whitespace nowarn|warn|error] [--reverse]merge --to <branch> --strategy squash|no-ff|ff-only [--dry-run] [--message "<m>"|--message-file <path>]end [--keep-branch] [--force-delete]abort [--hard]statusdoctor(repo health)
- Index‑only: applies hunks to the index; working tree is untouched.
- Input: choose exactly one of
--stdinor--patch-file. - Pre‑check: internal
--check;--check-onlyvalidates without changes; failure returns 41. - TTY behavior: with
--stdinon an interactive TTY, it waits for input/EOF (Ctrl‑D). Prefer pipe/redirect or--patch-filein automation. - Produce patches:
git diff -U0 -- <paths> > patch.diff(U0works well with defaults).
- NOT_GIT/20: run in repo root or pass
--repo. - NO_SESSION/12: run
diffk initfirst. - DIRTY_WORKTREE/13: retry
initwith--dirty=stash(or clean first). - LOCKED/14: serialize; short back‑off retry; if crash left a stale lock, remove
.git/diffkeeper/lockafter ensuring no active process. - NOTHING_TO_COMMIT/15: modify files or limit with
--paths. - PATCH_APPLY_FAILED/41: patch mismatches current state; recompute/align or sync working tree.
- CONFLICT/10: resolve conflicts, commit, then retry merge.
- INVALID_ARGS/2: check signature;
diffk help <command>. - INTERNAL/100 or 50: add
--debugand inspect stderr.
.gitignore: recommended; auto snapshot (init --dirty commit) and normalcommitboth respect it.- Process lock:
.git/diffkeeper/lock; concurrent attempts returnLOCKED(14). - Push protection:
init --install-hooksblocks pushingdiffkeeper/*; override withDIFFKEEPER_ALLOW_PUSH=1.
- NOT_GIT/20: set
--repoor run from the repo root. - NO_SESSION/12: ensure session with
diffk init. - PATCH_APPLY_FAILED/41: confirm how patches are produced; try
--check-onlyfirst. - Interactive block:
stage --stdinwaits on TTY; use< patch.diffor--patch-file.