-
Notifications
You must be signed in to change notification settings - Fork 0
GhostDiff
github-actions[bot] edited this page Feb 28, 2026
·
1 revision
Ghost Diff detects when AI session file changes diverge from your spec files (.claw/specs/). It acts as a soft guardrail — the daemon fires a ghost_drift_detected push event and the UI shows a warning banner before drift compounds.
Write plain markdown with an "Expected behavior" section:
# Session Module Spec
## Expected behavior
- Sessions must persist across daemon restarts using SQLite storage
- Session IDs must be globally unique (UUID v4)
- Sessions time out after 30 minutes of inactivity
- All session operations are atomic (no partial writes)The ghost diff engine extracts bullet points from "Expected behavior", "Specification", and "Requirements" sections. Files elsewhere in the document are used if no section is found.
# Run ghost diff check in terminal
clawd ghost-diff
# Exit non-zero on any drift (CI integration)
clawd ghost-diff --strict- name: Ghost diff check
run: clawd ghost-diff --strictExits with code 1 if any spec violations are detected.
When the daemon detects drift in real-time (file saved → spec check fails), it fires:
{
"method": "ghost_drift_detected",
"params": {
"file": "src/session.rs",
"spec": "session.md",
"divergenceSummary": "File may diverge from spec: missing concepts: persist, atomic",
"severity": "medium"
}
}The Ghost Diff panel (in Session → Details) shows:
- List of drift warnings with spec name + file path
- Spec snippet vs actual code side-by-side
- "Accept Drift" button — updates the spec to match current code
- "Revert" button — opens git diff view to undo the file change
| Method | Description |
|---|---|
ghost_diff.check |
Run ghost diff for a repo, returns list of GhostDriftWarning
|
- Get files changed since last git commit (
git diff HEAD --name-only) - Load all spec files from
.claw/specs/ - Match each changed file against relevant specs by name
- Extract keywords from "Expected behavior" sections
- Check that keyword concepts appear in the file content
- Flag files where more than half the spec concepts are absent
ClawDE · GitHub · MIT License
ClawDE
Getting started
Reference
- Architecture
- Daemon-Reference
- Folder-Structure
- Providers
- Multi-Account
- Security
- Features
- Features/Daemon
- Features/Session-Manager
- Features/Mode-System
- Features/Repo-Intelligence
- Features/Projects
- Features/Remote-Access
- Features/Desktop-App
- Features/Provider-Knowledge
- Features/Coding-Standards
- Roadmap
Branding
Contributing