Skip to Content
Search & AskText to Cypher

Text to Cypher

⌘2. Your question goes to Claude (through Claude Code) or ChatGPT (through Codex) with your graph’s shape, and comes back as one Cypher query and a one-sentence explanation. The query runs on your Mac.

What the model is told

The system prompt says it translates questions about a personal knowledge graph into a single Cypher query for LadybugDB, that the person sees the results on a canvas and in a table, and gives it exactly the shape: each node table with its columns (and which is “the node’s title”), each relationship table with the pairs it connects, its columns, and “two-way, so match it without direction” where that’s so. Then the rules:

  • It must only read; CREATE, MERGE, SET, DELETE, DROP, ALTER, COPY and CALL are refused. If the question asks to change the graph, or can’t be answered from this shape, return an empty query and say why.
  • Return whole nodes and relationships so they can be highlighted, not individual properties; scalars only for counts, aggregates or specific values, with short readable aliases.
  • Follow the listed directions; use an undirected pattern only when the question doesn’t care.
  • Compare text loosely: lower(n.title) CONTAINS lower('free energy'), using the title property.
  • The dialect notes (see Raw Cypher).
  • Ids: when the question contains a UUID, match it exactly ignoring case; otherwise never return id as a column.
  • Add a LIMIT only when the question asks for one; ORDER BY when the question implies an order, since large answers are paged in the order returned.
  • The explanation is one plain sentence for the person, with no Cypher syntax in it.

Only the question and the shape go out. Not a node, not a value.

The trail

  1. Translating to Cypher · Sonnet, with the model’s thinking streaming under it (“Thinking · 4 s” and the latest line; click to read all of it; afterwards “Thought for 12 s”).
  2. Translated to Cypher · Sonnet · 3.2 s: click the chevron to open the query, syntax-coloured, with Copy and Edit and re-run.
  3. Running on your graph → Ran on your graph · 12 rows · 4 ms.
  4. The explanation in italics, then the results.

Repair

If the database rejects the query, the trail says The database rejected the query with the error, then Repairing the query: the model sees the question, its attempt and the error, and writes a corrected one. Up to two repairs; then it stops.

Cached answers

The same question on the same shape doesn’t ask the model again: the trail says Used cached query · Sonnet · no API call and runs the saved query. If that query no longer runs (the shape changed), the model is asked with the failure attached. A button under the explanation, Ask Claude again, routes and translates afresh instead.

Refusals

Ask to delete something and the model returns no query; the trail shows No query for this with its explanation (“Ask only reads your graph; deleting is done in Graph mode.”). Ask something the shape can’t answer and the same happens, with the reason.

Narrowing

When an answer is large (or hit the 500-row cap) and the model wrote the query, the pager under the canvas offers Narrow with Claude. The model is shown the question, the query that answered it and how many rows it returned, and asked for a narrower query that keeps the results that matter most: filter more specifically where the question allows, ORDER BY what makes a result relevant, LIMIT around 25, and say in the explanation what it now leaves out. The trail shows Narrowing the query → Narrowed the query.

Every query, written by the model or by you, passes the same guard and runs in the same read-only transaction. The model is also told this, so it knows to refuse rather than try.

Models and effort

The model and its effort are the Writes queries choice in the mode popover’s AI models tab, or Settings › Model. Each answer’s meta says which model actually answered (the tool may report a dated id; it’s shown by family: Sonnet).