Skip to main content
MindStudio
Pricing
Blog About
My Workspace
ClaudeWorkflowsAutomation

How to Build a Learnings Loop for Claude Code Skills That Self-Improve

Learn how to add a learnings.md feedback loop to your Claude Code skills so every session makes your AI workflows smarter and more consistent over time.

MindStudio Team
How to Build a Learnings Loop for Claude Code Skills That Self-Improve

Why Your Claude Code Sessions Keep Starting From Scratch

Every time you start a new Claude Code session, it doesn’t remember what happened yesterday. It doesn’t know that the payment API requires a specific retry pattern, that your staging environment uses a different schema, or that the last three attempts to refactor the auth module failed in exactly the same way.

That’s the core problem with Claude Code skills today — the prompts, workflows, and custom behaviors you build get smarter during a session, but that intelligence evaporates when the session ends. The next session starts over.

A learnings loop fixes this. By maintaining a persistent learnings.md file that Claude reads at the start of every session and updates at the end, your Claude Code workflows accumulate knowledge over time. Each session makes the next one incrementally better, without you having to re-explain context you’ve already established.

This guide walks through the full setup — from file structure to self-improving consolidation to automation.


What a Learnings Loop Actually Is

A learnings loop is a structured feedback mechanism. It captures what worked, what failed, and what patterns emerged during a Claude Code session — then stores those insights in a file Claude can access in future sessions.

It’s not a chat history replay. Replaying old conversations adds noise without signal. A learnings loop extracts the relevant insight and records only that.

It’s also not a replacement for your CLAUDE.md file. These two files serve different purposes:

  • CLAUDE.md — Stable configuration. How to run tests, code style conventions, project structure, environment setup. Things that don’t change session to session.
  • learnings.md — Evolving knowledge. Discoveries made during sessions, patterns that keep appearing, mistakes to avoid, solutions to recurring problems.

Think of CLAUDE.md as your project handbook and learnings.md as the running notes from sprint retrospectives. Both are useful. They’re just not the same thing.


Step 1: Create and Structure Your learnings.md File

Start simple. Create learnings.md in your project root. Structure matters here because Claude needs to parse and update the file reliably across sessions.

Here’s a template that works well:

# Project Learnings

## Patterns That Work
- [Date] Description of what worked and why

## Mistakes to Avoid
- [Date] Description of what went wrong and how to prevent it

## Domain Knowledge
- Key facts about the codebase, APIs, or business logic discovered during sessions

## Open Questions
- Things that need more investigation

## Consolidated Principles
- High-level rules synthesized from the above (reviewed during consolidation runs)

A few structural choices to make deliberately:

Include dates. Learnings age. Something true about your external API in January might be wrong by April. Dates let Claude weight recent entries more heavily and give you a signal for what to prune.

Keep entries atomic. One insight per bullet point. Long paragraphs get processed less reliably. Short, specific notes get used.

Separate raw observations from synthesized principles. The “Consolidated Principles” section is where Claude takes the raw notes and distills them into standing rules. This is where knowledge compounds rather than just accumulates.


Step 2: Wire learnings.md Into Claude Code

Claude Code reads CLAUDE.md automatically. For learnings.md, you need to tell it to.

Open your CLAUDE.md and add a section like this:

## Session Protocol

At the start of each session:
1. Read LEARNINGS.md
2. Briefly summarize what you've loaded from it so I know it's been processed

At the end of each task or session:
1. Identify any new patterns, mistakes, or domain knowledge worth recording
2. Append entries to the appropriate sections of LEARNINGS.md
3. Do not overwrite existing entries — only append, or correct with a dated note

This is the minimal wiring. Claude will now treat reading and writing learnings.md as part of its normal session behavior.

Strengthen the Start-of-Session Check

When you open a new Claude Code session, prompt it explicitly:

Before we begin, confirm you've read LEARNINGS.md and summarize the top 3 most relevant points for today's work.

This forces active processing rather than passive loading. It also gives you an immediate sanity check that the file is being read correctly — which is easy to miss if context loading fails silently.

Build a Custom Slash Command

Claude Code supports custom slash commands through the .claude/commands/ directory. Create a file at .claude/commands/update-learnings.md:

Review the work from this session. Identify new learnings — patterns, mistakes, domain discoveries, or solutions worth remembering. Update LEARNINGS.md with concise entries in the appropriate sections. Include today's date with each new entry.

Now you can trigger a learnings update at any point with /update-learnings. This is useful for long sessions where you want to capture an insight mid-stream before context gets crowded out.


Step 3: Build the Update Ritual

The best learnings loops have a consistent rhythm. Without one, the file gets updated sporadically — too sparse to be useful, or too bloated to be read.

A rhythm that works:

  • During a session: Use /update-learnings when something significant happens — a problem solved, a wrong path discovered, an unexpected API behavior.
  • At session end: Ask Claude to do a final sweep: “Review what we did today and update learnings.md with anything we haven’t captured yet.”
  • Weekly: Run a consolidation pass (covered in Step 4). This is the step that turns raw notes into standing principles.

What Deserves to Be Recorded

Not every observation belongs in the file. Good entries share these qualities:

  • Specific — “The webhook requires HMAC verification in the header, not the body” beats “webhooks need auth.”
  • Reusable — Something a future Claude session would benefit from knowing, not just useful in the current context.
  • Actionable — It should change behavior. If knowing it doesn’t affect what Claude does, skip it.
  • Dated — So it can be aged and pruned during consolidation.

Bad candidates: general coding best practices (those belong in CLAUDE.md or nowhere), one-off situations that won’t recur, things already covered in your codebase documentation.


Step 4: Make the Loop Self-Improving

This is where the loop starts compounding. The goal is for Claude to not just record learnings, but to actively improve the quality of the learnings file over time.

Run a Consolidation Session

Once a week, or when the file exceeds roughly 100 bullet points, run a consolidation. Prompt Claude:

Open LEARNINGS.md. Review all entries. Do the following:
1. Remove entries that are outdated, superseded, or no longer applicable
2. Merge duplicate or closely related entries
3. Identify patterns across multiple entries and write a synthesized principle in the Consolidated Principles section
4. Flag any entries that need human review with [REVIEW NEEDED]

Rewrite the file with these improvements. Show me what changed.

This session typically takes 5–10 minutes. After a few consolidation runs, the “Consolidated Principles” section becomes the most valuable part of the file — standing rules Claude applies without you having to re-explain them every session.

Maintain a Global Learnings File

Some learnings apply to one project. Others apply to everything you build. For those, maintain a second file at ~/.claude/learnings.md — a home directory file Claude can reference across all projects.

Entries worth promoting to the global file:

  • Preferred patterns for error handling or logging
  • Authentication approaches you use frequently
  • Personal preferences about output format, verbosity, or code structure

This separation keeps project-specific noise out of your global context and prevents global preferences from cluttering project files.

Version Control the Loop

Commit learnings.md to your repository. This makes it part of the project’s institutional memory. New team members who set up Claude Code on the project immediately get access to everything the team has learned. Mistakes from last quarter become visible and won’t be repeated.

The git history of learnings.md is itself useful — a record of where complexity concentrated and which problems took the most iteration to resolve.


How MindStudio Extends the Loop

The setup above works well for individual workflows. If you want to automate the consolidation step — or connect the learnings loop to broader agentic workflows — the MindStudio Agent Skills Plugin is a practical addition.

The plugin is an npm SDK (@mindstudio-ai/agent) that lets Claude Code call MindStudio workflows as simple method calls. Instead of manually running a consolidation prompt each week, you can build a MindStudio workflow that processes raw session notes and outputs a cleaned, structured learnings update — then invoke it from Claude Code with agent.runWorkflow():

import { MindStudio } from '@mindstudio-ai/agent';
const agent = new MindStudio();

const result = await agent.runWorkflow('learnings-consolidator', {
  rawNotes: sessionNotes,
  existingLearnings: fs.readFileSync('LEARNINGS.md', 'utf8')
});

fs.writeFileSync('LEARNINGS.md', result.updatedLearnings);

The MindStudio workflow handles the AI reasoning — deduplication, synthesis, pruning — while Claude Code stays focused on the coding work. The infrastructure layer (rate limiting, retries, auth) is handled by the plugin, so there’s nothing to manage.

You can build that consolidation workflow in MindStudio’s no-code builder in about 20 minutes. Connect it to Claude or any of the 200+ available models, add your consolidation prompt, and expose it as an API endpoint. If you’re already building automated AI workflows in MindStudio, the learnings consolidator becomes another node in that system — scheduled to run automatically rather than triggered manually.

You can try MindStudio free at mindstudio.ai.


Common Mistakes That Break the Loop

Letting the File Grow Without Pruning

A learnings.md file with 400 unsorted bullet points is worse than no file at all. Claude loads context into its window, and a bloated file crowds out more useful information. Run consolidation regularly. The file should stay lean enough that Claude can actually use it.

Writing for Documentation, Not for Claude

Some entries get written like developer documentation — thorough, formal, comprehensive. That’s not the goal. Write for a reader who needs to make a decision quickly. Short, specific, action-oriented entries get used. Dense paragraphs get skipped.

Treating Every Insight as Worth Keeping

The bar for inclusion should be: “Would a future Claude session meaningfully change behavior based on this?” If the answer is no, leave it out. Restraint here keeps the file useful.

Blurring the Global and Project Distinction

If everything goes into the project file, your global file never develops. If everything goes into the global file, project-specific context gets diluted. Be deliberate about which level an insight belongs on before you write it down.

Not Verifying the File Is Being Read

Claude Code sessions can fail to load context correctly — especially when files are large or there are multiple competing configuration files in the project. The start-of-session confirmation check described in Step 2 catches this early. Without it, you might run an entire session assuming Claude has context it doesn’t actually have.


Frequently Asked Questions

What is a learnings.md file in Claude Code?

A learnings.md file is a persistent markdown document that stores knowledge accumulated from Claude Code sessions. It captures patterns that worked, mistakes to avoid, domain-specific facts, and synthesized principles. By referencing it in your CLAUDE.md configuration, Claude reads and updates it automatically — giving your AI workflow a form of persistent memory across sessions.

How does Claude Code remember things between sessions?

By default, Claude Code doesn’t retain memory between sessions. Each session starts fresh. To create persistence, you use files like CLAUDE.md for stable project settings and learnings.md for evolving knowledge. These files are read at the start of each session, giving Claude the context to build on previous work rather than repeat it.

What’s the difference between CLAUDE.md and learnings.md?

CLAUDE.md is for stable, declarative configuration — project structure, test commands, code style rules. It changes rarely. learnings.md is for accumulating knowledge from sessions — discoveries, solved problems, mistakes, recurring patterns. It grows over time. Both serve different roles, and a well-functioning Claude Code setup uses both.

Can Claude Code automatically update its own learnings file?

Yes. By adding update instructions to CLAUDE.md and creating a custom slash command like /update-learnings, Claude will append new entries to learnings.md at the end of each session. For fully automated consolidation, MindStudio’s Agent Skills Plugin lets you build a workflow that processes raw notes and rewrites the file on a schedule — no manual prompting required.

How often should I consolidate my learnings.md?

A practical rule: consolidate when the file hits 80–100 bullet points, or once a week — whichever comes first. The consolidation step removes noise, merges duplicates, and synthesizes higher-level principles. Skipping it turns the file into a pile of notes too long to be useful. Automated workflows can handle this on a schedule so you don’t have to remember.

Does a learnings loop work for shared team projects?

Yes, and it often works better with a team than alone. When learnings.md is committed to the repository, every team member’s Claude Code session starts with the accumulated knowledge of the whole team. Mistakes made last month become visible immediately. Established patterns get followed consistently. The main thing to coordinate is write conflicts — establish a convention for who reviews and merges learnings updates, and how often.


Key Takeaways

  • A learnings loop gives Claude Code persistent memory by maintaining a structured learnings.md file that’s read and updated each session.
  • Keep entries short, specific, dated, and actionable. Write for fast decision-making, not documentation completeness.
  • Wire the loop into CLAUDE.md and use custom slash commands to make updates part of normal session rhythm.
  • The consolidation step — reviewing and synthesizing the file weekly — is what separates a useful loop from a pile of notes.
  • Maintain separate project-level and global learnings files. Not every insight belongs in both.
  • Commit learnings.md to source control so it becomes the team’s institutional memory, not just a personal productivity tool.
  • Tools like MindStudio’s Agent Skills Plugin can automate the consolidation step and connect your learnings loop to broader AI workflows.

The setup takes a few hours upfront. After that, it runs quietly in the background — and your Claude Code skills improve with every session, compounding rather than resetting.

Presented by MindStudio

No spam. Unsubscribe anytime.