Tags: claude-code repository-instructions coding Code & Dev Template: Markdown Input: Repository (code, document) Output: Updated_or_proposed_CLAUDE_md_changes (document, text) anthropic-claude-*

Set Up a Self-Improvement Protocol in CLAUDE.md

Use Claude Code in Plan mode to add a concise self-improvement protocol to the repository’s CLAUDE.md while preserving existing guidance and respecting a 2,500-token limit.

By Threads — Published on

Screenshots

Prompt template

In Claude Code, select Claude Opus 4.7, set Access permissions to Plan mode, and run this prompt:

Read and follow these instructions in this repository.

Update the CLAUDE.md file at the repository root. Create it if it does not exist. If it exists, read it in full and preserve its existing content. Add the block below immediately after the project heading; if there is no project heading, add it at the beginning. Consolidate duplicate rules when appropriate, but do not silently remove existing guidance.

Before editing, estimate the file’s total size in tokens after the addition. If it would exceed 2,500 tokens, first show me which overlapping or outdated rules you propose to consolidate or remove, and wait for my approval before making those changes. Keep the file within 2,500 tokens.

Add this block:

## Self-improvement protocol
- After any correction I make, propose a concise rule and add it to the appropriate section of this CLAUDE.md.
- Write each rule as one imperative sentence, without justification or examples unless the case is ambiguous.
- Search this file before adding a rule. If an existing rule already covers the case, refine that rule instead of duplicating it.
- Keep CLAUDE.md within 2,500 tokens by merging overlapping rules and removing outdated ones when needed.
- After fixing a bug, record a rule about the root-cause class, not the specific symptom.

Comments — 0

Related prompts