Claude Code Rules
Path-scoped rules that auto-load by file type when Claude Code edits files.
Rules in .claude/rules/ provide language-specific and workflow-specific context to Claude Code sessions. They load automatically based on file patterns in their paths frontmatter. Source: .claude/rules/
Always-Loaded Rules
Ethos (ethos.md)
Loads on every session. See Agent Ethos for full content. Sets the baseline: surgeon mindset, minimal fixes, hard limits, deletions over additions.
Review (review.md)
Loads when touching PR/review files. Defines blocking vs non-blocking comment prefixes for code review.
Language Rules
Python (python.md)
Loads for **/*.py. Covers: Ruff formatting (4 spaces, 100 chars, double quotes), explicit I/O (io: Io pattern), early returns, named parameters, terse locals, no Any/object/raw dicts, Result[T, E] for domain logic, inline tests, column-aligned field comments.
TypeScript (typescript.md)
Loads for **/*.ts, **/*.tsx, **/*.js, **/*.jsx. Covers: type over interface, unknown over any, satisfies, import type, discriminated unions, branded types, Result<T, E>, Zod at boundaries, console warnings with origin labels, oxfmt formatting.
React (react.md)
Loads for **/*.tsx, **/*.jsx. Covers: Rules of Hooks (no hooks inside conditions/after early returns), exhaustive-deps, setState in effects, useSyncExternalStore migration.
Rust (rust.md)
Loads for **/*.rs. Covers: reader-first design, implicit last expression, thiserror/anyhow split, no unwrap on runtime data, actor pattern, RAII, idempotent operations, sealed traits, // SAFETY: comments, surgical #[cfg].
Go (go.md)
Loads for **/*.go. Covers: gofmt, MixedCaps naming, no Get prefix, 400-line file target, if err != nil patterns, table-driven tests, three-group imports.
Terraform (terraform.md)
Loads for **/*.tf, **/*.tfvars. Covers: remote backend, state boundaries, no hardcoded mutable IDs, saved plans before apply, version pinning, provider-level tags.
Design (design.md)
Loads for **/*.css, **/*.scss, animation files. Covers: when to animate (feedback, spatial consistency, explanation, delight), when NOT to animate (>10 times per session = instant), speed under 300ms, seven practical rules.
Workflow Rules
Atomic Branch Ops (atomic-branch-ops.md)
Historical pattern for quick cross-branch operations: stash -> switch -> work -> switch back -> pop. This is no longer an active recommendation in Kevin's shared agent worktrees because stash/switch workflows can hide unowned work and invalidate running tool state. Prefer an isolated git worktree for any write operation on another branch. Source: AGENTS.md Git Safety, 2026-06-17
Worktree-First (worktree-first.md)
Decision tree: read-only on another branch -> inspect without changing this checkout. Any write on another branch -> create a separate worktree. Extended work -> session worktree. Parallel tasks -> multiple agents with worktree isolation. Branch switches in a shared monorepo are destructive: caches invalidate, editor buffers go stale, dev servers pick up the wrong code. Source: AGENTS.md Git Safety
Ultracite Agent Hooks
Ultracite generates agent hook configs that run npx ultracite fix after every AI edit. For Claude Code, this lives in .claude/settings.json. The hook fires after the agent edits a file, formatting and applying safe auto-fixes before the agent even reviews its own output. Combined with custom lint rules (see Lint-Enforced Agent Guardrails), this creates a structural enforcement loop - agents cannot commit slop because the hook catches it in real time. See Ultracite & Fast Validation Recipe for full setup.
Timeline
- 2026-06-17 | Updated branch-operation guidance to align with current git-safety policy: use isolated worktrees, not stash/switch workflows, for writes on another branch. Source: AGENTS.md Git Safety
- 2026-04-07 | Added Ultracite hook integration and rule-loading summary. Source: .claude/rules/
- 2026-04-06 | Created Claude Code rules page from path-scoped rule files. Source: .claude/rules/