Preface
- Who this is for
- What you will learn
- The honesty note
- The labels
- The running examples
- How to use this book
- What you need before starting
- Owning the file
- Series note
- One last thing
What a Rules File Is, and What It Is Not
- The problem it solves
- A small example
- How an agent uses it
- The three layers of instruction
- What a rules file is not
- What it can do
- What it cannot do
- Size and focus
- When you do not need one
- The name of the file
- One session, in slow motion
- Checklist
Anatomy of a Good Rules File
- Project overview
- Commands
- Structure
- Conventions
- Boundaries
- Testing
- Security
- Definition of done
- A complete skeleton with all eight blocks
- Why the order matters, in general terms
- Reading an existing file against this anatomy
- A summary of the eight blocks
- When the anatomy fights your project
- Checklist
Writing Rules an Agent Can Follow
- Specific beats vague
- Positive and negative rules
- Show, don’t tell
- Priorities, and how to make conflicts resolve safely
- Avoiding contradictions
- Keep it short
- Tone: imperative, present tense
- Writing for two readers at once
- An exercise: your first three rules
- Rewrite stress test
- The three-fate rule
- Checklist
Testing Your Rules
- The before-and-after method
- What to measure
- The log
- Reading results: the four verdicts
- When a rule should be removed
- How often to test
- The test, from start to finish
- When A and B are both bad
- What testing cannot promise
- What to record when you test
- Checklist
Web App Starter
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- Growing the file after week one
- Checklist
API and Backend Services
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- Reading an agent endpoint diff in sixty seconds
- Checklist
Mobile App Projects (Flutter Style)
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- The three decisions this file makes for you
- How to test it
- Common mistakes and variations
- Checklist
Python Scripts and Data Projects
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- A worked example: the expenses summary
- Checklist
Education and School Tools
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- Checklist
Finance and Data Apps
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- Checklist
Database and Migration Safety
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- Checklist
Security Guardrails
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- Checklist
Testing and Review Rules
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- Why this recipe is short on purpose
- How to test it
- Common mistakes and variations
- Checklist
Git and Workflow Rules
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Reading the commits, not just the diff
- Common mistakes and variations
- Checklist
Documentation and Handover Rules
- Goal and when to use it
- Ingredients
- The rules file
- Why each rule is there
- How to test it
- Common mistakes and variations
- A release note that works, in eight lines
- Checklist
Larger Projects and Teams
- Goal and when to use it
- Ingredients
- The rules file - root (shared/global only)
- The rules file - one package (local rules only)
- Why each rule is there
- Team rules, in brief
- How to test it
- Common mistakes and variations
- Checklist
Maintaining Your Rules File
- Why maintenance matters
- The two triggers for a review
- The review routine, twenty minutes
- The pruning list
- Rule debt
- Versioning the file cheaply
- Choosing to rewrite from scratch
- After tool and model changes
- What to expect when the file is healthy
- Expanding from rules: the file as team documentation
- The signals that a deep clean is due
- Checklist
When the Agent Ignores Your Rules
- What ignoring usually looks like
- The diagnosis checklist, in order
- Shorter, sharper, higher
- Repeat critical rules in the chat
- The rewrite loop: every miss becomes data
- When to start a fresh session
- Accept the ceiling, and gate the stakes
- A closing calibration
- What not to do
- Sixty-second triage
- When the whole file stops working
- Checklist
Appendix A: Starter Template
- How to fill it in
- What to do next
Appendix B: Rules Library by Topic
- Commands
- Structure
- Conventions
- Boundaries
- Testing
- Git
- Security (defensive only)
- Privacy and data
- Money and numbers
- Documentation
- Agent behavior
- How to use this appendix
Appendix C: Checklists
- New project checklist
- Before sharing a rules file
- Monthly review checklist