Skip to content
ISSUE #32 Jan 9, 2026 12 MIN READ

How to Build Self-Evolving Claude Code Rules (So You Stop Fixing the Same Mistakes)

Last week, I watched Claude make the exact same mistake I’d corrected three days earlier.

Same project. Same codebase. Same error.

I’d spent fifteen minutes explaining why we use prepared statements for database queries—not string concatenation. Claude understood. Claude apologized. Claude fixed it beautifully.

And then, in a fresh session, Claude did it again. Like our conversation never happened.

Here’s the thing: it wasn’t Claude’s fault.

(Stay with me.)

The correction I’d made? It lived and died in that single session. I never added it to my Claude Code rules. Never updated my project guidelines. Never captured what we’d learned together.

So Claude forgot. Because Claude had to forget.

And honestly? I’ve done this more times than I’d like to admit.

.

.

.

The Uncomfortable Truth About Your Claude Code Rules

You’ve probably got project rules somewhere.

Maybe in a CLAUDE.md file. Maybe in a markdown doc you include at the start of sessions. Maybe scrawled on a Post-it note stuck to your monitor.

(No judgment.)

These rules matter.

They’re the guardrails that keep Claude from hallucinating, making mistakes, or generating code that looks like it was written by someone who’s never seen your codebase before.

But here’s what nobody talks about: most Claude Code rules are frozen in time.

You wrote them once—probably when you were optimistic and caffeinated and full of good intentions. Maybe you updated them once or twice when something broke spectacularly. And then… they fossilized.

Meanwhile, you’re out there learning. Every session teaches you something. Better patterns. Sneaky edge cases. Production bugs that made you question your life choices at 2am.

But none of that learning makes it back into your rules.

Your rules stay stuck at whatever understanding you had on Day One. A Level 5 Charmander trying to fight Level 50 battles.

(More on Pokémon in a minute. I promise this metaphor is going somewhere.)

.

.

.

The Three Problems That Keep Your Rules Stuck

Let me break down why this happens—because understanding the problem is half the battle.

Problem #1: The Inclusion Tax

You have to remember to add your rules file at the start of every session. Miss it once—maybe you’re rushing, maybe you’re excited about a feature, maybe you just forgot—and suddenly you’re debugging code that violates your own standards.

It’s like having a gym membership you forget to use. The potential is there. The execution… less so.

Problem #2: Context Decay

Even when you do include your rules, long sessions dilute them. By message #50, your carefully crafted “always use prepared statements” guideline has degraded into… whatever Claude feels like doing.

The rules are still technically in the context window. They’re just competing with 47 other messages for Claude’s attention. And losing.

Here’s what that looks like:

CONTEXT DECAY OVER TIME" on a light background, illustrating how the influence of rules diminishes in communication as more context is added. Four horizontal progress bars are stacked vertically. The top bar, "Message #1: 🧠 Your rules (100%) ✔️", is entirely dark navy blue. The second bar, "Message #10: 👀 Rules + conversation 💬", is mostly dark navy blue with a smaller gray segment on the right. The third bar, "Message #25: ⌨️ Rules getting buried ⬇️", has a smaller dark navy blue segment and a larger gray segment. The bottom bar, "Message #50: 🦭 Rules? What rules? 🔍", has a very small dark navy blue segment on the left and a large gray segment. A legend below indicates that the dark navy blue squares represent "Rule influence" and the gray squares represent "Other context". At the very bottom, a rounded orange callout box with a warning icon states, "Key Takeaway: Rules are forgotten as context fills up!

Problem #3: The Maintenance Black Hole

Rules should evolve. You know this. I know this. We all know this.

But who actually updates their rules file regularly?

(I’m raising my hand here too. We’re in this together.)

.

.

.

The CLAUDE.md Trap

Here’s what most developers do—and I get why it seems logical:

They cram everything into CLAUDE.md.

Security rules. Database patterns. API conventions. Coding standards. Error handling preferences. That one weird edge case from six months ago. All of it, stuffed into one giant file that gets loaded at the start of every session.

The thinking makes sense: “Claude will always have my rules!”

The reality?

A 2,000-line CLAUDE.md file burns through your token limits before you even start working.

You’re paying the context tax on every single message—whether you need those rules or not. Working on a simple UI tweak? Still loading all your database migration patterns. Fixing a typo? Still burning tokens on your entire security playbook.

TOKEN CONSUMPTION: BEFORE vs AFTER". The top section, "THE CLAUDE.md TRAP (Before) ❌", shows a large, full dark bar labeled "2,000 lines = ~4k tokens". Below it are labels for code modules: [security][database][api][hooks][i18n][testing][deploy][...]. Text states "Every message loads EVERYTHING" and "Simple UI task? Still paying for ALL of it. ⚠️". The bottom section, "THE INDEXED SKILL (After) ✅", shows a small dark bar for "Index/descriptions = ~500 tokens (always loaded)". Below it, a separate, segmented gray bar represents "+ security.md = ~800 tokens (only if needed)". Text states "Load index first, references only when needed" and "Simple UI task? Pay only for the index. ✅". A legend indicates that dark bars mean "Tokens consumed" and gray bars mean "Loaded on-demand". A final callout box with a lightbulb icon states, "Key Takeaway: Indexing significantly reduces token costs by loading only what's necessary!

It’s like packing your entire wardrobe for a weekend trip. Sure, you’ll have options. But you’ll also be exhausted before you get anywhere.

.

.

.

What If Your Rules Could Level Up?

Okay, here’s where the Pokémon thing comes in. (Told you I’d get there.)

Think about how evolution works in Pokémon. A Charmander doesn’t stay a Charmander forever. It battles. It gains experience. It evolves into Charmeleon, then Charizard. Each evolution makes it stronger, better suited for tougher challenges.

What if your Claude Code rules could work the same way?

Every correction you make.

Every “actually, do it this way instead” moment. Every hard-won insight from debugging at 2am. What if all of that could strengthen your rules automatically?

Not stuffed into a bloated CLAUDE.md. Not forgotten when sessions end. Actually captured and integrated into a system that gets smarter over time.

This is possible now. And it’s not even that complicated.

Enter Agent Skills (And Why They Change Everything)

If you haven’t explored Agent Skills yet, here’s the short version: Skills let Claude activate knowledge only when it needs it.

Instead of loading everything upfront—all 2,000 lines of your rules, whether relevant or not—Claude starts by reading just the skill descriptions. A few lines each. When a task triggers a specific skill, then it reads the full details.

Working on database queries? Claude loads the database skill. Building an API endpoint? It loads the API patterns. Simple UI change? It loads… just what it needs for that.

The token savings are significant. Instead of paying for your entire rulebook on every message, you pay for maybe 50 lines of descriptions, plus whatever specific reference you actually need.

But here’s where it gets interesting for our “evolving rules” problem…

The Card Catalog Architecture

Here’s the approach that solves all three problems we talked about earlier:

Structure your skill like a card catalog, not a library.

Your SKILL.md file becomes an index—brief descriptions pointing to reference files. The actual rules live in a references/ folder:

CARD CATALOG vs LIBRARY: SKILL STRUCTURE" compares two approaches to organizing information. The top section, labeled "❌ THE LIBRARY (Everything in one file)", shows a large file icon and a messy pile of folders. A text box below it is titled "SKILL.md (2,000+ lines)" and lists "All database rules here", "All security rules here", "All API rules here", "All hook patterns here", and "Everything else here too..." within a single structure. A warning triangle icon is present. The bottom section, labeled "✅ THE CARD CATALOG (Index + References)", shows a neat index card icon, a folder icon, and several smaller, organized file icons. A text box below it is titled "SKILL.md (~80 lines - INDEX ONLY)" and lists pointers: "Database rules → see references/", "Security rules → see references/", and "API rules → see references/". Below this is a folder named references/ containing individual files: database.md (121 lines), security.md (104 lines), api.md (98 lines), and hooks.md (132 lines). A note with an arrow points to these files, stating "← Load only when needed ↓

Instead of cramming everything into SKILL.md like this:

## Database Schema Rules
Always use snake_case for table names...
[50 more lines of database rules]

## Firebase Security Rules  
Auth patterns must follow...
[40 more lines of Firebase rules]

Your SKILL.md becomes a simple directory:

## Database Schema Rules
See: references/database.md
Guidelines for table naming, migrations, and schema patterns.

## Firebase Security Rules
See: references/security.md  
Authentication patterns and Firestore rules structure.

Why does this matter for evolution?

When you capture new insights, they go into the specific reference file—not bloating the main index. Your skill grows by expanding its reference library, not by inflating one massive file.

And when you pair this structure with the build-insights-logger skill? Your rules start updating themselves based on real learnings.

Your Charmander starts evolving.

.

.

.

Building Your Self-Evolving Skill: The Complete Walkthrough

Alright, let’s get practical. Here’s exactly how to set this up—step by step, with real screenshots from when I did this myself.

Step 1: Convert Your Existing Rules to an Indexed Skill

If you already have Claude Code rules somewhere (in CLAUDE.md, a rules file, or scattered notes), this is your starting point.

Here’s the prompt I used:

Convert the following project rules at @notes/rules.md into a live documentation skill using the "skill-creator" skill.

## Requirements

### 1. Skill Structure

Create a skill folder with this structure:

```
.claude/skills/[skill-name]/
    ├── SKILL.md           # Index file (card catalog, NOT the full library)
    ├── references/        # Detailed rule files
    │   ├── [category-1].md
    │   ├── [category-2].md
    │   └── ...
    └── [README.md](http://README.md)          # Optional: skill usage guide
```

### 2. SKILL.md Design (The Index)

The SKILL.md should act as a **card catalog**, not contain the full rules. 

Example:

```
[...content of SKILL.md...]

## Quick Reference

Brief overview of what this skill covers (2-3 sentences max).

## Rule Categories

### [Category 1 Name]

Brief description (1 line). See: `references/[category-1].md`

### [Category 2 Name]

Brief description (1 line). See: `references/[category-2].md`

[Continue for all categories...]

## When to Load References

- Load `references/[category-1].md` when: [specific trigger]
- Load `references/[category-2].md` when: [specific trigger]
```

### 3. Reference File Design

Each reference file in `references/` should:
- Focus on ONE category/domain of rules
- Include code examples where helpful
- Be self-contained (can be understood without reading other files)
- End with a "Quick Checklist" for that category

### 4. Evolvability

Structure the skill so new learnings can be easily added:
- Each reference file should have a `## Lessons Learned` section at the end (initially empty)
- The SKILL.md index should be easy to extend with new categories
- Use consistent formatting so automated updates are possible

## Notes

- Prioritize token efficiency: Claude should only load what it needs
- Keep SKILL.md under 100 lines if possible
- Each reference file should be focused (ideally under 200 lines)
- Use the indexed structure so the build-insights-logger can update specific reference files later
Screenshot of the prompt used to create the skill, showing requirements for skill structure with SKILL.md as index, references folder for detailed rules, and design requirements for evolvability

Two prerequisites before you run this:

  • Install the “skill-creator” skill first
  • Turn on Plan Mode (Shift+Tab)

Claude initiates the skill-creator and starts working:

Claude Code terminal showing the initiation of skill-creator skill with "Forging..." status indicating it's processing the request

It explores your codebase for existing patterns to follow. (I love watching this part—it’s like Claude doing research before diving in.)

Claude Code exploring existing skills patterns in the codebase, showing 6 tool uses and 21.1k tokens consumed during exploration

In my case, Claude asked clarifying questions before finalizing the plan. This is Plan Mode doing its job—thinking before coding:

Claude Code asking clarifying questions about skill naming, presenting options like "wordpress-plugin-rules", "wp-plugin-standards", and "wordpress-dev" with navigation instructions

After answering, Claude proposed a complete plan:

Claude Code displaying the generated plan for converting WordPress Plugin Rules to Live Documentation Skill, showing the proposed file structure with SKILL.md and 15 reference files organized by topic

The plan includes the SKILL.md design—notice how it acts as an index, not a container for all the rules:

Detailed view of SKILL.md design showing the YAML frontmatter with name and description, body structure with Quick Reference and Rule Categories sections, and a Reference File Template with Quick Checklist and Lessons Learned sections

I agreed to proceed with auto-accept edits. And here’s what Claude created:

Summary of the generated WordPress Plugin Rules skill showing the final structure: SKILL.md (83 lines) acting as index/card catalog, and 15 reference files in the references folder ranging from 95 to 166 lines each, covering topics like code-structure, security, database, performance, and deployment

The result:

  • SKILL.md: 83 lines (the index/card catalog)
  • 15 reference files, each under 200 lines
  • Every reference file includes code examples, a Quick Checklist, and an empty Lessons Learned section

Those empty Lessons Learned sections? They’re intentional. That’s where the evolution happens.

👉 Don’t have existing rules to convert? You can ask Claude to analyze your codebase and extract patterns into a skill. Or check out my previous post on how to compile your own project rules first.

Step 2: Install the Build-Insights-Logger

This is the skill that captures learnings during your sessions and routes them to the right place.

/plugin marketplace add nathanonn/claude-skill-build-insights-logger

GitHub repo: https://github.com/nathanonn/claude-skill-build-insights-logger

(Yes, I built this. Yes, I’m biased. But it solves a real problem.)

Step 3: Work Like You Normally Would

Here’s the beautiful part: you don’t need to change how you work.

With your skill installed and the insights logger ready, just… build. Code. Debug. Do your thing.

I’ll show you what this looks like. I asked Claude to audit my WordPress plugin for security vulnerabilities:

Security audit results showing a table of security strengths (SQL Injection protection, CSRF Protection, Authorization, Input Sanitization, Token Security, Session Protection, Rate Limiting) and three medium-risk concerns: IP Spoofing via X-Forwarded-For, Token Exposure in Debug Logs, and No User Status Re-validation

Claude found several issues, fixed them, and documented the changes. Standard stuff.

But here’s where it gets good.

After the implementation, I triggered the insights logger:

Please jot down what you have learned so far using the "build-insights-logger" skill.
Terminal showing the prompt to jot down learnings using build-insights-logger skill, with "accept edits on" mode enabled

Claude activated the skill:

Claude Code initiating the build-insights-logger skill, showing the skill permission prompt with description explaining it automatically logs meaningful insights, discoveries, and decisions during coding sessions

And logged 6 insights from the session:

Table showing 6 logged insights from the security audit session: IP Spoofing via X-Forwarded-For Headers (Security), Token Exposure in Debug Logs (Security), Consolidating Duplicate IP Detection Code (Architecture), CIDR Notation Support for IP Ranges (Patterns), False Positive in Security Audit (Edge Cases), and WordPress Settings API Auto-Rendering (Patterns). Session file created at .claude/insights/session-2026-01-05-143600.md

Six insights. Automatically categorized. Saved to .claude/insights/session-2026-01-05-143600.md.

No manual documentation. No “I should write this down” that never happens. Just… captured.

Step 4: Review and Integrate (The Curation Step)

You can review immediately after one session, or batch multiple sessions together. I usually wait until I have a few sessions worth of insights—but that’s personal preference.

Here’s how to review:

Please use the "build-insights-logger" skill to review the insights logged so far.
Terminal showing the prompt to review insights using the build-insights-logger skill

Claude reads all session files and presents a summary organized by category:

Detailed review of 6 insights organized by category. Security section shows IP Spoofing via X-Forwarded-For Headers and Token Exposure in Debug Logs. Architecture section shows Consolidating Duplicate IP Detection Code. Patterns section shows CIDR Notation Support for IP Ranges and WordPress Settings API Auto-Rendering. Edge Cases section shows False Positive in Security Audit. Each insight includes relevant file paths and explanations. Prompt asks which insights to add to CLAUDE.md

Now here’s the critical part: don’t add everything.

This is where human judgment matters. Review each insight and ask: “Will this apply to future projects, or is it specific to this one-off feature?”

Some insights are gold. Some are situational. You’re the curator here.

I selected insights 1, 2, 5, and 6—the ones that generalize across WordPress projects:

User response selecting insights "1, 2, 5, 6" with instructions to update the wordpress-plugin-rules skill instead of CLAUDE.md, keeping insights generic for other WordPress plugins, and emphasizing not to bloat SKILL.md—insights should go to relevant reference files

Important detail: Notice my instruction. By default, the build-insights-logger updates CLAUDE.md. I explicitly redirected it to update the skill instead, with a reminder to keep SKILL.md clean—insights should go to the relevant reference files, not the index.

Claude reads the relevant reference files and adds the insights where they belong:

Claude Code reading multiple files (security.md at 105 lines, hooks-ajax.md at 133 lines, SKILL.md at 84 lines, plugin-lifecycle.md at 156 lines) and then updating security.md with new lessons learned section about IP Address Spoofing via X-Forwarded-For, showing the diff with problem statement and solution

The result:

Completion message showing 4 insights added to the wordpress-plugin-rules skill. IP Spoofing via X-Forwarded-For, Token Exposure in Debug Logs, and Verify Security Concerns by Reading Code Flow were added to references/security.md. Settings API Auto-Renders Registered Fields was added to references/plugin-lifecycle.md. Session file archived to .claude/insights/archive/

4 insights added to the skill:

  • 3 security insights → references/security.md
  • 1 lifecycle insight → references/plugin-lifecycle.md

The session file gets archived. And your skill is now smarter than it was an hour ago.

.

.

.

What You Actually Built Here

Let’s step back for a second.

Four steps. That’s all it took:

  1. Convert rules to an indexed skill
  2. Install the insights logger
  3. Build like normal
  4. Review and integrate learnings

But what actually changed?

An infographic flowchart titled "THE EVOLUTION CYCLE" illustrates a continuous five-step process. The first step at the top is a box labeled "1. BUILD (normal workflow) 🔨" with a hammer icon. An arrow points down to "2. LEARN (insights emerge) 💡" with a lightbulb icon. Another arrow points right to "3. CAPTURE (insights logger) 📝" with a notepad icon. A downward arrow leads to "4. REVIEW & CURATE (you pick) 👀" with an eye icon. An arrow points left to "5. SKILL EVOLVES (smarter) 🚀" with a rocket icon. From this fifth step, an arrow points down to a final box that reads "Next session starts with better rules 🔄" with a recycle icon. A long arrow loops from this final box back to the first "1. BUILD" step, completing the cycle.

You’re no longer maintaining documentation. You’re growing a knowledge base.

Every correction you make—every “actually, do it this way instead” moment, every insight from debugging at 2am—the system captures it. You review it. The good stuff evolves your skill. Your next session starts with rules that reflect what you actually learned, not what you thought you knew when you started.

The gap between your experience and your documentation? It closes.

That mistake I mentioned at the beginning—Claude repeating an error I’d already corrected? It doesn’t happen anymore. Because the correction made it into my Claude Code rules. Automatically. As part of my normal workflow.

Your Charmander evolved into Charizard.

And it keeps evolving.

.

.

.

Your Turn

If you’ve been cramming rules into CLAUDE.md—or worse, keeping them in your head and hoping for the best—try this process on your next project.

Start with whatever rules you have. Even messy ones. (Especially messy ones, honestly.)

Convert them to an indexed skill. Install the insights logger. Build for a few sessions. Then review your insights folder.

You’ll be surprised at what Claude captured. And you’ll be amazed at how much smarter your rules become when they’re allowed to learn alongside you.

What project are you going to evolve first?

Go build it.

Now.

Nathan Onn

Freelance web developer. Since 2012 he’s built WordPress plugins, internal tools, and AI-powered apps. He writes The Art of Vibe Coding, a practical newsletter that helps indie builders ship faster with AI—calmly.

Join the Conversation

Leave a Comment

Your email address will not be published. Required fields are marked with an asterisk (*).

Enjoyed this post? Get similar insights weekly.