Coding rules
Where your agent's coding standards live, how language rules apply by path, how a repo's own manual takes precedence, and the default test policy.
Your agent reads rules from three places, and the most specific one wins:
- The repo's manual. A code repo keeps a full
AGENTS.mdat its root, with a.claude/CLAUDE.mdholding@../AGENTS.mdfor Claude Code, each host's file in its own dot-folder and no symlinks. The agent reads both before touching the repo, every time. The repo's build loop, conventions, and test policy beat everything below. - Language rules, applied by file path. They sit in
.claude/rules/in your agent home and apply automatically when a matching file is in play. - The operating manual's Engineering Standards in your home's
AGENTS.md: think before coding, simplicity, surgical changes, goal-driven execution, the index of the principles, toolchain, code style, and comments.
Language rules
| Rule | Applies to | Holds |
|---|---|---|
typescript.md | **/*.ts, **/*.tsx | Discriminated unions, branded ids, the narrowing order with as last, schema-first parsing, exhaustive switches, and house idioms |
swift.md | **/*.swift | Value types, typed throws, enums with payloads, exhaustive switches, Swift concurrency traps, Swift Testing |
xcode.md, xcode-project.md | Xcode pack only | The toolchain through the Xcode MCP, one build driver at a time, project files never hand-edited |
Claude Code reads .claude/rules/; Codex doesn't. The same guidance lives in the engineer skill's language-neutral principles, so Codex still gets it when it works on code.
The Xcode pack
Setup, permissions and the sandbox exclusion are on the Xcode pack page. This section covers what its rules hold.
xcode.md is written for Xcode 27.2. It points the agent at the skills Xcode itself ships: SwiftUI, App Intents, app resizability, translation, device interaction, Instruments' xctrace, accessibility audits and more, written by Apple's framework teams. The agent reads them as files; they are never loaded as a second plugin, which would register a duplicate xcode server. Xcode exports those skills per build, so you export them once, and again after every Xcode update.
The rule also covers:
- picking a preview's device;
- launching on the oldest supported OS to catch a symbol the app can't load there;
- undoing the scheme changes a run saves;
- what to check after an Xcode update.
Tests
The repo's manual decides how much to test. Without one, the default is lean:
- unit tests on shared low-level utilities, where a bug would corrupt everything downstream;
- a regression test for a fixed bug when a cheap local test exists;
- no integration or end-to-end suites unless the repo asks for them.
A test that would still pass if every imported function returned undefined observes nothing, so it gets rewritten or deleted.
Comments
None by default. A comment keeps only a why the code can't show, and the comment pass runs before any diff reaches you.