Skip to content

Overview

contox_add_link creates a directed link between two contexts identified by their schemaKeys. Links form a knowledge graph that helps the AI understand how different parts of the project relate to each other.

Parameters

NameTypeRequiredDefaultDescription
fromstringYesSource schemaKey (e.g., "root/frontend/hooks")
tostringYesTarget schemaKey (e.g., "root/api/auth")
linkTypeenumYesRelationship type: "see-also", "depends-on", "child-of", or "related"
reasonstringNoWhy this link exists
confidencenumberNoConfidence score from 0 to 1 (e.g., 0.9 = very confident)
TypeMeaning
see-alsoCross-reference — related information in another context
depends-onDependency — this context depends on the target
child-ofHierarchical — this context is a child of the target
relatedGeneral relationship — loosely connected contexts

Return value

Returns a confirmation message:

Link created: root/frontend/hooks -> root/api/auth [depends-on]

Usage examples

Linking a hook to its API dependency

Claude calls: contox_add_link({
  from: "root/frontend/hooks",
  to: "root/api/auth",
  linkType: "depends-on",
  reason: "useAuth hook calls the auth API endpoints for login and token refresh",
  confidence: 0.9
})
Claude calls: contox_add_link({
  from: "root/bugs",
  to: "root/implementation",
  linkType: "see-also",
  reason: "Bug fixes reference implementation details for context"
})

Notes

  • Links are directed: creating a link from A to B does not automatically create a link from B to A. Create both directions explicitly if needed.
  • Both the from and to schemaKeys must reference existing contexts.
  • Use contox_get_links to view existing links for a context.
  • The knowledge graph is used by the AI to understand how project components relate, enabling better context retrieval and more informed responses.