tx memory
Headless search over markdown directories — index, search, tag, and navigate your knowledge graph
Purpose
Memory provides filesystem-backed document search over markdown directories. Unlike learnings (which are structured records stored in SQLite), memory indexes your existing .md files — project notes, design docs, meeting notes, wikis — and makes them searchable via BM25 keyword search, vector similarity, and graph expansion through wikilinks and frontmatter relationships.
Documents are regular .md files with YAML frontmatter. tx indexes them; it does not own them. Your files stay where they are.
At A Glance
Memory Pipeline
Search Mode
Memory vs Learnings
Durable knowledge
tx memory
- Long-form notes, runbooks, design docs, and linked markdown.
- Searchable by BM25, semantic recall, and graph expansion.
- Best when backlinks, wikilinks, and document structure matter.
Reusable insight
tx learning
- Short patterns, pitfalls, reminders, and operator heuristics.
- Surfaces directly in learning search and task context.
- Best when the agent needs a concise hint, not a full document.
Commands
Source Management
| Command | Description |
|---|---|
tx memory source add <dir> | Register a directory for indexing |
tx memory source rm <dir> | Unregister a directory |
tx memory source list | Show registered directories |
Document Management
| Command | Description |
|---|---|
tx memory add <title> | Create a new .md file |
tx memory show <id> | Display a document |
tx memory list | List indexed documents |
Search & Indexing
| Command | Description |
|---|---|
tx memory search <query> | Search documents (BM25, vector, graph) |
tx memory index | Index all registered sources |
Metadata
| Command | Description |
|---|---|
tx memory tag <id> <tags...> | Add tags to frontmatter |
tx memory untag <id> <tags...> | Remove tags from frontmatter |
tx memory set <id> <key> <value> | Set a frontmatter property |
tx memory unset <id> <key> | Remove a frontmatter property |
tx memory props <id> | Show all properties |
tx memory relate <id> <target> | Add to frontmatter.related |
Graph Navigation
| Command | Description |
|---|---|
tx memory links <id> | Outgoing wikilinks + explicit edges |
tx memory backlinks <id> | Incoming links |
tx memory link <source-id> <target-ref> | Create an explicit edge |
Key Concepts
Memory IDs
Every indexed document gets a deterministic ID in the format mem-<12 hex chars>, derived from SHA256(relativePath + rootDir). The same file always produces the same ID.
Link Types
Memory supports three types of links between documents:
| Type | Source | Example |
|---|---|---|
wikilink | [[page-name]] in document body | Auto-detected during indexing |
frontmatter | related: array in YAML frontmatter | Managed via tx memory relate |
explicit | tx memory link command | Manual graph edges |
Reserved Frontmatter Keys
| Key | Managed By | Notes |
|---|---|---|
tags | tx memory tag / tx memory untag | Array of string tags |
related | tx memory relate | Array of related document references |
created | Auto-set on creation | ISO 8601 timestamp |
All other frontmatter keys are user-defined and can be managed via tx memory set / tx memory unset.
Source Management
tx memory source add
Register a directory of markdown files for indexing.
tx memory source add <dir> [options]Options:
| Option | Description |
|---|---|
--label <name> | Human-readable label for this source |
--json | Output as JSON |
Examples:
# Register a notes directory
tx memory source add ~/notes
# Register with a label
tx memory source add ./docs --label "Project Docs"
# Register and output JSON
tx memory source add ~/wiki --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
// Register a directory
const source = await tx.memory.sourceAdd('/Users/me/notes')
// Returns: { id, rootDir, label, createdAt }
// Register with a label
const docs = await tx.memory.sourceAdd('./docs', 'Project Docs')
console.log(`Registered: ${docs.rootDir} (${docs.label})`){
"tool": "tx_memory_source_add",
"arguments": {
"dir": "/Users/me/notes",
"label": "Project Notes"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
dir | Yes | Absolute path to directory to register |
label | No | Human-readable label for this source |
POST /api/memory/sources
Content-Type: application/json
{
"dir": "/Users/me/notes",
"label": "Project Notes"
}Example
curl -X POST http://localhost:3456/api/memory/sources \
-H "Content-Type: application/json" \
-d '{"dir": "/Users/me/notes", "label": "Project Notes"}'tx memory source rm
Unregister a directory. This removes the source from the index but does not delete any files.
tx memory source rm <dir> [options]Options:
| Option | Description |
|---|---|
--json | Output as JSON |
Examples:
# Remove a source
tx memory source rm ~/old-notes
# Remove with JSON output
tx memory source rm ./archive --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
await tx.memory.sourceRemove('/Users/me/old-notes'){
"tool": "tx_memory_source_rm",
"arguments": {
"dir": "/Users/me/old-notes"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
dir | Yes | Directory path to unregister |
DELETE /api/memory/sources
Content-Type: application/json
{
"dir": "/Users/me/old-notes"
}Example
curl -X DELETE http://localhost:3456/api/memory/sources \
-H "Content-Type: application/json" \
-d '{"dir": "/Users/me/old-notes"}'tx memory source list
Show all registered source directories.
tx memory source list [options]Options:
| Option | Description |
|---|---|
--json | Output as JSON |
Examples:
# List all sources
tx memory source list
# JSON output
tx memory source list --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
const sources = await tx.memory.sourceList()
// Returns: Array<{ id, rootDir, label, createdAt }>
for (const src of sources) {
console.log(`${src.rootDir} (${src.label ?? 'no label'})`)
}{
"tool": "tx_memory_source_list",
"arguments": {}
}Document Management
tx memory add
Create a new .md file in a registered source directory.
tx memory add <title> [options]Options:
| Option | Description |
|---|---|
-c, --content <text> | Initial document body content |
-t, --tags <tags...> | Tags to add to frontmatter |
--prop <key=value> | Set a frontmatter property (repeatable) |
-d, --dir <path> | Target source directory (defaults to first registered source) |
--json | Output as JSON |
Examples:
# Create a simple document
tx memory add "Meeting Notes 2024-01-15"
# Create with content and tags
tx memory add "Auth Architecture" \
-c "## Overview\nJWT-based authentication with refresh tokens." \
-t architecture auth
# Create with properties and target directory
tx memory add "Sprint Retro" \
--prop sprint=42 --prop team=backend \
-d ~/notes/retros
# Create and output JSON
tx memory add "API Design" -t api design --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
const doc = await tx.memory.add({
title: 'Auth Architecture',
content: '## Overview\nJWT-based authentication with refresh tokens.',
tags: ['architecture', 'auth'],
properties: { status: 'draft', sprint: '42' },
dir: '/Users/me/notes',
})
// Returns: { id, filePath, rootDir, title, content, tags, ... }
console.log(`Created: ${doc.id} at ${doc.filePath}`){
"tool": "tx_memory_add",
"arguments": {
"title": "Auth Architecture",
"content": "## Overview\nJWT-based authentication with refresh tokens.",
"tags": ["architecture", "auth"],
"properties": { "status": "draft" },
"dir": "/Users/me/notes"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
title | Yes | Document title (used to generate filename) |
content | No | Initial body content |
tags | No | Frontmatter tags |
properties | No | Key-value properties for frontmatter |
dir | No | Target directory (default: first registered source) |
POST /api/memory/documents
Content-Type: application/json
{
"title": "Auth Architecture",
"content": "## Overview\nJWT-based authentication with refresh tokens.",
"tags": ["architecture", "auth"],
"properties": { "status": "draft" }
}Example
curl -X POST http://localhost:3456/api/memory/documents \
-H "Content-Type: application/json" \
-d '{"title": "Auth Architecture", "tags": ["architecture", "auth"]}'tx memory show
Display a document's content and metadata.
tx memory show <id> [options]Options:
| Option | Description |
|---|---|
--json | Output as JSON |
Examples:
# Show a document
tx memory show mem-a1b2c3d4e5f6
# Show as JSON
tx memory show mem-a1b2c3d4e5f6 --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
const doc = await tx.memory.show('mem-a1b2c3d4e5f6')
// Returns: { id, filePath, rootDir, title, content, tags, frontmatter, ... }
console.log(doc.title)
console.log(doc.content){
"tool": "tx_memory_show",
"arguments": {
"id": "mem-a1b2c3d4e5f6"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID (e.g. mem-abc123def456) |
GET /api/memory/documents/:idExample
curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6tx memory list
List indexed documents with optional filtering.
tx memory list [options]Options:
| Option | Description |
|---|---|
--source <dir> | Filter by source directory |
-t, --tags <tags...> | Filter by tags |
--json | Output as JSON |
Examples:
# List all documents
tx memory list
# Filter by source
tx memory list --source ~/notes
# Filter by tags
tx memory list -t architecture design
# Combined filters with JSON
tx memory list --source ./docs -t api --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
// List all documents
const docs = await tx.memory.list()
// Filter by source and tags
const filtered = await tx.memory.list({
source: '/Users/me/notes',
tags: ['architecture'],
})
// Returns: Array<{ id, filePath, rootDir, title, content, tags, ... }>
for (const doc of filtered) {
console.log(`${doc.id}: ${doc.title}`)
}{
"tool": "tx_memory_list",
"arguments": {
"source": "/Users/me/notes",
"tags": ["architecture"]
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
source | No | Filter by source directory path |
tags | No | Filter by tags (documents must have all specified tags) |
GET /api/memory/documents?source=/Users/me/notes&tags=architecture,authExample
# List all documents
curl http://localhost:3456/api/memory/documents
# Filter by source and tags
curl "http://localhost:3456/api/memory/documents?source=/Users/me/notes&tags=architecture"Search & Indexing
tx memory search
Search documents using BM25 keyword search, vector similarity, or a combination with graph expansion. This is the primary command for querying the memory graph.
tx memory search <query> [options]Options:
| Option | Description |
|---|---|
-s, --semantic | Use vector similarity search (requires embeddings) |
-e, --expand | Expand results via wikilinks and frontmatter.related |
-t, --tags <tags...> | Filter by tags |
--prop <key=value> | Filter by frontmatter property (repeatable) |
-n, --limit <n> | Maximum results (default: 10) |
--min-score <n> | Minimum relevance score 0-1 |
--json | Output as JSON |
Search Modes:
| Mode | Flag | How it works |
|---|---|---|
| Keyword (BM25) | (default) | Full-text search with term frequency scoring |
| Semantic | --semantic | Cosine similarity on embedding vectors |
| Expanded | --expand | Follow wikilinks and related edges from initial results |
| Combined | --semantic --expand | RRF (Reciprocal Rank Fusion) across all signals |
Examples:
# Basic keyword search
tx memory search "authentication flow"
# Semantic similarity search
tx memory search "how does login work" --semantic
# Keyword search with graph expansion
tx memory search "database schema" --expand
# Combined: keyword + semantic + graph expansion
tx memory search "error handling patterns" --semantic --expand
# Filter by tags and properties
tx memory search "deployment" -t devops --prop env=production
# Limit results and set minimum score
tx memory search "react hooks" -n 5 --min-score 0.5
# JSON output for scripting
tx memory search "API design" --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
// Basic keyword search
const results = await tx.memory.search({ query: 'authentication flow' })
// Combined: semantic + graph expansion with filters
const expanded = await tx.memory.search({
query: 'error handling patterns',
semantic: true,
expand: true,
limit: 5,
minScore: 0.3,
tags: ['backend'],
props: { env: 'production' },
})
// Returns: Array<{ id, title, content, relevanceScore, bm25Score, vectorScore, ... }>
for (const doc of expanded) {
console.log(`[${doc.relevanceScore.toFixed(2)}] ${doc.title}`)
}{
"tool": "tx_memory_search",
"arguments": {
"query": "authentication flow",
"semantic": true,
"expand": true,
"limit": 5,
"tags": ["backend"]
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
query | Yes | Search query text |
limit | No | Maximum results (default: 100) |
minScore | No | Minimum relevance score 0-1 |
semantic | No | Enable vector similarity search |
expand | No | Enable graph expansion via wikilinks |
tags | No | Filter results by tags |
props | No | Filter by properties (format: key=value or key) |
GET /api/memory/search?query=authentication+flow&semantic=true&expand=true&limit=5Example
# Basic keyword search
curl "http://localhost:3456/api/memory/search?query=authentication+flow"
# Combined search with filters
curl "http://localhost:3456/api/memory/search?query=error+handling&semantic=true&expand=true&limit=5&tags=backend"Output
Search results for "authentication flow":
1. [0.92] auth-architecture.md
Tags: architecture, auth | Source: ~/notes
JWT-based authentication with refresh token rotation...
2. [0.78] login-flow.md
Tags: auth, frontend | Source: ~/notes
User enters credentials → API validates → issues token pair...
3. [0.61] security-review.md
Tags: security | Source: ~/docs
OAuth2 PKCE flow recommended for SPA clients...tx memory index
Index all registered source directories. Scans for .md files, parses frontmatter, extracts wikilinks, and updates the search index.
tx memory index [options]Options:
| Option | Description |
|---|---|
-i, --incremental | Only re-index files that changed since last index (based on file hash) |
--status | Show indexing status (file counts, coverage) without re-indexing |
--json | Output as JSON |
Examples:
# Full re-index
tx memory index
# Incremental index (skip unchanged files)
tx memory index --incremental
# Check indexing status
tx memory index --status
# Incremental with JSON output
tx memory index -i --jsonimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
// Full re-index
const result = await tx.memory.index()
// Returns: { indexed, skipped, removed }
console.log(`Indexed: ${result.indexed}, Skipped: ${result.skipped}`)
// Incremental index (only changed files)
const incremental = await tx.memory.index({ incremental: true })
// Check indexing status
const status = await tx.memory.indexStatus()
// Returns: { totalFiles, indexed, stale, embedded, links, sources }{
"tool": "tx_memory_index",
"arguments": {
"incremental": true
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
incremental | No | If true, only re-index changed files |
For index status, use:
{
"tool": "tx_memory_index_status",
"arguments": {}
}POST /api/memory/index
Content-Type: application/json
{
"incremental": true
}Examples
# Full re-index
curl -X POST http://localhost:3456/api/memory/index
# Incremental index
curl -X POST http://localhost:3456/api/memory/index \
-H "Content-Type: application/json" \
-d '{"incremental": true}'
# Check indexing status
curl http://localhost:3456/api/memory/index/statusMetadata
tx memory tag
Add tags to a document's YAML frontmatter.
tx memory tag <id> <tags...>Examples:
# Add a single tag
tx memory tag mem-a1b2c3d4e5f6 architecture
# Add multiple tags
tx memory tag mem-a1b2c3d4e5f6 backend api v2import { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
await tx.memory.tag('mem-a1b2c3d4e5f6', ['backend', 'api', 'v2']){
"tool": "tx_memory_tag",
"arguments": {
"id": "mem-a1b2c3d4e5f6",
"tags": ["backend", "api", "v2"]
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID |
tags | Yes | Tags to add |
POST /api/memory/documents/:id/tags
Content-Type: application/json
{
"tags": ["backend", "api", "v2"]
}Example
curl -X POST http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/tags \
-H "Content-Type: application/json" \
-d '{"tags": ["backend", "api", "v2"]}'tx memory untag
Remove tags from a document's YAML frontmatter.
tx memory untag <id> <tags...>Examples:
# Remove a single tag
tx memory untag mem-a1b2c3d4e5f6 draft
# Remove multiple tags
tx memory untag mem-a1b2c3d4e5f6 wip experimentalimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
await tx.memory.untag('mem-a1b2c3d4e5f6', ['wip', 'experimental']){
"tool": "tx_memory_untag",
"arguments": {
"id": "mem-a1b2c3d4e5f6",
"tags": ["wip", "experimental"]
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID |
tags | Yes | Tags to remove |
DELETE /api/memory/documents/:id/tags
Content-Type: application/json
{
"tags": ["wip", "experimental"]
}Example
curl -X DELETE http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/tags \
-H "Content-Type: application/json" \
-d '{"tags": ["wip", "experimental"]}'tx memory set
Set a frontmatter property on a document. Writes to both the YAML frontmatter in the .md file and the database index.
tx memory set <id> <key> <value>Examples:
# Set a string property
tx memory set mem-a1b2c3d4e5f6 status "reviewed"
# Set a numeric property
tx memory set mem-a1b2c3d4e5f6 priority 1
# Set a custom property
tx memory set mem-a1b2c3d4e5f6 owner "team-backend"import { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
await tx.memory.set('mem-a1b2c3d4e5f6', 'status', 'reviewed')
await tx.memory.set('mem-a1b2c3d4e5f6', 'owner', 'team-backend'){
"tool": "tx_memory_set",
"arguments": {
"id": "mem-a1b2c3d4e5f6",
"key": "status",
"value": "reviewed"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID |
key | Yes | Property key |
value | Yes | Property value |
PUT /api/memory/documents/:id/props/:key
Content-Type: application/json
{
"value": "reviewed"
}Example
curl -X PUT http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/props/status \
-H "Content-Type: application/json" \
-d '{"value": "reviewed"}'tx memory unset
Remove a frontmatter property from a document.
tx memory unset <id> <key>Examples:
# Remove a property
tx memory unset mem-a1b2c3d4e5f6 status
# Remove a custom property
tx memory unset mem-a1b2c3d4e5f6 ownerimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
await tx.memory.unset('mem-a1b2c3d4e5f6', 'status'){
"tool": "tx_memory_unset",
"arguments": {
"id": "mem-a1b2c3d4e5f6",
"key": "status"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID |
key | Yes | Property key to remove |
DELETE /api/memory/documents/:id/props/:keyExample
curl -X DELETE http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/props/statustx memory props
Show all frontmatter properties for a document.
tx memory props <id>Examples:
tx memory props mem-a1b2c3d4e5f6Output
Properties for mem-a1b2c3d4e5f6 (auth-architecture.md):
tags: architecture, auth
created: 2024-01-15T10:30:00Z
status: reviewed
owner: team-backend
related: login-flow.md, token-refresh.mdimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
const props = await tx.memory.props('mem-a1b2c3d4e5f6')
// Returns: Record<string, string>
for (const [key, value] of Object.entries(props)) {
console.log(`${key}: ${value}`)
}{
"tool": "tx_memory_props",
"arguments": {
"id": "mem-a1b2c3d4e5f6"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID |
GET /api/memory/documents/:id/propsExample
curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/propstx memory relate
Add a target document to a document's frontmatter.related array. This creates a frontmatter link type in the graph.
tx memory relate <id> <target>Examples:
# Relate two documents
tx memory relate mem-a1b2c3d4e5f6 mem-f6e5d4c3b2a1
# Relate by filename
tx memory relate mem-a1b2c3d4e5f6 login-flow.mdimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
await tx.memory.relate('mem-a1b2c3d4e5f6', 'mem-f6e5d4c3b2a1')
// Or relate by filename
await tx.memory.relate('mem-a1b2c3d4e5f6', 'login-flow.md'){
"tool": "tx_memory_relate",
"arguments": {
"id": "mem-a1b2c3d4e5f6",
"target": "login-flow.md"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Source memory document ID |
target | Yes | Target reference (document ID, title, or filename) |
POST /api/memory/documents/:id/relate
Content-Type: application/json
{
"target": "login-flow.md"
}Example
curl -X POST http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/relate \
-H "Content-Type: application/json" \
-d '{"target": "login-flow.md"}'Graph Navigation
tx memory links
Show outgoing links from a document, including wikilinks parsed from the body and explicit edges.
tx memory links <id>Examples:
tx memory links mem-a1b2c3d4e5f6Output
Outgoing links from auth-architecture.md:
[wikilink] → login-flow.md
[wikilink] → token-refresh.md
[frontmatter] → security-review.md
[explicit] → oauth2-spec.mdimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
const links = await tx.memory.links('mem-a1b2c3d4e5f6')
// Returns: Array<{ id, sourceDocId, targetDocId, targetRef, linkType, createdAt }>
for (const link of links) {
console.log(`[${link.linkType}] → ${link.targetRef}`)
}{
"tool": "tx_memory_links",
"arguments": {
"id": "mem-a1b2c3d4e5f6"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID |
GET /api/memory/documents/:id/linksExample
curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/linkstx memory backlinks
Show incoming links to a document from other documents.
tx memory backlinks <id>Examples:
tx memory backlinks mem-a1b2c3d4e5f6Output
Incoming links to auth-architecture.md:
[wikilink] ← api-design.md
[frontmatter] ← security-overview.md
[explicit] ← onboarding-guide.mdimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
const backlinks = await tx.memory.backlinks('mem-a1b2c3d4e5f6')
// Returns: Array<{ id, sourceDocId, targetDocId, targetRef, linkType, createdAt }>
for (const link of backlinks) {
console.log(`[${link.linkType}] <- ${link.sourceDocId}`)
}{
"tool": "tx_memory_backlinks",
"arguments": {
"id": "mem-a1b2c3d4e5f6"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | Memory document ID |
GET /api/memory/documents/:id/backlinksExample
curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/backlinkstx memory link
Create an explicit edge between two documents. This is a manual graph connection that persists independently of document content.
tx memory link <source-id> <target-ref>Examples:
# Link by memory ID
tx memory link mem-a1b2c3d4e5f6 mem-f6e5d4c3b2a1
# Link by filename reference
tx memory link mem-a1b2c3d4e5f6 deployment-guide.mdimport { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
await tx.memory.link('mem-a1b2c3d4e5f6', 'mem-f6e5d4c3b2a1')
// Or link by filename
await tx.memory.link('mem-a1b2c3d4e5f6', 'deployment-guide.md'){
"tool": "tx_memory_link",
"arguments": {
"sourceId": "mem-a1b2c3d4e5f6",
"targetRef": "deployment-guide.md"
}
}Parameters
| Parameter | Required | Description |
|---|---|---|
sourceId | Yes | Source memory document ID |
targetRef | Yes | Target reference (document ID, title, or filename) |
POST /api/memory/links
Content-Type: application/json
{
"sourceId": "mem-a1b2c3d4e5f6",
"targetRef": "deployment-guide.md"
}Example
curl -X POST http://localhost:3456/api/memory/links \
-H "Content-Type: application/json" \
-d '{"sourceId": "mem-a1b2c3d4e5f6", "targetRef": "deployment-guide.md"}'Agent Workflow
#!/bin/bash
# Agent uses memory to find relevant context before starting a task
TASK=$(tx ready --json --limit 1 | jq -r '.[0].id')
TITLE=$(tx show "$TASK" --json | jq -r '.title')
# Search memory for relevant documents
CONTEXT=$(tx memory search "$TITLE" --semantic --expand --json)
# Feed context into the agent prompt
claude --print "
Task: $TASK — $TITLE
Relevant docs: $CONTEXT
Read CLAUDE.md, implement the task, then run tx done $TASK
"
# After completing the task, create a memory document with findings
tx memory add "Implementation Notes: $TITLE" \
-c "## Approach\n...\n## Decisions\n..." \
-t implementation "$(echo "$TITLE" | tr ' ' '-')"Memory vs Learnings
| Feature | tx memory | tx learning |
|---|---|---|
| Storage | Filesystem (.md files) | SQLite database |
| Ownership | Your files, tx indexes them | tx owns the records |
| Structure | YAML frontmatter + markdown body | Flat text with category |
| Navigation | Graph (wikilinks, related, edges) | Flat list |
| Search | BM25 + vector + graph expansion | BM25 + vector + recency |
| Best for | Project docs, notes, wikis | Short insights, patterns, mistakes |
Use memory for rich, structured documents with relationships. Use learnings for quick insights that should surface in tx context.
Related Commands
tx learning- Record and search structured knowledgetx context- Get learnings relevant to a task