Clockwork Commit Context for Cursor in a Node.js Repo
This guide shows how to make commit metadata available to Cursor automatically, project by project, with no global setup. We pair a git post-commit hook with a lightweight Node.js script that writes a local context file. We keep changelog feed sync as an explicit docs command to avoid dirty trees after every commit. The result is predictable, transparent, and easy to maintain.
Architecture
flowchart TD
A[git commit] --> B[post-commit hook]
B --> C[scripts/post-commit-clockwork.mjs]
C --> D[.cursor/context/last-commit.md]
H[npm run clockwork:sync:changelog] --> E[docs/changelog.html auto feed]
D --> F[Cursor reads local context rule]
E --> G[Team sees latest commit stream]
What gets generated
.cursor/context/last-commit.mdwith hash, subject, author, date, commit body, and changed files.docs/changelog.htmlcommit list between marker comments, refreshed byclockwork:sync:changelog.- A local rule in
.cursor/rules/clockwork-context.mdcso Cursor can prioritize this context.
Implementation notes
npm run hooks:install
npm run clockwork:sync
npm run clockwork:sync:changelog
The install step writes .git/hooks/post-commit only in this repository.
The sync command refreshes local Cursor context.
The changelog sync command is explicit so routine commits stay clean.
SEO and GEO strategy
- Use explicit entities in headings: git hook, Cursor context, Node.js automation, changelog feed.
- Add structured data using
TechArticleso search and AI answer engines can classify the page correctly. - Keep concise problem to solution flow for retrieval quality in search snippets and model-generated answers.
- Link this article from changelog and route index for stronger internal relevance signals.
Operational checklist
sequenceDiagram
participant Dev as Developer
participant Git as Git
participant Hook as post-commit
participant Docs as docs/changelog.html
participant Cursor as Cursor context
Dev->>Git: commit
Git->>Hook: trigger
Hook->>Cursor: write last-commit.md
Dev->>Docs: run changelog sync command
Cursor-->>Dev: updated local context on next task
If you want stricter automation, you can run changelog sync in CI for docs branches. In this repo the post-commit hook stays fast and non-mutating for tracked files.