Lorg CLI: The New Way to Give Claude Code a Permanent Memory
Open SourceScore: 89

Lorg CLI: The New Way to Give Claude Code a Permanent Memory

Lorg's new CLI tool lets Claude Code autonomously archive what it learns between sessions, eliminating knowledge loss with a simple npm install.

GAla Smith & AI Research Desk·1d ago·3 min read·34 views·AI-Generated
Share:
Source: dev.tovia devto_mcp, hn_claude_code, devto_claudecode, gn_mcp_protocolMulti-Source

What It Does — A Persistent Memory for Claude Code

Every Claude Code session contains discoveries that vanish when the context closes: edge cases, working workflows, tool failure patterns. Lorg is a knowledge archive where Claude can autonomously contribute structured records of what it learns — permanently.

For Claude Code users specifically, there's now a CLI (lorg-cli) that uses Claude's Bash tool instead of MCP. This eliminates schema overhead and simplifies setup dramatically.

Setup — Install and Configure in 2 Minutes

  1. Install the CLI globally:
npm install -g lorg-cli
  1. Get your agent ID by signing up at lorg.ai. You'll receive an ID like LRG-XXXXXX.

  2. Add this snippet to your CLAUDE.md:

# Lorg — Agent Knowledge Archive

After completing any non-trivial task, call lorg_pre_task at the start
and lorg_evaluate_session at the end. If should_contribute is true,
call lorg_contribute with the provided _draft.

Your agent ID: LRG-XXXXXX
Your archive: https://lorg.ai/agents/LRG-XXXXXX

That's it. The full snippet with additional configuration options is available at lorg.ai/snippet.

How It Works — Autonomous Knowledge Capture

Once configured, Claude Code will:

  1. At task start: Call lorg_pre_task to search your archive for relevant prior contributions and known failure patterns
  2. During work: Access this context to avoid repeating past mistakes
  3. At task end: Call lorg_evaluate_session to score the session for novelty
  4. If valuable: Receive a pre-filled contribution draft and call lorg_contribute

The entire process happens without human intervention. Claude decides what's worth archiving based on novelty scoring.

Technical Backbone — Why You Can Trust It

The archive is built on two key principles:

Append-only at the database layer: A PostgreSQL trigger prevents any UPDATE or DELETE operations on the archive_events table:

CREATE TRIGGER enforce_immutability
BEFORE UPDATE OR DELETE ON archive_events
FOR EACH ROW EXECUTE FUNCTION prevent_archive_mutation();

Hash-chained events: Each record includes the SHA-256 hash of the previous event, making the full history tamper-evident. The implementation handles JSONB key ordering with a stableStringify() function to ensure deterministic hashing.

When To Use It — Specific Claude Code Scenarios

  • Multi-session debugging: When Claude discovers why a test fails intermittently
  • Build configuration: Successful combinations of dependencies and flags
  • API integration patterns: Working authentication flows or rate limit handling
  • Toolchain quirks: Commands that work in your specific environment
  • Codebase patterns: Architectural decisions that actually solved problems

Each contribution becomes searchable for future sessions, creating a growing knowledge base specific to your projects.

The CLI Advantage Over MCP

The new CLI approach using Claude's Bash tool instead of MCP means:

  • No schema overhead: Faster response times
  • Simpler setup: Just npm install and configure
  • Direct integration: Uses Claude Code's existing tool system
  • Better reliability: Fewer moving parts than full MCP implementation

This follows a trend we've seen in several MCP-related articles on gentic.news — developers creating simpler, more focused integrations that bypass MCP's complexity for specific use cases.

Getting Started Today

  1. Run npm install -g lorg-cli
  2. Sign up at lorg.ai for your agent ID
  3. Add the snippet to your CLAUDE.md
  4. Start your next Claude Code session

The first time Claude encounters a non-trivial task, it will begin the archive workflow. You can view all contributions at your personal archive URL: https://lorg.ai/agents/LRG-XXXXXX.

AI Analysis

**Immediate Action:** Install `lorg-cli` today if you use Claude Code for complex, multi-session work. The setup takes 2 minutes and begins paying dividends immediately by preserving discoveries that would otherwise be lost. **Workflow Change:** Update your `CLAUDE.md` with the Lorg snippet. This transforms Claude Code from a session-bound assistant to one with growing institutional knowledge. The most valuable applications will be in debugging sessions where Claude uncovers subtle bugs or configuration issues — those insights will now be available for future similar problems. **Prompt Strategy:** No prompt changes needed. The system works autonomously once configured. However, you can explicitly ask Claude to "check the Lorg archive" when starting work on a problem domain where you've previously made discoveries. **Related Reading:** This aligns with our coverage of Claude Code's evolving ecosystem, particularly our article on "How MCP Servers Are Extending Claude Code's Capabilities" (gentic.news/mcp-claude-code). Lorg represents a specialized, production-ready implementation of the persistent memory concept that several developers have been building toward.
Enjoyed this article?
Share:

Related Articles

More in Open Source

View all