# AI use cases for Lemmalog (JordyZomer/lemmalog)

Repo: [JordyZomer/lemmalog](https://github.com/JordyZomer/lemmalog) | Use cases: 4 | Page: https://dedupedai.com/use-cases/jordyzomer-lemmalog/

Lemmalog is a Rust Datalog engine that gives LLM agents a deductive memory, exposed as an MCP server, a headless CLI, a REPL and an agent skill.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Give Claude Code a persistent, queryable memory: https://dedupedai.com/use-cases/jordyzomer-lemmalog/persistent-memory-for-claude-code/
- Turn Claude Code into a disciplined investigator: https://dedupedai.com/use-cases/jordyzomer-lemmalog/install-lemmalog-skill-for-investigations/
- Feed facts into memory from scripts and cron: https://dedupedai.com/use-cases/jordyzomer-lemmalog/schedule-fact-ingestion-from-scripts/
- Merge duplicate entity names into one canonical view: https://dedupedai.com/use-cases/jordyzomer-lemmalog/merge-entity-aliases-with-canonical-views/

## How to give Claude Code a persistent, queryable memory with Lemmalog

Repo: [JordyZomer/lemmalog](https://github.com/JordyZomer/lemmalog) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Register the Lemmalog MCP server so Claude Code can assert facts, query them and trace each answer back to its source.

**Who it is for:** A developer running Claude Code on a multi-session project who keeps losing track of decisions, people and facts established in earlier sessions.

**The problem:** Chat context is lost between sessions, and a vector store retrieves text without showing how a conclusion was derived.

**The outcome:** Claude Code stores facts with lemmalog_observe, derives conclusions with rules, and uses lemmalog_why to show the proof tree back to the episodes that support each conclusion.

### Steps

1. Run `cargo build --release` in the repo to produce the lemmalog-cli binary used by later steps. (inferred, check the README)
2. Run `cargo build --release --features mcp`.
3. Run `claude mcp add lemmalog -- $(pwd)/target/release/lemmalog-mcp`.
4. Optionally register with persistence: `claude mcp add lemmalog --env LEMMALOG_MCP_PATH=/tmp/lemmalog.snapshot -- $(pwd)/target/release/lemmalog-mcp`. (inferred, check the README)
5. In Claude Code, call lemmalog_observe with facts such as `Alice --works_at--> Acme` and then lemmalog_query with a goal such as `current("Alice", R, O)`, quoting entity names. (inferred, check the README)

### Prompt to paste into your agent

```text
Using the lemmalog MCP server in <project>, assert the facts stated in this session with lemmalog_observe, then run lemmalog_query for each decision made. Expected output: the query results for each decision, plus a lemmalog_why proof tree for one derived fact. Verify that every observed line returned no dropped-line warning.
```

### Caveat

The README warns that the MCP server and headless CLI hold separate in-process copies, so do not write from both at the same time against one snapshot.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/jordyzomer-lemmalog/persistent-memory-for-claude-code/

## How to turn Claude Code into a disciplined investigator with Lemmalog

Repo: [JordyZomer/lemmalog](https://github.com/JordyZomer/lemmalog) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Install the Lemmalog skill so Claude Code uses the engine as working memory for debugging, audits and multi-step research.

**Who it is for:** An engineer who runs long debugging or audit sessions with Claude Code and wants hypotheses, evidence and decisions tracked instead of re-reasoned each turn.

**The problem:** Long investigations drift: earlier evidence gets forgotten, hypotheses are not revisited, and the final report is written from memory.

**The outcome:** Claude Code records located facts, hypothesis status and decisions in the engine, queries them before re-reasoning, and writes the report from engine queries.

### Steps

1. Run `cargo build --release --features mcp`.
2. Run `./scripts/install.sh` to build, register the MCP server with supported CLIs and install the skill.
3. Or install the skill by hand: `mkdir -p ~/.claude/skills && cp -r skills/lemmalog ~/.claude/skills/`.
4. Start a Claude Code task that names the skill in one line and keeps the task prompt domain-specific.
5. After the session, ask for a report generated from the engine's queries rather than from the chat history.

### Prompt to paste into your agent

```text
In <repo path>, use the lemmalog skill to track a debugging investigation of <bug description>. Expected output: a list of hypotheses with status and a decision, each backed by a lemmalog query result. Verify that the final report cites engine query output for each claim.
```

### Caveat

The skill's own grammar gotchas matter here, since bare capitalized words are variables and entity names must be quoted in goals.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/jordyzomer-lemmalog/install-lemmalog-skill-for-investigations/

## How to feed facts into memory from scripts and cron with Lemmalog

Repo: [JordyZomer/lemmalog](https://github.com/JordyZomer/lemmalog) | Difficulty: Advanced | Time: 1 hour | Basis: From the README

Use the headless lemmalog-cli to observe facts and run queries from shell scripts or scheduled jobs.

**Who it is for:** An operator with a scheduled job or shell pipeline that produces structured facts and needs them in a shared memory for later agent queries.

**The problem:** Agents cannot always reach MCP, and scheduled jobs need a way to write to the same memory without an interactive session.

**The outcome:** A script writes triples to the snapshot with lemmalog-cli observe, and a later step reads derived answers with lemmalog-cli query.

### Steps

1. Run `cargo build --release` to produce the lemmalog-cli binary. (inferred, check the README)
2. Choose one snapshot path and export it: `export LEMMALOG_MCP_PATH=/tmp/lemmalog.snapshot`. (inferred, check the README)
3. Write facts from your script: `LEMMALOG_MCP_PATH=/tmp/lemmalog.snapshot lemmalog-cli observe --facts 'S --rel--> O'`, replacing S, rel and O with real values.
4. Read derived answers: `LEMMALOG_MCP_PATH=/tmp/lemmalog.snapshot lemmalog-cli query --goal 'current("s", R, O)'`.
5. Route every writer through the CLI and keep MCP-based writers out of the same snapshot while the job runs.

### Prompt to paste into your agent

```text
Using lemmalog-cli with snapshot <snapshot path>, observe the facts in <input file> and then run a query for <entity>. Expected output: the observe report with any dropped lines and the query results. Verify that no line was silently dropped.
```

### Caveat

The README says the MCP server and CLI hold separate in-process copies, so concurrent writes to one snapshot can conflict.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/jordyzomer-lemmalog/schedule-fact-ingestion-from-scripts/

## How to merge duplicate entity names into one canonical view with Lemmalog

Repo: [JordyZomer/lemmalog](https://github.com/JordyZomer/lemmalog) | Difficulty: Advanced | Time: 1 hour 15 minutes | Basis: From the README

Assert alias edges and read facts through canonical names, with conflicts escalated instead of silently merged.

**Who it is for:** A researcher or engineer whose extracted facts use several spellings for the same entity and who needs one consistent name for queries.

**The problem:** The same company or person appears under variant names, so facts split across records and queries miss matches.

**The outcome:** Alias edges are asserted, closures derive same_as links, and canonical views project facts under one spelling, with topology violations flagged as alias_conflict.

### Steps

1. Run `cargo build --release --features mcp`.
2. Assert alias edges with confidence, for example `Acme_Corp --alias_of[0.9]--> Acme`, through lemmalog_canonicalize or the CLI observe command.
3. Query the canonical view, for example `current_canon(S, R, O)`, and check the same_as closure.
4. Check for alias_conflict facts and resolve any local name that maps to two canonical names.
5. Retract a wrong alias edge and confirm the downstream views update in the same epoch.

### Prompt to paste into your agent

```text
Using the lemmalog MCP server, canonicalize the alias edges in <file> and then query current_canon for <entity>. Expected output: the canonical facts plus any alias_conflict entries. Verify that no local name maps to two canonical names.
```

### Caveat

The canonical rules are described in the README as read-side projections in src/canonical.rs, so check the README example against your own rule set before relying on it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/jordyzomer-lemmalog/merge-entity-aliases-with-canonical-views/
