Driftlock is a commit-time gatekeeper that detects when your documentation has fallen behind your code—and then fixes it for you.
It watches every git commit, compares the actual structural changes (function
signatures, types, classes) with the documentation you claim describes them,
and if there’s a mismatch, it blocks the commit, rewrites the affected
documentation, and tells you to stage the new version. No more “I’ll update the
docs later.”
Optionally, it can log an immutable audit trail to a Solana devnet contract, because some of you work in industries where proving that docs matched code at every commit is a regulatory requirement.
flowchart TD
A[git commit] --> B[Git pre-commit hook]
B --> C[driftlock hook-run]
C --> D{Capture staged diff}
D --> E[AST structural extraction]
E --> F{Map changed files to docs}
F --> G[Read current doc content]
G --> H[LLM Check: TRUE/FALSE?]
H -->|TRUE| I["Log hash (optional), exit 0"]
H -->|FALSE| J[LLM Fix: generate updated doc]
J --> K[Write updated doc to working tree]
K --> L[Print message: docs updated, commit blocked]
L --> M[exit 1]
flowchart TD
subgraph CLI Layer
Root[cmd/driftlock/root.go]
InitCmd[init.go]
HookRunCmd[hook_run.go]
CheckCmd[check.go]
FixCmd[fix.go]
LogCmd[log.go]
end
subgraph Internal
Config[config/config.go]
GitUtils[git/git.go]
DiffCapture[diff/capture.go]
DiffStructural[diff/structural.go]
Parser[parser/parser.go + languages.go]
LLMClient[llm/client.go]
LLMPrompt[llm/prompt.go]
LLMResponse[llm/response.go]
Updater[updater/updater.go]
AuditHash[audit/hash.go]
AuditSolana[audit/solana.go]
HookOrch[hook/hook.go]
end
HookRunCmd --> HookOrch
HookOrch --> GitUtils
HookOrch --> DiffCapture
HookOrch --> DiffStructural
HookOrch --> Config
HookOrch --> LLMClient
HookOrch --> Updater
HookOrch --> AuditHash
HookOrch --> AuditSolana
LLMClient --> LLMPrompt
LLMClient --> LLMResponse
DiffStructural --> Parser
If you have Go 1.22+:
go install github.com/Ksschkw/driftlock/cmd/driftlock@latest
Download a static binary from the Releases page.
Linux, macOS, and Windows builds are available. Place the binary somewhere in
your PATH.
curl -fsSL https://raw.githubusercontent.com/Ksschkw/driftlock/main/install.sh | sh
Yes, that pipes a shell script into your shell. It downloads the right binary
for your OS and architecture, verifies a checksum, and drops it into
/usr/local/bin. If that terrifies you (it should), you can inspect the script
first at the same URL.
cd your-project
driftlock init # sets up the hook and a .driftlock.toml
git add . && git commit -m "commit message"
# If your docs are out of sync, the commit is blocked and the docs are updated.Because out-of-date documentation is technical debt that compiles. Driftlock treats it as a build failure.
MIT