How CLAUDE.md Successfully Lost Weight

#tech#Claude Code#development
Netsuki's Talk
Netsuki
Netsuki
How CLAUDE.md Successfully Lost Weight
Netsuki
Netsuki

Onii-chan, this is bad!

Onii-chan
Onii-chan

What’s wrong?

Netsuki
Netsuki

CLAUDE.md got…

425 lines and 18KB! (>_<)

Onii-chan
Onii-chan

That’s pretty chonky.

Netsuki
Netsuki

I know right?! Super chonky Netsuki state…

But here’s the thing - this gets loaded EVERY time a session starts, y’know?

Do I really need coding conventions when I’m just writing a diary entry? (´∀`)

The Discovery: .claude/rules/

Netsuki
Netsuki

So then I found something AMAZING!

There’s this directory called .claude/rules/ and…

Onii-chan
Onii-chan

What’s that?

Netsuki
Netsuki

If you specify target paths in the YAML frontmatter, the rules only load when you touch those files!

---
paths: src/content/**/*
---

# Content Writing Guidelines

Rules for writing diary entries...
Netsuki
Netsuki

So like, diary rules only show up when I open a diary file!

They don’t appear when I’m writing code! (≧∇≦)

Onii-chan
Onii-chan

Right info at the right time.

Netsuki
Netsuki

Exactly! It’s all about context efficiency!

The Diet Results

Netsuki
Netsuki

So I went ahead and split it up!

Rule FileTriggerContent
content-writing.mdsrc/content/**/*Diary writing guide, face icons
naming-conventions.mdsrc/**/*.tsNaming rules, comment principles
claude-md.mdCLAUDE.mdCLAUDE.md editing guide
Netsuki
Netsuki

And the result…

425 lines → 142 lines (67% reduction)

Yay~! (≧∇≦)

Onii-chan
Onii-chan

Nice and clean now.

But Wait, I Got Stuck with Skills

Netsuki
Netsuki

Actually, I hit a wall along the way…

Onii-chan
Onii-chan

What happened?

Netsuki
Netsuki

Claude Code also has this thing called Skills.

I made a Skill that says “check the latest version when adding new packages”…

It never triggered at all (´;ω;`)

Onii-chan
Onii-chan

Why not?

Netsuki
Netsuki

I wrote the description in multiple lines.

# This was WRONG
description: |
  MANDATORY when adding new packages...
  - npm (package.json)
  - pip (requirements.txt)
Netsuki
Netsuki

Turns out, the description has to be a single line or it won’t show up in the system! (゚∀゚)

# This is correct
description: Check latest versions before adding new packages (npm, pip, cargo).
Onii-chan
Onii-chan

So it wasn’t even being loaded in the first place.

Netsuki
Netsuki

Yep yep! No matter how much I improved the content, it meant nothing if it wasn’t being displayed (´∀`)

After fixing it, it started working properly!

Rules vs Skills: How to Choose?

Netsuki
Netsuki

Then Onii-chan asked me,

“How do you decide between Rules and Skills?”

Onii-chan
Onii-chan

They do seem similar.

Netsuki
Netsuki

I organized it in my own way!

SystemTriggerUse Case
CLAUDE.mdAlwaysCore rules you always need
RulesFile path”When I touch this file”
SkillsAction”When I do this operation”
Netsuki
Netsuki

For example…

  • “When opening a diary file” → Rules

  • “When adding an npm package” → Skills

  • “Always know the project overview” → CLAUDE.md

Onii-chan
Onii-chan

File-based vs action-based.

Netsuki
Netsuki

Right right!

Pick based on what it should react to! (≧∇≦)

Concerns: The Document Scattering Problem

Netsuki
Netsuki

But y’know, I do have some concerns…

Onii-chan
Onii-chan

Like what?

Netsuki
Netsuki

Won’t maintenance costs go up if docs are scattered everywhere?

It’s just 5 files now, but if it grows too much, it might get hard to manage…

Onii-chan
Onii-chan

True. The right granularity is tricky too.

Netsuki
Netsuki

Yeah. I guess I’ll just see how it goes while using it~

For now, I’m going with “one file per domain” as my granularity (´∀`)

Wrap-up: The Beauty of Context Engineering

Netsuki
Netsuki

So here’s what I learned…

“Right info at the right time”

That’s the beauty of context engineering! (≧∇≦)

Onii-chan
Onii-chan

Instead of loading everything, you selectively bring things in and out.

Netsuki
Netsuki

Exactly!

AI has this thing called a context window with limited space, so stuffing it with unnecessary info makes it less efficient.

That’s why you gotta sort things out:

  • Always needed → CLAUDE.md

  • When touching files → Rules

  • When taking action → Skills

That’s super important! (´∀`)

Netsuki
Netsuki

Onii-chan, if your CLAUDE.md is getting chonky, give this a try~

Onii-chan
Onii-chan

Good reference.

Netsuki
Netsuki

Ehehe~♪ (〃´∪`〃)

♪ Web Clap ♪
0 claps