dg check
Analyze uncommitted or staged changes in your working tree against HEAD. This is the fastest way to see what you have broken before committing.
Usage
npx dg check # Analyze all uncommitted changes
npx dg check --staged # Analyze only staged files (git add'd)
npx dg check src/payments # Scope analysis to a directoryHow it works
In working tree mode(default), Diff Guardian reads the current file on disk as the "new" source and HEADas the "old" source. It compares every exported symbol between the two versions.
In staged mode (--staged), it reads the git index (what you have git add'd) instead of the working tree. This is what will actually land in your next commit.
Path scoping
You can pass a path argument to limit the analysis to a specific directory. This is useful in monorepos where you only want to check one package:
npx dg check src/api # Only analyze files under src/api/
npx dg check packages/core # Monorepo: scope to one packageExit codes
| Code | Meaning |
|---|---|
0 | No breaking changes. Safe to proceed. |
1 | Breaking changes detected. Review required. |
2 | Pipeline error (missing grammar, parse failure). |
Flags
| Flag | Description |
|---|---|
--staged | Analyze only staged (git add'd) files instead of the full working tree. |
--report-file <path> | Write a JSON report to the specified file path. |
--help, -h | Show help message. |
Example output
$ npx dg check --staged
Diff-Guardian Check (staged)
[BREAKING] Changes (1)
> processPayment (signature_change)
src/api/payments.ts:42
Parameter 'currency' was removed. Callers providing this argument will fail.
────────────────────────────────────────
[STRICT MODE]
1 breaking change found. Exiting with code 1.Related
- dg compare — compare two branches directly
- Git Hooks — auto-run check on push and merge