Skip to content

Rule

A rule package provides guidelines, constraints, or best practices that shape how an AI coding assistant behaves in a project. Use this type when your package defines coding standards, review criteria, or project conventions rather than a specific action.

A rule package sets "type": "rule" in apkg.json. It uses only the base manifest fields — there are no rule-specific fields.

{
"name": "@acme/security-rules",
"version": "0.5.0",
"type": "rule",
"description": "Security-focused rules for code review",
"license": "MIT"
}

Automatic tool setup does not currently run for rule packages in Claude Code. Other tools like Cursor and Windsurf support auto-setup for rules. See Rules — Tool Integration for per-tool behavior, including alwaysApply and glob scoping support.

Create a rule package:

Terminal window
mkdir my-rules && cd my-rules
apkg init
# Choose type: rule

Add a rule definition:

---
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

Publish it:

Terminal window
apkg publish