Rules
Rule packages provide guidelines, constraints, and best practices that shape how an AI coding assistant behaves in a project. Rules are the most widely supported package type across tools — most tools have a native concept of project rules.
For general information about rule packages, see Rule package type.
Claude Code
Section titled “Claude Code”Auto-setup: No (manual placement) Target path:
.claude/rules/<rule-name>.mdFile format: Markdown with YAML frontmatter.
Frontmatter fields used:
| Field | Required | Description |
|---|---|---|
name | No | Identifier for the rule |
description | Yes | Short description of what the rule enforces |
alwaysApply | No | If true, the rule is always active. If false or omitted, Claude loads it contextually based on the description |
globs | No | File patterns that scope when the rule activates (e.g. **/*.ts) |
Behavior: Users copy rule definition files into .claude/rules/. Claude Code loads rules based on alwaysApply and globs:
alwaysApply: true— Rule is always included in Claude’s context.alwaysApply: falsewithglobs— Rule activates when working with files matching the glob patterns.alwaysApply: falsewithoutglobs— Rule is loaded contextually based on its description.
APKG installs rule packages but does not auto-copy files. After installation:
apkg add @acme/security-rulescp apkg_packages/@acme/security-rules/security-standards.md .claude/rules/Example definition file:
---name: security-standardsdescription: Enforce security best practicesalwaysApply: true---
When writing or reviewing code in this project, always:
- Never hardcode secrets, API keys, or credentials- Validate and sanitize all user input- Use parameterized queries for database access- Apply the principle of least privilege for file and network access- Flag any use of eval() or dynamic code executionCursor
Section titled “Cursor”Auto-setup: Yes Output path:
.cursor/rules/@<scope>/<name>.mdcFile format: Markdown with YAML frontmatter, saved as .mdc (Cursor’s rule format).
Frontmatter fields used:
| Field | Required | Description |
|---|---|---|
description | Yes | Cursor uses this for contextual matching |
globs | No | File patterns that scope rule activation |
alwaysApply | No | If true, rule is always active. If false, activated contextually |
Behavior: Rules are a native concept in Cursor. APKG auto-generates .mdc files in .cursor/rules/. Cursor supports the same alwaysApply and globs scoping model, making rules the most portable package type between Claude Code and Cursor.
Key difference from Claude Code: Auto-setup is supported — no manual file copying needed.
Windsurf
Section titled “Windsurf”Auto-setup: Yes Output path:
.windsurf/rules/@<scope>/<name>.mdFrontmatter fields used:
| Field | Required | Description |
|---|---|---|
description | Yes | Used for contextual matching |
globs | No | File patterns that scope activation |
alwaysApply | No | Controls auto-loading behavior |
Behavior: Windsurf has native rule support similar to Cursor. APKG auto-generates rule files that Windsurf loads based on the same alwaysApply and globs scoping model.
Auto-setup: Yes Output path:
.kiro/rules/@<scope>/<name>.mdFrontmatter fields used:
| Field | Required | Description |
|---|---|---|
description | Yes | Used for contextual matching |
globs | No | File patterns that scope activation |
alwaysApply | No | Controls auto-loading behavior |
Behavior: Kiro supports project-level steering rules. APKG auto-generates rule files that Kiro loads based on description matching and glob scoping.
Auto-setup: No (manual placement) Target path:
AGENTS.md (appended) or .codex/@<scope>/<name>.mdBehavior: Codex reads AGENTS.md at the project root as its primary instruction source. It does not have a directory-based rule system like Cursor or Windsurf. Rule content must be manually appended to AGENTS.md or placed in .codex/.
Since Codex treats all instructions uniformly, rules lose their scoping features (alwaysApply, globs) — all content is always active.
Key difference: Codex has no rule-level scoping. Every rule is effectively alwaysApply: true.
Feature comparison
Section titled “Feature comparison”| Feature | Claude Code | Cursor | Windsurf | Kiro | Codex |
|---|---|---|---|---|---|
| Auto-setup | No | Yes | Yes | Yes | No |
alwaysApply support | Yes | Yes | Yes | Yes | No (always on) |
globs scoping | Yes | Yes | Yes | Yes | No |
description matching | Yes | Yes | Yes | Yes | No |
| Native rule concept | Yes | Yes | Yes | Yes | No (uses instructions) |
Related pages
Section titled “Related pages”| Page | Description |
|---|---|
| Rule package type | Manifest fields and package structure |
| Tool Setup Explained | Detection, precedence, and the generic setup mechanism |