# Rules

> **Always-active guidelines that apply without explicit invocation.**

Rules are automatically enforced across all sessions. Unlike skills (loaded on-demand) or agents (invoked explicitly), rules are always active.

---

## Available Rules

| Rule | Purpose |
|------|---------|
| [coding-style](./coding-style.md) | Code formatting, naming, structure |
| [git-workflow](./git-workflow.md) | Branching, commits, PRs |
| [testing](./testing.md) | TDD, coverage, test patterns |
| [security](./security.md) | Security-first development |
| [performance](./performance.md) | Performance considerations |
| [agent-orchestration](./agent-orchestration.md) | How agents work together |

---

## How Rules Work

### Always Active
Rules are checked continuously during sessions:
- Code style enforced during writing
- Git workflow checked before commits
- Security rules applied to auth code
- Testing rules enforced on all implementations

### Automatic Enforcement
```
User: "Add a login endpoint"
       ↓
[TDD Rule] → Write test first
[Security Rule] → Use parameterized queries
[Git Rule] → Create feature branch
[Code Style] → Follow conventions
```

---

## Rule vs Skill vs Agent

| Aspect | Rule | Skill | Agent |
|--------|------|-------|-------|
| Activation | Always on | Context-loaded | Explicitly invoked |
| Purpose | Enforce standards | Provide knowledge | Perform actions |
| Example | "Always use type hints" | "How to write types" | "Add types to file" |

---

## Customization

Rules can be adjusted in `.claude/settings.json`:

```json
{
  "rules": {
    "testing": {
      "coverageTarget": 80,
      "tddStrict": true
    },
    "codingStyle": {
      "maxFileLines": 800
    }
  }
}
```

---

## Creating Custom Rules

1. Create `rules/<rule-name>.md`
2. Define when the rule applies
3. Specify enforcement criteria
4. Add to this README

### Template
```markdown
# Rule Name

## When Applied
[Conditions that trigger this rule]

## Requirements
- [ ] Requirement 1
- [ ] Requirement 2

## Enforcement
[How violations are detected and handled]
```
