Rag And Memory logo

Rag And Memory

Organization
DevelopersGlobal
rag-and-memory

Patterns for Retrieval-Augmented Generation (RAG) and agent memory systems. Retrieves only relevant context, prevents context bloat, and maintains coherent state across sessions.

Overview

PublisherDevelopersGlobal
Repositoryai-agent-skills
Skill namerag-and-memory
Stars
212
Forks
33
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by DevelopersGlobal on GitHub. Read the source before you install it.

Installation

Install the Rag And Memory AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/DevelopersGlobal/ai-agent-skills/tree/main/skills/rag-and-memory
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/DevelopersGlobal/ai-agent-skills.git /tmp/ai-agent-skills
mkdir -p .claude/skills
cp -r /tmp/ai-agent-skills/skills/rag-and-memory .claude/skills/rag-and-memory
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Rag And Memory in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Rag And Memory on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Rag And Memory is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Overview

RAG and memory systems are how AI agents work with knowledge that exceeds their context window. Done well: agents give accurate, grounded answers. Done poorly: context overflow, hallucination from stale retrieval, and performance degradation.

This skill covers the design principles and failure modes of RAG and memory architectures for production AI systems.

When to Use

  • Building any AI system that needs to access external knowledge
  • When agent context windows are being exceeded
  • When agents need to remember information across sessions
  • When building Q&A, document analysis, or knowledge base systems

Process

Step 1: Choose the Right Memory Architecture

  1. Identify what the agent needs to remember:
    • Ephemeral: Within a single session (use in-context memory)
    • Session-persistent: Across a user's sessions (use external key-value store)
    • Knowledge base: Organizational or domain knowledge (use vector DB + RAG)
    • Procedural: How to do tasks (encode in SKILL.md / system prompt)
  2. Match the memory type to the store:
Memory TypeRecommended Store
In-session factsContext window (summarized)
User preferencesKey-value store (Redis, DynamoDB)
Document corpusVector database (Pinecone, Weaviate, pgvector)
Long-term factsStructured DB + caching

Verify: Each type of information the agent needs has a defined storage mechanism.

Step 2: Design the RAG Pipeline

  1. Chunking strategy: Break documents into chunks at semantic boundaries (paragraphs, sections) — not arbitrary character counts.
  2. Embedding model: Match the embedding model to your query type. Use the same model for indexing and retrieval.
  3. Retrieval: Retrieve top-K most semantically similar chunks. K = 3–7 is usually optimal.
  4. Re-ranking: After retrieval, re-rank by relevance using a cross-encoder. Top K becomes top 3–5 for the prompt.
  5. Context injection: Inject retrieved chunks into the prompt with clear source citations.

Verify: Retrieved chunks are genuinely relevant to the query before injecting into context.

Step 3: Prevent Context Bloat

  1. Summarize, don't accumulate: For long sessions, summarize previous turns rather than appending them indefinitely.
  2. Retrieve, don't pre-load: Only load context relevant to the current query. Don't pre-load everything.
  3. Set context budgets: Define maximum token allocations for: system prompt, retrieved context, conversation history, user message.
  4. Compress before injecting: Summarize long retrieved documents to extract the relevant portion only.

Verify: Total prompt length is within model limits with buffer. Retrieved context is relevant to current query.

Step 4: Handle Retrieval Failures Gracefully

  1. If retrieval returns no relevant results: say so — do not hallucinate an answer.
  2. If retrieved documents are outdated: surface the document date to the user.
  3. If confidence is low: present the retrieved source and let the user evaluate.
  4. Design for "no relevant information found" as a first-class outcome.

Verify: System has defined behavior for failed/empty retrieval.

Step 5: Measure and Optimize

  1. Track retrieval quality:
    • Precision: Are retrieved chunks relevant to the query?
    • Recall: Are relevant chunks being retrieved at all?
  2. Track answer quality: Use RAGAS or similar evaluation framework.
  3. Monitor: context length per query, retrieval latency, hallucination rate.

Verify: Baseline metrics established. Retrieval precision > 80%.

Common Rationalizations (and Rebuttals)

ExcuseRebuttal
"Let's just put everything in the context"Context bloat degrades quality and costs money. Retrieve what's needed.
"The model knows this from training"Training knowledge is stale. Use RAG for current information.
"Vector search is good enough without re-ranking"Re-ranking improves precision significantly. It's a small cost for large quality gain.
"We'll fix retrieval quality later"Poor retrieval quality compounds into poor answer quality. Fix it now.

Red Flags

  • Entire document corpus pre-loaded into every prompt
  • Retrieval returning chunks from unrelated documents
  • No defined behavior for empty retrieval results
  • Context window regularly at 90%+ capacity
  • Agent answering from "training knowledge" instead of retrieved documents
  • No source citations for retrieved information

Verification

  • Memory architecture matches the type of information needed
  • RAG pipeline: chunk → embed → retrieve → re-rank → inject
  • Context budgets defined for all prompt sections
  • Empty retrieval has a defined graceful fallback
  • Retrieval precision measured and > 80%
  • Source citations included in AI responses

References

Frequently asked questions

What does the Rag And Memory AI skill do?

Patterns for Retrieval-Augmented Generation (RAG) and agent memory systems. Retrieves only relevant context, prevents context bloat, and maintains coherent state across sessions.

Why use Rag And Memory on TypingMind?

Because you install it once and use it with any model. Rag And Memory is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Rag And Memory in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/DevelopersGlobal/ai-agent-skills/tree/main/skills/rag-and-memory. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Rag And Memory?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Rag And Memory?

As many as you like. As long as a model supports skills, you can use Rag And Memory with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Rag And Memory AI skill free?

Yes. It is published on GitHub by DevelopersGlobal under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇