05. Resources

Make your AI
remember everything
the right way.

Memory is only as useful as the instructions you give your AI for using it. These are tested patterns that make AI assistants genuinely persistent — picking up exactly where you left off, every single session.

Rope Data Structure

Bodies longer than 4 KB are automatically chunked into a linked chain of nodes. You write one string; asanaDB handles the rest. No manual splitting, no lost context. Save everything in the graph. No need for markdown files.

Batch Save

Saving two or more memory nodes at once? memory_save_batch sends them in a single call. Faster, cleaner, and easier for your AI to reason about atomically.

Hottest Path

memory_hottest ranks nodes by recency × frequency. At session start, it surfaces what's actually relevant — without loading your entire memory graph, thus giving your model a "short-term memory".

Fidelity

Forget Writing Essays.
Live on the Edge.

The default AI reflex when asked to remember something is to write a paragraph. That's exactly backwards for a graph database. A traversal can find a node — but it can't answer "what does this relate to?" without re-parsing prose.

Before saving anything, the right first question isn't "what do I know about X?" — that produces a blob. It's "what does X relate to, and how?" — that produces a graph.

Use memory_relate for relationships. Reserve the body field for what genuinely can't be expressed as an edge — raw values, timestamps, free-form notes. Fidelity isn't how much prose you store. It's whether the graph's structure matches what's actually true.

// blob (low fidelity)

memory_save("db_password",
  body: "prod password, used
  by billing-service and
  reporting-job")

// graph (high fidelity)

memory_save("db_password")
memory_relate("db_password",
  "billing-service", "USED_BY")
memory_relate("db_password",
  "reporting-job", "USED_BY")

▲ same fact, one traversal finds it from either side

Live in the graph, not just documented

The graph teaches itself.

This isn't an illustration — it's a real, queryable subgraph saved in asanaDB's own memory. Read the trigger node at session start and one ordinary traversal pulls in the whole methodology behind it. No prompt file, no config flag. The graph instructs whatever's writing to it.

Trigger: before memory writeINVOKEGraph-first memory methodologyENTRY_POINT_FOR
  ▼
First question before any write
  │ LEADS_TO
  ▼
Role of content field
  │ LEADS_TO
  ▼
Edge semantics are model decisions
  │ PRODUCESFidelity

+ Graph-first memory methodology —DEFINES→ Fidelity, directly — the chain closes on itself.

// Choose your AI assistant

Claude + CLAUDE.md

Claude reads a file called CLAUDE.md at the start of every session — globally from ~/.claude/CLAUDE.md, or from the root of any project directory. This is where your memory directives live. Write them once; Claude follows them in every conversation, no reminders needed.

The pattern below is split into three parts: how to wake up at session start, how to save as you go, and how to find what you need mid-session. All three work together — skip one and the others are less useful.

CLAUDE.md
# AsanaDB Memory Directives

## Session Start

At the start of every new conversation, before responding to the first
message, run these two queries in parallel:

1. `memory_search("WIP")` — find any nodes tagged as active or in-progress.
2. `memory_hottest(n=10)` — load the 10 most recently and frequently used nodes.

Do not wait to be asked. These two queries are fast and give you enough
context to pick up exactly where the last session left off.

Do not call `memory_list` at session start — it loads the entire graph and
is only appropriate for admin/debug use.

## Bootstrap (once)

Before your first `memory_save`, check whether a node named
`Trigger: before memory write` already exists (`memory_search`). If it
doesn't, create the graph-first methodology subgraph once, using
`memory_save_batch` for the nodes and `memory_relate` for the edges:

Nodes (name — type — body):
- Trigger: before memory write — Trigger — Read before writing any memory. Points to the methodology below.
- Graph-first memory methodology — Methodology — Ask what this relates to before writing prose; a traversal can't answer relational questions by re-parsing a blob.
- First question before any write — Principle — Not "what do I know about X?" — "what does X relate to, and how?"
- Role of content field — Principle — Residual, not primary. Reserve it for what can't be expressed as an edge.
- Edge semantics are model decisions — Principle — Don't force relationships into a fixed vocabulary; choose the edge label that's actually true.
- Fidelity — Concept — The graph's structure matches what's true, not how much prose is stored.

Edges:
Trigger: before memory write --INVOKE--> Graph-first memory methodology
Graph-first memory methodology --ENTRY_POINT_FOR--> First question before any write
First question before any write --LEADS_TO--> Role of content field
Role of content field --LEADS_TO--> Edge semantics are model decisions
Edge semantics are model decisions --PRODUCES--> Fidelity
Graph-first memory methodology --DEFINES--> Fidelity

From then on, call `memory_context("Trigger: before memory write")`
alongside the session-start queries above — the traversal pulls in the
whole methodology.

## Saving Context

Save immediately after any decision, scope change, completed step, or
discovery. Do not wait until the end of the session.

Ask yourself: if this session were interrupted right now, would the next
session know where we left off? If not, save now.

- Use `memory_save_batch` when saving 2 or more nodes at once.
- When saving a body longer than 4 KB, write it as a single string. asanaDB
  automatically chunks large content using its Rope structure — linked nodes
  behind the scenes, seamless string on your end.
- Prefer `memory_supersede` over creating a new node for something that
  already exists. Clean memory is useful memory.
- Include a **Why:** line and a **How to apply:** line in feedback and project
  memories — so future sessions can handle edge cases without asking.
- Before writing, ask what this relates to — not just what it is. Use
  `memory_relate` for relationships; reserve the body field for what can't
  be expressed as an edge (raw values, timestamps, notes).

## Finding Context

- `memory_search(query)` — fuzzy match by name. Best for topic lookups.
- `memory_context(name)` — full body of a node plus all its related nodes.
  Use when you need to understand something in depth.
- `memory_hottest(n)` — top N nodes by recency × frequency score. Use at
  session start; repeat if context feels stale mid-session.

## Memory Types at a Glance

| Type      | What belongs here                          | Lifespan      |
|-----------|--------------------------------------------|---------------|
| user      | Who they are, preferences, expertise       | Long          |
| feedback  | How they want you to behave (with Why/How) | Long          |
| project   | Active work, decisions, open questions     | Short — update often |
| reference | Pointers to repos, dashboards, docs        | Medium        |

Where to put it

Drop it in ~/.claude/CLAUDE.md to apply globally to all projects, or in the root of a specific repo to scope it to that project. Claude merges both files automatically when both exist.

Local vs. Remote

Same tools, same directives.
Different wire.

Local

asanadb-mcp on the same machine

The MCP binary connects to asanaDB over a Unix domain socket — no network stack, no port configuration. Fast, private, and available on every license tier.

  • ConnectionUnix socket
  • Configzero
  • Available onall tiers

Remote

asanadb-mcp → remote server

Point asanadb-mcp at an asanaDB instance running on another machine. Your AI assistant gets the same memory tools; the graph lives on your server. Requires the RemoteMCP capability.

  • ConnectionTCP
  • Confighost + port
  • Available onStandard / Professional

The directives on this page work identically in both cases. The only thing that changes is the connection string you pass to asanadb-mcp. Everything your AI knows how to do with memory — batch saves, Rope, hottest, context — is available regardless of where the graph lives.

Application SDKs

Use the Compository from your app.

The Compository speaks plain TCP + newline-delimited JSON. Each SDK wraps that protocol with an idiomatic ORM-style API — map typed objects to documents, persist them, and get them back. No graph knowledge required.

Maven

<dependency>
  <groupId>com.asanasoft.asanadb</groupId>
  <artifactId>asanadb-document</artifactId>
  <version>0.16.0</version>
</dependency>

ORM example

import com.asanasoft.asanadb.document.*
import kotlinx.serialization.*
import kotlinx.serialization.json.Json

// Any @Serializable class maps to a Document. "slug" is the lookup key.
@Serializable
data class Article(val slug: String, val title: String, val body: String)

AsanaDbClient("127.0.0.1", 8080).use { client ->
    client.connect()
    client.useDatabase("mydb")

    // No id needed — the server assigns one on insert
    val doc = Document.from(Article.serializer(),
                  Article("hello-world", "Hello World", "My first document."),
                  keyField = "slug")
    val (id) = client.insertOne(doc)     // doc is now bound to client, doc._id is set
    println("stored as _id=$id")

    doc.add("views", 1)
    doc.update()                         // ORM — no client arg needed

    // Look it up later by the business key, not by id
    val found   = client.findByKey("slug", "hello-world")!!
    val article = Json.decodeFromString(Article.serializer(), found.toString())
    println(article.title)               // Hello World
}

Node.js 18+ required for the TypeScript SDK (plain TCP — not browser-compatible). All SDKs at resources/<lang>/asanadb-document in the asanaDB repo.

Sample Dataset

A real connected subgraph to load and explore.

A GraphSON export of a social-network-style graph — People, and the Comments, Posts, and Forums they're actually connected to (not an isolated vertex dump; every edge in the file has both endpoints included, so it imports as a real, walkable graph). Good for a first look at Gremlin traversals and the admin UI's graph view without loading your own data first.

download_sample()

asanadb-sample-social-network.json — 546 vertices, 420 edges

Load it with asanadb graphson-import --file asanadb-sample-social-network.json.