Skip to content

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.

Auto-setup: No (manual placement) Target path:

.claude/rules/<rule-name>.md

File format: Markdown with YAML frontmatter.

Frontmatter fields used:

FieldRequiredDescription
nameNoIdentifier for the rule
descriptionYesShort description of what the rule enforces
alwaysApplyNoIf true, the rule is always active. If false or omitted, Claude loads it contextually based on the description
globsNoFile 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: false with globs — Rule activates when working with files matching the glob patterns.
  • alwaysApply: false without globs — Rule is loaded contextually based on its description.

APKG installs rule packages but does not auto-copy files. After installation:

Terminal window
apkg add @acme/security-rules
cp apkg_packages/@acme/security-rules/security-standards.md .claude/rules/

Example definition file:

---
name: security-standards
description: Enforce security best practices
alwaysApply: 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 execution

Auto-setup: Yes Output path:

.cursor/rules/@<scope>/<name>.mdc

File format: Markdown with YAML frontmatter, saved as .mdc (Cursor’s rule format).

Frontmatter fields used:

FieldRequiredDescription
descriptionYesCursor uses this for contextual matching
globsNoFile patterns that scope rule activation
alwaysApplyNoIf 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.

Auto-setup: Yes Output path:

.windsurf/rules/@<scope>/<name>.md

Frontmatter fields used:

FieldRequiredDescription
descriptionYesUsed for contextual matching
globsNoFile patterns that scope activation
alwaysApplyNoControls 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>.md

Frontmatter fields used:

FieldRequiredDescription
descriptionYesUsed for contextual matching
globsNoFile patterns that scope activation
alwaysApplyNoControls 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>.md

Behavior: 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.

FeatureClaude CodeCursorWindsurfKiroCodex
Auto-setupNoYesYesYesNo
alwaysApply supportYesYesYesYesNo (always on)
globs scopingYesYesYesYesNo
description matchingYesYesYesYesNo
Native rule conceptYesYesYesYesNo (uses instructions)
PageDescription
Rule package typeManifest fields and package structure
Tool Setup ExplainedDetection, precedence, and the generic setup mechanism