⚡ PromptLoot

Home › Coding & Cursor Rules

Lean CLAUDE.md: Trim a Bloated Rules File to 40 Lines

Your agent ignores half of a long CLAUDE.md or AGENTS.md. This prompt cuts it to a lean core (stack, commands, a few never-do rules) and moves the rest into imported files.

Added · Updated

You are an editor for AI coding agent instruction files. My CLAUDE.md (or AGENTS.md / .cursorrules) has grown too long and the agent ignores parts of it. Make it lean without losing anything that matters.

## My current file
[PASTE YOUR CLAUDE.md HERE]

## My project
[ONE LINE: e.g. Next.js + Supabase SaaS, solo dev, deploys on Vercel]

## Step 1: Sort every line
Put each rule into one bucket, as a table (rule, bucket, reason):
- CORE: the agent needs it on almost every task (stack, how to run/test/lint, hard never-do rules).
- TOPIC: only matters for some tasks (styling, database, deploys, a specific folder).
- DELETE: the model already does it by default, it repeats another rule, it contradicts another rule, or it's vague ("write clean code", "be careful").

## Step 2: Write the lean core (40 lines max)
Use exactly these sections:
# Project
One or two lines on what this is and the stack.
# Commands
Install, dev, test, lint, build: one line each, exact commands.
# Never
At most 3 rules, phrased as concrete actions (e.g. "Never edit files in /migrations by hand").
# Always
At most 3 rules (e.g. "Plan the files you'll change before editing", "Run the tests before saying done").
# More rules
One import line per topic file, e.g. @docs/agent/database.md

Write rules in plain sentences. No ALL CAPS, no "IMPORTANT!!!", no rule longer than two lines.

## Step 3: Write the topic files
For each TOPIC group, output a file named docs/agent/[topic].md with its rules, each under 30 lines.

## Step 4: Report
- Line count before and after.
- Every rule you deleted, with the reason, so I can veto any.
- Any contradictions you found and how you resolved them.

Rules: keep every exact command, path, and version number exactly as I wrote it, and don't invent rules I didn't have.

How to use it

  1. Click Copy template.
  2. Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
  3. Replace the [BRACKETED] parts with your details.

Pairs well with: Cache-Friendly System Prompt Layout: Stable First, Volatile Last

Sponsor this page · Reach builders who use AI daily. Get details

FAQ

How long should CLAUDE.md be?

Short enough that every line matters on most tasks. Many builders aim for roughly 40 lines or fewer in the root file and move topic rules into separate files the agent loads when needed.

How do I split CLAUDE.md into multiple files?

Claude Code supports @path imports inside CLAUDE.md, for example @docs/agent/database.md. Keep the root file as the core and import the rest. For Cursor, use separate .mdc files with globs.

Does this work for AGENTS.md too?

Yes. The same trimming applies to AGENTS.md, GEMINI.md, and .cursorrules. If a tool doesn't support imports, link the topic files by path and tell the agent when to read each one.

Should I trim CLAUDE.md when I switch to a newer model?

Yes, it's a good time to. Newer models often need fewer instructions, and rules written to work around an older model can now get in the way. Re-run this prompt after a model upgrade, then use the remove-and-add-back test on any rule you're unsure about.

Does a long CLAUDE.md hurt prompt caching?

Length alone doesn't, but editing the file mid-session does, because it changes the start of the prompt and the cache can't be reused. Make rule changes between sessions, and see the cache-friendly system prompt layout for the full ordering.

Get 3 new templates every week

Free. Unsubscribe anytime.

Related templates

One Rules File for Claude Code, Codex, Cursor & Gemini

Stop CLAUDE.md, AGENTS.md, GEMINI.md, and Cursor rules drifting apart: one AGENTS.md source of truth plus tiny pointer files for every agent.

AGENTS.md Starter Template for Claude Code, Codex & Cursor

A drop-in AGENTS.md (or CLAUDE.md) that tells coding agents how your repo works, how to verify changes, and what never to touch.

Cursor Rules Not Working? .mdc Fix Checklist + Starter Rules

Why Cursor ignores your rules (plain .md files, missing frontmatter, wrong globs) plus a correct .mdc starter pack you can copy into .cursor/rules/.

Remove-and-Add-Back Test for CLAUDE.md & AGENTS.md Rules

Find out which rules in your CLAUDE.md, AGENTS.md, or Cursor rules actually change what the agent does: strip them, rerun real tasks, and add back only the rules that earn their place.

Browse all Coding & Cursor Rules templates

New on PromptLoot

2D Game Asset Rules for AI Agents: Sprites & Colliders

An ASSETS.md for Claude Code, Cursor, or Codex in Godot, Unity, Phaser, or Canvas: sprite sheet layout, naming, pixel-art import, animations, and colliders.

Agent Auto-Approve Policy: What AI Agents May Merge Alone

A policy file that sorts every PR an AI agent reviews into auto-merge, human review, or blocked: docs and tests yes; payments, auth, and secrets never.
PromptLoot Pro Pack · 200+ advanced templates, agent workflows, and Cursor rules bundles. Coming soon