dkg-annotate

A set of coding rules that records each substantial chat exchange in a project's shared knowledge graph, a linked collection of project information.

In plain words
What is it for?
It is for automatically adding decisions, context, and other useful conversation details to the project's DKG knowledge graph.
Why use it?
It keeps project memory connected and easier to navigate across conversations. Each record can be traced back to the chat turn that created it.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/origintrail/dkg/dkg-annotate
Clone the repo
git clone --depth 1 https://github.com/OriginTrail/dkg

Made for: Cursor.

Per session 2,909 This file is loaded in full into every session.
When invoked 2,909 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02909 $0.02909
Opus 5 $0.01455 $0.01455
Sonnet 5 $0.00582 $0.00582
Haiku 4.5 $0.00291 $0.00291

Measured 3d ago against content hash 2c32d0c8799b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dkg-annotate scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/dkg-annotate.mdc · 167 lines

How it starts

The opening of the file, as written. The whole thing — 167 lines — stays where its author put it; the contents beside it link to each section on GitHub.

DKG annotation protocol (V10)

This repository is bound to a DKG V10 context graph (dkg-code-project). Use the dkg MCP server to keep the graph rich and convergent. The full canonical instructions live in AGENTS.md; this file is the Cursor-specific mirror.

Session context — read this every turn

Your incoming prompt is prefixed with a block injected by packages/mcp-dkg/hooks/inject-session-context.mjs:

<dkg-session-context>
  <session-id>{sessionKey}</session-id>
  <next-turn-index>{N}</next-turn-index>
  <turn-uri>urn:dkg:chat:session:{sessionKey}#turn:{N}</turn-uri>
  <agent-uri>{your agent URI}</agent-uri>
</dkg-session-context>

Parse it once and hold <turn-uri> + <agent-uri> in working memory. The capture hook at packages/mcp-dkg/hooks/capture-chat.mjs will write chat:Turn at exactly this URI after your response, so any <turn-uri> chat:proposes <X> edge you author during the turn JOINs cleanly once the post-response write lands.

If the block is missing, fall back: annotations still stand on dcterms:created + prov:wasAttributedTo even without the turn-URI edge.

(V9 sourced the session id from a session-start additionalContext payload. That path is retired in V10 — use the <dkg-session-context> block instead.)

Hook ordering is documented in the installed .cursor/hooks.json — capture-chat runs first (stashes prompt + writes state file with pendingTurnIndex), inject-session-context runs second (reads state, prepends block), inject-inbox runs third (prepends its own notice on top). Don't re-order without understanding the dependencies.

After every substantive turn

Author one per-turn assertion. Over-eagerness is not a failure mode; under-coverage is. Skip only one-line acknowledgements.

The V9 sugared dkg_annotate_turn is gone — V10 uses an explicit three-step write (create → write → share):

Read the full file on GitHub · 167 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 167 lines · 2,909 tokens per session scan A 2c32d0c8799b

Subscribe to this mod's changes

dkg-annotate is a cursor rule published in the GitHub repository OriginTrail/dkg (145 stars, last pushed 3d ago), licensed Apache-2.0. It adds 2,909 tokens to every session, about $0.0145 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.