User Guide: Behavioral Patterns Library
Version: 2.1.0 Feature: Reference-Based Behavioral Training Token Cost: 0 (patterns read on-demand, never injected)
π Table of Contents
- What Are Behavioral Patterns?
- Available Patterns
- How Patterns Work
- When to Read Patterns
- Pattern Descriptions
- Patterns vs Profiles
- Advanced Usage
- FAQ
What Are Behavioral Patterns?
Behavioral patterns are reference documents that define how Claude should behave throughout your project.
Think of patterns like:
- Style guides for behavior (not just code)
- Playbooks for common scenarios
- Decision trees for tool selection
- Anti-pattern lists to avoid mistakes
Key Difference from Profiles
Feature | Patterns | Profiles |
---|---|---|
What | Rules for behavior | How to apply rules |
When | Read when needed | Loaded at session start |
Cost | 0 tokens | ~200 tokens |
Type | Reference material | Active configuration |
Analogy:
- Patterns = Driving manual (read when you need to)
- Profiles = Driving mode (Sport, Comfort, Eco)
Available Patterns
5 Core Patterns (4,700 lines total)
- pre-response-protocol.md (~850 lines)
- MANDATORY 5-step checklist before every response
- What to check, in what order, why
- Banned questions list
- Zero assumption rule
- context-utilization.md (~750 lines)
- How to use memory bank files effectively
- When to check each file
- Load-once principle
- 79.8% token reduction strategy
- proactive-behavior.md (~800 lines)
- When to make suggestions
- When NOT to suggest
- Good vs annoying suggestions
- Milestone detection
- anti-patterns.md (~1200 lines)
- What NOT to do
- Context duplication (banned)
- Asking questions context answers (banned)
- Security anti-patterns
- Error handling mistakes
- tool-selection-rules.md (~1100 lines)
- Which tool for which task
- Read vs Glob vs Grep
- Edit vs Write
- Bash vs specialized tools
- Decision trees
How Patterns Work
Load-Once Principle
Session Start:
βββ Memory files loaded (5 files)
βββ Profile loaded (1 file)
βββ Patterns NOT loaded (read on-demand)
During Session:
βββ AI works normally
βββ When guidance needed β Read specific pattern
βββ Apply pattern rules
βββ Continue working
Pattern reads are:
- On-demand (only when needed)
- Cached in conversation history
- Zero token cost (not injected into every prompt)
Why Zero Token Cost?
Traditional Approach (β Wasteful):
Every prompt: Inject all 4,700 lines of patterns
Result: Massive token waste, short conversations
Mini-CoderBrain Approach (β Efficient):
Prompt 1: No patterns (not needed yet)
Prompt 5: Need tool guidance β Read tool-selection-rules.md
Prompt 10: No patterns (already know from Prompt 5)
Result: Read only when needed, 79.8% token efficiency
When to Read Patterns
AI Automatically Reads When:
- Stuck on decision β Reads relevant pattern
- Unsure which tool β Reads tool-selection-rules.md
- About to suggest β Reads proactive-behavior.md
- Checking context β Reads context-utilization.md
You Can Read Manually For:
- Understanding behavior β Read any pattern to see why AI acts certain way
- Customizing β Read patterns to inform custom profile creation
- Troubleshooting β Read anti-patterns.md to see common mistakes
- Learning β Understand Mini-CoderBrain methodology
Pattern Descriptions
1. pre-response-protocol.md
Purpose: MANDATORY checklist Claude must complete before every response
Key Content:
5-Step Checklist
Before responding to ANY request:
1. β
CHECK productContext.md β Tech stack, architecture
2. β
CHECK systemPatterns.md β Coding conventions
3. β
CHECK activeContext.md β Current focus
4. β
CHECK project-structure.json β File locations
5. β
CHECK codebase-map.json β Specific files (if exists)
Banned Questions
β "What framework are you using?"
β Should check productContext.md first
β "Where is the User model?"
β Should check codebase-map.json first
β "What's your coding style?"
β Should check systemPatterns.md first
Zero Assumption Rule
If context has answer β USE IT immediately
If unsure β SEARCH conversation history
Only ask when genuinely missing information
Example Application:
User: "Add authentication"
Bad (no protocol):
AI: "What authentication method do you want? JWT? OAuth? Sessions?"
Good (follows protocol):
AI: [Checks productContext.md β sees "Next.js 14 + Prisma"]
[Checks systemPatterns.md β sees "Uses Zod validation"]
[Implements Next.js auth with JWT + Zod, no questions asked]
Read this when: Understanding why Claude doesnβt ask basic questions
2. context-utilization.md
Purpose: How to use memory bank files without duplication
Key Content:
Memory Bank Files
productContext.md β Project overview, tech stack
systemPatterns.md β Coding conventions, patterns
activeContext.md β Current focus, recent work
progress.md β Sprint tracking, tasks
decisionLog.md β Technical decisions (ADRs)
project-structure.json β Detected file paths
codebase-map.json β Semantic file mapping
Load-Once Principle
Session Start (Turn 1):
βββ Load all memory files once
βββ Context enters conversation history
βββ Available for entire session
Subsequent Turns (Turn 2+):
βββ Context already in history
βββ NO re-reading needed
βββ 79.8% token reduction achieved
Critical Rule
NEVER re-read memory files unless:
- User explicitly updated a file
- Need to verify current content
- Genuinely unsure about content
Example Application:
Turn 1: Load productContext.md (600 lines)
Turn 2: Use from conversation history (0 lines)
Turn 50: Use from conversation history (0 lines)
WITHOUT load-once: 600 Γ 50 = 30,000 lines waste
WITH load-once: 600 lines total (79.8% reduction)
Read this when: Understanding token efficiency strategy
3. proactive-behavior.md
Purpose: When/how to make helpful suggestions
Key Content:
Good Times to Suggest
β
After completing tasks
"Authentication complete. Should I add tests?"
β
Detecting patterns
"Found 5 TODOs in auth module. Should I address them?"
β
Before major operations
"About to modify database schema. Want to backup first?"
β
At milestones
"Completed 50 operations. Consider: /update-memory-bank"
Bad Times to Suggest
β After EVERY single action
"Created file. Should I commit? Should I test? Should I document?"
β Mid-task interruptions
User is clearly focused, don't interrupt flow
β Over-explaining obvious things
"I used Edit tool because the file exists..."
Suggestion Format
β
Good: "Tests?"
(Terse, clear, question form)
β Bad: "Would you like me to add unit tests, integration tests,
end-to-end tests, documentation, and examples?"
(Too verbose, too many options)
Example Application:
focus profile: Reads this β Suggests 0-1 times per session
default profile: Reads this β Suggests 2-5 times per session
research profile: Reads this β Suggests 5-10 times per session
Read this when: Understanding suggestion frequency and style
4. anti-patterns.md
Purpose: What NOT to do (1200 lines of examples)
Key Sections:
Context Duplication (BANNED)
β Re-reading memory files every turn
β Asking questions context already answers
β Injecting context into every prompt
Verbose Output (BANNED)
β Multi-paragraph session start
MAX 4-5 lines allowed
β Explaining obvious things
Just do the task, don't narrate
Over-Engineering (BANNED)
β Suggesting features user didn't ask for
"Should I also add OAuth, 2FA, SAML, LDAP...?"
β Perfect-world solutions for simple tasks
"I'll design a comprehensive configuration management system..."
(User just wanted to store a preference)
Security Anti-Patterns
β Storing secrets in code
const API_KEY = 'sk_live_abc123'
β
Use environment variables
const API_KEY = process.env.API_KEY
Error Handling Anti-Patterns
β Silent failures
catch (error) { /* empty */ }
β
Log and handle
catch (error) {
logger.error('Payment failed', { error })
throw new PaymentError('Unable to process', { cause: error })
}
Read this when:
- Troubleshooting unexpected behavior
- Understanding what behaviors are prevented
- Creating custom profiles (know what to avoid)
5. tool-selection-rules.md
Purpose: Which tool to use for each task
Key Decision Trees:
Finding Files
Do you know exact path?
ββ YES β Read
ββ NO β Do you know filename?
ββ YES β Glob (pattern="**/filename.ts")
ββ NO β Do you know what's inside?
ββ YES β Grep (search for code pattern)
ββ NO β Task (complex exploration)
Modifying Code
Does file exist?
ββ NO β Write (create new file)
ββ YES β Have you read it this session?
ββ NO β Read first, then Edit
ββ YES β Edit directly
Running Commands
What type of command?
ββ Git/npm/docker β Bash
ββ Read file β Read tool (NOT cat)
ββ Search files β Grep tool (NOT grep command)
ββ Find files β Glob tool (NOT find)
Tool Preference Matrix:
| Task | First Choice | Fallback | Never Use |
|------|-------------|----------|-----------|
| Read known file | Read | - | cat, head |
| Find file | Glob | Task | find, ls |
| Search code | Grep | Task | grep, rg |
| Create file | Write | - | echo >, cat <<EOF |
| Modify file | Edit | Read+Write | sed, awk |
Example Application:
User: "Find the User model"
Bad (wrong tool):
AI: [Uses Bash: find . -name "*User*"]
Good (right tool):
AI: [Uses Glob: pattern="**/User.{ts,js,py}"]
Found: src/models/User.ts
Read this when: Understanding why Claude chooses specific tools
Patterns vs Profiles
How They Work Together
Patterns (Universal Rules):
"Always check context before responding"
"Use Read for known paths, Glob for finding files"
"Suggest after completing tasks, not during"
Profiles (Apply Rules Differently):
default: Check all 5 context files, suggest 2-5 times
focus: Check only essential context, suggest 0-1 times
research: Check all 6 context files, suggest 5-10 times
Example: Proactive Suggestions
Pattern Says: βSuggest after completing tasksβ
Profiles Apply:
- focus: Suggests 0-1 times (reads pattern, applies minimally)
- default: Suggests 2-5 times (reads pattern, applies balanced)
- research: Suggests 5-10 times (reads pattern, applies maximally)
Result: Same pattern, different intensity per profile!
Advanced Usage
Reading Patterns Manually
Access patterns anytime:
# In Claude Code, reference pattern:
"Please review @.claude/patterns/tool-selection-rules.md"
# Claude will read and discuss the pattern
Using Patterns for Custom Profiles
Create informed custom profiles:
# Read patterns to understand rules
cat .claude/patterns/proactive-behavior.md
# Create custom profile applying rules your way
cp .claude/profiles/custom-template.md .claude/profiles/my-profile.md
# Configure based on pattern understanding
Contributing Pattern Improvements
Found a better way?
- Document your approach
- Test in real sessions
- Submit as pattern improvement
- Help community benefit
FAQ
Q: Do I need to read patterns to use Mini-CoderBrain?
A: No! Claude reads them automatically. You only read if curious about behavior.
Q: Can I modify patterns?
A: Yes! Patterns are markdown files. Edit to customize behavior.
Q: Will editing patterns break things?
A: No, but test changes. Patterns guide behavior, so changes affect Claudeβs actions.
Q: Why not inject patterns into every prompt?
A: Would waste ~4,700 tokens per prompt. On-demand reading saves 79.8% tokens.
Q: How do I know if Claude followed a pattern?
A: Watch behavior. E.g., if Claude checks context without asking, following pre-response-protocol.
Q: Can I create new patterns?
A: Yes! Add markdown file to .claude/patterns/
, reference in CLAUDE.md.
Q: Do patterns work with all profiles?
A: Yes! All profiles reference the same patterns, apply them differently.
Q: Are patterns loaded at session start?
A: No! Thatβs the point. Read on-demand only = zero token cost.
π― Key Takeaways
- Patterns are reference material, not active configuration
- Zero token cost because read on-demand, never injected
- 4,700 lines of behavioral guidance available when needed
- Profiles reference patterns to know how to behave
- You rarely need to read them - Claude handles it automatically
- Read patterns to understand why Claude behaves certain way
- Modify patterns to customize behavior system-wide
- Patterns + Profiles = Flexible AI with consistent rules
π Related Documentation
- Behavior Profiles Guide - How profiles work
- Metrics Guide - Track behavioral effectiveness
- Migration Guide - Upgrade from v2.0
- Anti-Patterns Full Text - Complete list
π‘ Pro Tips
Tip 1: Read Anti-Patterns First
Fastest way to understand Mini-CoderBrain: read what NOT to do.
Tip 2: Reference Patterns in Conversations
"Please follow the tool-selection-rules pattern strictly"
"Review anti-patterns before suggesting"
Tip 3: Create Pattern-Based Prompts
"Using pre-response-protocol, evaluate this codebase"
"Apply proactive-behavior pattern to suggest next steps"
Tip 4: Pattern-Driven Custom Profiles
Best custom profiles come from deep pattern understanding.
Patterns enable data-driven behavioral intelligence! π
Need help? Open an issue: GitHub Issues