Skip to content
Concise Rule Writing logo

Concise Rule Writing

This skill should be used when the user asks to 'write a rule', 'create a rule', 'make rule shorter', 'keep rules minimal', 'reduce rule size', 'optimize rule', or needs guidance on writing precise, context-efficient rules for CLAUDE.md.

SKILL.md

Full skill instructions

Concise Rule Writing

Guide for writing precise, short rules that minimize context usage while maximizing clarity and enforceability.

Core Principle

Every token counts. Rules load into context on every interaction. Verbose rules waste tokens and reduce available context for actual work.

Target Metrics

MetricTargetMaximum
Words per rule<3050
Characters per rule<200350
Lines per rule1-23
Total CLAUDE.md<500 words1000 words

Rule Anatomy

A good rule has three components in minimal space:

[CONSTRAINT] [ACTION] [CONTEXT (optional)]

Examples:

Never commit .env files                     # 4 words
Use snake_case for Python variables         # 5 words
Run tests before commit                     # 4 words

Writing Techniques

1. Remove Filler Words

Remove: actually, basically, essentially, really, very, definitely, certainly, obviously, simply, just

BeforeAfter
"You should always make sure to run tests""Run tests before commit"
"It's really important to never commit secrets""Never commit secrets"
"Basically, all API endpoints should have auth""All endpoints require auth"

2. Use Imperative Form

Start with verb. No "you should", "make sure to", "always remember to".

BeforeAfter
"You should use TypeScript for type safety""Use TypeScript"
"Make sure to validate user input""Validate all input"
"Always remember to add error handling""Add error handling"

3. Eliminate Redundancy

BeforeAfter
"Never ever commit any secrets or API keys""Never commit secrets"
"Use consistent naming conventions throughout""Consistent naming"
"All functions should have proper error handling""Handle errors in functions"

4. Use Standard Terms

Replace verbose descriptions with known terms:

VerboseConcise
"Make sure passwords are scrambled""Hash passwords"
"Check that data is correct before saving""Validate before persist"
"Write code that can be tested""Write testable code"
"Don't repeat the same code""DRY code"

5. Scope Implicitly

Don't over-specify when context makes it clear:

BeforeAfter
"In this Python project, use snake_case""Use snake_case"
"When writing React components, use hooks""Use React hooks"
"For all database queries, use parameterized queries""Parameterized queries only"

Rule Patterns

Security Rules

Never commit secrets
Never log passwords
Sanitize all user input
Parameterized queries only
Validate auth on all endpoints

Code Style Rules

snake_case for Python
camelCase for TypeScript
Max 100 chars per line
One class per file

Git Rules

Feature branches only
Run tests before commit
Conventional commit messages
No force push to main

Architecture Rules

Services in /​services
Components in /​components
No business logic in controllers
Dependency injection for testing

Placement Decision

Rule TypeLocationExample
Security-criticalCLAUDE.md"Never commit secrets"
Universal (80%+ tasks)CLAUDE.md"Run tests before commit"
Language-specific.claude/​rules/[lang].md"Use Pydantic for validation"
Framework-specific.claude/​rules/[framework].md"Use React Query for API calls"
With examples needed.claude/​rules/[domain].mdComplex patterns

Optimization Process

Step 1: Draft

Write the rule naturally:

"When working with the database, you should always make sure to use
parameterized queries to prevent SQL injection attacks"

Step 2: Extract Core

Identify the essential constraint:

Use parameterized queries

Step 3: Add Minimal Context

Only if ambiguity exists:

Parameterized queries for all DB access

Step 4: Verify

  • Is it clear? ✓
  • Is it actionable? ✓
  • Is it <50 words? ✓ (6 words)
  • Could it be shorter without losing meaning? No

Step 5: Final

Parameterized queries for all DB access

Anti-Patterns

Avoid: Explanatory Rules

# Bad - includes explanation
Never commit .env files because they contain sensitive information
that could be exposed if the repository is public

# Good - just the rule
Never commit .env files

Avoid: Conditional Chains

# Bad - too many conditions
If working on frontend, use React, and if using React, use hooks,
and if using hooks, prefer useCallback for functions

# Good - separate rules
Use React hooks
Prefer useCallback for callback functions

Avoid: Vague Rules

# Bad - not actionable
Write good code
Be careful with security
Think about performance

# Good - specific and actionable
Max cyclomatic complexity: 10
Sanitize all user input
Index foreign keys

Avoid: Duplicate Intent

# Bad - same intent, different words
Never expose secrets
Don't commit API keys
Keep credentials out of code

# Good - one comprehensive rule
Never commit secrets (keys, tokens, passwords)

Context File Rules

Rules in .claude/​rules/​*.md can be slightly longer since they load on-demand. Still aim for brevity:

# .claude/​rules/​python.md

## Patterns

- Pydantic for API validation
- AsyncIO for I/​O operations
- Type hints on public functions
- Pytest for testing

## Avoid

- Global mutable state
- Bare except clauses
- String concatenation for SQL

Measuring Success

Before Optimization

# CLAUDE.md - 847 words

You should always make sure that whenever you're working with this
project, you remember to never commit any files that contain secrets,
API keys, passwords, or any other sensitive information...

[continues for pages]

After Optimization

# CLAUDE.md - 127 words

## Security
- Never commit secrets
- Sanitize user input
- Hash passwords

## Git
- Feature branches only
- Run tests before commit

## Code
- snake_case (Python)
- camelCase (TypeScript)
- Max 100 chars/​line

## Context
| Task | Read |
|------|------|
| Python | .claude/​rules/​python.md |
| React | .claude/​rules/​react.md |

Result: 85% token reduction, same coverage.

Quick Reference

Rule Checklist

  • <50 words
  • Starts with verb (imperative)
  • No filler words
  • Specific and actionable
  • Not duplicating existing rule
  • Correct placement (critical vs context)

Word Budget Guide

ComponentWords
Single rule3-10
Rule with qualifier10-20
Rule with example20-40
Maximum50

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View