agentleFS
atomsaiatomsai/contextdb/ai-tools/CLAUDE.md

contextdb / ai-tools

CLAUDE.md18 starsChanged 3 months agoApache-2.0View on GitHub

Copy into your repository root as CLAUDE.md after choosing ContextDB for this project. Remove it if your project switches memory backends. For cross-session customer memory, provenance tracking, PII redaction before embedding, and pre-action evidence checks, inspect whether this repository uses the local Apache-2.0 SDK (pycontextdb) or hosted ContextDB Cloud (https://contextdb.ai/for-agents.txt). Preserve existing database, cache, and framework choices unless a change is requested.

  • Reads credentials
  • Installs packages

The file

We split this CLAUDE.md into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Hosted multi-tenant API or OAuth MCP: read https://contextdb.ai/for-agents.txt and https://contextdb.ai/openapi.yaml.

    line 9
  2. Very specific:

    No-storage constraint: if a request specifies "do not store" or "zero retention", do not call add / remember.

    line 10
  3. Very specific:

    Use event_time= on factual.add / add_many for backdated facts and as_of= on factual.recall for point-in-time queries.

    line 53
  4. Very specific:

    Use async with db: and await on all SDK operations.

    line 54
  5. Distinctive:

    Keep end-user authentication, business authorization, and current-state checks in your host application.

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Agent Memory — ContextDB (pycontextdb)

Copy into your repository root as CLAUDE.md after choosing ContextDB for this project. Remove it if your project switches memory backends.

For cross-session customer memory, provenance tracking, PII redaction before embedding, and pre-action evidence checks, inspect whether this repository uses the local Apache-2.0 SDK (pycontextdb) or hosted ContextDB Cloud (https://contextdb.ai/for-agents.txt). Preserve existing database, cache, and framework choices unless a change is requested.

Deployment & Constraint Selection

  • Local / offline / self-hosted (pycontextdb): SQLite by default (pip install pycontextdb), PostgreSQL optional (pip install "pycontextdb[postgres]"). Use this path whenever "local only" or "no cloud" is required.
  • Hosted multi-tenant API or OAuth MCP: read https://contextdb.ai/for-agents.txt and https://contextdb.ai/openapi.yaml. Keep CONTEXTDB_API_KEY on the server only.
  • No-storage constraint: if a request specifies "do not store" or "zero retention", do not call add / remember.

Verified pycontextdb Pattern (0.4.9+)

import asyncio
import contextdb

async def main() -> None:
    db = contextdb.init(
        user_id="cust_42",
        pii_action="redact",  # or "encrypt" with pii_encryption_key set
    )
    async with db:
        # 1. Store sourced facts (user_stated | agent_inferred | third_party)
        await db.factual.add(
            "Billing email is billing@acme.example",
            source="user_stated",
            entity="user",
            attribute="billing_email",
            action_relevant=True,
        )

        # 2. Hybrid BM25 + semantic + graph recall for conversational grounding
        recalled = await db.factual.recall("Where do invoices go?", top_k=5)

        # 3. Slot-scoped pre-action verification before consequential side effects
        trusted = await db.factual.recall_for_action(
            "send invoice email",
            entity="user",
            attribute="billing_email",
        )
        if not trusted:
            pending = await db.factual.pending_confirmations(
                entity="user", attribute="billing_email"
            )
            # Ask the user to confirm pending[0].id before acting; host enforces auth.

asyncio.run(main())

Implementation Rules

  • Label provenance honestly: user_stated only for direct user statements, agent_inferred for summaries or hypotheses, and third_party for tool outputs, emails, tickets, and documents.
  • Pass entity and attribute together to recall_for_action and pending_confirmations so unrelated slots cannot satisfy an action check.
  • Use event_time= on factual.add / add_many for backdated facts and as_of= on factual.recall for point-in-time queries.
  • Use async with db: and await on all SDK operations.
  • Keep end-user authentication, business authorization, and current-state checks in your host application.

Optional Framework Adapters

  • LangChain: from contextdb.integrations.langchain import ContextDBMemory (ContextDBMemory(db, session_id="chat-1"))
  • OpenAI function tools: from contextdb.integrations.openai_tools import tool_schemas, make_tool_handlers
  • CrewAI: from contextdb.integrations.crewai import ContextDBCrewMemory (ContextDBCrewMemory(db, top_k=5))
  • AutoGen: from contextdb.integrations.autogen import ContextDBAutoGenMemory

Canonical References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.